diff --git a/Cargo.lock b/Cargo.lock index b1334fe318a..b5cd8e397e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13903,17 +13903,17 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" -version = "0.16.0" -source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#9942645b3891607e13f11f6444ca320ba36a6a1f" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" +version = "0.35.0" +source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#b5ee21ec07edc43b7e03edc3b9138bf78b3fd332" dependencies = [ "leb128", ] @@ -13990,15 +13990,15 @@ dependencies = [ [[package]] name = "wasm-smith" -version = "0.11.4" -source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#9942645b3891607e13f11f6444ca320ba36a6a1f" +version = "0.12.21" +source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#b5ee21ec07edc43b7e03edc3b9138bf78b3fd332" dependencies = [ "arbitrary", "flagset", - "indexmap 1.9.3", + "indexmap 2.0.0", "leb128", - "wasm-encoder 0.16.0", - "wasmparser 0.90.0", + "wasm-encoder 0.35.0", + "wasmparser 0.115.0", ] [[package]] @@ -14402,14 +14402,6 @@ version = "0.83.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" -[[package]] -name = "wasmparser" -version = "0.90.0" -source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#9942645b3891607e13f11f6444ca320ba36a6a1f" -dependencies = [ - "indexmap 1.9.3", -] - [[package]] name = "wasmparser" version = "0.100.0" @@ -14430,6 +14422,15 @@ dependencies = [ "semver 1.0.18", ] +[[package]] +name = "wasmparser" +version = "0.115.0" +source = "git+https://github.com/gear-tech/wasm-tools.git?branch=gear-stable#b5ee21ec07edc43b7e03edc3b9138bf78b3fd332" +dependencies = [ + "indexmap 2.0.0", + "semver 1.0.18", +] + [[package]] name = "wasmparser-nostd" version = "0.83.0" diff --git a/Cargo.toml b/Cargo.toml index 064c7f9220e..75c0f16a2da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -240,7 +240,7 @@ runtime-primitives = { package = "gear-runtime-primitives", path = "runtime/prim service = { package = "gear-service", path = "node/service", default-features = false } testing = { package = "gear-node-testing", path = "node/testing" } vara-runtime = { path = "runtime/vara", default-features = false } -wasm-smith = { version = "0.11.4", git = "https://github.com/gear-tech/wasm-tools.git", branch = "gear-stable" } +wasm-smith = { version = "0.12.21", git = "https://github.com/gear-tech/wasm-tools.git", branch = "gear-stable" } validator-set = { package = 'substrate-validator-set', git = 'https://github.com/gear-tech/substrate-validator-set.git', branch = 'gear-polkadot-v0.9.41-canary-revert-oom-changes', default-features = false } # Substrate deps diff --git a/utils/node-loader/src/utils.rs b/utils/node-loader/src/utils.rs index c73cd4bd07a..2b37f07b21c 100644 --- a/utils/node-loader/src/utils.rs +++ b/utils/node-loader/src/utils.rs @@ -239,7 +239,6 @@ pub fn get_wasm_gen_config( injection_types, params_config, initial_pages: initial_pages as u32, - unreachable_enabled: false, ..Default::default() } } diff --git a/utils/runtime-fuzzer/src/gear_calls.rs b/utils/runtime-fuzzer/src/gear_calls.rs index e616f9cfe4b..033be476ad8 100644 --- a/utils/runtime-fuzzer/src/gear_calls.rs +++ b/utils/runtime-fuzzer/src/gear_calls.rs @@ -442,7 +442,6 @@ fn config( existing_addresses, log_info, params_config, - unreachable_enabled: false, initial_pages: initial_pages as u32, ..Default::default() } diff --git a/utils/wasm-gen/src/config.rs b/utils/wasm-gen/src/config.rs index 2ec76ebfeb7..3b797ed5d15 100644 --- a/utils/wasm-gen/src/config.rs +++ b/utils/wasm-gen/src/config.rs @@ -28,7 +28,6 @@ //! //! fn my_config<'a>(u: &'a mut Unstructured<'a>) -> Result { //! let selectable_params = SelectableParams { -//! call_indirect_enabled: false, //! allowed_instructions: vec![ //! InstructionKind::Numeric, //! InstructionKind::Reference, @@ -41,7 +40,6 @@ //! max_instructions: 100_000, //! min_funcs: NonZeroUsize::new(15).unwrap(), //! max_funcs: NonZeroUsize::new(30).unwrap(), -//! unreachable_enabled: true, //! }; //! let arbitrary = ArbitraryParams::arbitrary(u)?; //! Ok((selectable_params, arbitrary).into()) @@ -142,9 +140,6 @@ pub struct StandardGearWasmConfigsBundle { pub existing_addresses: Option>, /// Flag which signals whether recursions must be removed. pub remove_recursion: bool, - /// Flag which signals whether `call_indirect` instruction must be used - /// during wasm generation. - pub call_indirect_enabled: bool, /// Injection type for each syscall. pub injection_types: SysCallsInjectionTypes, /// Config of gear wasm call entry-points (exports). @@ -155,9 +150,6 @@ pub struct StandardGearWasmConfigsBundle { pub stack_end_page: Option, /// Syscalls params config pub params_config: SysCallsParamsConfig, - /// Flag which signals whether `unreachable` instruction must be used - /// during wasm generation. - pub unreachable_enabled: bool, } impl Default for StandardGearWasmConfigsBundle { @@ -166,13 +158,11 @@ impl Default for StandardGearWasmConfigsBundle { log_info: Some("StandardGearWasmConfigsBundle".into()), existing_addresses: None, remove_recursion: false, - call_indirect_enabled: true, injection_types: SysCallsInjectionTypes::all_once(), entry_points_set: Default::default(), initial_pages: DEFAULT_INITIAL_SIZE, stack_end_page: None, params_config: SysCallsParamsConfig::default(), - unreachable_enabled: true, } } } @@ -183,20 +173,14 @@ impl> ConfigsBundle for StandardGearWasmConfigsBundle { log_info, existing_addresses, remove_recursion, - call_indirect_enabled, injection_types, entry_points_set, initial_pages, stack_end_page, params_config, - unreachable_enabled, } = self; - let selectable_params = SelectableParams { - call_indirect_enabled, - unreachable_enabled, - ..SelectableParams::default() - }; + let selectable_params = SelectableParams::default(); let mut syscalls_config_builder = SysCallsConfigBuilder::new(injection_types); if let Some(log_info) = log_info { diff --git a/utils/wasm-gen/src/config/module.rs b/utils/wasm-gen/src/config/module.rs index 709c35a2678..5e473d85d74 100644 --- a/utils/wasm-gen/src/config/module.rs +++ b/utils/wasm-gen/src/config/module.rs @@ -18,7 +18,7 @@ //! Config entities related to generating plain wasm module using `wasm-smith`. //! -//! We don't give access to wasm_smith::`SwarmConfig` direct;y, but with several adaptors, +//! We don't give access to [`wasm_smith::SwarmConfig`] directly, but with several adaptors, //! because valid wasm module is not always valid gear module. So, some configurational variables //! can be arbitrary, but some must be constantly set. That's implemented with [`ArbitraryParams`] //! and [`ConstantParams`]. @@ -31,7 +31,7 @@ use wasm_smith::{InstructionKind::*, InstructionKinds, SwarmConfig}; /// Wasm module generation config. /// -/// This config wraps the `wasm_smith::SwarmConfig`. That's to make it +/// This config wraps the [`wasm_smith::SwarmConfig`]. That's to make it /// easy creating a configuration, which is custom, from one side, and, /// from another side, results in generating valid gear wasm modules. #[derive(Debug, Clone)] @@ -58,6 +58,7 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { let ConstantParams { allow_start_export, bulk_memory_enabled, + disallow_traps, exceptions_enabled, max_exports, max_imports, @@ -69,6 +70,7 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { min_imports, multi_value_enabled, reference_types_enabled, + tail_call_enabled, relaxed_simd_enabled, saturating_float_to_int_enabled, sign_extension_enabled, @@ -82,12 +84,10 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { } = ConstantParams::default(); let SelectableParams { - call_indirect_enabled, allowed_instructions, max_instructions, min_funcs, max_funcs, - unreachable_enabled, } = selectable_params; let min_funcs = min_funcs.get(); @@ -129,6 +129,7 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { available_imports, bulk_memory_enabled, canonicalize_nans, + disallow_traps, exceptions_enabled, export_everything, max_aliases, @@ -168,6 +169,7 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { min_uleb_size, multi_value_enabled, reference_types_enabled, + tail_call_enabled, relaxed_simd_enabled, saturating_float_to_int_enabled, sign_extension_enabled, @@ -178,8 +180,6 @@ impl From<(SelectableParams, ArbitraryParams)> for WasmModuleConfig { max_table_elements, table_max_size_required, memory_grow_enabled, - call_indirect_enabled, - unreachable_instruction_enabled: unreachable_enabled, }) } } @@ -289,6 +289,7 @@ impl Arbitrary<'_> for ArbitraryParams { pub struct ConstantParams { allow_start_export: bool, bulk_memory_enabled: bool, + disallow_traps: bool, exceptions_enabled: bool, max_data_segments: usize, max_exports: usize, @@ -303,6 +304,7 @@ pub struct ConstantParams { min_imports: usize, multi_value_enabled: bool, reference_types_enabled: bool, + tail_call_enabled: bool, relaxed_simd_enabled: bool, saturating_float_to_int_enabled: bool, sign_extension_enabled: bool, @@ -319,6 +321,7 @@ impl Default for ConstantParams { sign_extension_enabled: false, saturating_float_to_int_enabled: false, reference_types_enabled: false, + tail_call_enabled: false, // This is related to reference_types_enabled. max_tables: 1, simd_enabled: false, @@ -326,6 +329,7 @@ impl Default for ConstantParams { relaxed_simd_enabled: false, exceptions_enabled: false, memory64_enabled: false, + disallow_traps: true, allow_start_export: false, multi_value_enabled: false, memory_grow_enabled: false, @@ -346,9 +350,6 @@ impl Default for ConstantParams { /// Selectable wasm module generation params. #[derive(Debug, Clone)] pub struct SelectableParams { - /// Flag signalizing whether `call_indirect` instruction - /// must be used or not. - pub call_indirect_enabled: bool, /// Set of [`InstructionKind`], that are allowed to /// be generated by `wasm-gen`. pub allowed_instructions: Vec, @@ -361,22 +362,17 @@ pub struct SelectableParams { /// Maximum amount of functions `wasm-gen` will insert /// into generated wasm. pub max_funcs: NonZeroUsize, - /// Flag signalizing whether `unreachable` instruction - /// must be used or not. - pub unreachable_enabled: bool, } impl Default for SelectableParams { fn default() -> Self { Self { - call_indirect_enabled: true, allowed_instructions: vec![ Numeric, Reference, Parametric, Variable, Table, Memory, Control, ], max_instructions: 500, min_funcs: NonZeroUsize::new(3).expect("from non zero value; qed."), max_funcs: NonZeroUsize::new(5).expect("from non zero value; qed."), - unreachable_enabled: true, } } } diff --git a/utils/wasm-gen/src/tests.rs b/utils/wasm-gen/src/tests.rs index 9acfc5c83c0..0cc7ce34c37 100644 --- a/utils/wasm-gen/src/tests.rs +++ b/utils/wasm-gen/src/tests.rs @@ -344,12 +344,10 @@ fn execute_wasm_with_custom_configs( .with_entry_points_config(EntryPointsSet::Init) .build(), SelectableParams { - call_indirect_enabled: false, allowed_instructions: vec![], max_instructions: 0, min_funcs: NonZeroUsize::new(1).unwrap(), max_funcs: NonZeroUsize::new(1).unwrap(), - unreachable_enabled: true, }, );