Skip to main content
5 votes
Accepted

I'm struggling to understand the concept of runtime calls, RPC calls, and extrinsics in Substrate

A blockchain is basically a database whose current state depends entirely on the data within the blocks. Each block contains a bunch of transactions*, and so the only way for a user to update the ...
jsdw's user avatar
  • 1,335
4 votes
Accepted

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

I don't think the hosted Polkadot JS UI supports Custom RPCs. You need to follow the instructions for defining custom RPCs when initializing your own Polkadot JS instance as documented here Custom ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes

How to make runtime api available from polkadot js

The runtime calls shown on https://polkadot.js.org/app are not loaded from node metadata but probably hardcoded. To invoke runtime api calls, you will need to use the rpc extension method state_call(...
Ankan's user avatar
  • 335
4 votes
Accepted

Why do runtime APIs have a block_height parameter on the client side but not on the runtime side?

The block hash is for client-side rather than the runtime itself - it tells the client to invoke the runtime API using the post-state of the given block hash. The way this manifests is in how the ...
rob's user avatar
  • 2,126
3 votes
Accepted

How to update the pallet's storage from the runtime api?

No it is not possible. Conceptually a Runtime API runs outside of consensus. They can be called by anyone on a RPC node and are permissionless. It would therefore not make any sense to change the on-...
Oliver Tale-Yazdi's user avatar
3 votes
Accepted

Does RuntimeApis storage accesses counts towards PoV when called from RPC and not any extrinisc?

The storage proof (which is part of the Pov) is only collected while building a block. Each storage read that happens in this process is going into the storage proof. When you are doing RPC calls, ...
bkchr's user avatar
  • 11.6k
3 votes

Does RuntimeApis storage accesses counts towards PoV when called from RPC and not any extrinisc?

The PoV is given to the validator for it to be able to execute the state transition function and calculate the new state root (new state). This is to verify the collators have done their work ...
Daan van der Plas's user avatar
3 votes
Accepted

Provide more details about the compilation target of Polkadot's wasm runtime

does it target WebAssembly 1.0 specification? The wasm runtime actually targets WebAssembly MVP, i.e. without any extensions enabled. is it possible to use language with automatic memory management? ...
pepyakin's user avatar
  • 2,184
3 votes
Accepted

Why is `initialize_block` in the `Core` runtime API (as opposed to `BlockBuilder`)?

These are historical reasons. As I implemented the runtime api in the current form as traits, we always called initialize_block before every runtime api function call. Thus, I moved the call to the ...
bkchr's user avatar
  • 11.6k
3 votes
Accepted

Testing Custom RPC with a Mock Runtime API

tldr: used the sp_api::mock_impl_runtime_apis! macro to mock the implementation. Example is in this PR along with a lot of other changes: https://github.com/LibertyDSNP/frequency/pull/490 See pallets/...
Wil W's user avatar
  • 433
2 votes

unreachable` instruction executed when running overhead benchmark

There is inherent data missing that the parachain-system pallet expects. It needs to be added in your inherent_benchmark_data function which currently only injects timestamp data. The exact inherent ...
Oliver Tale-Yazdi's user avatar
2 votes
Accepted

Does sp_api::Core::execute_block return a Result? If not shall I panic when importing a bad block?

So I want to clarify whether there is a return type or not, and why is there this apparent discrepancy between the definition and usage? Yeah we need to improve the docs for these generated traits. ...
bkchr's user avatar
  • 11.6k
2 votes

How to make runtime api available from polkadot js

Polkadot JS API now supports runtime calls. Ankan pointed out that an issue was opened to add such support, and the subsequent PRs are now merged. await api.call.<endpoint>.<call>(args) ...
Ross's user avatar
  • 171
2 votes
Accepted

jsonrpc method `payment_queryInfo` is being deprecated

for the time being the RPC is still available, but will soon be faded out, that's why it's marked as deprecated. You could use the api.call.transactionPaymentApi.queryInfo as you mentioned or, if you ...
Alberto Nicolas Penayo's user avatar
2 votes
Accepted

What's the difference between the runtime Block type and the opaque::Block type?

The reason for this is exactly as the comment you quoted above the opaque module describes--agnosticity over runtime format changes. To be more specific, runtime::opaque::Block and runtime::Block are ...
Nate Armstrong's user avatar
2 votes
Accepted

How to connect the our local chain to the frontend?

you can start with https://polkadot.js.org/docs/api The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript.
dadzerlaze's user avatar
  • 1,083
1 vote
Accepted

Expensive runtime api: attack vector?

The worst case with such an api is that the RPC node could be brought down. However, the API could also be called via light clients, so you should try to not have some runtime API that iterates the ...
bkchr's user avatar
  • 11.6k
1 vote

Custom RPC vs. runtime API

I would always prefer to add a Runtime API over a custom RPC call. Runtime API call information is included in the metadata from V15 (which was recently stabilised), which means that tools (like subxt)...
jsdw's user avatar
  • 1,335
1 vote

Error on custom rpc in new version

New example code is present in transaction-payment rpc that uses jsonrpsee https://github.com/paritytech/substrate/blob/master/frame/transaction-payment/rpc/src/lib.rs impl<C, Block, AccountId> ...
Amiya Behera's user avatar
1 vote

Nested runtime Api's `fn execute_in_transaction` calls no longer supported in v0.9.42?

The function execute_in_transaction was actually never written with nested transaction in mind. In the early implementation we did not even supported "real" transactions. But yeah the last ...
bkchr's user avatar
  • 11.6k
1 vote

When should an RPC be unsafe?

While it is hard to draw the exact line, there is a possibility that the new hypothetical RPC should actually be unsafe, because there is an important difference between the two. Namely, in ...
kianenigma's user avatar
  • 2,799
1 vote

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

In order to have your RPC methods to show up, you would need to decorate the types as explained in Shawn's answer, which then need to be added to ./packages/src/api/typesBundle.ts. I am sure there is ...
Ramsey - Decentration's user avatar
1 vote
Accepted

Panic when Using Rayon with runtime_api in a custom RPC

The impl_runtime_apis! macro added some invalid unsafe trait implementations of Sync and Send. These are going to be removed by this pr. Creating the runtime_api would be the correct way, as you ...
bkchr's user avatar
  • 11.6k
1 vote
Accepted

Simple runtime call in Rust

I think you've found this out, but for others: In chrome you can run polkadot js and then inspect the webpage and switch over to the network tab. From there if you click on ws to filter to the ...
Squirrel's user avatar
  • 3,849

Only top scored, non community-wiki answers of a minimum length are eligible