From cdfd25d0c89238bdddba995615ab67ed268313a7 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 19 Jul 2023 16:16:32 +0200 Subject: [PATCH 01/11] Replace parity-wasm with wasmparser --- Cargo.lock | 7 - packages/vm/Cargo.toml | 1 - packages/vm/src/cache.rs | 4 +- packages/vm/src/capabilities.rs | 8 +- packages/vm/src/compatibility.rs | 238 +++++++++++++++++++---------- packages/vm/src/errors/vm_error.rs | 8 + packages/vm/src/static_analysis.rs | 141 ++++++++++------- 7 files changed, 262 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6177ed20d8..445fa69cff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -528,7 +528,6 @@ dependencies = [ "hex", "hex-literal", "leb128", - "parity-wasm", "rand", "schemars", "serde", @@ -1448,12 +1447,6 @@ version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" version = "0.9.7" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 934cb8d34e..d30584dad3 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -43,7 +43,6 @@ cosmwasm-std = { path = "../std", version = "1.3.0", default-features = false } cosmwasm-crypto = { path = "../crypto", version = "1.3.0" } derivative = "2" hex = "0.4" -parity-wasm = { version = "0.45", features = ["sign_ext"] } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } serde_json = "1.0.40" diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 701a314cdd..e21f8d259a 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -15,7 +15,7 @@ use crate::filesystem::mkdir_p; use crate::instance::{Instance, InstanceOptions}; use crate::modules::{CachedModule, FileSystemCache, InMemoryCache, PinnedMemoryCache}; use crate::size::Size; -use crate::static_analysis::{deserialize_wasm, has_ibc_entry_points}; +use crate::static_analysis::{deserialize_exports, has_ibc_entry_points}; use crate::wasm_backend::{compile, make_compiling_engine, make_runtime_engine}; const STATE_DIR: &str = "state"; @@ -254,7 +254,7 @@ where pub fn analyze(&self, checksum: &Checksum) -> VmResult { // Here we could use a streaming deserializer to slightly improve performance. However, this way it is DRYer. let wasm = self.load_wasm(checksum)?; - let module = deserialize_wasm(&wasm)?; + let module = deserialize_exports(&wasm)?; Ok(AnalysisReport { has_ibc_entry_points: has_ibc_entry_points(&module), required_capabilities: required_capabilities_from_module(&module), diff --git a/packages/vm/src/capabilities.rs b/packages/vm/src/capabilities.rs index 85dabe9c95..af560c007d 100644 --- a/packages/vm/src/capabilities.rs +++ b/packages/vm/src/capabilities.rs @@ -15,7 +15,7 @@ pub fn capabilities_from_csv(csv: &str) -> HashSet { /// Implementation for check_wasm, based on static analysis of the bytecode. /// This is used for code upload, to perform check before compiling the Wasm. -pub fn required_capabilities_from_module(module: &impl ExportInfo) -> HashSet { +pub fn required_capabilities_from_module(module: impl ExportInfo) -> HashSet { module .exported_function_names(Some(REQUIRES_PREFIX)) .into_iter() @@ -33,7 +33,7 @@ pub fn required_capabilities_from_module(module: &impl ExportInfo) -> HashSet) -> VmResult<()> { - let module = deserialize_wasm(wasm_code)?; - check_wasm_tables(&module)?; - check_wasm_memories(&module)?; - check_interface_version(&module)?; - check_wasm_exports(&module)?; - check_wasm_imports(&module, SUPPORTED_IMPORTS)?; - check_wasm_capabilities(&module, available_capabilities)?; + let parsed = Parser::new(0).parse_all(wasm_code); + let mut validator = Validator::new(); + // TODO: some of the validator checks are duplicated in our checks below + + let mut memory_section: Option> = None; + for payload in parsed { + let payload = payload?; + validator.payload(&payload)?; + + match payload { + Payload::TableSection(t) => check_wasm_tables(t)?, + Payload::MemorySection(m) => memory_section = Some(m), + Payload::ExportSection(e) => { + let exports = e.into_iter().collect::, _>>()?; + check_interface_version(&exports)?; + check_wasm_exports(&exports)?; + check_wasm_capabilities(&exports, available_capabilities)?; + } + Payload::ImportSection(i) => check_wasm_imports(i, SUPPORTED_IMPORTS)?, + _ => {} + } + } + check_wasm_memories(memory_section)?; + Ok(()) } -fn check_wasm_tables(module: &Module) -> VmResult<()> { - let sections: &[TableType] = module - .table_section() - .map_or(&[], |section| section.entries()); - match sections.len() { +fn check_wasm_tables(mut tables: TableSectionReader<'_>) -> VmResult<()> { + match tables.get_count() { 0 => Ok(()), 1 => { - let limits = sections[0].limits(); - if let Some(maximum) = limits.maximum() { - if limits.initial() > maximum { + let limits = tables.read()?; + if let Some(maximum) = limits.maximum { + if limits.initial > maximum { return Err(VmError::static_validation_err( "Wasm contract's first table section has a initial limit > max limit", )); @@ -114,8 +137,8 @@ fn check_wasm_tables(module: &Module) -> VmResult<()> { } } -fn check_wasm_memories(module: &Module) -> VmResult<()> { - let section = match module.memory_section() { +fn check_wasm_memories(memory: Option>) -> VmResult<()> { + let mut section = match memory { Some(section) => section, None => { return Err(VmError::static_validation_err( @@ -124,24 +147,21 @@ fn check_wasm_memories(module: &Module) -> VmResult<()> { } }; - let memories = section.entries(); - if memories.len() != 1 { + if section.get_count() != 1 { return Err(VmError::static_validation_err( "Wasm contract must contain exactly one memory", )); } - let memory = memories[0]; - // println!("Memory: {:?}", memory); - let limits = memory.limits(); + let memory = section.read()?; - if limits.initial() > MEMORY_LIMIT { + if memory.initial > MEMORY_LIMIT as u64 { return Err(VmError::static_validation_err(format!( "Wasm contract memory's minimum must not exceed {MEMORY_LIMIT} pages." ))); } - if limits.maximum().is_some() { + if memory.maximum.is_some() { return Err(VmError::static_validation_err( "Wasm contract memory's maximum must be unset. The host will set it for you.", )); @@ -149,8 +169,8 @@ fn check_wasm_memories(module: &Module) -> VmResult<()> { Ok(()) } -fn check_interface_version(module: &Module) -> VmResult<()> { - let mut interface_version_exports = module +fn check_interface_version(exports: &[Export<'_>]) -> VmResult<()> { + let mut interface_version_exports = exports .exported_function_names(Some(INTERFACE_VERSION_PREFIX)) .into_iter(); if let Some(first_interface_version_export) = interface_version_exports.next() { @@ -179,8 +199,8 @@ fn check_interface_version(module: &Module) -> VmResult<()> { } } -fn check_wasm_exports(module: &Module) -> VmResult<()> { - let available_exports: HashSet = module.exported_function_names(None); +fn check_wasm_exports(exports: &[Export<'_>]) -> VmResult<()> { + let available_exports: HashSet = exports.exported_function_names(None); for required_export in REQUIRED_EXPORTS { if !available_exports.contains(*required_export) { return Err(VmError::static_validation_err(format!( @@ -194,20 +214,21 @@ fn check_wasm_exports(module: &Module) -> VmResult<()> { /// Checks if the import requirements of the contract are satisfied. /// When this is not the case, we either have an incompatibility between contract and VM /// or a error in the contract. -fn check_wasm_imports(module: &Module, supported_imports: &[&str]) -> VmResult<()> { - let required_imports: &[ImportEntry] = module - .import_section() - .map_or(&[], |import_section| import_section.entries()); - - if required_imports.len() > MAX_IMPORTS { +fn check_wasm_imports(imports: ImportSectionReader, supported_imports: &[&str]) -> VmResult<()> { + if imports.get_count() > MAX_IMPORTS { return Err(VmError::static_validation_err(format!( "Import count exceeds limit. Imports: {}. Limit: {}.", - required_imports.len(), + imports.get_count(), MAX_IMPORTS ))); } - for required_import in required_imports { + let required_imports = imports + .into_iter() + .map(|i| Ok(i?)) + .collect::>>()?; + + for required_import in &required_imports { let full_name = full_import_name(required_import); if !supported_imports.contains(&full_name.as_str()) { let required_import_names: BTreeSet<_> = @@ -218,25 +239,25 @@ fn check_wasm_imports(module: &Module, supported_imports: &[&str]) -> VmResult<( ))); } - match required_import.external() { - External::Function(_) => {}, // ok + match required_import.ty { + TypeRef::Func(_) => {} // ok _ => return Err(VmError::static_validation_err(format!( "Wasm contract requires non-function import: \"{full_name}\". Right now, all supported imports are functions." - ))), - }; + ))) + } } Ok(()) } -fn full_import_name(ie: &ImportEntry) -> String { - format!("{}.{}", ie.module(), ie.field()) +fn full_import_name(ie: &Import) -> String { + format!("{}.{}", ie.module, ie.name) } fn check_wasm_capabilities( - module: &Module, + exports: &[Export<'_>], available_capabilities: &HashSet, ) -> VmResult<()> { - let required_capabilities = required_capabilities_from_module(module); + let required_capabilities = required_capabilities_from_module(exports); if !required_capabilities.is_subset(available_capabilities) { // We switch to BTreeSet to get a sorted error message let unavailable: BTreeSet<_> = required_capabilities @@ -253,7 +274,10 @@ fn check_wasm_capabilities( #[cfg(test)] mod tests { use super::*; - use crate::errors::VmError; + use crate::{ + errors::VmError, + static_analysis::{deserialize_exports, extract_reader}, + }; static CONTRACT_0_7: &[u8] = include_bytes!("../testdata/hackatom_0.7.wasm"); static CONTRACT_0_12: &[u8] = include_bytes!("../testdata/hackatom_0.12.wasm"); @@ -321,29 +345,48 @@ mod tests { fn check_wasm_tables_works() { // No tables is fine let wasm = wat::parse_str("(module)").unwrap(); - check_wasm_tables(&deserialize_wasm(&wasm).unwrap()).unwrap(); + assert!(extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .unwrap() + .is_none()); // One table (bound) let wasm = wat::parse_str("(module (table $name 123 123 funcref))").unwrap(); - check_wasm_tables(&deserialize_wasm(&wasm).unwrap()).unwrap(); + check_wasm_tables( + extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .unwrap() + .unwrap(), + ) + .unwrap(); // One table (bound, initial > max) let wasm = wat::parse_str("(module (table $name 124 123 funcref))").unwrap(); - let err = check_wasm_tables(&deserialize_wasm(&wasm).unwrap()).unwrap_err(); + let err = check_wasm_tables( + extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .unwrap() + .unwrap(), + ) + .unwrap_err(); assert!(err .to_string() .contains("Wasm contract's first table section has a initial limit > max limit")); // One table (bound, max too large) let wasm = wat::parse_str("(module (table $name 100 9999 funcref))").unwrap(); - let err = check_wasm_tables(&deserialize_wasm(&wasm).unwrap()).unwrap_err(); + let err = extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .map(|_| ()) // map away the `Ok` value, it does not impl Debug + .unwrap_err(); assert!(err .to_string() .contains("Wasm contract's first table section has a too large max limit")); // One table (unbound) let wasm = wat::parse_str("(module (table $name 100 funcref))").unwrap(); - let err = check_wasm_tables(&deserialize_wasm(&wasm).unwrap()).unwrap_err(); + let err = check_wasm_tables( + extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .unwrap() + .unwrap(), + ) + .unwrap_err(); assert!(err .to_string() .contains("Wasm contract must not have unbound table section")); @@ -352,13 +395,16 @@ mod tests { #[test] fn check_wasm_memories_ok() { let wasm = wat::parse_str("(module (memory 1))").unwrap(); - check_wasm_memories(&deserialize_wasm(&wasm).unwrap()).unwrap() + check_wasm_memories(extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap()) + .unwrap() } #[test] fn check_wasm_memories_no_memory() { let wasm = wat::parse_str("(module)").unwrap(); - match check_wasm_memories(&deserialize_wasm(&wasm).unwrap()) { + match check_wasm_memories( + extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), + ) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract doesn't have a memory section")); } @@ -382,7 +428,9 @@ mod tests { )) .unwrap(); - match check_wasm_memories(&deserialize_wasm(&wasm).unwrap()) { + match check_wasm_memories( + extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), + ) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract must contain exactly one memory")); } @@ -403,7 +451,9 @@ mod tests { )) .unwrap(); - match check_wasm_memories(&deserialize_wasm(&wasm).unwrap()) { + match check_wasm_memories( + extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), + ) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract must contain exactly one memory")); } @@ -415,10 +465,15 @@ mod tests { #[test] fn check_wasm_memories_initial_size() { let wasm_ok = wat::parse_str("(module (memory 512))").unwrap(); - check_wasm_memories(&deserialize_wasm(&wasm_ok).unwrap()).unwrap(); + check_wasm_memories( + extract_reader!(&wasm_ok, MemorySection, MemorySectionReader<'_>).unwrap(), + ) + .unwrap(); let wasm_too_big = wat::parse_str("(module (memory 513))").unwrap(); - match check_wasm_memories(&deserialize_wasm(&wasm_too_big).unwrap()) { + match check_wasm_memories( + extract_reader!(&wasm_too_big, MemorySection, MemorySectionReader<'_>).unwrap(), + ) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract memory's minimum must not exceed 512 pages")); } @@ -430,7 +485,9 @@ mod tests { #[test] fn check_wasm_memories_maximum_size() { let wasm_max = wat::parse_str("(module (memory 1 5))").unwrap(); - match check_wasm_memories(&deserialize_wasm(&wasm_max).unwrap()) { + match check_wasm_memories( + extract_reader!(&wasm_max, MemorySection, MemorySectionReader<'_>).unwrap(), + ) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract memory's maximum must be unset")); } @@ -454,7 +511,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); check_interface_version(&module).unwrap(); #[cfg(feature = "allow_interface_version_7")] @@ -472,7 +529,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); check_interface_version(&module).unwrap(); } @@ -488,7 +545,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!( @@ -513,7 +570,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!( @@ -537,7 +594,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); @@ -558,7 +615,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); @@ -581,7 +638,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); check_wasm_exports(&module).unwrap(); // this is invalid, as it doesn't any required export @@ -593,7 +650,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract doesn't have required export: \"allocate\"")); @@ -612,7 +669,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!( @@ -626,7 +683,7 @@ mod tests { #[test] fn check_wasm_exports_of_old_contract() { - let module = deserialize_wasm(CONTRACT_0_7).unwrap(); + let module = deserialize_exports(CONTRACT_0_7).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!( @@ -655,7 +712,13 @@ mod tests { )"#, ) .unwrap(); - check_wasm_imports(&deserialize_wasm(&wasm).unwrap(), SUPPORTED_IMPORTS).unwrap(); + check_wasm_imports( + extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) + .unwrap() + .unwrap(), + SUPPORTED_IMPORTS, + ) + .unwrap(); } #[test] @@ -766,8 +829,13 @@ mod tests { )"#, ) .unwrap(); - let err = - check_wasm_imports(&deserialize_wasm(&wasm).unwrap(), SUPPORTED_IMPORTS).unwrap_err(); + let err = check_wasm_imports( + extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) + .unwrap() + .unwrap(), + SUPPORTED_IMPORTS, + ) + .unwrap_err(); match err { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Import count exceeds limit. Imports: 101. Limit: 100."); @@ -804,7 +872,12 @@ mod tests { "env.debug", "env.query_chain", ]; - let result = check_wasm_imports(&deserialize_wasm(&wasm).unwrap(), supported_imports); + let result = check_wasm_imports( + extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) + .unwrap() + .unwrap(), + supported_imports, + ); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { println!("{msg}"); @@ -819,8 +892,10 @@ mod tests { #[test] fn check_wasm_imports_of_old_contract() { - let module = deserialize_wasm(CONTRACT_0_7).unwrap(); - let result = check_wasm_imports(&module, SUPPORTED_IMPORTS); + let module = extract_reader!(&CONTRACT_0_7, ImportSection, ImportSectionReader<'_>) + .unwrap() + .unwrap(); + let result = check_wasm_imports(module, SUPPORTED_IMPORTS); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert!( @@ -834,7 +909,12 @@ mod tests { #[test] fn check_wasm_imports_wrong_type() { let wasm = wat::parse_str(r#"(module (import "env" "db_read" (memory 1 1)))"#).unwrap(); - let result = check_wasm_imports(&deserialize_wasm(&wasm).unwrap(), SUPPORTED_IMPORTS); + let result = check_wasm_imports( + extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) + .unwrap() + .unwrap(), + SUPPORTED_IMPORTS, + ); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert!( @@ -860,7 +940,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); let available = [ "water".to_string(), "nutrients".to_string(), @@ -887,7 +967,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); // Available set 1 let available = [ diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index ed7adc6674..b0ed25f9a5 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -343,6 +343,14 @@ impl From for VmError { } } +impl From for VmError { + fn from(original: wasmer::wasmparser::BinaryReaderError) -> Self { + VmError::static_validation_err(format!( + "Wasm bytecode could not be deserialized. Deserialization error: \"{original}\"" + )) + } +} + impl From for VmError { fn from(original: wasmer::ExportError) -> Self { VmError::resolve_err(format!("Could not get export: {original}")) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 94e644721d..767c96977e 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -1,7 +1,8 @@ -use parity_wasm::elements::{deserialize_buffer, Internal, Module}; use std::collections::HashSet; -use crate::errors::{VmError, VmResult}; +use wasmer::wasmparser::{Export, ExportSectionReader, ExternalKind}; + +use crate::errors::VmResult; pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ "ibc_channel_open", @@ -12,47 +13,88 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ "ibc_packet_timeout", ]; -pub fn deserialize_wasm(wasm_code: &[u8]) -> VmResult { - deserialize_buffer(wasm_code).map_err(|err| { - VmError::static_validation_err(format!( - "Wasm bytecode could not be deserialized. Deserialization error: \"{err}\"" - )) - }) +/// A small helper macro to validate the wasm module and extract a reader for a specific section. +/// +/// # Example +/// ``` +/// use wasmer::wasmparser::{ExportSectionReader, Export}; +/// use cosmwasm_vm::extract_reader; +/// +/// let wasm_ok = wat::parse_str("(module (memory 512))").unwrap(); +/// check_wasm_memories( +/// extract_reader!(&wasm_ok, MemorySection, MemorySectionReader<'_>).unwrap(), +/// ) +/// .unwrap(); +/// ``` +macro_rules! extract_reader { + ($wasm_code: expr, $payload: ident, $t: ty) => {{ + fn extract(wasm_code: &[u8]) -> crate::VmResult> { + use wasmer::wasmparser::{Parser, Payload, Validator}; + + let mut validator = Validator::new(); + let parser = Parser::new(0); + + let mut value = None; + for p in parser.parse_all(wasm_code) { + let p = p?; + validator.payload(&p)?; + if let Payload::$payload(e) = p { + // do not return immediately, as we want to validate the entire module + value = Some(e); + } + } + + Ok(value) + } + + extract($wasm_code) + }}; +} + +pub(crate) use extract_reader; + +pub fn deserialize_exports(wasm_code: &[u8]) -> VmResult>> { + let exports = extract_reader!(wasm_code, ExportSection, ExportSectionReader<'_>)?; + Ok(exports + .map(|e| e.into_iter().collect::, _>>()) + .transpose()? + .unwrap_or_default()) } /// A trait that allows accessing shared functionality of `parity_wasm::elements::Module` /// and `wasmer::Module` in a shared fashion. pub trait ExportInfo { /// Returns all exported function names with the given prefix - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet; + fn exported_function_names(self, prefix: Option<&str>) -> HashSet; } -impl ExportInfo for Module { - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet { - self.export_section() - .map_or(HashSet::default(), |export_section| { - export_section - .entries() - .iter() - .filter_map(|entry| match entry.internal() { - Internal::Function(_) => Some(entry.field()), - _ => None, - }) - .filter(|name| { - if let Some(required_prefix) = prefix { - name.starts_with(required_prefix) - } else { - true - } - }) - .map(|name| name.to_string()) - .collect() +impl ExportInfo for &[Export<'_>] { + fn exported_function_names(self, prefix: Option<&str>) -> HashSet { + self.iter() + .filter_map(|export| match export.kind { + ExternalKind::Func => Some(export.name), + _ => None, + }) + .filter(|name| { + if let Some(required_prefix) = prefix { + name.starts_with(required_prefix) + } else { + true + } }) + .map(|name| name.to_string()) + .collect() } } -impl ExportInfo for wasmer::Module { - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet { +impl ExportInfo for &Vec> { + fn exported_function_names(self, prefix: Option<&str>) -> HashSet { + self[..].exported_function_names(prefix) + } +} + +impl ExportInfo for &wasmer::Module { + fn exported_function_names(self, prefix: Option<&str>) -> HashSet { self.exports() .functions() .filter_map(|function_export| { @@ -74,7 +116,7 @@ impl ExportInfo for wasmer::Module { /// Returns true if and only if all IBC entry points ([`REQUIRED_IBC_EXPORTS`]) /// exist as exported functions. This does not guarantee the entry points /// are functional and for simplicity does not even check their signatures. -pub fn has_ibc_entry_points(module: &impl ExportInfo) -> bool { +pub fn has_ibc_entry_points(module: impl ExportInfo) -> bool { let available_exports = module.exported_function_names(None); REQUIRED_IBC_EXPORTS .iter() @@ -83,38 +125,33 @@ pub fn has_ibc_entry_points(module: &impl ExportInfo) -> bool { #[cfg(test)] mod tests { + use crate::VmError; + use super::*; - use parity_wasm::elements::Internal; use wasmer::{Cranelift, Store}; static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm"); static CORRUPTED: &[u8] = include_bytes!("../testdata/corrupted.wasm"); #[test] - fn deserialize_wasm_works() { - let module = deserialize_wasm(CONTRACT).unwrap(); - assert_eq!(module.version(), 1); + fn deserialize_exports_works() { + let module = deserialize_exports(CONTRACT).unwrap(); + // assert_eq!(module.version(), 1); // TODO: not implemented anymore let exported_functions = module - .export_section() - .unwrap() - .entries() .iter() - .filter(|entry| matches!(entry.internal(), Internal::Function(_))); + .filter(|entry| matches!(entry.kind, ExternalKind::Func)); assert_eq!(exported_functions.count(), 8); // 4 required exports plus "execute", "migrate", "query" and "sudo" let exported_memories = module - .export_section() - .unwrap() - .entries() .iter() - .filter(|entry| matches!(entry.internal(), Internal::Memory(_))); + .filter(|entry| matches!(entry.kind, ExternalKind::Memory)); assert_eq!(exported_memories.count(), 1); } #[test] fn deserialize_wasm_corrupted_data() { - match deserialize_wasm(CORRUPTED).unwrap_err() { + match deserialize_exports(CORRUPTED).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert!(msg.starts_with("Wasm bytecode could not be deserialized.")) } @@ -125,7 +162,7 @@ mod tests { #[test] fn exported_function_names_works_for_parity_with_no_prefix() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); let exports = module.exported_function_names(None); assert_eq!(exports, HashSet::new()); @@ -141,7 +178,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); let exports = module.exported_function_names(None); assert_eq!( exports, @@ -152,7 +189,7 @@ mod tests { #[test] fn exported_function_names_works_for_parity_with_prefix() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); let exports = module.exported_function_names(Some("b")); assert_eq!(exports, HashSet::new()); @@ -169,7 +206,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); let exports = module.exported_function_names(Some("b")); assert_eq!( exports, @@ -257,7 +294,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); assert!(!has_ibc_entry_points(&module)); // IBC contract @@ -282,7 +319,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); assert!(has_ibc_entry_points(&module)); // Missing packet ack @@ -306,7 +343,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_exports(&wasm).unwrap(); assert!(!has_ibc_entry_points(&module)); } } From b63b3a2e8d66b3132b1723a6d3ea4293a34d0f9d Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 19 Jul 2023 17:07:29 +0200 Subject: [PATCH 02/11] Fix tests --- packages/vm/src/cache.rs | 5 +++- packages/vm/src/compatibility.rs | 45 +++++++++++++----------------- packages/vm/src/static_analysis.rs | 12 -------- 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index e21f8d259a..1fe61f9933 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -571,7 +571,10 @@ mod tests { let save_result = cache.save_wasm(&wasm); match save_result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { - assert_eq!(msg, "Wasm contract doesn\'t have a memory section") + assert_eq!( + msg, + "Wasm contract missing a required marker export: interface_version_*" + ) } e => panic!("Unexpected error {e:?}"), } diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index f64bca067d..f0af607f44 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -114,11 +114,6 @@ fn check_wasm_tables(mut tables: TableSectionReader<'_>) -> VmResult<()> { 1 => { let limits = tables.read()?; if let Some(maximum) = limits.maximum { - if limits.initial > maximum { - return Err(VmError::static_validation_err( - "Wasm contract's first table section has a initial limit > max limit", - )); - } if maximum > TABLE_SIZE_LIMIT { return Err(VmError::static_validation_err( "Wasm contract's first table section has a too large max limit", @@ -323,19 +318,17 @@ mod tests { }; match check_wasm(CONTRACT_0_12, &default_capabilities()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ), + Err(VmError::StaticValidationErr { msg, .. }) => { + assert!(msg.contains("Wasm contract requires unsupported import")) + } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("This must not succeeed"), }; match check_wasm(CONTRACT_0_7, &default_capabilities()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ), + Err(VmError::StaticValidationErr { msg, .. }) => { + assert!(msg.contains("Wasm contract requires unsupported import")) + } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("This must not succeeed"), }; @@ -360,21 +353,22 @@ mod tests { // One table (bound, initial > max) let wasm = wat::parse_str("(module (table $name 124 123 funcref))").unwrap(); + // this should be caught by the validator + let err = extract_reader!(&wasm, TableSection, TableSectionReader<'_>) + .map(|_| ()) + .unwrap_err(); + assert!(err + .to_string() + .contains("size minimum must not be greater than maximum")); + + // One table (bound, max too large) + let wasm = wat::parse_str("(module (table $name 100 9999 funcref))").unwrap(); let err = check_wasm_tables( extract_reader!(&wasm, TableSection, TableSectionReader<'_>) .unwrap() .unwrap(), ) .unwrap_err(); - assert!(err - .to_string() - .contains("Wasm contract's first table section has a initial limit > max limit")); - - // One table (bound, max too large) - let wasm = wat::parse_str("(module (table $name 100 9999 funcref))").unwrap(); - let err = extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .map(|_| ()) // map away the `Ok` value, it does not impl Debug - .unwrap_err(); assert!(err .to_string() .contains("Wasm contract's first table section has a too large max limit")); @@ -428,11 +422,10 @@ mod tests { )) .unwrap(); - match check_wasm_memories( - extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), - ) { + // wrong number of memories should be caught by the validator + match extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!(msg.starts_with("Wasm contract must contain exactly one memory")); + assert!(msg.contains("multiple memories")); } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("Didn't reject wasm with invalid api"), diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 767c96977e..5e79585ef5 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -14,18 +14,6 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ ]; /// A small helper macro to validate the wasm module and extract a reader for a specific section. -/// -/// # Example -/// ``` -/// use wasmer::wasmparser::{ExportSectionReader, Export}; -/// use cosmwasm_vm::extract_reader; -/// -/// let wasm_ok = wat::parse_str("(module (memory 512))").unwrap(); -/// check_wasm_memories( -/// extract_reader!(&wasm_ok, MemorySection, MemorySectionReader<'_>).unwrap(), -/// ) -/// .unwrap(); -/// ``` macro_rules! extract_reader { ($wasm_code: expr, $payload: ident, $t: ty) => {{ fn extract(wasm_code: &[u8]) -> crate::VmResult> { From 7eea2db491d21e5c891560cfcc72b96b4a43a6c6 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 20 Jul 2023 11:27:51 +0200 Subject: [PATCH 03/11] Fix contract lock files --- contracts/burner/Cargo.lock | 74 +++++++++++---------------- contracts/crypto-verify/Cargo.lock | 74 +++++++++++---------------- contracts/cyberpunk/Cargo.lock | 30 +++-------- contracts/floaty/Cargo.lock | 74 +++++++++++---------------- contracts/hackatom/Cargo.lock | 74 +++++++++++---------------- contracts/ibc-reflect-send/Cargo.lock | 74 +++++++++++---------------- contracts/ibc-reflect/Cargo.lock | 74 +++++++++++---------------- contracts/queue/Cargo.lock | 74 +++++++++++---------------- contracts/reflect/Cargo.lock | 74 +++++++++++---------------- contracts/staking/Cargo.lock | 74 +++++++++++---------------- contracts/virus/Cargo.lock | 74 +++++++++++---------------- 11 files changed, 297 insertions(+), 473 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 780b58f1e6..7a1e1425cb 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -261,7 +261,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -993,30 +992,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1141,9 +1134,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1839,35 +1832,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1877,9 +1861,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1889,9 +1873,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1901,9 +1885,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1913,15 +1897,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1931,9 +1915,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 8b0074ca41..83e09bcd08 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -1010,30 +1009,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1158,9 +1151,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1882,35 +1875,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1920,9 +1904,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1932,9 +1916,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1944,9 +1928,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1956,15 +1940,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1974,9 +1958,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index ae1b4aa6b4..ba0cf97246 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -285,7 +285,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -1091,30 +1090,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.9", + "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets 0.48.0", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1237,15 +1230,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "redox_syscall" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" -dependencies = [ - "bitflags", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -1580,7 +1564,7 @@ checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall", "rustix", "windows-sys 0.45.0", ] diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index b22982c2b0..067d47d4c0 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -994,30 +993,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1142,9 +1135,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1840,35 +1833,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1878,9 +1862,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1890,9 +1874,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1902,9 +1886,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1914,15 +1898,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1932,9 +1916,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 43d3659f6b..bc781605fe 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -995,30 +994,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1143,9 +1136,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1841,35 +1834,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1879,9 +1863,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1891,9 +1875,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1903,9 +1887,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1915,15 +1899,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1933,9 +1917,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 82cac20de9..4f0cbebd58 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -993,30 +992,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1141,9 +1134,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1839,35 +1832,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1877,9 +1861,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1889,9 +1873,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1901,9 +1885,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1913,15 +1897,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1931,9 +1915,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index cd927806fb..1319868f94 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -993,30 +992,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1141,9 +1134,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1839,35 +1832,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1877,9 +1861,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1889,9 +1873,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1901,9 +1885,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1913,15 +1897,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1931,9 +1915,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 0c2b3eda62..573e612f00 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -982,30 +981,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1141,9 +1134,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1839,35 +1832,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1877,9 +1861,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1889,9 +1873,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1901,9 +1885,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1913,15 +1897,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1931,9 +1915,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 9f042e0cc5..2151faa4d0 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -982,30 +981,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1130,9 +1123,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1840,35 +1833,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1878,9 +1862,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1890,9 +1874,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1902,9 +1886,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1914,15 +1898,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1932,9 +1916,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 534b141cc7..f0875ba7b9 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -988,30 +987,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1136,9 +1129,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1867,35 +1860,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1905,9 +1889,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1917,9 +1901,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1929,9 +1913,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1941,15 +1925,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1959,9 +1943,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index fd55847fb4..1be41e542a 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -177,7 +177,7 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys 0.33.0", + "windows-sys", ] [[package]] @@ -250,7 +250,6 @@ dependencies = [ "derivative", "enumset", "hex", - "parity-wasm", "schemars", "serde", "serde_json", @@ -982,30 +981,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -1130,9 +1123,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -1840,35 +1833,26 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.2", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -1878,9 +1862,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -1890,9 +1874,9 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -1902,9 +1886,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -1914,15 +1898,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -1932,9 +1916,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" From f3a234a6d71b5fcc063d079c3d1907b64e219c2b Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 20 Jul 2023 11:49:57 +0200 Subject: [PATCH 04/11] Fix lint --- packages/vm/src/compatibility.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index f0af607f44..9cfdc4dfe1 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -885,7 +885,7 @@ mod tests { #[test] fn check_wasm_imports_of_old_contract() { - let module = extract_reader!(&CONTRACT_0_7, ImportSection, ImportSectionReader<'_>) + let module = extract_reader!(CONTRACT_0_7, ImportSection, ImportSectionReader<'_>) .unwrap() .unwrap(); let result = check_wasm_imports(module, SUPPORTED_IMPORTS); From d09523db823a7338acc3306ecd65e2d0c70fd21a Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 20 Jul 2023 14:48:47 +0200 Subject: [PATCH 05/11] Validate function bodies --- packages/vm/src/static_analysis.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 5e79585ef5..ddf55195e2 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -17,7 +17,7 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ macro_rules! extract_reader { ($wasm_code: expr, $payload: ident, $t: ty) => {{ fn extract(wasm_code: &[u8]) -> crate::VmResult> { - use wasmer::wasmparser::{Parser, Payload, Validator}; + use wasmer::wasmparser::{Parser, Payload, ValidPayload, Validator}; let mut validator = Validator::new(); let parser = Parser::new(0); @@ -25,7 +25,11 @@ macro_rules! extract_reader { let mut value = None; for p in parser.parse_all(wasm_code) { let p = p?; - validator.payload(&p)?; + // validate the payload + if let ValidPayload::Func(mut fv, body) = validator.payload(&p)? { + // also validate function bodies + fv.validate(&body)?; + } if let Payload::$payload(e) = p { // do not return immediately, as we want to validate the entire module value = Some(e); From 6bd9a8f5ff8bf3ad42908e807529da569be6817c Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 20 Jul 2023 15:57:35 +0200 Subject: [PATCH 06/11] Refactor wasm validation --- packages/vm/src/compatibility.rs | 16 +++---- packages/vm/src/static_analysis.rs | 68 +++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index 9cfdc4dfe1..e11300d188 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -5,15 +5,14 @@ use wasmer::wasmparser::Export; use wasmer::wasmparser::Import; use wasmer::wasmparser::ImportSectionReader; use wasmer::wasmparser::MemorySectionReader; -use wasmer::wasmparser::Parser; use wasmer::wasmparser::Payload; use wasmer::wasmparser::TableSectionReader; use wasmer::wasmparser::TypeRef; -use wasmer::wasmparser::Validator; use crate::capabilities::required_capabilities_from_module; use crate::errors::{VmError, VmResult}; use crate::limited::LimitedDisplay; +use crate::static_analysis::validate_wasm; use crate::static_analysis::ExportInfo; /// Lists all imports we provide upon instantiating the instance in Instance::from_module() @@ -81,15 +80,8 @@ const MAX_IMPORTS: u32 = 100; /// Checks if the data is valid wasm and compatibility with the CosmWasm API (imports and exports) pub fn check_wasm(wasm_code: &[u8], available_capabilities: &HashSet) -> VmResult<()> { - let parsed = Parser::new(0).parse_all(wasm_code); - let mut validator = Validator::new(); - // TODO: some of the validator checks are duplicated in our checks below - let mut memory_section: Option> = None; - for payload in parsed { - let payload = payload?; - validator.payload(&payload)?; - + validate_wasm(wasm_code, |payload| { match payload { Payload::TableSection(t) => check_wasm_tables(t)?, Payload::MemorySection(m) => memory_section = Some(m), @@ -102,7 +94,9 @@ pub fn check_wasm(wasm_code: &[u8], available_capabilities: &HashSet) -> Payload::ImportSection(i) => check_wasm_imports(i, SUPPORTED_IMPORTS)?, _ => {} } - } + Ok(()) + })?; + // we want to fail if there is no memory section, so this check is delayed until the end check_wasm_memories(memory_section)?; Ok(()) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index ddf55195e2..74a2dfe578 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -1,6 +1,9 @@ use std::collections::HashSet; -use wasmer::wasmparser::{Export, ExportSectionReader, ExternalKind}; +use wasmer::wasmparser::{ + Export, ExportSectionReader, ExternalKind, Parser, Payload, ValidPayload, Validator, + WasmFeatures, +}; use crate::errors::VmResult; @@ -13,29 +16,56 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ "ibc_packet_timeout", ]; +/// Validates the given wasm code and calls the callback for each payload. +/// "Validates" in this case refers to general WebAssembly validation, not specific to CosmWasm. +pub fn validate_wasm<'a>( + wasm_code: &'a [u8], + mut handle_payload: impl FnMut(Payload<'a>) -> VmResult<()>, +) -> VmResult<()> { + let mut validator = Validator::new_with_features(WasmFeatures { + mutable_global: false, + saturating_float_to_int: false, + sign_extension: true, + reference_types: true, + multi_value: false, + bulk_memory: false, + component_model: false, + simd: false, + relaxed_simd: false, + threads: false, + tail_call: false, + deterministic_only: true, + multi_memory: false, + exceptions: false, + memory64: false, + extended_const: false, + }); + + for p in Parser::new(0).parse_all(wasm_code) { + let p = p?; + // validate the payload + if let ValidPayload::Func(fv, body) = validator.payload(&p)? { + // also validate function bodies + fv.into_validator(Default::default()).validate(&body)?; + } + // tell caller about the payload + handle_payload(p)?; + } + + Ok(()) +} + /// A small helper macro to validate the wasm module and extract a reader for a specific section. macro_rules! extract_reader { ($wasm_code: expr, $payload: ident, $t: ty) => {{ - fn extract(wasm_code: &[u8]) -> crate::VmResult> { - use wasmer::wasmparser::{Parser, Payload, ValidPayload, Validator}; - - let mut validator = Validator::new(); - let parser = Parser::new(0); - + fn extract(wasm_code: &[u8]) -> $crate::VmResult> { let mut value = None; - for p in parser.parse_all(wasm_code) { - let p = p?; - // validate the payload - if let ValidPayload::Func(mut fv, body) = validator.payload(&p)? { - // also validate function bodies - fv.validate(&body)?; - } - if let Payload::$payload(e) = p { - // do not return immediately, as we want to validate the entire module - value = Some(e); + $crate::static_analysis::validate_wasm(wasm_code, |p| { + if let Payload::$payload(p) = p { + value = Some(p); } - } - + Ok(()) + })?; Ok(value) } From 749586fbe7b018593c28aa75610ec6f9f995ac64 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 20 Jul 2023 16:36:08 +0200 Subject: [PATCH 07/11] Adjust WasmFeatures for validation --- packages/vm/src/static_analysis.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 74a2dfe578..3a43140009 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -23,22 +23,14 @@ pub fn validate_wasm<'a>( mut handle_payload: impl FnMut(Payload<'a>) -> VmResult<()>, ) -> VmResult<()> { let mut validator = Validator::new_with_features(WasmFeatures { - mutable_global: false, - saturating_float_to_int: false, - sign_extension: true, - reference_types: true, - multi_value: false, - bulk_memory: false, + deterministic_only: true, component_model: false, simd: false, relaxed_simd: false, threads: false, - tail_call: false, - deterministic_only: true, multi_memory: false, - exceptions: false, memory64: false, - extended_const: false, + ..Default::default() }); for p in Parser::new(0).parse_all(wasm_code) { From bc7cd910533feff01265f618bc5a9240cc273c28 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 24 Jul 2023 12:57:26 +0200 Subject: [PATCH 08/11] Reuse validator allocations --- packages/vm/src/static_analysis.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 3a43140009..f3e5804427 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -33,12 +33,15 @@ pub fn validate_wasm<'a>( ..Default::default() }); + let mut fun_allocations = Default::default(); for p in Parser::new(0).parse_all(wasm_code) { let p = p?; // validate the payload if let ValidPayload::Func(fv, body) = validator.payload(&p)? { // also validate function bodies - fv.into_validator(Default::default()).validate(&body)?; + let mut fun_validator = fv.into_validator(fun_allocations); + fun_validator.validate(&body)?; + fun_allocations = fun_validator.into_allocations(); } // tell caller about the payload handle_payload(p)?; From c23482fae66c04c672707ca9c1a6f2381877ef4d Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 24 Jul 2023 16:34:09 +0200 Subject: [PATCH 09/11] Parse and validate wasm before static analysis --- packages/vm/src/cache.rs | 10 +- packages/vm/src/capabilities.rs | 7 +- packages/vm/src/compatibility.rs | 211 +++++++++-------------------- packages/vm/src/lib.rs | 1 + packages/vm/src/parsed_wasm.rs | 70 ++++++++++ packages/vm/src/static_analysis.rs | 102 +++----------- 6 files changed, 160 insertions(+), 241 deletions(-) create mode 100644 packages/vm/src/parsed_wasm.rs diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 1fe61f9933..7d853affa0 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -14,8 +14,9 @@ use crate::errors::{VmError, VmResult}; use crate::filesystem::mkdir_p; use crate::instance::{Instance, InstanceOptions}; use crate::modules::{CachedModule, FileSystemCache, InMemoryCache, PinnedMemoryCache}; +use crate::parsed_wasm::ParsedWasm; use crate::size::Size; -use crate::static_analysis::{deserialize_exports, has_ibc_entry_points}; +use crate::static_analysis::has_ibc_entry_points; use crate::wasm_backend::{compile, make_compiling_engine, make_runtime_engine}; const STATE_DIR: &str = "state"; @@ -254,7 +255,7 @@ where pub fn analyze(&self, checksum: &Checksum) -> VmResult { // Here we could use a streaming deserializer to slightly improve performance. However, this way it is DRYer. let wasm = self.load_wasm(checksum)?; - let module = deserialize_exports(&wasm)?; + let module = ParsedWasm::parse(&wasm)?; Ok(AnalysisReport { has_ibc_entry_points: has_ibc_entry_points(&module), required_capabilities: required_capabilities_from_module(&module), @@ -571,10 +572,7 @@ mod tests { let save_result = cache.save_wasm(&wasm); match save_result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { - assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ) + assert_eq!(msg, "Wasm contract must contain exactly one memory") } e => panic!("Unexpected error {e:?}"), } diff --git a/packages/vm/src/capabilities.rs b/packages/vm/src/capabilities.rs index af560c007d..8281105011 100644 --- a/packages/vm/src/capabilities.rs +++ b/packages/vm/src/capabilities.rs @@ -32,8 +32,9 @@ pub fn required_capabilities_from_module(module: impl ExportInfo) -> HashSet) -> VmResult<()> { - let mut memory_section: Option> = None; - validate_wasm(wasm_code, |payload| { - match payload { - Payload::TableSection(t) => check_wasm_tables(t)?, - Payload::MemorySection(m) => memory_section = Some(m), - Payload::ExportSection(e) => { - let exports = e.into_iter().collect::, _>>()?; - check_interface_version(&exports)?; - check_wasm_exports(&exports)?; - check_wasm_capabilities(&exports, available_capabilities)?; - } - Payload::ImportSection(i) => check_wasm_imports(i, SUPPORTED_IMPORTS)?, - _ => {} - } - Ok(()) - })?; - // we want to fail if there is no memory section, so this check is delayed until the end - check_wasm_memories(memory_section)?; + let module = ParsedWasm::parse(wasm_code)?; + + check_wasm_tables(&module)?; + check_wasm_memories(&module)?; + check_interface_version(&module)?; + check_wasm_exports(&module)?; + check_wasm_imports(&module, SUPPORTED_IMPORTS)?; + check_wasm_capabilities(&module, available_capabilities)?; Ok(()) } -fn check_wasm_tables(mut tables: TableSectionReader<'_>) -> VmResult<()> { - match tables.get_count() { +fn check_wasm_tables(module: &ParsedWasm) -> VmResult<()> { + match module.tables.len() { 0 => Ok(()), 1 => { - let limits = tables.read()?; + let limits = &module.tables[0]; if let Some(maximum) = limits.maximum { if maximum > TABLE_SIZE_LIMIT { return Err(VmError::static_validation_err( @@ -126,23 +111,13 @@ fn check_wasm_tables(mut tables: TableSectionReader<'_>) -> VmResult<()> { } } -fn check_wasm_memories(memory: Option>) -> VmResult<()> { - let mut section = match memory { - Some(section) => section, - None => { - return Err(VmError::static_validation_err( - "Wasm contract doesn't have a memory section", - )); - } - }; - - if section.get_count() != 1 { +fn check_wasm_memories(module: &ParsedWasm) -> VmResult<()> { + if module.memories.len() != 1 { return Err(VmError::static_validation_err( "Wasm contract must contain exactly one memory", )); } - - let memory = section.read()?; + let memory = &module.memories[0]; if memory.initial > MEMORY_LIMIT as u64 { return Err(VmError::static_validation_err(format!( @@ -158,8 +133,8 @@ fn check_wasm_memories(memory: Option>) -> VmResult<()> Ok(()) } -fn check_interface_version(exports: &[Export<'_>]) -> VmResult<()> { - let mut interface_version_exports = exports +fn check_interface_version(module: &ParsedWasm) -> VmResult<()> { + let mut interface_version_exports = module .exported_function_names(Some(INTERFACE_VERSION_PREFIX)) .into_iter(); if let Some(first_interface_version_export) = interface_version_exports.next() { @@ -188,8 +163,8 @@ fn check_interface_version(exports: &[Export<'_>]) -> VmResult<()> { } } -fn check_wasm_exports(exports: &[Export<'_>]) -> VmResult<()> { - let available_exports: HashSet = exports.exported_function_names(None); +fn check_wasm_exports(module: &ParsedWasm) -> VmResult<()> { + let available_exports: HashSet = module.exported_function_names(None); for required_export in REQUIRED_EXPORTS { if !available_exports.contains(*required_export) { return Err(VmError::static_validation_err(format!( @@ -203,25 +178,20 @@ fn check_wasm_exports(exports: &[Export<'_>]) -> VmResult<()> { /// Checks if the import requirements of the contract are satisfied. /// When this is not the case, we either have an incompatibility between contract and VM /// or a error in the contract. -fn check_wasm_imports(imports: ImportSectionReader, supported_imports: &[&str]) -> VmResult<()> { - if imports.get_count() > MAX_IMPORTS { +fn check_wasm_imports(module: &ParsedWasm, supported_imports: &[&str]) -> VmResult<()> { + if module.imports.len() > MAX_IMPORTS { return Err(VmError::static_validation_err(format!( "Import count exceeds limit. Imports: {}. Limit: {}.", - imports.get_count(), + module.imports.len(), MAX_IMPORTS ))); } - let required_imports = imports - .into_iter() - .map(|i| Ok(i?)) - .collect::>>()?; - - for required_import in &required_imports { + for required_import in &module.imports { let full_name = full_import_name(required_import); if !supported_imports.contains(&full_name.as_str()) { let required_import_names: BTreeSet<_> = - required_imports.iter().map(full_import_name).collect(); + module.imports.iter().map(full_import_name).collect(); return Err(VmError::static_validation_err(format!( "Wasm contract requires unsupported import: \"{}\". Required imports: {}. Available imports: {:?}.", full_name, required_import_names.to_string_limited(200), supported_imports @@ -243,7 +213,7 @@ fn full_import_name(ie: &Import) -> String { } fn check_wasm_capabilities( - exports: &[Export<'_>], + exports: &ParsedWasm, available_capabilities: &HashSet, ) -> VmResult<()> { let required_capabilities = required_capabilities_from_module(exports); @@ -263,10 +233,7 @@ fn check_wasm_capabilities( #[cfg(test)] mod tests { use super::*; - use crate::{ - errors::VmError, - static_analysis::{deserialize_exports, extract_reader}, - }; + use crate::errors::VmError; static CONTRACT_0_7: &[u8] = include_bytes!("../testdata/hackatom_0.7.wasm"); static CONTRACT_0_12: &[u8] = include_bytes!("../testdata/hackatom_0.12.wasm"); @@ -313,7 +280,9 @@ mod tests { match check_wasm(CONTRACT_0_12, &default_capabilities()) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!(msg.contains("Wasm contract requires unsupported import")) + assert!(msg.contains( + "Wasm contract missing a required marker export: interface_version_*" + )) } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("This must not succeeed"), @@ -321,7 +290,9 @@ mod tests { match check_wasm(CONTRACT_0_7, &default_capabilities()) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!(msg.contains("Wasm contract requires unsupported import")) + assert!(msg.contains( + "Wasm contract missing a required marker export: interface_version_*" + )) } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("This must not succeeed"), @@ -332,49 +303,30 @@ mod tests { fn check_wasm_tables_works() { // No tables is fine let wasm = wat::parse_str("(module)").unwrap(); - assert!(extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .unwrap() - .is_none()); + assert!(ParsedWasm::parse(&wasm).unwrap().memories.is_empty()); // One table (bound) let wasm = wat::parse_str("(module (table $name 123 123 funcref))").unwrap(); - check_wasm_tables( - extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .unwrap() - .unwrap(), - ) - .unwrap(); + check_wasm_tables(&ParsedWasm::parse(&wasm).unwrap()).unwrap(); // One table (bound, initial > max) let wasm = wat::parse_str("(module (table $name 124 123 funcref))").unwrap(); // this should be caught by the validator - let err = extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .map(|_| ()) - .unwrap_err(); + let err = &ParsedWasm::parse(&wasm).unwrap_err(); assert!(err .to_string() .contains("size minimum must not be greater than maximum")); // One table (bound, max too large) let wasm = wat::parse_str("(module (table $name 100 9999 funcref))").unwrap(); - let err = check_wasm_tables( - extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .unwrap() - .unwrap(), - ) - .unwrap_err(); + let err = check_wasm_tables(&ParsedWasm::parse(&wasm).unwrap()).unwrap_err(); assert!(err .to_string() .contains("Wasm contract's first table section has a too large max limit")); // One table (unbound) let wasm = wat::parse_str("(module (table $name 100 funcref))").unwrap(); - let err = check_wasm_tables( - extract_reader!(&wasm, TableSection, TableSectionReader<'_>) - .unwrap() - .unwrap(), - ) - .unwrap_err(); + let err = check_wasm_tables(&ParsedWasm::parse(&wasm).unwrap()).unwrap_err(); assert!(err .to_string() .contains("Wasm contract must not have unbound table section")); @@ -383,18 +335,15 @@ mod tests { #[test] fn check_wasm_memories_ok() { let wasm = wat::parse_str("(module (memory 1))").unwrap(); - check_wasm_memories(extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap()) - .unwrap() + check_wasm_memories(&ParsedWasm::parse(&wasm).unwrap()).unwrap() } #[test] fn check_wasm_memories_no_memory() { let wasm = wat::parse_str("(module)").unwrap(); - match check_wasm_memories( - extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), - ) { + match check_wasm_memories(&ParsedWasm::parse(&wasm).unwrap()) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!(msg.starts_with("Wasm contract doesn't have a memory section")); + assert!(msg.starts_with("Wasm contract must contain exactly one memory")); } Err(e) => panic!("Unexpected error {e:?}"), Ok(_) => panic!("Didn't reject wasm with invalid api"), @@ -417,7 +366,7 @@ mod tests { .unwrap(); // wrong number of memories should be caught by the validator - match extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>) { + match ParsedWasm::parse(&wasm) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.contains("multiple memories")); } @@ -438,9 +387,7 @@ mod tests { )) .unwrap(); - match check_wasm_memories( - extract_reader!(&wasm, MemorySection, MemorySectionReader<'_>).unwrap(), - ) { + match check_wasm_memories(&ParsedWasm::parse(&wasm).unwrap()) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract must contain exactly one memory")); } @@ -452,15 +399,10 @@ mod tests { #[test] fn check_wasm_memories_initial_size() { let wasm_ok = wat::parse_str("(module (memory 512))").unwrap(); - check_wasm_memories( - extract_reader!(&wasm_ok, MemorySection, MemorySectionReader<'_>).unwrap(), - ) - .unwrap(); + check_wasm_memories(&ParsedWasm::parse(&wasm_ok).unwrap()).unwrap(); let wasm_too_big = wat::parse_str("(module (memory 513))").unwrap(); - match check_wasm_memories( - extract_reader!(&wasm_too_big, MemorySection, MemorySectionReader<'_>).unwrap(), - ) { + match check_wasm_memories(&ParsedWasm::parse(&wasm_too_big).unwrap()) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract memory's minimum must not exceed 512 pages")); } @@ -472,9 +414,7 @@ mod tests { #[test] fn check_wasm_memories_maximum_size() { let wasm_max = wat::parse_str("(module (memory 1 5))").unwrap(); - match check_wasm_memories( - extract_reader!(&wasm_max, MemorySection, MemorySectionReader<'_>).unwrap(), - ) { + match check_wasm_memories(&ParsedWasm::parse(&wasm_max).unwrap()) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract memory's maximum must be unset")); } @@ -498,7 +438,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); check_interface_version(&module).unwrap(); #[cfg(feature = "allow_interface_version_7")] @@ -516,7 +456,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); check_interface_version(&module).unwrap(); } @@ -532,7 +472,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!( @@ -557,7 +497,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!( @@ -581,7 +521,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); @@ -602,7 +542,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_interface_version(&module).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); @@ -625,7 +565,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); check_wasm_exports(&module).unwrap(); // this is invalid, as it doesn't any required export @@ -637,7 +577,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!(msg.starts_with("Wasm contract doesn't have required export: \"allocate\"")); @@ -656,7 +596,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!( @@ -670,7 +610,7 @@ mod tests { #[test] fn check_wasm_exports_of_old_contract() { - let module = deserialize_exports(CONTRACT_0_7).unwrap(); + let module = ParsedWasm::parse(CONTRACT_0_7).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { assert!( @@ -699,13 +639,7 @@ mod tests { )"#, ) .unwrap(); - check_wasm_imports( - extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) - .unwrap() - .unwrap(), - SUPPORTED_IMPORTS, - ) - .unwrap(); + check_wasm_imports(&ParsedWasm::parse(&wasm).unwrap(), SUPPORTED_IMPORTS).unwrap(); } #[test] @@ -816,13 +750,8 @@ mod tests { )"#, ) .unwrap(); - let err = check_wasm_imports( - extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) - .unwrap() - .unwrap(), - SUPPORTED_IMPORTS, - ) - .unwrap_err(); + let err = + check_wasm_imports(&ParsedWasm::parse(&wasm).unwrap(), SUPPORTED_IMPORTS).unwrap_err(); match err { VmError::StaticValidationErr { msg, .. } => { assert_eq!(msg, "Import count exceeds limit. Imports: 101. Limit: 100."); @@ -859,12 +788,7 @@ mod tests { "env.debug", "env.query_chain", ]; - let result = check_wasm_imports( - extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) - .unwrap() - .unwrap(), - supported_imports, - ); + let result = check_wasm_imports(&ParsedWasm::parse(&wasm).unwrap(), supported_imports); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { println!("{msg}"); @@ -879,9 +803,7 @@ mod tests { #[test] fn check_wasm_imports_of_old_contract() { - let module = extract_reader!(CONTRACT_0_7, ImportSection, ImportSectionReader<'_>) - .unwrap() - .unwrap(); + let module = &ParsedWasm::parse(CONTRACT_0_7).unwrap(); let result = check_wasm_imports(module, SUPPORTED_IMPORTS); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { @@ -896,12 +818,7 @@ mod tests { #[test] fn check_wasm_imports_wrong_type() { let wasm = wat::parse_str(r#"(module (import "env" "db_read" (memory 1 1)))"#).unwrap(); - let result = check_wasm_imports( - extract_reader!(&wasm, ImportSection, ImportSectionReader<'_>) - .unwrap() - .unwrap(), - SUPPORTED_IMPORTS, - ); + let result = check_wasm_imports(&ParsedWasm::parse(&wasm).unwrap(), SUPPORTED_IMPORTS); match result.unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert!( @@ -927,7 +844,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); let available = [ "water".to_string(), "nutrients".to_string(), @@ -954,7 +871,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); // Available set 1 let available = [ diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index af7ed2f519..05987bac76 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -16,6 +16,7 @@ mod instance; mod limited; mod memory; mod modules; +mod parsed_wasm; mod sections; mod serde; mod size; diff --git a/packages/vm/src/parsed_wasm.rs b/packages/vm/src/parsed_wasm.rs new file mode 100644 index 0000000000..6de9fbaed4 --- /dev/null +++ b/packages/vm/src/parsed_wasm.rs @@ -0,0 +1,70 @@ +use wasmer::wasmparser::{ + Export, Import, MemoryType, Parser, TableType, ValidPayload, Validator, WasmFeatures, +}; + +use crate::VmResult; + +/// A parsed and validated wasm module. +/// It keeps track of the parts that are important for our static analysis and compatibility checks. +#[derive(Debug)] +pub struct ParsedWasm<'a> { + pub version: u32, + pub exports: Vec>, + pub imports: Vec>, + pub tables: Vec, + pub memories: Vec, +} + +impl<'a> ParsedWasm<'a> { + pub fn parse(wasm: &'a [u8]) -> VmResult { + let mut validator = Validator::new_with_features(WasmFeatures { + deterministic_only: true, + component_model: false, + simd: false, + relaxed_simd: false, + threads: false, + multi_memory: false, + memory64: false, + ..Default::default() + }); + + let mut this = Self { + version: 0, + exports: vec![], + imports: vec![], + tables: vec![], + memories: vec![], + }; + + let mut fun_allocations = Default::default(); + for p in Parser::new(0).parse_all(wasm) { + let p = p?; + // validate the payload + if let ValidPayload::Func(fv, body) = validator.payload(&p)? { + // also validate function bodies + let mut fun_validator = fv.into_validator(fun_allocations); + fun_validator.validate(&body)?; + fun_allocations = fun_validator.into_allocations(); + } + + match p { + wasmer::wasmparser::Payload::Version { num, .. } => this.version = num, + wasmer::wasmparser::Payload::ImportSection(i) => { + this.imports = i.into_iter().collect::, _>>()?; + } + wasmer::wasmparser::Payload::TableSection(t) => { + this.tables = t.into_iter().collect::, _>>()?; + } + wasmer::wasmparser::Payload::MemorySection(m) => { + this.memories = m.into_iter().collect::, _>>()?; + } + wasmer::wasmparser::Payload::ExportSection(e) => { + this.exports = e.into_iter().collect::, _>>()?; + } + _ => {} // ignore everything else + } + } + + Ok(this) + } +} diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index f3e5804427..7e20fb95f3 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -1,11 +1,8 @@ use std::collections::HashSet; -use wasmer::wasmparser::{ - Export, ExportSectionReader, ExternalKind, Parser, Payload, ValidPayload, Validator, - WasmFeatures, -}; +use wasmer::wasmparser::ExternalKind; -use crate::errors::VmResult; +use crate::parsed_wasm::ParsedWasm; pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ "ibc_channel_open", @@ -16,68 +13,6 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ "ibc_packet_timeout", ]; -/// Validates the given wasm code and calls the callback for each payload. -/// "Validates" in this case refers to general WebAssembly validation, not specific to CosmWasm. -pub fn validate_wasm<'a>( - wasm_code: &'a [u8], - mut handle_payload: impl FnMut(Payload<'a>) -> VmResult<()>, -) -> VmResult<()> { - let mut validator = Validator::new_with_features(WasmFeatures { - deterministic_only: true, - component_model: false, - simd: false, - relaxed_simd: false, - threads: false, - multi_memory: false, - memory64: false, - ..Default::default() - }); - - let mut fun_allocations = Default::default(); - for p in Parser::new(0).parse_all(wasm_code) { - let p = p?; - // validate the payload - if let ValidPayload::Func(fv, body) = validator.payload(&p)? { - // also validate function bodies - let mut fun_validator = fv.into_validator(fun_allocations); - fun_validator.validate(&body)?; - fun_allocations = fun_validator.into_allocations(); - } - // tell caller about the payload - handle_payload(p)?; - } - - Ok(()) -} - -/// A small helper macro to validate the wasm module and extract a reader for a specific section. -macro_rules! extract_reader { - ($wasm_code: expr, $payload: ident, $t: ty) => {{ - fn extract(wasm_code: &[u8]) -> $crate::VmResult> { - let mut value = None; - $crate::static_analysis::validate_wasm(wasm_code, |p| { - if let Payload::$payload(p) = p { - value = Some(p); - } - Ok(()) - })?; - Ok(value) - } - - extract($wasm_code) - }}; -} - -pub(crate) use extract_reader; - -pub fn deserialize_exports(wasm_code: &[u8]) -> VmResult>> { - let exports = extract_reader!(wasm_code, ExportSection, ExportSectionReader<'_>)?; - Ok(exports - .map(|e| e.into_iter().collect::, _>>()) - .transpose()? - .unwrap_or_default()) -} - /// A trait that allows accessing shared functionality of `parity_wasm::elements::Module` /// and `wasmer::Module` in a shared fashion. pub trait ExportInfo { @@ -85,9 +20,10 @@ pub trait ExportInfo { fn exported_function_names(self, prefix: Option<&str>) -> HashSet; } -impl ExportInfo for &[Export<'_>] { +impl ExportInfo for &ParsedWasm<'_> { fn exported_function_names(self, prefix: Option<&str>) -> HashSet { - self.iter() + self.exports + .iter() .filter_map(|export| match export.kind { ExternalKind::Func => Some(export.name), _ => None, @@ -104,12 +40,6 @@ impl ExportInfo for &[Export<'_>] { } } -impl ExportInfo for &Vec> { - fn exported_function_names(self, prefix: Option<&str>) -> HashSet { - self[..].exported_function_names(prefix) - } -} - impl ExportInfo for &wasmer::Module { fn exported_function_names(self, prefix: Option<&str>) -> HashSet { self.exports() @@ -152,15 +82,17 @@ mod tests { #[test] fn deserialize_exports_works() { - let module = deserialize_exports(CONTRACT).unwrap(); - // assert_eq!(module.version(), 1); // TODO: not implemented anymore + let module = ParsedWasm::parse(CONTRACT).unwrap(); + assert_eq!(module.version, 1); let exported_functions = module + .exports .iter() .filter(|entry| matches!(entry.kind, ExternalKind::Func)); assert_eq!(exported_functions.count(), 8); // 4 required exports plus "execute", "migrate", "query" and "sudo" let exported_memories = module + .exports .iter() .filter(|entry| matches!(entry.kind, ExternalKind::Memory)); assert_eq!(exported_memories.count(), 1); @@ -168,7 +100,7 @@ mod tests { #[test] fn deserialize_wasm_corrupted_data() { - match deserialize_exports(CORRUPTED).unwrap_err() { + match ParsedWasm::parse(CORRUPTED).unwrap_err() { VmError::StaticValidationErr { msg, .. } => { assert!(msg.starts_with("Wasm bytecode could not be deserialized.")) } @@ -179,7 +111,7 @@ mod tests { #[test] fn exported_function_names_works_for_parity_with_no_prefix() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); let exports = module.exported_function_names(None); assert_eq!(exports, HashSet::new()); @@ -195,7 +127,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); let exports = module.exported_function_names(None); assert_eq!( exports, @@ -206,7 +138,7 @@ mod tests { #[test] fn exported_function_names_works_for_parity_with_prefix() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); let exports = module.exported_function_names(Some("b")); assert_eq!(exports, HashSet::new()); @@ -223,7 +155,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); let exports = module.exported_function_names(Some("b")); assert_eq!( exports, @@ -311,7 +243,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); assert!(!has_ibc_entry_points(&module)); // IBC contract @@ -336,7 +268,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); assert!(has_ibc_entry_points(&module)); // Missing packet ack @@ -360,7 +292,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_exports(&wasm).unwrap(); + let module = ParsedWasm::parse(&wasm).unwrap(); assert!(!has_ibc_entry_points(&module)); } } From 18faa267029c42c9838c533da73a4b473c72a939 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Tue, 25 Jul 2023 11:29:07 +0200 Subject: [PATCH 10/11] Fix review comments --- packages/vm/src/compatibility.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index 7654978a2f..c1c6d824b5 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -213,10 +213,10 @@ fn full_import_name(ie: &Import) -> String { } fn check_wasm_capabilities( - exports: &ParsedWasm, + module: &ParsedWasm, available_capabilities: &HashSet, ) -> VmResult<()> { - let required_capabilities = required_capabilities_from_module(exports); + let required_capabilities = required_capabilities_from_module(module); if !required_capabilities.is_subset(available_capabilities) { // We switch to BTreeSet to get a sorted error message let unavailable: BTreeSet<_> = required_capabilities @@ -303,7 +303,7 @@ mod tests { fn check_wasm_tables_works() { // No tables is fine let wasm = wat::parse_str("(module)").unwrap(); - assert!(ParsedWasm::parse(&wasm).unwrap().memories.is_empty()); + assert!(ParsedWasm::parse(&wasm).unwrap().tables.is_empty()); // One table (bound) let wasm = wat::parse_str("(module (table $name 123 123 funcref))").unwrap(); From 55cfdf15b7db90d4f6639d02197695f72b94242c Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Wed, 26 Jul 2023 10:35:49 +0200 Subject: [PATCH 11/11] Add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e21eaca8bd..dd8ea7f1ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,15 @@ and this project adheres to - cosmwasm-vm: Upgrade Wasmer to version 4.1. ([#1674], [#1693], [#1701], [#1793]) - cosmwasm-check: Update clap dependency to version 4 ([#1677]) +- cosmwasm-vm: Use `wasmparser` for initial validation instead of `parity-wasm` + ([#1786]) [#1667]: https://github.com/CosmWasm/cosmwasm/pull/1667 [#1674]: https://github.com/CosmWasm/cosmwasm/pull/1674 [#1677]: https://github.com/CosmWasm/cosmwasm/pull/1677 [#1693]: https://github.com/CosmWasm/cosmwasm/pull/1693 [#1701]: https://github.com/CosmWasm/cosmwasm/pull/1701 +[#1786]: https://github.com/CosmWasm/cosmwasm/pull/1786 [#1793]: https://github.com/CosmWasm/cosmwasm/pull/1793 ## [1.3.0] - 2023-07-17