Questions tagged [runtime-api]
The runtime-api tag has no usage guidance.
38
questions
0
votes
0
answers
10
views
Modifying storage and calling extrinsics for overhead benchmark
I am trying to implement the Overhead benchmark command for our parachain
Here is the code I have already:
BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| {
...
0
votes
1
answer
18
views
How to extract and call Runtimes Calls
Could you explain me how Runtimes calls (https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fpolkadot-rpc-tn.dwellir.com#/runtime) are extracted and called from v14 Metadata ?
I went throw the Polkadot JS ...
0
votes
0
answers
27
views
how can i decode api.call.metadata.metadata so that its parsable?
I am trying to get the runtime calls from the runtime metadata...
async function fetchRuntimeMetadata(api: ApiPromise) {
const metadata = await api.call.metadata.metadata();
// i naively ...
0
votes
1
answer
34
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
...
2
votes
1
answer
58
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
109
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
84
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": "...
1
vote
1
answer
151
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 ...
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
58
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. ...
2
votes
1
answer
208
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 ...
3
votes
1
answer
117
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.
...
0
votes
1
answer
26
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
56
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
77
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
43
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
49
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 ...
6
votes
2
answers
373
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 ...
1
vote
1
answer
48
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 ...
5
votes
2
answers
172
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 ...
4
votes
1
answer
80
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
71
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
115
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
121
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(...
5
votes
2
answers
133
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-...
4
votes
0
answers
178
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
461
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
137
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
81
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, ...