From 5cda36eba1cefdf9230ef5eea9031da5002c900b Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 11 May 2021 13:57:56 +0700 Subject: [PATCH] Adds SandboxExecutionMethod enum for cli param --- client/cli/src/arg_enums.rs | 11 +++++++++++ client/cli/src/params/import_params.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index aeb3eeacc6f2c..c62f02c645744 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -216,3 +216,14 @@ pub const DEFAULT_EXECUTION_BLOCK_CONSTRUCTION: ExecutionStrategy = ExecutionStr pub const DEFAULT_EXECUTION_OFFCHAIN_WORKER: ExecutionStrategy = ExecutionStrategy::Native; /// Default value for the `--execution-other` parameter. pub const DEFAULT_EXECUTION_OTHER: ExecutionStrategy = ExecutionStrategy::Native; + +arg_enum! { + /// How to execute wasm in a sandboxed environment + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SandboxExecutionMethod { + // Uses an interpreter. + Interpreted, + // Uses a compiled runtime. + Compiled, + } +} diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 7409dbf79dc0f..1cb2bd5471acd 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::arg_enums::{ - ExecutionStrategy, WasmExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, + ExecutionStrategy, WasmExecutionMethod, SandboxExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, DEFAULT_EXECUTION_IMPORT_BLOCK, DEFAULT_EXECUTION_IMPORT_BLOCK_VALIDATOR, DEFAULT_EXECUTION_OFFCHAIN_WORKER, DEFAULT_EXECUTION_OTHER, DEFAULT_EXECUTION_SYNCING, }; @@ -56,6 +56,16 @@ pub struct ImportParams { )] pub wasm_method: WasmExecutionMethod, + /// Method for executing Wasm in a sandbox environment + #[structopt( + long = "sandbox-execution", + value_name = "METHOD", + possible_values = &SandboxExecutionMethod::variants(), + case_insensitive = true, + default_value = "Interpreted" + )] + pub sandbox_method: SandboxExecutionMethod, + /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches.