This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 ada7f67. * 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>
- Loading branch information
1 parent
3e5b4a2
commit eb9033b
Showing
12 changed files
with
421 additions
and
139 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! WS RPC API for one off RPC calls to a substrate node. | ||
// TODO: Consolidate one off RPC calls https://github.com/paritytech/substrate/issues/8988 | ||
|
||
use super::*; | ||
|
||
/// Get the header of the block identified by `at` | ||
pub async fn get_header<B: BlockT, S: AsRef<str>>(from: S, at: B::Hash) -> Result<B::Header, String> | ||
where | ||
B::Header: serde::de::DeserializeOwned, | ||
{ | ||
use jsonrpsee_ws_client::traits::Client; | ||
let at = serde_json::to_value(at) | ||
.map_err(|e| format!("Block hash could not be converted to JSON due to {:?}", e))?; | ||
let params = vec![at]; | ||
let client = WsClientBuilder::default() | ||
.max_request_body_size(u32::MAX) | ||
.build(from.as_ref()) | ||
.await | ||
.map_err(|e| format!("`WsClientBuilder` failed to build do to {:?}", e))?; | ||
client.request::<B::Header>("chain_getHeader", JsonRpcParams::Array(params)) | ||
.await | ||
.map_err(|e| format!("chain_getHeader request failed due to {:?}", e)) | ||
} | ||
|
||
/// Get the finalized head | ||
pub async fn get_finalized_head<B: BlockT, S: AsRef<str>>(from: S) -> Result<B::Hash, String> { | ||
use jsonrpsee_ws_client::traits::Client; | ||
let client = WsClientBuilder::default() | ||
.max_request_body_size(u32::MAX) | ||
.build(from.as_ref()) | ||
.await | ||
.map_err(|e| format!("`WsClientBuilder` failed to build do to {:?}", e))?; | ||
client.request::<B::Hash>("chain_getFinalizedHead", JsonRpcParams::NoParams) | ||
.await | ||
.map_err(|e| format!("chain_getFinalizedHead request failed due to {:?}", e)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.