mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
WASM Local-blob override (#7317)
* Provide WASM overwrite functionality in LocalCallExecutor - add a new module `wasm_overwrite.rs` in client - scrapes given folder for runtimes - add two new CLI Options `wasm-overwrite` and `wasm_overwrite_path` * formatting * Make comment clearer remove sc-runtime-test from dev-dependencies * comments * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix spaces, remove call into backend for 'heap_pages' in 'try_replace' * Error if path is not a directory, Comments, Doc Comment for WasmOverwrite * make WasmOverwrite Option<> * Change to one CLI argument for overwrites - move getting runtime version into LocalCallExecutor * change unwrap() to expect() * comment * Remove `check_overwrites` * Encapsulate checking for overwrites in LocalCallExecutor * move duplicate code into function * Update client/cli/src/params/import_params.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * comma * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cache hash in WasmBlob * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/client.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * move getting overwrite into its own function * fix error when directory is not a directory * Error on duplicate WASM runtimes * better comment, grammar * docs * Revert StateBackend back to _ * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/call_executor.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Add two tests, fix doc comments Add a test for the runtime_version method of WasmOverwrite Add a test for check_overwrite method of LocalCallExecutor * remove redundant `Return` from expect msg * Update client/cli/src/params/import_params.rs Co-authored-by: David <dvdplm@gmail.com> * Update client/service/src/client/call_executor.rs Co-authored-by: David <dvdplm@gmail.com> * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: David <dvdplm@gmail.com> * Update client/service/src/config.rs Co-authored-by: David <dvdplm@gmail.com> * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: David <dvdplm@gmail.com> * Add Module Documentation, match on '.wasm' extension * Add test for scraping WASM blob * fix expect * remove creating another block in LocalCallExecutor test * remove unused import * add tests for duplicates and scraping wasm * make tests a bit nicer * add test for ignoring non-.wasm files * check error message in test * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * remove println * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * make tests prettier * Update client/service/src/client/wasm_overwrite.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * comment for seemingly random client * locally-built -> custom * remove unused import * fix comment * rename all references to overwrite with override * fix cli flag in module documentation Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
This commit is contained in:
@@ -278,6 +278,15 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
/// Get the path where WASM overrides live.
|
||||
///
|
||||
/// By default this is `None`.
|
||||
fn wasm_runtime_overrides(&self) -> Option<PathBuf> {
|
||||
self.import_params()
|
||||
.map(|x| x.wasm_runtime_overrides())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Get the execution strategies.
|
||||
///
|
||||
/// By default this is retrieved from `ImportParams` if it is available. Otherwise its
|
||||
@@ -492,6 +501,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
state_cache_child_ratio: self.state_cache_child_ratio()?,
|
||||
pruning: self.pruning(unsafe_pruning, &role)?,
|
||||
wasm_method: self.wasm_method()?,
|
||||
wasm_runtime_overrides: self.wasm_runtime_overrides(),
|
||||
execution_strategies: self.execution_strategies(is_dev, is_validator)?,
|
||||
rpc_http: self.rpc_http(DCV::rpc_http_listen_port())?,
|
||||
rpc_ws: self.rpc_ws(DCV::rpc_ws_listen_port())?,
|
||||
|
||||
@@ -25,6 +25,7 @@ use crate::params::DatabaseParams;
|
||||
use crate::params::PruningParams;
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
use structopt::StructOpt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Parameters for block import.
|
||||
#[derive(Debug, StructOpt)]
|
||||
@@ -55,6 +56,12 @@ pub struct ImportParams {
|
||||
)]
|
||||
pub wasm_method: WasmExecutionMethod,
|
||||
|
||||
/// Specify the path where local WASM runtimes are stored.
|
||||
///
|
||||
/// These runtimes will override on-chain runtimes when the version matches.
|
||||
#[structopt(long, value_name = "PATH", parse(from_os_str))]
|
||||
pub wasm_runtime_overrides: Option<PathBuf>,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub execution_strategies: ExecutionStrategiesParams,
|
||||
@@ -103,6 +110,12 @@ impl ImportParams {
|
||||
self.wasm_method.into()
|
||||
}
|
||||
|
||||
/// Enable overriding on-chain WASM with locally-stored WASM
|
||||
/// by specifying the path where local WASM is stored.
|
||||
pub fn wasm_runtime_overrides(&self) -> Option<PathBuf> {
|
||||
self.wasm_runtime_overrides.clone()
|
||||
}
|
||||
|
||||
/// Get execution strategies for the parameters
|
||||
pub fn execution_strategies(&self, is_dev: bool, is_validator: bool) -> ExecutionStrategies {
|
||||
let exec = &self.execution_strategies;
|
||||
|
||||
Reference in New Issue
Block a user