A simple check to reject obviously wrong validation code binaries (#1989)

* A simple check to reject obviously wrong validation code binaries

* Use wasm-magic constants in the tests.

* tabs not spaces

* move WASM_MAGIC into lib.rs
This commit is contained in:
Sergei Shulepov
2020-11-19 20:22:17 +01:00
committed by GitHub
parent 759ff2bb6e
commit 94670d8082
3 changed files with 21 additions and 9 deletions
+4
View File
@@ -49,6 +49,10 @@ pub use impls::ToAuthor;
pub type NegativeImbalance<T> = <pallet_balances::Module<T> as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
/// The sequence of bytes a valid wasm module binary always starts with. Apart from that it's also a
/// valid wasm module.
const WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];
/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic
/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`.
pub const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_perthousand(25);