mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
[try-runtime-cli] Offchain worker support (#8966)
* make remote-ext work with ws and safe RPCs * Update docs. * Update utils/frame/remote-externalities/Cargo.toml Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Fix test * Update lock file * Update utils/frame/remote-externalities/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix build again. * checkpoint, merging the paged rpc now * revert lifetime stuff * WIP: remote client init not working * Small cleanups * use jsonrpsee alpha.7 * WIP * Executiing without errors * Reorg & cleanup * Trivial cleaning * Add txpool & keystore extension * Small cleaning * More :cleaning * Flags: page-size, override-code * WIP * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Remove heap_pages * Dry code extraction from state * Formatting * More formatting * Add issue todo * Use jsonrpsee 0.2.0 * Try trigger gitlab * Fix "block_import_works" test * fix native_big_block_import_fails_on_fallback test * fix commit should work * Rewrite UI tests * Revert "Rewrite UI tests" This reverts commit ada7f670f701c21fb399946a3f6918453f537bcb. * try again with UI * Use const for legacy heap pages val * Move parse module to its own file * Move rpc_api module to its own file * Apply suggestions from code review Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * trait names: Block, not B * Corect HEAP_PAGES_TEST_LEGACY export * Update utils/frame/remote-externalities/src/rpc_api.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Revert test_ext heap_page insert; adjust storage root instead * Doc comments for try_runtime::cli::Command * TryRuntime stub * trailing comma * Remove unused dev dep in frame-executive * Improve parse::hash variable name & error index * Use Result for rpc_api fns * Richer err messagges * Remove HEAP_PAGE_TEST_LEGACY * Update bin/node/executor/tests/basic.rs Co-authored-by: kianenigma <kian@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
@@ -34,9 +34,11 @@ use sp_core::{
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use jsonrpsee_ws_client::{
|
||||
WsClientBuilder, WsClient, v2::params::JsonRpcParams, traits::Client,
|
||||
WsClientBuilder, WsClient, v2::params::JsonRpcParams,
|
||||
};
|
||||
|
||||
pub mod rpc_api;
|
||||
|
||||
type KeyPair = (StorageKey, StorageData);
|
||||
|
||||
const LOG_TARGET: &str = "remote-ext";
|
||||
@@ -72,7 +74,7 @@ impl<B: BlockT> Default for Mode<B> {
|
||||
}
|
||||
}
|
||||
|
||||
/// configuration of the online execution.
|
||||
/// Configuration of the offline execution.
|
||||
///
|
||||
/// A state snapshot config must be present.
|
||||
#[derive(Clone)]
|
||||
@@ -81,7 +83,7 @@ pub struct OfflineConfig {
|
||||
pub state_snapshot: SnapshotConfig,
|
||||
}
|
||||
|
||||
/// Description of the transport protocol.
|
||||
/// Description of the transport protocol (for online execution).
|
||||
#[derive(Debug)]
|
||||
pub struct Transport {
|
||||
uri: String,
|
||||
@@ -115,10 +117,17 @@ pub struct OnlineConfig<B: BlockT> {
|
||||
pub transport: Transport,
|
||||
}
|
||||
|
||||
impl<B: BlockT> OnlineConfig<B> {
|
||||
/// Return rpc (ws) client.
|
||||
fn rpc_client(&self) -> &WsClient {
|
||||
self.transport.client.as_ref().expect("ws client must have been initialized by now; qed.")
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> Default for OnlineConfig<B> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transport: Transport { uri: DEFAULT_TARGET.to_string(), client: None },
|
||||
transport: Transport { uri: DEFAULT_TARGET.to_owned(), client: None },
|
||||
at: None,
|
||||
state_snapshot: None,
|
||||
modules: vec![],
|
||||
@@ -126,12 +135,6 @@ impl<B: BlockT> Default for OnlineConfig<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> OnlineConfig<B> {
|
||||
/// Return rpc (ws) client.
|
||||
fn rpc_client(&self) -> &WsClient {
|
||||
self.transport.client.as_ref().expect("ws client must have been initialized by now; qed.")
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration of the state snapshot.
|
||||
#[derive(Clone)]
|
||||
@@ -189,6 +192,7 @@ impl<B: BlockT> Builder<B> {
|
||||
|
||||
// RPC methods
|
||||
impl<B: BlockT> Builder<B> {
|
||||
/// Get the latest finalized head.
|
||||
async fn rpc_get_head(&self) -> Result<B::Hash, &'static str> {
|
||||
trace!(target: LOG_TARGET, "rpc: finalized_head");
|
||||
RpcApi::<B>::finalized_head(self.as_online().rpc_client()).await.map_err(|e| {
|
||||
@@ -250,6 +254,7 @@ impl<B: BlockT> Builder<B> {
|
||||
prefix: StorageKey,
|
||||
at: B::Hash,
|
||||
) -> Result<Vec<KeyPair>, &'static str> {
|
||||
use jsonrpsee_ws_client::traits::Client;
|
||||
use serde_json::to_value;
|
||||
let keys = self.get_keys_paged(prefix, at).await?;
|
||||
let keys_count = keys.len();
|
||||
@@ -438,8 +443,10 @@ impl<B: BlockT> Builder<B> {
|
||||
info!(target: LOG_TARGET, "injecting a total of {} keys", kv.len());
|
||||
for (k, v) in kv {
|
||||
let (k, v) = (k.0, v.0);
|
||||
// Insert the key,value pair into the test trie backend
|
||||
ext.insert(k, v);
|
||||
}
|
||||
|
||||
Ok(ext)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user