Skip to main content

Questions tagged [runtime-api]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
81 views

payment_queryInfo returning Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed

I was trying to query payment_queryInfo on current Westend testnet, and the following payload used to works at spec 9430. { "jsonrpc": "2.0", "method": "...
0 votes
1 answer
23 views

How to declare runtime api?

I have a runtime constant declared in a pallet like this: /// How much space there is on the network. #[pallet::constant] type TotalSpacePledged: Get<u128>; Source code ...
5 votes
2 answers
130 views

Runtime api not available just after client creation? Exported method is not found

I am trying to incorporate benchmark overhead command to our parachain. The issue i have is that runtime api methods are not available right away after client is created. https://github.com/mangata-...
2 votes
1 answer
57 views

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

Is it possible to update the storage of pallets through runtime api? Is yes. Do we have any resources for this same?
0 votes
0 answers
19 views

Why are any of the `RuntimeApiSubsystemClient` trait methods marked `async` when its not needed?

The trait RuntimeApiSubsystemClient and its implementation DefaultSubsystemClient (https://github.com/paritytech/polkadot-sdk/blob/c421b87978404954dec4555895d50ef028b73cf0/polkadot/node/subsystem-...
4 votes
0 answers
97 views

Polkadot JS API: Is is possible to define a custom runtime API?

Polkadot JS Api is aware of a lot of common runtime apis in the Substrate ecosystem. The docs contain a complete list of supported runtime apis. One that is missing is the PoW Difficulty API. Because ...
1 vote
1 answer
117 views

jsonrpc method `payment_queryInfo` is being deprecated

I saw this polkadot API document: https://polkadot.js.org/docs/substrate/rpc/#payment and it mentioned that the payment_queryInfo is deprecated and should use api.call.transactionPaymentApi.queryInfo ...
5 votes
2 answers
170 views

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

At the moment I try to figure out why PolkadotJS UI (https://polkadot.js.org/) is not able to show my custom RPC endpoints or runtime APIs. They are available in general and also available in the list ...
3 votes
0 answers
48 views

Integrating External Data into Blockchain: Can Validators Fetch and Incorporate API-sourced Data?

Is it feasible for validators to retrieve information from external APIs, particularly news data, and seamlessly incorporate it into the blockchain?
1 vote
0 answers
56 views

How are the node threads and tasks managed?

When we run a node, we start a bunch of tasks using task_manager.spawn_handle() or task_manager.spawn_essential_handle(). From my understanding, those spawn new Tokio tasks. If my computer has ...
1 vote
0 answers
20 views

Why can't runtime APIs have default implementations?

I encountered a compile error error: A runtime API function cannot have a default implementation! when attempting to define a default implementation for a runtime API. Why is this not possible?
0 votes
0 answers
15 views

Standalone Runtime

I want to use Substrate Runtime in my application without consensus layer (outer node). I only want to create extrinsics in memory and pass them to runtime (or FRAME) of my custom pallets to proceed. ...
6 votes
2 answers
359 views

How to make runtime api available from polkadot js

I declared runtime api, implemented it in runtime, but i can't call my runtime api from polkadot.js. What i need to do to be able to call it? Declaration: sp_api::decl_runtime_apis! { pub trait ...
3 votes
1 answer
105 views

Custom RPC vs. runtime API

As a Substrate builder, I don't see any reason of still implementing custom RPCs as runtime API seems superior to me. So I was wondering about any arguments for still adding custom RPCs to the client. ...
2 votes
1 answer
187 views

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

Can someone please explain these concepts in a simplified manner and highlight their key distinctions? I would greatly appreciate any help in clarifying these concepts. I'm relatively new to Substrate ...
0 votes
1 answer
25 views

Error on custom rpc in new version

Updating to new version of substrate, of the branch = "polkadot-v0.9.42", it giving error, impl<C, Block, AccountId> ProfileValidationApi<<Block as BlockT>::Hash, AccountId>...
6 votes
1 answer
25 views

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

When upgrading our codebase on top of substrate's polkadot-v0.9.42, we discovered it is no longer possible to make nested request to fn execute_in_transaction(call), from within the call. Given in ...
1 vote
1 answer
55 views

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

In a substrate runtime, take the node-template as an example, we have two definitions from Block, among other types such as BlockId but let's focus on Block.. : // runtime/src/lib.rs pub type Block = ...
3 votes
1 answer
75 views

How to connect the our local chain to the frontend?

I want to build a frontend for our local chain. how can we connect our local to chain to the frontend?
2 votes
0 answers
40 views

Steps to handle renaming runtime api + upgrade

I'm considering a large refactor in our substrate codebase which would involve moving large chunks of code around. This includes a runtime api. In it's destined place, the runtime api's name(both its ...
1 vote
1 answer
42 views

Expensive runtime api: attack vector?

If i have a very expensive runtime api, that can be called via an rpc, is this a vector for a dos attack? I understand that this is an offchain query to storage and therefore should not interfere with ...
1 vote
1 answer
20 views

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

The rustdocs for execute_block indicate that it returns a Result<(), ApiError>. However, when I look at a real-world runtime like in the node template , there is no return type. So I want to ...
2 votes
2 answers
47 views

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

We have some custom RPCs that call some custom RuntimeApis that from inside our pallets expose some on chain data. I know that any access (read or write) of on-chain storage from extrinsics will ...
1 vote
1 answer
47 views

When should an RPC be unsafe?

When making a new RPC/runtime-api endpoint, what criteria should you have in mind regarding making it safe/unsafe? For example, assume that a UI wants to fetch a large amount of data (a lot of keys in ...
4 votes
1 answer
78 views

Panic when Using Rayon with runtime_api in a custom RPC

Works: Use normal iteration in a custom RPC with a runtime_api() call. Goal: Use rayon parallel iteration instead. Result: Panic Working code Simplified Real Code in GitHub let api = self.client....
1 vote
0 answers
68 views

Use state call to query from custom Runtime Api, Balance in frontend is not equal to Balance in Runtime

Background Our front end use state call to query custom RuntimeApi of our solo chain. We try to use state call to replace custom rpcs. Definition Balance is our chain is u128. RuntimeApi Definition ...
3 votes
1 answer
114 views

Testing Custom RPC with a Mock Runtime API

I'm trying to test a Custom RPC. Let's make it a simple pass through. p_api::decl_runtime_apis! { pub trait SimpleApi<AccountId> where AccountId: Codec, { fn is_true() -&...
2 votes
1 answer
117 views

unreachable` instruction executed when running overhead benchmark

for some reason running overhead benchmarks fails in our parachain. cargo run --release --features=runtime-benchmarks benchmark overhead --chain local results with following stacktrace Error: Client(...
4 votes
0 answers
177 views

api.call.transactionPaymentApi.queryInfo returns partial fee 0

With the update to the Polkadot-JS api depreciating rpc.payment.queryInfo in favor for api.call.transactionPaymentApi.queryInfo I am currently trying to migrate my code over. However I used to get the ...
1 vote
0 answers
55 views

Why isn't the state root checked on the client side?

Substrate requires that every header has a state root. (See Trait Header.) When the runtime executes a block authored by a peer, it is assumed that the runtime will check the state root from the ...
1 vote
1 answer
453 views

Simple runtime call in Rust

I am building a somewhat generic client for Substrate-based chains in Rust using the subxt crate. To learn about runtime calls, my goal was to call the core.version runtime API directly using the RPC ...
3 votes
1 answer
136 views

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

I am trying to compile my own runtime, as PoC, but I don't use Rust's toolchain and some things are unclear how to do it at the moment. With Substrate, you can write your blockchain logic in any ...
3 votes
0 answers
80 views

Ways to mock client + custom runtime api from client side

I have some code in a Substrate client that needs to call one of my runtime apis. I'd like an easy way to mock the client and custom runtime api functions to check that they're called. Is there an ...
2 votes
1 answer
47 views

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

Every Substrate runtime implements several Runtime APIs. Two essential ones are the Core and BlockBuilder APIs. The Core API is for executing blocks, a task that will be performed by all nodes. A ...
3 votes
1 answer
89 views

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

Runtime APIs are declared using the decl_runtime_api! macro. This is typically in a primitives crate. For example: decl_runtime_apis! { pub trait ExampleApi { fn get_info(param1: u32, ...