diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index 62ac663e28..2df4502958 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -259,12 +259,7 @@ fn test_genesis_head(size: usize) -> HeadData { } fn test_validation_code(size: usize) -> ValidationCode { - let mut validation_code = vec![0u8; size as usize]; - // Replace first bytes of code with "WASM_MAGIC" to pass validation test. - let _ = validation_code.splice( - ..crate::WASM_MAGIC.len(), - crate::WASM_MAGIC.iter().cloned(), - ).collect::>(); + let validation_code = vec![0u8; size as usize]; ValidationCode(validation_code) } diff --git a/polkadot/runtime/common/src/lib.rs b/polkadot/runtime/common/src/lib.rs index b0589ad0b7..7d43a5eaf9 100644 --- a/polkadot/runtime/common/src/lib.rs +++ b/polkadot/runtime/common/src/lib.rs @@ -59,10 +59,6 @@ pub use impls::ToAuthor; pub type NegativeImbalance = as Currency<::AccountId>>::NegativeImbalance; -/// The sequence of bytes a valid wasm module binary always starts with. Apart from that it's also a -/// valid wasm module. -pub const WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]; - /// We assume that an on-initialize consumes 1% of the weight on average, hence a single extrinsic /// will not be allowed to consume more than `AvailableBlockRatio - 1%`. pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1); diff --git a/polkadot/runtime/common/src/mock.rs b/polkadot/runtime/common/src/mock.rs index 79ae6014f9..d6bea16652 100644 --- a/polkadot/runtime/common/src/mock.rs +++ b/polkadot/runtime/common/src/mock.rs @@ -160,12 +160,7 @@ impl Registrar for TestRegistrar { #[cfg(test)] fn worst_validation_code() -> ValidationCode { - let mut validation_code = vec![0u8; 1000]; - // Replace first bytes of code with "WASM_MAGIC" to pass validation test. - let _ = validation_code.splice( - ..crate::WASM_MAGIC.len(), - crate::WASM_MAGIC.iter().cloned(), - ).collect::>(); + let validation_code = vec![0u8; 1000]; validation_code.into() } diff --git a/polkadot/runtime/common/src/paras_registrar.rs b/polkadot/runtime/common/src/paras_registrar.rs index 6625b925cf..345cb88022 100644 --- a/polkadot/runtime/common/src/paras_registrar.rs +++ b/polkadot/runtime/common/src/paras_registrar.rs @@ -17,7 +17,6 @@ //! Module to handle parathread/parachain registration and related fund management. //! In essence this is a simple wrapper around `paras`. -use crate::WASM_MAGIC; use sp_std::{prelude::*, result}; use frame_support::{ decl_storage, decl_module, decl_error, decl_event, ensure, @@ -133,8 +132,6 @@ decl_error! { CodeTooLarge, /// Invalid para head data size. HeadDataTooLarge, - /// The validation code provided doesn't start with the Wasm file magic string. - DefinitelyNotWasm, /// Para is not a Parachain. NotParachain, /// Para is not a Parathread. @@ -304,12 +301,7 @@ impl Registrar for Module { fn worst_validation_code() -> ValidationCode { // TODO: Figure a way to allow bigger wasm in benchmarks? let max_code_size = (T::MaxCodeSize::get()).min(4 * 1024 * 1024); - let mut validation_code = vec![0u8; max_code_size as usize]; - // Replace first bytes of code with "WASM_MAGIC" to pass validation test. - let _ = validation_code.splice( - ..crate::WASM_MAGIC.len(), - crate::WASM_MAGIC.iter().cloned(), - ).collect::>(); + let validation_code = vec![0u8; max_code_size as usize]; validation_code.into() } @@ -378,7 +370,6 @@ impl Module { ) -> Result<(ParaGenesisArgs, BalanceOf), sp_runtime::DispatchError> { ensure!(validation_code.0.len() <= T::MaxCodeSize::get() as usize, Error::::CodeTooLarge); ensure!(genesis_head.0.len() <= T::MaxHeadSize::get() as usize, Error::::HeadDataTooLarge); - ensure!(validation_code.0.starts_with(WASM_MAGIC), Error::::DefinitelyNotWasm); let per_byte_fee = T::DataDepositPerByte::get(); let deposit = T::ParaDeposit::get() @@ -557,12 +548,7 @@ mod tests { } fn test_validation_code(size: usize) -> ValidationCode { - let mut validation_code = vec![0u8; size as usize]; - // Replace first bytes of code with "WASM_MAGIC" to pass validation test. - let _ = validation_code.splice( - ..crate::WASM_MAGIC.len(), - crate::WASM_MAGIC.iter().cloned(), - ).collect::>(); + let validation_code = vec![0u8; size as usize]; ValidationCode(validation_code) } @@ -811,7 +797,7 @@ mod tests { Origin::signed(1), 1u32.into(), vec![1; 3].into(), - WASM_MAGIC.to_vec().into(), + vec![1, 2, 3].into() )); // 2 session changes to fully onboard. @@ -827,7 +813,7 @@ mod tests { Origin::signed(1), 1u32.into(), vec![1; 3].into(), - WASM_MAGIC.to_vec().into(), + vec![1, 2, 3].into() ), Error::::AlreadyRegistered); // By session 4, it is offboarded, and we can register again. @@ -837,7 +823,7 @@ mod tests { Origin::signed(1), 1u32.into(), vec![1; 3].into(), - WASM_MAGIC.to_vec().into(), + vec![1, 2, 3].into() )); }); } diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index 80bf0b3e35..650269cf6b 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -16,7 +16,6 @@ //! A simple wrapper allowing `Sudo` to call into `paras` routines. -use crate::WASM_MAGIC; use sp_std::prelude::*; use frame_support::{ decl_error, decl_module, ensure, @@ -47,8 +46,6 @@ decl_error! { /// A DMP message couldn't be sent because it exceeds the maximum size allowed for a downward /// message. ExceedsMaxMessageSize, - /// The validation code provided doesn't start with the Wasm file magic string. - DefinitelyNotWasm, /// Could not schedule para cleanup. CouldntCleanup, /// Not a parathread. @@ -75,7 +72,6 @@ decl_module! { genesis: ParaGenesisArgs, ) -> DispatchResult { ensure_root(origin)?; - ensure!(genesis.validation_code.0.starts_with(WASM_MAGIC), Error::::DefinitelyNotWasm); runtime_parachains::schedule_para_initialize::(id, genesis).map_err(|_| Error::::ParaAlreadyExists)?; Ok(()) }