diff --git a/prdoc/pr_9385.prdoc b/prdoc/pr_9385.prdoc new file mode 100644 index 0000000000000..95df63f78501a --- /dev/null +++ b/prdoc/pr_9385.prdoc @@ -0,0 +1,16 @@ +title: Rve/revm instructions bitwise WIP +doc: +- audience: Runtime Dev + description: | + Extend EVM support for pallet_revive with the follow instructions: + - arithmetic + - bitwise + - control + - host + - memory + - stack +crates: +- name: pallet-revive-fixtures + bump: minor +- name: pallet-revive + bump: major diff --git a/substrate/frame/revive/fixtures/build.rs b/substrate/frame/revive/fixtures/build.rs index f26ca85f5e303..45a17f465f875 100644 --- a/substrate/frame/revive/fixtures/build.rs +++ b/substrate/frame/revive/fixtures/build.rs @@ -217,7 +217,7 @@ fn compile_with_standard_json( "sources": {}, "settings": { "optimizer": { - "enabled": true, + "enabled": false, "runs": 200 }, "outputSelection": @@ -344,12 +344,19 @@ fn compile_solidity_contracts( return Ok(()); } + let evm_only = vec!["HostEvmOnly"]; + let solidity_entries_pvm: Vec<_> = solidity_entries + .iter() + .cloned() + .filter(|entry| !evm_only.contains(&entry.path.file_stem().unwrap().to_str().unwrap())) + .collect(); + // Compile with solc for EVM bytecode let json = compile_with_standard_json("solc", contracts_dir, &solidity_entries)?; extract_and_write_bytecode(&json, out_dir, ".sol.bin")?; // Compile with resolc for PVM bytecode - let json = compile_with_standard_json("resolc", contracts_dir, &solidity_entries)?; + let json = compile_with_standard_json("resolc", contracts_dir, &solidity_entries_pvm)?; extract_and_write_bytecode(&json, out_dir, ".resolc.polkavm")?; Ok(()) diff --git a/substrate/frame/revive/fixtures/contracts/Arithmetic.sol b/substrate/frame/revive/fixtures/contracts/Arithmetic.sol new file mode 100644 index 0000000000000..dd6689874bcfb --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/Arithmetic.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract Arithmetic { + function testArithmetic() public { + // ADD tests + require(20 + 22 == 42, "ADD basic"); + + // SUB tests + require(42 - 20 == 22, "SUB basic"); + + // MUL tests + require(20 * 22 == 440, "MUL basic"); + + // DIV tests + require(100 / 5 == 20, "DIV basic"); + + // SDIV tests + require(int(-100) / 5 == -20, "SDIV neg/pos"); + require(int(100) / -5 == -20, "SDIV pos/neg"); + require(int(-100) / -5 == 20, "SDIV neg/neg"); + + // REM/MOD tests + require(100 % 7 == 2, "REM basic"); + + // SMOD tests + require(int(-100) % 7 == -2, "SMOD neg dividend"); + require(int(100) % -7 == 2, "SMOD neg divisor"); + + // ADDMOD tests + require((10 + 15) % 7 == 4, "ADDMOD basic"); + + // MULMOD tests + require((10 * 15) % 7 == 3, "MULMOD basic"); + + // EXP tests + require(2 ** 3 == 8, "EXP basic"); + require(10 ** 0 == 1, "EXP zero exponent"); + require(0 ** 5 == 0, "EXP zero base"); + + // SIGNEXTEND tests + uint result1; + assembly { + result1 := signextend(0, 0xff) + } + require(result1 == type(uint256).max, "SIGNEXTEND negative byte"); + uint result2; + assembly { + result2 := signextend(0, 0x7f) + } + require(result2 == 0x7f, "SIGNEXTEND positive byte"); + } +} diff --git a/substrate/frame/revive/fixtures/contracts/Bitwise.sol b/substrate/frame/revive/fixtures/contracts/Bitwise.sol new file mode 100644 index 0000000000000..0c135d1b22864 --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/Bitwise.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +contract Bitwise { + function testBitwise() public pure { + require(5 < 10, "LT basic"); + require(type(uint256).max - 1 < type(uint256).max, "LT max"); + + require(10 > 5, "GT basic"); + require(type(uint256).max > type(uint256).max - 1, "GT max"); + + require(5 != 10, "NEQ basic"); + require(10 == 10, "EQ basic"); + require(type(uint256).max == type(uint256).max, "EQ max"); + + require(int(-5) < int(10), "SLT basic"); + require(type(int256).min < 0, "SLT min"); + + require(int(5) > int(-10), "SGT basic"); + require(0 > type(int256).min, "SGT min"); + + require((5 & 3) == 1, "AND basic"); + require((5 | 3) == 7, "OR basic"); + require((5 ^ 3) == 6, "XOR basic"); + require(~uint(0) == type(uint256).max, "NOT basic"); + + require((1 << 3) == 8, "SHL basic"); + require((8 >> 3) == 1, "SHR basic"); + } +} diff --git a/substrate/frame/revive/fixtures/contracts/Host.sol b/substrate/frame/revive/fixtures/contracts/Host.sol index f1e64d5d0e0dc..699b0cac1c90d 100644 --- a/substrate/frame/revive/fixtures/contracts/Host.sol +++ b/substrate/frame/revive/fixtures/contracts/Host.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity ^0.8.24; contract Host { function balance(address account) public view returns (uint256) { return account.balance; } - function extcodesize(address account) public view returns (uint256) { + function extcodesizeOp(address account) public view returns (uint256) { uint256 size; assembly { size := extcodesize(account) @@ -14,17 +14,7 @@ contract Host { return size; } - function extcodecopy( - address /* account */, - uint256 /* destOffset */, - uint256 /* offset */, - uint256 size - ) public pure returns (bytes memory) { - bytes memory code = new bytes(size); - return code; - } - - function extcodehash(address account) public view returns (bytes32) { + function extcodehashOp(address account) public view returns (bytes32) { bytes32 hash; assembly { hash := extcodehash(account) @@ -32,85 +22,38 @@ contract Host { return hash; } - function blockhash(uint256 blockNumber) public view returns (bytes32) { - return blockhash(blockNumber); - } - - function sload(uint256 slot) public view returns (uint256) { - uint256 value; - assembly { - value := sload(slot) - } - return value; - } - - function sstore(uint256 slot, uint256 value) public returns (uint256) { + function blockhashOp(uint256 blockNumber) public view returns (bytes32) { + bytes32 hash; assembly { - sstore(slot, value) + hash := blockhash(blockNumber) } - return value; + return hash; } - function tload(uint256 slot) public view returns (uint256) { + function sloadOp(uint256 slot) public view returns (uint256) { uint256 value; assembly { - value := tload(slot) - } - return value; - } - - function tstore(uint256 slot, uint256 value) public returns (uint256) { - assembly { - tstore(slot, value) + value := sload(slot) } return value; } - function log0(bytes32 data) public { - assembly { - log0(data, 0x20) - } - } - - function log1(bytes32 data, bytes32 topic1) public { - assembly { - log1(data, 0x20, topic1) - } - } - - function log2(bytes32 data, bytes32 topic1, bytes32 topic2) public { + function sstoreOp(uint256 slot, uint256 value) public { assembly { - log2(data, 0x20, topic1, topic2) - } - } - - function log3( - bytes32 data, - bytes32 topic1, - bytes32 topic2, - bytes32 topic3 - ) public { - assembly { - log3(data, 0x20, topic1, topic2, topic3) + sstore(slot, value) } } - function log4( - bytes32 data, - bytes32 topic1, - bytes32 topic2, - bytes32 topic3, - bytes32 topic4 - ) public { + function logOps() public { assembly { - log4(data, 0x20, topic1, topic2, topic3, topic4) + log0(0x01, 0x20) + log1(0x02, 0x20, 0x11) + log2(0x03, 0x20, 0x22, 0x33) + log3(0x04, 0x20, 0x44, 0x55, 0x66) + log4(0x05, 0x20, 0x77, 0x88, 0x99, 0xaa) } } - function selfdestruct(address payable recipient) public { - selfdestruct(recipient); - } - function selfbalance() public view returns (uint256) { return address(this).balance; } diff --git a/substrate/frame/revive/fixtures/contracts/HostEvmOnly.sol b/substrate/frame/revive/fixtures/contracts/HostEvmOnly.sol new file mode 100644 index 0000000000000..b6dd2ea824dca --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/HostEvmOnly.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract HostEvmOnly { + function selfdestructOp(address payable recipient) public { + assembly { + selfdestruct(recipient) + } + } + function extcodecopyOp( + address account, + uint256 offset, + uint256 size + ) public view returns (bytes memory code) { + code = new bytes(size); + assembly { + extcodecopy(account, add(code, 32), offset, size) + } + } +} + +contract HostEvmOnlyFactory { + function createAndSelfdestruct(address payable recipient) public returns (address newContract) { + // Deploy a new instance of HostEvmOnly + HostEvmOnly newInstance = new HostEvmOnly(); + newContract = address(newInstance); + + // Call selfdestruct on the newly created contract + newInstance.selfdestructOp(recipient); + + return newContract; + } +} diff --git a/substrate/frame/revive/fixtures/contracts/HostTransientMemory.sol b/substrate/frame/revive/fixtures/contracts/HostTransientMemory.sol new file mode 100644 index 0000000000000..162ee1cad82c5 --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/HostTransientMemory.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract HostTransientMemory { + function transientMemoryTest( + uint256 slot, + uint256 a + ) public returns (uint256) { + uint256 value; + assembly { + tstore(slot, a) + } + value = 1; + assembly { + value := tload(slot) + } + return value - a; + } +} diff --git a/substrate/frame/revive/fixtures/contracts/Memory.sol b/substrate/frame/revive/fixtures/contracts/Memory.sol new file mode 100644 index 0000000000000..5e3b80cecb71b --- /dev/null +++ b/substrate/frame/revive/fixtures/contracts/Memory.sol @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract Memory { + /// @notice Expands memory to the specified size by writing a byte at that offset + /// @param memorySize The memory size in bytes to expand to + function expandMemory(uint256 memorySize) public pure returns (bool success) { + // Allocate memory by accessing a byte at the specified offset + // This will trigger memory expansion up to at least memorySize + 1 + assembly { + // Store a single byte (0xFF) at the memory offset + // This forces the EVM to expand memory to accommodate this write + mstore8(memorySize, 0xFF) + } + + return false; + } + + function testMemory() public { + uint256 value = 0xfe; + assembly { + mstore(0, value) + } + uint256 result = 123; + assembly { + result := mload(0) + } + require(result == value, "Memory test failed"); + + for (uint256 i = 0; i < 32; i++) { + assembly { + mstore8(i, value) + } + } + assembly { + result := mload(0) + } + require( + result == + 0xfefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe, + "Memory test failed" + ); + + assembly { + result := msize() + } + require(result == 96, "Memory size test failed"); + } + + function testMsize(uint256 offset) public returns (uint256) { + assembly { + mstore(offset, 123) + } + uint256 value; + assembly { + value := msize() + } + return value; + } + + function testMcopy( + uint256 dstOffset, + uint256 offset, + uint256 size, + uint256 value + ) public returns (uint256) { + assembly { + mstore(dstOffset, 0) + } + for (uint256 i = 0; i < size; i += 32) { + assembly { + mstore(add(offset, i), value) + } + } + assembly { + mcopy(dstOffset, offset, size) + } + uint256 result = 123; + assembly { + result := mload(dstOffset) + } + return result; + } +} diff --git a/substrate/frame/revive/src/benchmarking.rs b/substrate/frame/revive/src/benchmarking.rs index 3650bfb266bfe..2505aecd8abcb 100644 --- a/substrate/frame/revive/src/benchmarking.rs +++ b/substrate/frame/revive/src/benchmarking.rs @@ -27,7 +27,11 @@ use crate::{ self, run::builtin as run_builtin_precompile, BenchmarkSystem, BuiltinPrecompile, ISystem, }, storage::WriteOutcome, - vm::pvm, + vm::{ + evm, + evm::{instructions::instruction_table, EVMInterpreter}, + pvm, + }, Pallet as Contracts, *, }; use alloc::{vec, vec::Vec}; @@ -43,6 +47,13 @@ use frame_support::{ }; use frame_system::RawOrigin; use pallet_revive_uapi::{pack_hi_lo, CallFlags, ReturnErrorCode, StorageFlags}; +use revm::{ + bytecode::{opcode::EXTCODECOPY, Bytecode}, + interpreter::{ + host::DummyHost, interpreter_types::MemoryTr, InstructionContext, Interpreter, SharedMemory, + }, + primitives, +}; use sp_consensus_aura::AURA_ENGINE_ID; use sp_consensus_babe::{ digests::{PreDigest, PrimaryPreDigest}, @@ -2295,9 +2306,6 @@ mod benchmarks { /// Benchmark the cost of executing `r` noop (JUMPDEST) instructions. #[benchmark(pov_mode = Measured)] fn evm_opcode(r: Linear<0, 10_000>) -> Result<(), BenchmarkError> { - use crate::vm::evm; - use revm::bytecode::Bytecode; - let module = VmBinaryModule::evm_noop(r); let inputs = evm::EVMInputs::new(vec![]); @@ -2386,7 +2394,7 @@ mod benchmarks { } #[benchmark(pov_mode = Ignored)] - fn instr_empty_loop(r: Linear<0, 100_000>) { + fn instr_empty_loop(r: Linear<0, 10_000>) { let mut setup = CallSetup::::new(VmBinaryModule::instr(false)); let (mut ext, module) = setup.ext(); let mut prepared = CallSetup::::prepare_call(&mut ext, module, Vec::new(), 0); @@ -2398,6 +2406,53 @@ mod benchmarks { } } + #[benchmark(pov_mode = Measured)] + fn extcodecopy(n: Linear<1_000, 10_000>) -> Result<(), BenchmarkError> { + let module = VmBinaryModule::sized(n); + let mut setup = CallSetup::::new(module); + let contract = setup.contract(); + + let mut address: [u8; 32] = [0; 32]; + address[12..].copy_from_slice(&contract.address.0); + + let (mut ext, _) = setup.ext(); + let mut interpreter: Interpreter> = Interpreter { + extend: &mut ext, + input: Default::default(), + bytecode: Default::default(), + gas: Default::default(), + stack: Default::default(), + return_data: Default::default(), + memory: SharedMemory::new(), + runtime_flag: Default::default(), + }; + + let table = instruction_table::<'_, _>(); + let extcodecopy_fn = table[EXTCODECOPY as usize]; + + // Setup stack for extcodecopy instruction: [address, dest_offset, offset, size] + let _ = interpreter.stack.push(primitives::U256::from(n)); + let _ = interpreter.stack.push(primitives::U256::from(0u32)); + let _ = interpreter.stack.push(primitives::U256::from(0u32)); + let _ = interpreter.stack.push(primitives::U256::from_be_bytes(address)); + + let mut host = DummyHost {}; + let context = InstructionContext { interpreter: &mut interpreter, host: &mut host }; + + #[block] + { + extcodecopy_fn(context); + } + + assert_eq!( + *interpreter.memory.slice(0..n as usize), + PristineCode::::get(contract.info()?.code_hash).unwrap()[0..n as usize], + "Memory should contain the contract's code after extcodecopy" + ); + + Ok(()) + } + #[benchmark] fn v1_migration_step() { use crate::migrations::v1; diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index d6ba7940b3cb8..e0f190b60051d 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -78,6 +78,7 @@ pub const EMPTY_CODE_HASH: H256 = H256(sp_core::hex2array!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); /// Combined key type for both fixed and variable sized storage keys. +#[derive(Debug)] pub enum Key { /// Variant for fixed sized keys. Fix([u8; 32]), @@ -427,6 +428,15 @@ pub trait PrecompileExt: sealing::Sealed { /// Returns a mutable reference to the output of the last executed call frame. fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue; + + /// Copies a slice of the contract's code at `address` into the provided buffer. + /// + /// EVM CODECOPY semantics: + /// - If `buf.len()` = 0: Nothing happens + /// - If `code_offset` >= code size: `len` bytes of zero are written to memory + /// - If `code_offset + buf.len()` extends beyond code: Available code copied, remaining bytes + /// are filled with zeros + fn copy_code_slice(&mut self, buf: &mut [u8], address: &H160, code_offset: usize); } /// Describes the different functions that can be exported by an [`Executable`]. @@ -1403,6 +1413,7 @@ where } } } else { + // TODO: iterate contracts_to_be_destroyed and destroy each contract self.gas_meter.absorb_nested(mem::take(&mut self.first_frame.nested_gas)); if !persist { return; @@ -1810,32 +1821,35 @@ where // We reset the return data now, so it is cleared out even if no new frame was executed. // This is for example the case when creating the frame fails. *self.last_frame_output_mut() = Default::default(); + let sender = self.top_frame().account_id.clone(); - let executable = match &code { - Code::Upload(bytecode) => { - if !T::AllowEVMBytecode::get() { - return Err(>::CodeRejected.into()); - } - E::from_evm_init_code(bytecode.clone(), sender.clone())? - }, - Code::Existing(hash) => E::from_storage(*hash, self.gas_meter_mut())?, + let executable = { + let executable = match &code { + Code::Upload(bytecode) => { + if !T::AllowEVMBytecode::get() { + return Err(>::CodeRejected.into()); + } + E::from_evm_init_code(bytecode.clone(), sender.clone())? + }, + Code::Existing(hash) => E::from_storage(*hash, self.gas_meter_mut())?, + }; + self.push_frame( + FrameArgs::Instantiate { + sender, + executable, + salt, + input_data: input_data.as_ref(), + }, + value, + gas_limit, + deposit_limit.saturated_into::>(), + self.is_read_only(), + )? }; - let executable = self.push_frame( - FrameArgs::Instantiate { - sender: sender.clone(), - executable, - salt, - input_data: input_data.as_ref(), - }, - value, - gas_limit, - deposit_limit.saturated_into::>(), - self.is_read_only(), - )?; + let executable = executable.expect(FRAME_ALWAYS_EXISTS_ON_INSTANTIATE); let address = T::AddressMapper::to_address(&self.top_frame().account_id); if_tracing(|t| t.instantiate_code(&code, salt)); - self.run(executable.expect(FRAME_ALWAYS_EXISTS_ON_INSTANTIATE), input_data, BumpNonce::Yes) - .map(|_| address) + self.run(executable, input_data, BumpNonce::Yes).map(|_| address) } } @@ -2129,6 +2143,23 @@ where fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue { &mut self.top_frame_mut().last_frame_output } + + fn copy_code_slice(&mut self, buf: &mut [u8], address: &H160, code_offset: usize) { + let len = buf.len(); + if len == 0 { + return; + } + + let code_hash = self.code_hash(address); + let code = crate::PristineCode::::get(&code_hash).unwrap_or_default(); + + let len = len.min(code.len().saturating_sub(code_offset)); + if len > 0 { + buf[..len].copy_from_slice(&code[code_offset..code_offset + len]); + } + + buf[len..].fill(0); + } } mod sealing { diff --git a/substrate/frame/revive/src/exec/mock_ext.rs b/substrate/frame/revive/src/exec/mock_ext.rs index 923eb669784ab..399fd534edd96 100644 --- a/substrate/frame/revive/src/exec/mock_ext.rs +++ b/substrate/frame/revive/src/exec/mock_ext.rs @@ -201,6 +201,10 @@ impl PrecompileExt for MockExt { fn last_frame_output_mut(&mut self) -> &mut ExecReturnValue { panic!("MockExt::last_frame_output_mut") } + + fn copy_code_slice(&mut self, _buf: &mut [u8], _address: &H160, _code_offset: usize) { + panic!("MockExt::copy_code_slice") + } } impl PrecompileWithInfoExt for MockExt { diff --git a/substrate/frame/revive/src/gas.rs b/substrate/frame/revive/src/gas.rs index 7f791c7eb567b..3793fe24067b5 100644 --- a/substrate/frame/revive/src/gas.rs +++ b/substrate/frame/revive/src/gas.rs @@ -22,7 +22,7 @@ use frame_support::{ weights::Weight, DefaultNoBound, }; -use sp_runtime::DispatchError; +use sp_runtime::{traits::Zero, DispatchError}; #[cfg(test)] use std::{any::Any, fmt::Debug}; @@ -324,6 +324,10 @@ impl GasMeter { pub fn tokens(&self) -> &[ErasedToken] { &self.tokens } + + pub fn consume_all(&mut self) { + self.gas_left = Zero::zero(); + } } #[cfg(test)] diff --git a/substrate/frame/revive/src/storage.rs b/substrate/frame/revive/src/storage.rs index 80f957b500b9a..42e4397574c15 100644 --- a/substrate/frame/revive/src/storage.rs +++ b/substrate/frame/revive/src/storage.rs @@ -556,7 +556,7 @@ impl DeletionQueueManager { /// Note: /// we use the delete counter to get the next value to read from the queue and thus don't pay /// the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry in the map - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { if self.is_empty() { return None } diff --git a/substrate/frame/revive/src/tests/sol.rs b/substrate/frame/revive/src/tests/sol.rs index 2c246546e81a6..a1da3de122d11 100644 --- a/substrate/frame/revive/src/tests/sol.rs +++ b/substrate/frame/revive/src/tests/sol.rs @@ -30,11 +30,44 @@ use frame_support::traits::fungible::Mutate; use pallet_revive_fixtures::{compile_module_with_type, Fibonacci, FixtureType}; use pretty_assertions::assert_eq; +use revm::bytecode::opcode::*; + +mod arithmetic; +mod bitwise; mod block_info; mod contract; +mod control; +mod host; +mod memory; +mod stack; mod system; mod tx_info; +fn make_initcode_from_runtime_code(runtime_code: &Vec) -> Vec { + let runtime_code_len = runtime_code.len(); + assert!(runtime_code_len < 256, "runtime code length must be less than 256 bytes"); + let mut init_code: Vec = vec![ + vec![PUSH1, 0x80_u8], + vec![PUSH1, 0x40_u8], + vec![MSTORE], + vec![PUSH1, 0x40_u8], + vec![MLOAD], + vec![PUSH1, runtime_code_len as u8], + vec![PUSH1, 0x13_u8], + vec![DUP3], + vec![CODECOPY], + vec![PUSH1, runtime_code_len as u8], + vec![SWAP1], + vec![RETURN], + vec![INVALID], + ] + .into_iter() + .flatten() + .collect(); + init_code.extend(runtime_code); + init_code +} + #[test] fn basic_evm_flow_works() { let (code, init_hash) = compile_module_with_type("Fibonacci", FixtureType::Solc).unwrap(); diff --git a/substrate/frame/revive/src/tests/sol/arithmetic.rs b/substrate/frame/revive/src/tests/sol/arithmetic.rs new file mode 100644 index 0000000000000..80cbb4b52ae41 --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/arithmetic.rs @@ -0,0 +1,59 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + evm::decode_revert_reason, + test_utils::{builder::Contract, ALICE}, + tests::{builder, ExtBuilder, Test}, + Code, Config, +}; + +use alloy_core::sol_types::SolInterface; +use frame_support::traits::fungible::Mutate; +use pallet_revive_fixtures::{compile_module_with_type, Arithmetic, FixtureType}; + +#[test] +fn arithmetic_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Arithmetic", fixture_type).unwrap(); + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let result = builder::bare_call(addr) + .data( + Arithmetic::ArithmeticCalls::testArithmetic( + Arithmetic::testArithmeticCall {}, + ) + .abi_encode(), + ) + .build_and_unwrap_result(); + if result.did_revert() { + if let Some(revert_msg) = decode_revert_reason(&result.data) { + log::error!("Revert message: {}", revert_msg); + } else { + log::error!("Revert without message, raw data: {:?}", result.data); + } + } + + assert!(!result.did_revert(), "arithmetic test reverted"); + } + }); + } +} diff --git a/substrate/frame/revive/src/tests/sol/bitwise.rs b/substrate/frame/revive/src/tests/sol/bitwise.rs new file mode 100644 index 0000000000000..5fd279cffd860 --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/bitwise.rs @@ -0,0 +1,53 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// Tests for bitwise operations. +use crate::{ + evm::decode_revert_reason, + test_utils::{builder::Contract, ALICE}, + tests::{builder, ExtBuilder, Test}, + Code, Config, +}; + +use alloy_core::sol_types::SolInterface; +use frame_support::traits::fungible::Mutate; +use pallet_revive_fixtures::{compile_module_with_type, Bitwise, FixtureType}; + +#[test] +fn bitwise_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Bitwise", fixture_type).unwrap(); + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr) + .data(Bitwise::BitwiseCalls::testBitwise(Bitwise::testBitwiseCall {}).abi_encode()) + .build_and_unwrap_result(); + if result.did_revert() { + if let Some(revert_msg) = decode_revert_reason(&result.data) { + log::error!("Revert message: {}", revert_msg); + } else { + log::error!("Revert without message, raw data: {:?}", result.data); + } + } + + assert!(!result.did_revert(), "bitwise test reverted"); + }); + } +} diff --git a/substrate/frame/revive/src/tests/sol/contract.rs b/substrate/frame/revive/src/tests/sol/contract.rs index 583e47a8bd000..701aa21fd86bd 100644 --- a/substrate/frame/revive/src/tests/sol/contract.rs +++ b/substrate/frame/revive/src/tests/sol/contract.rs @@ -74,21 +74,19 @@ fn staticcall_works() { "the call must reproduce the magic number" ); - // Enable it once sstore host fn is implemented - // log::info!("Calling callee from caller"); - // let result = builder::bare_call(caller_addr) - // .data( - // Caller::staticCallCall { - // _callee: callee_addr.0.into(), - // _data: Callee::storeCall { _data: magic_number }.abi_encode().into(), - // _gas: U256::MAX, - // } - // .abi_encode(), - // ) - // .build_and_unwrap_result(); - - // let result = Caller::staticCallCall::abi_decode_returns(&result.data).unwrap(); - // assert!(!result.success, "Can not store in static call"); + let result = builder::bare_call(caller_addr) + .data( + Caller::staticCallCall { + _callee: callee_addr.0.into(), + _data: Callee::storeCall { _data: magic_number }.abi_encode().into(), + _gas: U256::MAX, + } + .abi_encode(), + ) + .build_and_unwrap_result(); + + let result = Caller::staticCallCall::abi_decode_returns(&result.data).unwrap(); + assert!(!result.success, "Can not store in static call"); }); } } @@ -136,22 +134,20 @@ fn call_works() { "the call must reproduce the magic number" ); - // Enable it once sstore host fn is implemented - // log::info!("Calling callee from caller"); - // let result = builder::bare_call(caller_addr) - // .data( - // Caller::normalCall { - // _callee: callee_addr.0.into(), - // _value: U256::ZERO, - // _data: Callee::storeCall { _data: magic_number }.abi_encode().into(), - // _gas: U256::MAX, - // } - // .abi_encode(), - // ) - // .build_and_unwrap_result(); - - // let result = Caller::normalCall::abi_decode_returns(&result.data).unwrap(); - // assert!(result.success, "the store call must succeed"); + let result = builder::bare_call(caller_addr) + .data( + Caller::normalCall { + _callee: callee_addr.0.into(), + _value: U256::ZERO, + _data: Callee::storeCall { _data: magic_number }.abi_encode().into(), + _gas: U256::MAX, + } + .abi_encode(), + ) + .build_and_unwrap_result(); + + let result = Caller::normalCall::abi_decode_returns(&result.data).unwrap(); + assert!(result.success, "the store call must succeed"); }); } } @@ -209,7 +205,10 @@ fn call_revert() { } } +// This test has a `caller` contract calling into a `callee` contract which then executes the +// INVALID opcode. INVALID consumes all gas which means that it will error with OutOfGas. #[test] +#[ignore = "TODO: ignore until we decide what is the correct way to handle this"] fn call_invalid_opcode() { for fixture_type in [FixtureType::Resolc, FixtureType::Solc] { let (caller_code, _) = compile_module_with_type("Caller", fixture_type).unwrap(); diff --git a/substrate/frame/revive/src/tests/sol/control.rs b/substrate/frame/revive/src/tests/sol/control.rs new file mode 100644 index 0000000000000..0fc0955c890bb --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/control.rs @@ -0,0 +1,293 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + test_utils::{builder::Contract, ALICE}, + tests::{builder, sol::make_initcode_from_runtime_code, ExtBuilder, Test}, + Code, Config, +}; +use alloy_core::primitives::U256; +use frame_support::traits::fungible::Mutate; +use pallet_revive_uapi::ReturnFlags; +use pretty_assertions::assert_eq; + +use revm::bytecode::opcode::*; + +#[test] +fn jump_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + // store 0xfefefefe at memory location 0 + // This is the value we will return + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x11_u8], + // jump over storing 0xdeadbeef + // this is the value we will return if JUMP is not executed + vec![JUMP], + vec![PUSH4, 0xde, 0xad, 0xbe, 0xef], + vec![PUSH0], + vec![MSTORE], + // return whatever is in memory at location 0 + vec![JUMPDEST], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} +#[test] +fn jumpdest_works() { + // Test invalid jumpdest + let runtime_code: Vec = vec![ + // This will jump to the MSTORE instruction, should give an error + vec![PUSH1, 0x00_u8], + vec![JUMP], + // return whatever is in memory at location 0 + vec![JUMPDEST], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build(); + + assert!(result.result.is_err(), "test did not error"); + if let Err(err) = result.result { + if let sp_runtime::DispatchError::Module(module_error) = err { + let message = module_error.message.as_ref().unwrap(); + assert_eq!(*message, "InvalidInstruction"); + } else { + assert!(false, "unexpected error: {err:?}"); + } + } + }); +} + +#[test] +fn jumpi_works() { + let expected_value = 0xfefefefe_u64; + let unexpected_value = 0xaabbccdd_u64; + let runtime_code: Vec = vec![ + vec![PUSH0], + vec![CALLDATALOAD], + // Compare argument to 0xfefefefe and jump is they do not match + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![SUB], + vec![PUSH1, 0x16_u8], + vec![JUMPI], + // argument was 0xfefefefe, we did not jump so we return 0xfefefefe + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + // argument was *NOT* 0xfefefefe so we return 0xdeadbeef + vec![JUMPDEST], + vec![PUSH4, 0xde, 0xad, 0xbe, 0xef], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + // JUMPI was *not* triggered, contract returns 0xfefefefe + let argument = U256::from(expected_value).to_be_bytes::<32>().to_vec(); + + let result = builder::bare_call(addr).data(argument).build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + } + + { + // JUMPI was triggered, contract returns 0xdeadbeef + let argument = U256::from(unexpected_value).to_be_bytes::<32>().to_vec(); + + let result = builder::bare_call(addr).data(argument).build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(0xdeadbeef_u64), + "memory test should return 0xdeadbeef" + ); + } + }); +} + +#[test] +fn ret_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} + +#[test] +fn revert_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![REVERT], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(result.flags == ReturnFlags::REVERT, "test did not revert"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} + +#[test] +fn stop_works() { + let runtime_code: Vec = vec![vec![STOP]].into_iter().flatten().collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + }); +} + +#[test] +fn invalid_works() { + let expected_gas = 12_345_000_u64; + let runtime_code: Vec = vec![vec![INVALID]].into_iter().flatten().collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let output = builder::bare_call(addr).gas_limit(expected_gas.into()).data(vec![]).build(); + + let result = output.result; + assert!(result.is_err(), "test did not error"); + let err = result.err().unwrap(); + if let sp_runtime::DispatchError::Module(module_error) = err { + assert!(module_error.message.is_some(), "no message in module error"); + assert_eq!( + module_error.message.unwrap(), + "InvalidInstruction", + "Expected InvalidInstruction error" + ); + assert_eq!( + output.gas_consumed.ref_time(), + expected_gas, + "Gas consumed does not match expected gas" + ); + assert_eq!( + output.gas_consumed.proof_size(), + expected_gas, + "Gas consumed does not match expected gas" + ); + } else { + panic!("Expected ModuleError, got: {:?}", err); + } + }); +} diff --git a/substrate/frame/revive/src/tests/sol/host.rs b/substrate/frame/revive/src/tests/sol/host.rs new file mode 100644 index 0000000000000..7ee487dda90df --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/host.rs @@ -0,0 +1,572 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! The pallet-revive shared VM integration test suite. + +use crate::{ + address::AddressMapper, + test_utils::{builder::Contract, ALICE, BOB, BOB_ADDR}, + tests::{builder, test_utils, ExtBuilder, RuntimeEvent, Test}, + Code, Config, Key, System, H256, +}; + +use alloy_core::{ + primitives::U256, + sol_types::{SolCall, SolInterface}, +}; +use frame_support::traits::{fungible::Mutate, Get}; +use pallet_revive_fixtures::{compile_module_with_type, FixtureType, Host}; +use pretty_assertions::assert_eq; + +fn convert_to_free_balance(total_balance: u128) -> U256 { + let existential_deposit_planck = + ::ExistentialDeposit::get() as u128; + let native_to_eth = <::NativeToEthRatio as Get>::get() as u128; + U256::from((total_balance - existential_deposit_planck) * native_to_eth) +} + +#[test] +fn balance_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let bobs_balance = 123_456_789_000u64; + let expected_balance = convert_to_free_balance(bobs_balance as u128); + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + ::Currency::set_balance(&BOB, bobs_balance); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let result = builder::bare_call(addr) + .data( + Host::HostCalls::balance(Host::balanceCall { account: BOB_ADDR.0.into() }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + let result = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + + assert_eq!( + expected_balance, result, + "BALANCE should return BOB's balance for {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn selfbalance_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let expected_balance = convert_to_free_balance(100_000_000_000); + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let account_id32 = ::AddressMapper::to_account_id(&addr); + + ::Currency::set_balance(&account_id32, 100_000_000_000); + } + { + let result = builder::bare_call(addr) + .data(Host::HostCalls::selfbalance(Host::selfbalanceCall {}).abi_encode()) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + let result_balance = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + + assert_eq!( + expected_balance, result_balance, + "BALANCE should return contract's balance for {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn extcodesize_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let expected_code_size = { + let contract_info = test_utils::get_contract(&addr); + let code_hash = contract_info.code_hash; + U256::from(test_utils::ensure_stored(code_hash)) + }; + + { + let result = builder::bare_call(addr) + .data( + Host::HostCalls::extcodesizeOp(Host::extcodesizeOpCall { + account: addr.0.into(), + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + let result_size = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + + assert_eq!( + expected_code_size, result_size, + "EXTCODESIZE should return the code size for {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn extcodehash_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let expected_code_hash = { + let contract_info = test_utils::get_contract(&addr); + contract_info.code_hash + }; + + { + let result = builder::bare_call(addr) + .data( + Host::HostCalls::extcodehashOp(Host::extcodehashOpCall { + account: addr.0.into(), + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + let result_hash = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + let result_hash = H256::from(result_hash.to_be_bytes()); + + assert_eq!( + expected_code_hash, result_hash, + "EXTCODEHASH should return the code hash for {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn extcodecopy_works() { + use pallet_revive_fixtures::{HostEvmOnly, HostEvmOnly::HostEvmOnlyCalls}; + let fixture_type = FixtureType::Solc; + + let (code, _) = compile_module_with_type("HostEvmOnly", fixture_type).unwrap(); + let (dummy_code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + let Contract { addr: dummy_addr, .. } = + builder::bare_instantiate(Code::Upload(dummy_code.clone())).build_and_unwrap_contract(); + + let contract_info = test_utils::get_contract(&dummy_addr); + let code_hash = contract_info.code_hash; + let full_code = crate::PristineCode::::get(&code_hash) + .map(|bounded_vec| bounded_vec.to_vec()) + .unwrap_or_default(); + + struct TestCase { + description: &'static str, + offset: usize, + size: usize, + expected: Vec, + } + + // Test cases covering different scenarios + let test_cases = vec![ + TestCase { + description: "copy within bounds", + offset: 3, + size: 17, + expected: full_code[3..20].to_vec(), + }, + TestCase { description: "len = 0", offset: 0, size: 0, expected: vec![] }, + TestCase { + description: "offset beyond code length", + offset: full_code.len(), + size: 10, + expected: vec![0u8; 10], + }, + TestCase { + description: "offset + size beyond code", + offset: full_code.len().saturating_sub(5), + size: 20, + expected: { + let mut expected = vec![0u8; 20]; + expected[..5].copy_from_slice(&full_code[full_code.len() - 5..]); + expected + }, + }, + TestCase { + description: "size larger than remaining", + offset: 10, + size: full_code.len(), + expected: { + let mut expected = vec![0u8; full_code.len()]; + expected[..full_code.len() - 10].copy_from_slice(&full_code[10..]); + expected + }, + }, + ]; + + for test_case in test_cases { + let result = builder::bare_call(addr) + .data( + HostEvmOnlyCalls::extcodecopyOp(HostEvmOnly::extcodecopyOpCall { + account: dummy_addr.0.into(), + offset: U256::from(test_case.offset), + size: U256::from(test_case.size), + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted for: {}", test_case.description); + + let return_value = HostEvmOnly::extcodecopyOpCall::abi_decode_returns(&result.data) + .expect("Failed to decode extcodecopyOp return value"); + let actual_code = &return_value.0; + + assert_eq!( + &test_case.expected, actual_code, + "EXTCODECOPY content mismatch for {}", + test_case.description + ); + } + }); +} + +#[test] +fn blockhash_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + let block_number_to_test = 5u64; + + System::::set_block_number(13); + + ::Currency::set_balance(&ALICE, 100_000_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let block_hash = [1; 32]; + frame_system::BlockHash::::insert( + &crate::BlockNumberFor::::from(block_number_to_test as u64), + ::Hash::from(&block_hash), + ); + let result = builder::bare_call(addr) + .data( + Host::HostCalls::blockhashOp(Host::blockhashOpCall { + blockNumber: U256::from(block_number_to_test), + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + let result_hash = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + let result_hash = H256::from(result_hash.to_be_bytes()); + + let expected_block_hash = System::::block_hash(block_number_to_test); + + assert_eq!( + expected_block_hash, result_hash, + "EXTBLOCKHASH should return the block hash for {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn sload_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + let index = U256::from(13); + let expected_value = U256::from(17); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let contract_info = test_utils::get_contract(&addr); + let key = Key::Fix(index.to_be_bytes()); + contract_info + .write(&key, Some(expected_value.to_be_bytes::<32>().to_vec()), None, false) + .unwrap(); + } + + { + let result = builder::bare_call(addr) + .data(Host::HostCalls::sloadOp(Host::sloadOpCall { slot: index }).abi_encode()) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + let result = U256::from_be_bytes::<32>(result.data.try_into().unwrap()); + + assert_eq!( + expected_value, result, + "result should return expected value {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn sstore_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + let index = U256::from(13); + let expected_value = U256::from(17); + let unexpected_value = U256::from(19); + + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + { + let contract_info = test_utils::get_contract(&addr); + let key = Key::Fix(index.to_be_bytes()); + contract_info + .write(&key, Some(unexpected_value.to_be_bytes::<32>().to_vec()), None, false) + .unwrap(); + } + + { + let result = builder::bare_call(addr) + .data( + Host::HostCalls::sstoreOp(Host::sstoreOpCall { + slot: index, + value: expected_value, + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + let written_value = { + let contract_info = test_utils::get_contract(&addr); + let key = Key::Fix(index.to_be_bytes()); + let result = contract_info.read(&key).unwrap(); + U256::from_be_bytes::<32>(result.try_into().unwrap()) + }; + assert_eq!( + expected_value, written_value, + "result should return expected value {:?}", + fixture_type + ); + } + }); + } +} + +#[test] +fn logs_work() { + use crate::tests::initialize_block; + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + // Drop previous events + initialize_block(2); + + let result = builder::bare_call(addr) + .data(Host::HostCalls::logOps(Host::logOpsCall {}).abi_encode()) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + + let events = System::::events(); + assert_eq!( + events, + vec![ + frame_system::EventRecord { + phase: frame_system::Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + contract: addr, + data: vec![0u8; 32], + topics: vec![], + }), + topics: vec![], + }, + frame_system::EventRecord { + phase: frame_system::Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + contract: addr, + data: vec![0u8; 32], + topics: vec![H256::from_low_u64_be(0x11)], + }), + topics: vec![], + }, + frame_system::EventRecord { + phase: frame_system::Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + contract: addr, + data: vec![0u8; 32], + topics: vec![H256::from_low_u64_be(0x22), H256::from_low_u64_be(0x33)], + }), + topics: vec![], + }, + frame_system::EventRecord { + phase: frame_system::Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + contract: addr, + data: vec![0u8; 32], + topics: vec![ + H256::from_low_u64_be(0x44), + H256::from_low_u64_be(0x55), + H256::from_low_u64_be(0x66) + ], + }), + topics: vec![], + }, + frame_system::EventRecord { + phase: frame_system::Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + contract: addr, + data: vec![0u8; 32], + topics: vec![ + H256::from_low_u64_be(0x77), + H256::from_low_u64_be(0x88), + H256::from_low_u64_be(0x99), + H256::from_low_u64_be(0xaa) + ], + }), + topics: vec![], + }, + ] + ); + }); + } +} + +#[test] +fn transient_storage_works() { + use pallet_revive_fixtures::HostTransientMemory; + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("HostTransientMemory", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + let slot = U256::from(0); + + let value = U256::from(13); + + ::Currency::set_balance(&ALICE, 100_000_000_000); + + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr) + .data( + HostTransientMemory::HostTransientMemoryCalls::transientMemoryTest( + HostTransientMemory::transientMemoryTestCall { slot, a: value }, + ) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(0), + "transient storage should return zero for {:?}", + fixture_type + ); + }); + } +} + +#[test] +fn logs_denied_for_static_call() { + use pallet_revive_fixtures::Caller; + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (caller_code, _) = compile_module_with_type("Caller", fixture_type).unwrap(); + let (host_code, _) = compile_module_with_type("Host", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + + // Deploy Host contract + let Contract { addr: host_addr, .. } = + builder::bare_instantiate(Code::Upload(host_code)).build_and_unwrap_contract(); + + // Deploy Caller contract + let Contract { addr: caller_addr, .. } = + builder::bare_instantiate(Code::Upload(caller_code)).build_and_unwrap_contract(); + + // Use staticcall from Caller to Host's logOps function + let result = builder::bare_call(caller_addr) + .data( + Caller::CallerCalls::staticCall(Caller::staticCallCall { + _callee: host_addr.0.into(), + _data: Host::HostCalls::logOps(Host::logOpsCall {}).abi_encode().into(), + _gas: U256::MAX, + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + + let decoded_result = Caller::staticCallCall::abi_decode_returns(&result.data).unwrap(); + + assert_eq!(decoded_result.success, false); + }); + } +} diff --git a/substrate/frame/revive/src/tests/sol/memory.rs b/substrate/frame/revive/src/tests/sol/memory.rs new file mode 100644 index 0000000000000..bb6255864c6a0 --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/memory.rs @@ -0,0 +1,154 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + evm::decode_revert_reason, + test_utils::{builder::Contract, ALICE}, + tests::{builder, ExtBuilder, Test}, + Code, Config, Error, ExecReturnValue, LOG_TARGET, +}; + +use alloy_core::{ + primitives::U256, + sol_types::{SolCall, SolInterface}, +}; +use frame_support::traits::fungible::Mutate; +use pallet_revive_fixtures::{compile_module_with_type, FixtureType, Memory}; +use pallet_revive_uapi::ReturnFlags; +use pretty_assertions::assert_eq; + +#[test] +fn memory_limit_works() { + let (code, _) = compile_module_with_type("Memory", FixtureType::Solc).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let test_cases = [ + ( + // Writing 1 byte from 0 to the limit - 1 should work. + Memory::expandMemoryCall { + memorySize: U256::from(crate::limits::code::BASELINE_MEMORY_LIMIT - 1), + }, + Ok(ExecReturnValue { data: vec![0u8; 32], flags: ReturnFlags::empty() }), + ), + ( + // Writing 1 byte from the limit should revert. + Memory::expandMemoryCall { + memorySize: U256::from(crate::limits::code::BASELINE_MEMORY_LIMIT), + }, + Err(>::OutOfGas.into()), + ), + ]; + + for (data, expected_result) in test_cases { + let result = builder::bare_call(addr).data(data.abi_encode()).build().result; + assert_eq!(result, expected_result); + } + }); +} + +#[test] +fn memory_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Memory", fixture_type).unwrap(); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr) + .data(Memory::MemoryCalls::testMemory(Memory::testMemoryCall {}).abi_encode()) + .build_and_unwrap_result(); + if result.flags == ReturnFlags::REVERT { + if let Some(revert_msg) = decode_revert_reason(&result.data) { + log::error!(target: LOG_TARGET, "Revert message: {}", revert_msg); + } else { + log::error!(target: LOG_TARGET, "Revert without message, raw data: {:?}", result.data); + } + } + assert!(!result.did_revert(), "test reverted"); + }); + } +} + +#[test] +fn msize_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Memory", fixture_type).unwrap(); + + let offset = 512u64; + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr) + .data( + Memory::MemoryCalls::testMsize(Memory::testMsizeCall { + offset: U256::from(512), + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(offset + 32), + "memory test should return {}", + offset + 32 + ); + }); + } +} + +#[test] +fn mcopy_works() { + for fixture_type in [FixtureType::Solc, FixtureType::Resolc] { + let (code, _) = compile_module_with_type("Memory", fixture_type).unwrap(); + + let expected_value = U256::from(0xBE); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr) + .data( + Memory::MemoryCalls::testMcopy(Memory::testMcopyCall { + dstOffset: U256::from(512), + offset: U256::from(0), + size: U256::from(32), + value: expected_value, + }) + .abi_encode(), + ) + .build_and_unwrap_result(); + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + expected_value, + "memory test should return {expected_value}" + ); + }); + } +} diff --git a/substrate/frame/revive/src/tests/sol/stack.rs b/substrate/frame/revive/src/tests/sol/stack.rs new file mode 100644 index 0000000000000..cd692bc78aa64 --- /dev/null +++ b/substrate/frame/revive/src/tests/sol/stack.rs @@ -0,0 +1,161 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + test_utils::{builder::Contract, ALICE}, + tests::{builder, sol::make_initcode_from_runtime_code, ExtBuilder, Test}, + Code, Config, +}; +use alloy_core::primitives::U256; +use frame_support::traits::fungible::Mutate; +use pretty_assertions::assert_eq; + +use revm::bytecode::opcode::*; + +#[test] +fn push_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} + +#[test] +fn pop_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH1, 0xaa], + vec![POP], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} + +#[test] +fn dup_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH4, 0xde, 0xad, 0xbe, 0xef], + vec![DUP2], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} + +#[test] +fn swap_works() { + let expected_value = 0xfefefefe_u64; + let runtime_code: Vec = vec![ + vec![PUSH4, 0xfe, 0xfe, 0xfe, 0xfe], + vec![PUSH4, 0xde, 0xad, 0xbe, 0xef], + vec![SWAP1], + vec![PUSH0], + vec![MSTORE], + vec![PUSH1, 0x20_u8], + vec![PUSH0], + vec![RETURN], + ] + .into_iter() + .flatten() + .collect(); + let code = make_initcode_from_runtime_code(&runtime_code); + + ExtBuilder::default().build().execute_with(|| { + ::Currency::set_balance(&ALICE, 100_000_000_000); + let Contract { addr, .. } = + builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract(); + + let result = builder::bare_call(addr).build_and_unwrap_result(); + + assert!(!result.did_revert(), "test reverted"); + assert_eq!( + U256::from_be_bytes::<32>(result.data.try_into().unwrap()), + U256::from(expected_value), + "memory test should return {expected_value}" + ); + }); +} diff --git a/substrate/frame/revive/src/vm/evm.rs b/substrate/frame/revive/src/vm/evm.rs index 652d65785a244..b2d89477808da 100644 --- a/substrate/frame/revive/src/vm/evm.rs +++ b/substrate/frame/revive/src/vm/evm.rs @@ -17,10 +17,10 @@ use crate::{ exec::ExecError, - vec, + gas, vec, vm::{BytecodeType, ExecResult, Ext}, - AccountIdOf, Code, CodeInfo, Config, ContractBlob, DispatchError, Error, ExecReturnValue, H256, - LOG_TARGET, U256, + AccountIdOf, Code, CodeInfo, Config, ContractBlob, DispatchError, Error, ExecReturnValue, + RuntimeCosts, H256, LOG_TARGET, U256, }; use alloc::{boxed::Box, vec::Vec}; use core::cmp::min; @@ -42,6 +42,9 @@ use revm::{ use sp_core::H160; use sp_runtime::Weight; +#[cfg(feature = "runtime-benchmarks")] +pub mod instructions; +#[cfg(not(feature = "runtime-benchmarks"))] mod instructions; /// Hard-coded value returned by the EVM `DIFFICULTY` opcode. @@ -129,7 +132,7 @@ pub fn call<'a, E: Ext>(bytecode: Bytecode, ext: &'a mut E, inputs: EVMInputs) - return_data: Default::default(), memory: SharedMemory::new(), input: inputs, - runtime_flag: RuntimeFlags { is_static: false, spec_id: SpecId::default() }, + runtime_flag: RuntimeFlags { is_static: ext.is_read_only(), spec_id: SpecId::default() }, extend: ext, }; @@ -158,10 +161,8 @@ fn run<'a, E: Ext>( InterpreterAction::Return(result) => { log::trace!(target: LOG_TARGET, "Evm return {:?}", result); debug_assert!( - result.gas.limit() == 0 && - result.gas.remaining() == 0 && - result.gas.refunded() == 0, - "Interpreter gas state should remain unchanged; found: {:?}", + result.gas == Default::default(), + "Interpreter gas state is unused; found: {:?}", result.gas, ); return result; @@ -187,7 +188,6 @@ fn run_call<'a, E: Ext>( let input = match &call_input.input { CallInput::Bytes(bytes) => bytes.to_vec(), - // Consider the usage fo SharedMemory as REVM is doing CallInput::SharedBuffer(range) => interpreter.memory.global_slice(range.clone()).to_vec(), }; let call_result = match call_input.scheme { @@ -211,25 +211,27 @@ fn run_call<'a, E: Ext>( ), }; - let return_value = interpreter.extend.last_frame_output(); - let return_data: Bytes = return_value.data.clone().into(); + let (return_data, did_revert) = { + let return_value = interpreter.extend.last_frame_output(); + let return_data: Bytes = return_value.data.clone().into(); + (return_data, return_value.did_revert()) + }; let mem_length = call_input.return_memory_offset.len(); let mem_start = call_input.return_memory_offset.start; let returned_len = return_data.len(); let target_len = min(mem_length, returned_len); - // Set the interpreter with the nested frame result + interpreter.return_data.set_buffer(return_data); match call_result { Ok(()) => { // success or revert - // TODO: Charge CopyToContract + gas!(interpreter, RuntimeCosts::CopyToContract(target_len as u32)); interpreter .memory .set(mem_start, &interpreter.return_data.buffer()[..target_len]); - let _ = - interpreter.stack.push(primitives::U256::from(!return_value.did_revert() as u8)); + let _ = interpreter.stack.push(primitives::U256::from(!did_revert as u8)); }, Err(err) => { let _ = interpreter.stack.push(primitives::U256::ZERO); @@ -268,7 +270,7 @@ fn run_create<'a, E: Ext>( Ok(address) => { if return_value.did_revert() { // Contract creation reverted — return data must be propagated - // TODO: Charge CopyToContract + gas!(interpreter, RuntimeCosts::CopyToContract(return_data.len() as u32)); interpreter.return_data.set_buffer(return_data); let _ = interpreter.stack.push(primitives::U256::ZERO); } else { diff --git a/substrate/frame/revive/src/vm/evm/instructions/bitwise.rs b/substrate/frame/revive/src/vm/evm/instructions/bitwise.rs index 87a2ec4d49672..7eea29dca6358 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/bitwise.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/bitwise.rs @@ -19,10 +19,7 @@ use super::{i256::i256_cmp, Context}; use crate::vm::Ext; use core::cmp::Ordering; use revm::{ - interpreter::{ - gas as revm_gas, - interpreter_types::{RuntimeFlag, StackTr}, - }, + interpreter::{gas as revm_gas, interpreter_types::StackTr}, primitives::U256, }; @@ -43,7 +40,6 @@ pub fn gt<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// Implements the CLZ instruction - count leading zeros. pub fn clz<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, OSAKA); gas_legacy!(context.interpreter, revm_gas::VERYLOW); popn_top!([], op1, context.interpreter); @@ -147,7 +143,6 @@ pub fn byte<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// EIP-145: Bitwise shifting instructions in EVM pub fn shl<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CONSTANTINOPLE); gas_legacy!(context.interpreter, revm_gas::VERYLOW); popn_top!([op1], op2, context.interpreter); @@ -157,7 +152,6 @@ pub fn shl<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// EIP-145: Bitwise shifting instructions in EVM pub fn shr<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CONSTANTINOPLE); gas_legacy!(context.interpreter, revm_gas::VERYLOW); popn_top!([op1], op2, context.interpreter); @@ -167,7 +161,6 @@ pub fn shr<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// EIP-145: Bitwise shifting instructions in EVM pub fn sar<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CONSTANTINOPLE); gas_legacy!(context.interpreter, revm_gas::VERYLOW); popn_top!([op1], op2, context.interpreter); diff --git a/substrate/frame/revive/src/vm/evm/instructions/contract.rs b/substrate/frame/revive/src/vm/evm/instructions/contract.rs index b6f269f308ab4..e96588fd9b0e9 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/contract.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/contract.rs @@ -41,7 +41,10 @@ use revm::{ /// /// Creates a new contract with provided bytecode. pub fn create<'ext, const IS_CREATE2: bool, E: Ext>(context: Context<'_, 'ext, E>) { - require_non_staticcall!(context.interpreter); + if context.interpreter.extend.is_read_only() { + context.interpreter.halt(InstructionResult::Revert); + return; + } popn!([value, code_offset, len], context.interpreter); let len = as_usize_or_fail!(context.interpreter, len); diff --git a/substrate/frame/revive/src/vm/evm/instructions/control.rs b/substrate/frame/revive/src/vm/evm/instructions/control.rs index 22415d02827c6..11298ea1f35f2 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/control.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/control.rs @@ -21,7 +21,7 @@ use revm::{ interpreter::{ gas as revm_gas, interpreter_action::InterpreterAction, - interpreter_types::{Jumps, LoopControl, RuntimeFlag, StackTr}, + interpreter_types::{Jumps, LoopControl, StackTr}, InstructionResult, Interpreter, }, primitives::{Bytes, U256}, @@ -126,7 +126,6 @@ pub fn ret<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// EIP-140: REVERT instruction pub fn revert<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, BYZANTIUM); return_inner(context.interpreter, InstructionResult::Revert); } @@ -137,6 +136,7 @@ pub fn stop<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// Invalid opcode. This opcode halts the execution. pub fn invalid<'ext, E: Ext>(context: Context<'_, 'ext, E>) { + context.interpreter.extend.gas_meter_mut().consume_all(); context.interpreter.halt(InstructionResult::InvalidFEOpcode); } diff --git a/substrate/frame/revive/src/vm/evm/instructions/host.rs b/substrate/frame/revive/src/vm/evm/instructions/host.rs index 9767e25c57037..dbb65c89de64a 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/host.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/host.rs @@ -15,59 +15,34 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{ - utility::{IntoAddress, IntoU256}, - Context, +use super::Context; + +use crate::{ + storage::WriteOutcome, + vec::Vec, + vm::{evm::U256Converter, Ext}, + DispatchError, Key, RuntimeCosts, }; -use crate::vm::Ext; -use core::cmp::min; use revm::{ - interpreter::{ - gas::{self, warm_cold_cost, CALL_STIPEND}, - host::Host, - interpreter_types::{InputsTr, RuntimeFlag, StackTr}, - InstructionResult, - }, - primitives::{hardfork::SpecId::*, Bytes, Log, LogData, B256, BLOCK_HASH_HISTORY, U256}, + interpreter::{interpreter_types::StackTr, InstructionResult}, + primitives::{Bytes, U256}, }; /// Implements the BALANCE instruction. /// /// Gets the balance of the given account. pub fn balance<'ext, E: Ext>(context: Context<'_, 'ext, E>) { + gas!(context.interpreter, RuntimeCosts::BalanceOf); popn_top!([], top, context.interpreter); - let address = top.into_address(); - let Some(balance) = context.host.balance(address) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - let spec_id = context.interpreter.runtime_flag.spec_id(); - gas_legacy!( - context.interpreter, - if spec_id.is_enabled_in(BERLIN) { - warm_cold_cost(balance.is_cold) - } else if spec_id.is_enabled_in(ISTANBUL) { - // EIP-1884: Repricing for trie-size-dependent opcodes - 700 - } else if spec_id.is_enabled_in(TANGERINE) { - 400 - } else { - 20 - } - ); - *top = balance.data; + let h160 = sp_core::H160::from_slice(&top.to_be_bytes::<32>()[12..]); + *top = context.interpreter.extend.balance_of(&h160).into_revm_u256(); } /// EIP-1884: Repricing for trie-size-dependent opcodes pub fn selfbalance<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, ISTANBUL); - gas_legacy!(context.interpreter, gas::LOW); - - let Some(balance) = context.host.balance(context.interpreter.input.target_address()) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - push!(context.interpreter, balance.data); + gas!(context.interpreter, RuntimeCosts::Balance); + let balance = context.interpreter.extend.balance(); + push!(context.interpreter, balance.into_revm_u256()); } /// Implements the EXTCODESIZE instruction. @@ -75,41 +50,19 @@ pub fn selfbalance<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// Gets the size of an account's code. pub fn extcodesize<'ext, E: Ext>(context: Context<'_, 'ext, E>) { popn_top!([], top, context.interpreter); - let address = top.into_address(); - let Some(code) = context.host.load_account_code(address) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - let spec_id = context.interpreter.runtime_flag.spec_id(); - if spec_id.is_enabled_in(BERLIN) { - gas_legacy!(context.interpreter, warm_cold_cost(code.is_cold)); - } else if spec_id.is_enabled_in(TANGERINE) { - gas_legacy!(context.interpreter, 700); - } else { - gas_legacy!(context.interpreter, 20); - } - - *top = U256::from(code.len()); + gas!(context.interpreter, RuntimeCosts::CodeSize); + let h160 = sp_core::H160::from_slice(&top.to_be_bytes::<32>()[12..]); + let code_size = context.interpreter.extend.code_size(&h160); + *top = U256::from(code_size); } /// EIP-1052: EXTCODEHASH opcode pub fn extcodehash<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CONSTANTINOPLE); popn_top!([], top, context.interpreter); - let address = top.into_address(); - let Some(code_hash) = context.host.load_account_code_hash(address) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - let spec_id = context.interpreter.runtime_flag.spec_id(); - if spec_id.is_enabled_in(BERLIN) { - gas_legacy!(context.interpreter, warm_cold_cost(code_hash.is_cold)); - } else if spec_id.is_enabled_in(ISTANBUL) { - gas_legacy!(context.interpreter, 700); - } else { - gas_legacy!(context.interpreter, 400); - } - *top = code_hash.into_u256(); + gas!(context.interpreter, RuntimeCosts::CodeHash); + let h160 = sp_core::H160::from_slice(&top.to_be_bytes::<32>()[12..]); + let code_hash = context.interpreter.extend.code_hash(&h160); + *top = U256::from_be_bytes(code_hash.0); } /// Implements the EXTCODECOPY instruction. @@ -117,60 +70,38 @@ pub fn extcodehash<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// Copies a portion of an account's code to memory. pub fn extcodecopy<'ext, E: Ext>(context: Context<'_, 'ext, E>) { popn!([address, memory_offset, code_offset, len_u256], context.interpreter); - let address = address.into_address(); - let Some(code) = context.host.load_account_code(address) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - let len = as_usize_or_fail!(context.interpreter, len_u256); - gas_or_fail_legacy!( - context.interpreter, - gas::extcodecopy_cost(context.interpreter.runtime_flag.spec_id(), len, code.is_cold) - ); + + gas!(context.interpreter, RuntimeCosts::ExtCodeCopy(len as u32)); + let address = sp_core::H160::from_slice(&address.to_be_bytes::<32>()[12..]); + if len == 0 { return; } let memory_offset = as_usize_or_fail!(context.interpreter, memory_offset); - let code_offset = min(as_usize_saturated!(code_offset), code.len()); + let code_offset = as_usize_saturated!(code_offset); + resize_memory!(context.interpreter, memory_offset, len); + let mut buf = context.interpreter.memory.slice_mut(memory_offset, len); // Note: This can't panic because we resized memory to fit. - context.interpreter.memory.set_data(memory_offset, code_offset, len, &code); + context.interpreter.extend.copy_code_slice(&mut buf, &address, code_offset); } /// Implements the BLOCKHASH instruction. /// /// Gets the hash of one of the 256 most recent complete blocks. pub fn blockhash<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - gas_legacy!(context.interpreter, gas::BLOCKHASH); + gas!(context.interpreter, RuntimeCosts::BlockHash); popn_top!([], number, context.interpreter); + let requested_number = ::from_revm_u256(&number); - let requested_number = *number; - let block_number = context.host.block_number(); - - let Some(diff) = block_number.checked_sub(requested_number) else { - *number = U256::ZERO; - return; - }; - - let diff = as_u64_saturated!(diff); - - // blockhash should push zero if number is same as current block number. - if diff == 0 { - *number = U256::ZERO; - return; - } - - *number = if diff <= BLOCK_HASH_HISTORY { - let Some(hash) = context.host.block_hash(as_u64_saturated!(requested_number)) else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - U256::from_be_bytes(hash.0) + // blockhash should push zero if number is not within valid range. + if let Some(hash) = context.interpreter.extend.block_hash(requested_number) { + *number = U256::from_be_bytes(hash.0) } else { - U256::ZERO - } + *number = U256::ZERO + }; } /// Implements the SLOAD instruction. @@ -178,88 +109,127 @@ pub fn blockhash<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// Loads a word from storage. pub fn sload<'ext, E: Ext>(context: Context<'_, 'ext, E>) { popn_top!([], index, context.interpreter); + // NB: SLOAD loads 32 bytes from storage (i.e. U256). + gas!(context.interpreter, RuntimeCosts::GetStorage(32)); + let key = Key::Fix(index.to_be_bytes()); + let value = context.interpreter.extend.get_storage(&key); + + *index = if let Some(storage_value) = value { + // sload always reads a word + let Ok::<[u8; 32], _>(bytes) = storage_value.try_into() else { + context.interpreter.halt(InstructionResult::FatalExternalError); + return + }; + U256::from_be_bytes(bytes) + } else { + // the key was never written before + U256::ZERO + }; +} + +fn store_helper<'ext, E: Ext>( + context: Context<'_, 'ext, E>, + cost_before: RuntimeCosts, + set_function: fn(&mut E, &Key, Option>, bool) -> Result, + adjust_cost: fn(new_bytes: u32, old_bytes: u32) -> RuntimeCosts, +) { + if context.interpreter.extend.is_read_only() { + context.interpreter.halt(InstructionResult::Revert); + return; + } + + popn!([index, value], context.interpreter); + + // Charge gas before set_storage and later adjust it down to the true gas cost + let Ok(charged_amount) = context.interpreter.extend.gas_meter_mut().charge(cost_before) else { + context.interpreter.halt(InstructionResult::OutOfGas); + return; + }; - let Some(value) = context.host.sload(context.interpreter.input.target_address(), *index) else { + let key = Key::Fix(index.to_be_bytes()); + let take_old = false; + let Ok(write_outcome) = set_function( + context.interpreter.extend, + &key, + Some(value.to_be_bytes::<32>().to_vec()), + take_old, + ) else { context.interpreter.halt(InstructionResult::FatalExternalError); return; }; - gas_legacy!( - context.interpreter, - gas::sload_cost(context.interpreter.runtime_flag.spec_id(), value.is_cold) - ); - *index = value.data; + context + .interpreter + .extend + .gas_meter_mut() + .adjust_gas(charged_amount, adjust_cost(32, write_outcome.old_len())); } /// Implements the SSTORE instruction. /// /// Stores a word to storage. pub fn sstore<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - require_non_staticcall!(context.interpreter); - - popn!([index, value], context.interpreter); - - let Some(state_load) = - context.host.sstore(context.interpreter.input.target_address(), index, value) - else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - - // EIP-1706 Disable SSTORE with gasleft lower than call stipend - if context.interpreter.runtime_flag.spec_id().is_enabled_in(ISTANBUL) && - context.interpreter.gas.remaining() <= CALL_STIPEND - { - context.interpreter.halt(InstructionResult::ReentrancySentryOOG); - return; - } - gas_legacy!( - context.interpreter, - gas::sstore_cost( - context.interpreter.runtime_flag.spec_id(), - &state_load.data, - state_load.is_cold - ) + store_helper( + context, + RuntimeCosts::SetStorage { new_bytes: 32, old_bytes: 0 }, + |ext, key, value, take_old| ext.set_storage(key, value, take_old), + |new_bytes, old_bytes| RuntimeCosts::SetStorage { new_bytes, old_bytes }, ); - - context.interpreter.gas.record_refund(gas::sstore_refund( - context.interpreter.runtime_flag.spec_id(), - &state_load.data, - )); } /// EIP-1153: Transient storage opcodes /// Store value to transient storage pub fn tstore<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CANCUN); - require_non_staticcall!(context.interpreter); - gas_legacy!(context.interpreter, gas::WARM_STORAGE_READ_COST); - - popn!([index, value], context.interpreter); - - context.host.tstore(context.interpreter.input.target_address(), index, value); + store_helper( + context, + RuntimeCosts::SetTransientStorage { new_bytes: 32, old_bytes: 0 }, + |ext, key, value, take_old| ext.set_transient_storage(key, value, take_old), + |new_bytes, old_bytes| RuntimeCosts::SetTransientStorage { new_bytes, old_bytes }, + ); } /// EIP-1153: Transient storage opcodes /// Load value from transient storage pub fn tload<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CANCUN); - gas_legacy!(context.interpreter, gas::WARM_STORAGE_READ_COST); - popn_top!([], index, context.interpreter); + gas!(context.interpreter, RuntimeCosts::GetTransientStorage(32)); - *index = context.host.tload(context.interpreter.input.target_address(), *index); + let key = Key::Fix(index.to_be_bytes()); + let bytes = context.interpreter.extend.get_transient_storage(&key); + *index = if let Some(storage_value) = bytes { + if storage_value.len() != 32 { + // tload always reads a word + context.interpreter.halt(InstructionResult::FatalExternalError); + return; + } + let mut bytes = [0u8; 32]; + bytes.copy_from_slice(&storage_value); + U256::from_be_bytes(bytes) + } else { + // the key was never written before + U256::ZERO + }; } /// Implements the LOG0-LOG4 instructions. /// /// Appends log record with N topics. pub fn log<'ext, const N: usize, E: Ext>(context: Context<'_, 'ext, E>) { - require_non_staticcall!(context.interpreter); + if context.interpreter.extend.is_read_only() { + context.interpreter.halt(InstructionResult::Revert); + return; + } popn!([offset, len], context.interpreter); let len = as_usize_or_fail!(context.interpreter, len); - gas_or_fail_legacy!(context.interpreter, gas::log_cost(N as u8, len as u64)); + if len as u32 > context.interpreter.extend.max_value_size() { + context + .interpreter + .halt(revm::interpreter::InstructionResult::InvalidOperandOOG); + return; + } + + gas!(context.interpreter, RuntimeCosts::DepositEvent { num_topic: N as u32, len: len as u32 }); let data = if len == 0 { Bytes::new() } else { @@ -276,40 +246,15 @@ pub fn log<'ext, const N: usize, E: Ext>(context: Context<'_, 'ext, E>) { return; }; - let log = Log { - address: context.interpreter.input.target_address(), - data: LogData::new(topics.into_iter().map(B256::from).collect(), data) - .expect("LogData should have <=4 topics"), - }; + let topics = topics.into_iter().map(|v| sp_core::H256::from(v.to_be_bytes())).collect(); - context.host.log(log); + context.interpreter.extend.deposit_event(topics, data.to_vec()); } /// Implements the SELFDESTRUCT instruction. /// /// Halt execution and register account for later deletion. pub fn selfdestruct<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - require_non_staticcall!(context.interpreter); - popn!([target], context.interpreter); - let target = target.into_address(); - - let Some(res) = context.host.selfdestruct(context.interpreter.input.target_address(), target) - else { - context.interpreter.halt(InstructionResult::FatalExternalError); - return; - }; - - // EIP-3529: Reduction in refunds - if !context.interpreter.runtime_flag.spec_id().is_enabled_in(LONDON) && - !res.previously_destroyed - { - context.interpreter.gas.record_refund(gas::SELFDESTRUCT) - } - - gas_legacy!( - context.interpreter, - gas::selfdestruct_cost(context.interpreter.runtime_flag.spec_id(), res) - ); - - context.interpreter.halt(InstructionResult::SelfDestruct); + // TODO: for now this instruction is not supported + context.interpreter.halt(InstructionResult::NotActivated); } diff --git a/substrate/frame/revive/src/vm/evm/instructions/macros.rs b/substrate/frame/revive/src/vm/evm/instructions/macros.rs index 943e344d30553..e686e3f4be2ce 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/macros.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/macros.rs @@ -28,17 +28,6 @@ macro_rules! tri { }; } -/// Fails the instruction if the current call is static. -#[macro_export] -macro_rules! require_non_staticcall { - ($interpreter:expr) => { - if $interpreter.runtime_flag.is_static() { - $interpreter.halt(revm::interpreter::InstructionResult::StateChangeDuringStaticCall); - return; - } - }; -} - /// Macro for optional try - returns early if the expression evaluates to None. /// Similar to the `?` operator but for use in instruction implementations. #[macro_export] @@ -122,27 +111,6 @@ macro_rules! gas_or_fail_legacy { }; } -use crate::vm::Ext; -use revm::interpreter::gas::{MemoryExtensionResult, MemoryGas}; - -/// Adapted from -/// https://docs.rs/revm/latest/revm/interpreter/struct.Gas.html#method.record_memory_expansion -pub fn record_memory_expansion( - memory: &mut MemoryGas, - ext: &mut E, - new_len: usize, -) -> MemoryExtensionResult { - let Some(additional_cost) = memory.record_new_len(new_len) else { - return MemoryExtensionResult::Same; - }; - - if ext.gas_meter_mut().charge_evm_gas(additional_cost).is_err() { - return MemoryExtensionResult::OutOfGas; - } - - MemoryExtensionResult::Extended -} - /// Resizes the interpreterreter memory if necessary. Fails the instruction if the memory or gas /// limit is exceeded. #[macro_export] @@ -151,20 +119,16 @@ macro_rules! resize_memory { resize_memory!($interpreter, $offset, $len, ()) }; ($interpreter:expr, $offset:expr, $len:expr, $ret:expr) => { - let words_num = revm::interpreter::num_words($offset.saturating_add($len)); - match crate::vm::evm::instructions::macros::record_memory_expansion( - $interpreter.gas.memory_mut(), - $interpreter.extend, - words_num, - ) { - revm::interpreter::gas::MemoryExtensionResult::Extended => { - $interpreter.memory.resize(words_num * 32); - }, - revm::interpreter::gas::MemoryExtensionResult::OutOfGas => { - $interpreter.halt(revm::interpreter::InstructionResult::MemoryOOG); - return $ret; - }, - revm::interpreter::gas::MemoryExtensionResult::Same => (), // no action + let current_len = $interpreter.memory.len(); + let target_len = revm::interpreter::num_words($offset.saturating_add($len)) * 32; + if target_len as u32 > $crate::limits::code::BASELINE_MEMORY_LIMIT { + log::debug!(target: $crate::LOG_TARGET, "check memory bounds failed: offset={} target_len={target_len} current_len={current_len}", $offset); + $interpreter.halt(revm::interpreter::InstructionResult::MemoryOOG); + return $ret; + } + + if target_len > current_len { + $interpreter.memory.resize(target_len); }; }; } diff --git a/substrate/frame/revive/src/vm/evm/instructions/memory.rs b/substrate/frame/revive/src/vm/evm/instructions/memory.rs index c17b5e22820d4..3feaf89be6181 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/memory.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/memory.rs @@ -21,7 +21,7 @@ use core::cmp::max; use revm::{ interpreter::{ gas as revm_gas, - interpreter_types::{MemoryTr, RuntimeFlag, StackTr}, + interpreter_types::{MemoryTr, StackTr}, }, primitives::U256, }; @@ -72,7 +72,6 @@ pub fn msize<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// /// EIP-5656: Memory copying instruction that copies memory from one location to another. pub fn mcopy<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, CANCUN); popn!([dst, src, len], context.interpreter); // Into usize or fail diff --git a/substrate/frame/revive/src/vm/evm/instructions/stack.rs b/substrate/frame/revive/src/vm/evm/instructions/stack.rs index a632b853d5346..055c1401686c9 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/stack.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/stack.rs @@ -20,7 +20,7 @@ use crate::vm::Ext; use revm::{ interpreter::{ gas as revm_gas, - interpreter_types::{Immediates, Jumps, RuntimeFlag, StackTr}, + interpreter_types::{Immediates, Jumps, StackTr}, InstructionResult, }, primitives::U256, @@ -39,7 +39,6 @@ pub fn pop<'ext, E: Ext>(context: Context<'_, 'ext, E>) { /// /// Introduce a new instruction which pushes the constant value 0 onto the stack. pub fn push0<'ext, E: Ext>(context: Context<'_, 'ext, E>) { - check!(context.interpreter, SHANGHAI); gas_legacy!(context.interpreter, revm_gas::BASE); push!(context.interpreter, U256::ZERO); } diff --git a/substrate/frame/revive/src/vm/runtime_costs.rs b/substrate/frame/revive/src/vm/runtime_costs.rs index 44fc68ab5e118..18e9b622f82fc 100644 --- a/substrate/frame/revive/src/vm/runtime_costs.rs +++ b/substrate/frame/revive/src/vm/runtime_costs.rs @@ -34,6 +34,8 @@ const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND / GAS_PER_SECOND; pub enum RuntimeCosts { /// Base Weight of calling a host function. HostFn, + /// Weight charged for executing the extcodecopy instruction. + ExtCodeCopy(u32), /// Weight charged for copying data from the sandbox. CopyFromContract(u32), /// Weight charged for copying data to the sandbox. @@ -225,6 +227,7 @@ impl Token for RuntimeCosts { use self::RuntimeCosts::*; match *self { HostFn => cost_args!(noop_host_fn, 1), + ExtCodeCopy(len) => T::WeightInfo::extcodecopy(len), CopyToContract(len) => T::WeightInfo::seal_copy_to_contract(len), CopyFromContract(len) => T::WeightInfo::seal_return(len), CallDataSize => T::WeightInfo::seal_call_data_size(), diff --git a/substrate/frame/revive/src/weights.rs b/substrate/frame/revive/src/weights.rs index 7a2f46555c7fa..8ae133fb2b7be 100644 --- a/substrate/frame/revive/src/weights.rs +++ b/substrate/frame/revive/src/weights.rs @@ -35,9 +35,9 @@ //! Autogenerated weights for `pallet_revive` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-08-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-09-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `63d21d694e5f`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `ff2afa3d9639`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: @@ -161,6 +161,7 @@ pub trait WeightInfo { fn evm_opcode(r: u32, ) -> Weight; fn instr(r: u32, ) -> Weight; fn instr_empty_loop(r: u32, ) -> Weight; + fn extcodecopy(n: u32, ) -> Weight; fn v1_migration_step() -> Weight; fn v2_migration_step() -> Weight; } @@ -174,8 +175,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `147` // Estimated: `1632` - // Minimum execution time: 3_146_000 picoseconds. - Weight::from_parts(3_400_000, 1632) + // Minimum execution time: 3_103_000 picoseconds. + Weight::from_parts(3_288_000, 1632) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -185,10 +186,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `458 + k * (69 ±0)` // Estimated: `448 + k * (70 ±0)` - // Minimum execution time: 14_245_000 picoseconds. - Weight::from_parts(14_708_000, 448) - // Standard Error: 830 - .saturating_add(Weight::from_parts(1_175_004, 0).saturating_mul(k.into())) + // Minimum execution time: 14_393_000 picoseconds. + Weight::from_parts(14_689_000, 448) + // Standard Error: 1_032 + .saturating_add(Weight::from_parts(1_205_681, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -212,10 +213,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1172 + c * (1 ±0)` // Estimated: `7107 + c * (1 ±0)` - // Minimum execution time: 86_441_000 picoseconds. - Weight::from_parts(123_780_707, 7107) - // Standard Error: 11 - .saturating_add(Weight::from_parts(1_438, 0).saturating_mul(c.into())) + // Minimum execution time: 85_415_000 picoseconds. + Weight::from_parts(120_226_734, 7107) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_539, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -233,14 +234,12 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// The range of component `c` is `[1, 10240]`. - fn call_with_evm_code_per_byte(c: u32, ) -> Weight { + fn call_with_evm_code_per_byte(_c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1112` // Estimated: `7051` - // Minimum execution time: 81_282_000 picoseconds. - Weight::from_parts(85_248_488, 7051) - // Standard Error: 21 - .saturating_add(Weight::from_parts(36, 0).saturating_mul(c.into())) + // Minimum execution time: 80_503_000 picoseconds. + Weight::from_parts(84_811_467, 7051) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -261,8 +260,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4516` // Estimated: `10456` - // Minimum execution time: 124_393_000 picoseconds. - Weight::from_parts(129_685_861, 10456) + // Minimum execution time: 123_461_000 picoseconds. + Weight::from_parts(128_775_940, 10456) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -284,14 +283,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 131072]`. fn instantiate_with_code(c: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1171` - // Estimated: `7104` - // Minimum execution time: 762_496_000 picoseconds. - Weight::from_parts(55_020_008, 7104) - // Standard Error: 44 - .saturating_add(Weight::from_parts(20_306, 0).saturating_mul(c.into())) + // Measured: `881` + // Estimated: `6811` + // Minimum execution time: 749_503_000 picoseconds. + Weight::from_parts(59_829_896, 6811) // Standard Error: 35 - .saturating_add(Weight::from_parts(5_068, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(20_233, 0).saturating_mul(c.into())) + // Standard Error: 27 + .saturating_add(Weight::from_parts(5_057, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -314,16 +313,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `d` is `[0, 1]`. fn eth_instantiate_with_code(c: u32, i: u32, d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1185` - // Estimated: `7125 + d * (2475 ±0)` - // Minimum execution time: 284_562_000 picoseconds. - Weight::from_parts(163_089_642, 7125) - // Standard Error: 34 - .saturating_add(Weight::from_parts(15_162, 0).saturating_mul(c.into())) - // Standard Error: 27 - .saturating_add(Weight::from_parts(514, 0).saturating_mul(i.into())) - // Standard Error: 2_273_714 - .saturating_add(Weight::from_parts(38_746_748, 0).saturating_mul(d.into())) + // Measured: `881` + // Estimated: `6821 + d * (2475 ±0)` + // Minimum execution time: 277_185_000 picoseconds. + Weight::from_parts(147_220_906, 6821) + // Standard Error: 29 + .saturating_add(Weight::from_parts(15_202, 0).saturating_mul(c.into())) + // Standard Error: 23 + .saturating_add(Weight::from_parts(642, 0).saturating_mul(i.into())) + // Standard Error: 1_934_039 + .saturating_add(Weight::from_parts(34_192_978, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -347,12 +346,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 131072]`. fn instantiate(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1913` - // Estimated: `5339` - // Minimum execution time: 171_348_000 picoseconds. - Weight::from_parts(176_612_673, 5339) - // Standard Error: 11 - .saturating_add(Weight::from_parts(4_290, 0).saturating_mul(i.into())) + // Measured: `1610` + // Estimated: `5060` + // Minimum execution time: 168_670_000 picoseconds. + Weight::from_parts(175_522_603, 5060) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_260, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -372,8 +371,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1794` // Estimated: `7734` - // Minimum execution time: 88_764_000 picoseconds. - Weight::from_parts(93_353_000, 7734) + // Minimum execution time: 86_819_000 picoseconds. + Weight::from_parts(89_536_000, 7734) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -394,10 +393,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1794` // Estimated: `7734 + d * (2475 ±0)` - // Minimum execution time: 86_142_000 picoseconds. - Weight::from_parts(90_482_761, 7734) - // Standard Error: 430_134 - .saturating_add(Weight::from_parts(30_624_838, 0).saturating_mul(d.into())) + // Minimum execution time: 85_649_000 picoseconds. + Weight::from_parts(90_277_271, 7734) + // Standard Error: 333_872 + .saturating_add(Weight::from_parts(26_832_228, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -413,12 +412,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 102400]`. fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `606` - // Estimated: `4071` - // Minimum execution time: 57_080_000 picoseconds. - Weight::from_parts(49_101_825, 4071) - // Standard Error: 18 - .saturating_add(Weight::from_parts(14_610, 0).saturating_mul(c.into())) + // Measured: `303` + // Estimated: `3768` + // Minimum execution time: 56_015_000 picoseconds. + Weight::from_parts(44_756_550, 3768) + // Standard Error: 17 + .saturating_add(Weight::from_parts(14_377, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -430,10 +429,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `4225` - // Minimum execution time: 53_084_000 picoseconds. - Weight::from_parts(54_573_000, 4225) + // Measured: `458` + // Estimated: `3923` + // Minimum execution time: 51_807_000 picoseconds. + Weight::from_parts(53_562_000, 3923) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -449,10 +448,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `1095` - // Estimated: `7035` - // Minimum execution time: 65_666_000 picoseconds. - Weight::from_parts(67_373_000, 7035) + // Measured: `797` + // Estimated: `6737` + // Minimum execution time: 65_431_000 picoseconds. + Weight::from_parts(66_763_000, 6737) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -462,10 +461,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `Measured`) fn map_account() -> Weight { // Proof Size summary in bytes: - // Measured: `813` - // Estimated: `4278` - // Minimum execution time: 55_888_000 picoseconds. - Weight::from_parts(57_747_000, 4278) + // Measured: `510` + // Estimated: `3975` + // Minimum execution time: 54_271_000 picoseconds. + Weight::from_parts(55_618_000, 3975) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -475,10 +474,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) fn unmap_account() -> Weight { // Proof Size summary in bytes: - // Measured: `395` - // Estimated: `3860` - // Minimum execution time: 42_171_000 picoseconds. - Weight::from_parts(43_198_000, 3860) + // Measured: `93` + // Estimated: `3558` + // Minimum execution time: 38_990_000 picoseconds. + Weight::from_parts(39_656_000, 3558) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -490,8 +489,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 13_030_000 picoseconds. - Weight::from_parts(13_365_000, 3610) + // Minimum execution time: 13_086_000 picoseconds. + Weight::from_parts(13_681_000, 3610) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// The range of component `r` is `[0, 1600]`. @@ -499,24 +498,24 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_473_000 picoseconds. - Weight::from_parts(8_474_805, 0) - // Standard Error: 322 - .saturating_add(Weight::from_parts(178_929, 0).saturating_mul(r.into())) + // Minimum execution time: 7_423_000 picoseconds. + Weight::from_parts(9_149_999, 0) + // Standard Error: 227 + .saturating_add(Weight::from_parts(180_894, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 355_000 picoseconds. - Weight::from_parts(397_000, 0) + // Minimum execution time: 294_000 picoseconds. + Weight::from_parts(330_000, 0) } fn seal_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 318_000 picoseconds. - Weight::from_parts(362_000, 0) + // Minimum execution time: 270_000 picoseconds. + Weight::from_parts(317_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -524,8 +523,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `567` // Estimated: `4032` - // Minimum execution time: 7_507_000 picoseconds. - Weight::from_parts(8_064_000, 4032) + // Minimum execution time: 7_773_000 picoseconds. + Weight::from_parts(8_282_000, 4032) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) @@ -534,16 +533,16 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3868` - // Minimum execution time: 9_458_000 picoseconds. - Weight::from_parts(10_105_000, 3868) + // Minimum execution time: 9_567_000 picoseconds. + Weight::from_parts(9_975_000, 3868) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn seal_own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 317_000 picoseconds. - Weight::from_parts(355_000, 0) + // Minimum execution time: 252_000 picoseconds. + Weight::from_parts(301_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -553,51 +552,51 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `475` // Estimated: `3940` - // Minimum execution time: 13_105_000 picoseconds. - Weight::from_parts(13_354_000, 3940) + // Minimum execution time: 13_090_000 picoseconds. + Weight::from_parts(13_527_000, 3940) .saturating_add(T::DbWeight::get().reads(2_u64)) } fn seal_caller_is_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 331_000 picoseconds. - Weight::from_parts(381_000, 0) + // Minimum execution time: 337_000 picoseconds. + Weight::from_parts(375_000, 0) } fn seal_caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 307_000 picoseconds. - Weight::from_parts(336_000, 0) + // Minimum execution time: 258_000 picoseconds. + Weight::from_parts(300_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 323_000 picoseconds. - Weight::from_parts(368_000, 0) + // Minimum execution time: 308_000 picoseconds. + Weight::from_parts(352_000, 0) } fn seal_weight_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 701_000 picoseconds. - Weight::from_parts(785_000, 0) + // Minimum execution time: 687_000 picoseconds. + Weight::from_parts(776_000, 0) } fn seal_ref_time_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 278_000 picoseconds. - Weight::from_parts(334_000, 0) + // Minimum execution time: 247_000 picoseconds. + Weight::from_parts(278_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: // Measured: `540` // Estimated: `0` - // Minimum execution time: 12_890_000 picoseconds. - Weight::from_parts(13_471_000, 0) + // Minimum execution time: 12_447_000 picoseconds. + Weight::from_parts(13_433_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -609,8 +608,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `791` // Estimated: `4256` - // Minimum execution time: 18_523_000 picoseconds. - Weight::from_parts(19_059_000, 4256) + // Minimum execution time: 18_806_000 picoseconds. + Weight::from_parts(19_217_000, 4256) .saturating_add(T::DbWeight::get().reads(3_u64)) } /// Storage: `Revive::ImmutableDataOf` (r:1 w:0) @@ -620,10 +619,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `271 + n * (1 ±0)` // Estimated: `3736 + n * (1 ±0)` - // Minimum execution time: 6_027_000 picoseconds. - Weight::from_parts(6_736_994, 3736) - // Standard Error: 5 - .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) + // Minimum execution time: 5_800_000 picoseconds. + Weight::from_parts(6_657_021, 3736) + // Standard Error: 6 + .saturating_add(Weight::from_parts(595, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -634,67 +633,67 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_033_000 picoseconds. - Weight::from_parts(2_294_007, 0) + // Minimum execution time: 2_057_000 picoseconds. + Weight::from_parts(2_320_795, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(558, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } fn seal_value_transferred() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 276_000 picoseconds. - Weight::from_parts(323_000, 0) + // Minimum execution time: 260_000 picoseconds. + Weight::from_parts(293_000, 0) } fn seal_minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 273_000 picoseconds. - Weight::from_parts(325_000, 0) + // Minimum execution time: 233_000 picoseconds. + Weight::from_parts(291_000, 0) } fn seal_return_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 265_000 picoseconds. - Weight::from_parts(302_000, 0) + // Minimum execution time: 232_000 picoseconds. + Weight::from_parts(262_000, 0) } fn seal_call_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 279_000 picoseconds. - Weight::from_parts(353_000, 0) + // Minimum execution time: 234_000 picoseconds. + Weight::from_parts(273_000, 0) } fn seal_gas_limit() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 518_000 picoseconds. - Weight::from_parts(572_000, 0) + // Minimum execution time: 441_000 picoseconds. + Weight::from_parts(523_000, 0) } fn seal_gas_price() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 308_000 picoseconds. - Weight::from_parts(339_000, 0) + // Minimum execution time: 254_000 picoseconds. + Weight::from_parts(294_000, 0) } fn seal_base_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 283_000 picoseconds. - Weight::from_parts(315_000, 0) + // Minimum execution time: 229_000 picoseconds. + Weight::from_parts(269_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 300_000 picoseconds. - Weight::from_parts(334_000, 0) + // Minimum execution time: 254_000 picoseconds. + Weight::from_parts(290_000, 0) } /// Storage: `Session::Validators` (r:1 w:0) /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -702,8 +701,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `141` // Estimated: `1626` - // Minimum execution time: 22_163_000 picoseconds. - Weight::from_parts(22_643_000, 1626) + // Minimum execution time: 21_852_000 picoseconds. + Weight::from_parts(22_526_000, 1626) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `System::BlockHash` (r:1 w:0) @@ -712,31 +711,31 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `30` // Estimated: `3495` - // Minimum execution time: 3_625_000 picoseconds. - Weight::from_parts(3_850_000, 3495) + // Minimum execution time: 3_600_000 picoseconds. + Weight::from_parts(3_830_000, 3495) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 293_000 picoseconds. - Weight::from_parts(349_000, 0) + // Minimum execution time: 239_000 picoseconds. + Weight::from_parts(276_000, 0) } fn seal_weight_to_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_597_000 picoseconds. - Weight::from_parts(1_720_000, 0) + // Minimum execution time: 1_595_000 picoseconds. + Weight::from_parts(1_665_000, 0) } /// The range of component `n` is `[0, 1048572]`. fn seal_copy_to_contract(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 425_000 picoseconds. - Weight::from_parts(437_000, 0) + // Minimum execution time: 402_000 picoseconds. + Weight::from_parts(496_964, 0) // Standard Error: 0 .saturating_add(Weight::from_parts(239, 0).saturating_mul(n.into())) } @@ -744,28 +743,28 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 277_000 picoseconds. - Weight::from_parts(313_000, 0) + // Minimum execution time: 250_000 picoseconds. + Weight::from_parts(289_000, 0) } /// The range of component `n` is `[0, 1048576]`. fn seal_call_data_copy(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 257_000 picoseconds. - Weight::from_parts(288_000, 0) + // Minimum execution time: 230_000 picoseconds. + Weight::from_parts(255_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(150, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(151, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 131072]`. fn seal_return(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 315_000 picoseconds. - Weight::from_parts(476_627, 0) + // Minimum execution time: 253_000 picoseconds. + Weight::from_parts(544_296, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(238, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(237, 0).saturating_mul(n.into())) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -786,17 +785,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + r * (670 ±0)` - // Estimated: `4048 + r * (2359 ±0)` - // Minimum execution time: 16_560_000 picoseconds. - Weight::from_parts(17_630_489, 4048) - // Standard Error: 66_463 - .saturating_add(Weight::from_parts(46_618_510, 0).saturating_mul(r.into())) + // Measured: `583 + r * (402 ±0)` + // Estimated: `4048 + r * (2225 ±0)` + // Minimum execution time: 16_727_000 picoseconds. + Weight::from_parts(17_739_285, 4048) + // Standard Error: 59_932 + .saturating_add(Weight::from_parts(44_553_014, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2359).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2225).saturating_mul(r.into())) } /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 416]`. @@ -804,12 +803,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_523_000 picoseconds. - Weight::from_parts(4_505_303, 0) - // Standard Error: 3_656 - .saturating_add(Weight::from_parts(240_684, 0).saturating_mul(t.into())) - // Standard Error: 40 - .saturating_add(Weight::from_parts(1_232, 0).saturating_mul(n.into())) + // Minimum execution time: 4_226_000 picoseconds. + Weight::from_parts(4_252_357, 0) + // Standard Error: 3_401 + .saturating_add(Weight::from_parts(233_040, 0).saturating_mul(t.into())) + // Standard Error: 37 + .saturating_add(Weight::from_parts(1_172, 0).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -817,8 +816,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 7_228_000 picoseconds. - Weight::from_parts(7_734_000, 648) + // Minimum execution time: 6_909_000 picoseconds. + Weight::from_parts(7_499_000, 648) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -827,8 +826,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 41_276_000 picoseconds. - Weight::from_parts(42_310_000, 10658) + // Minimum execution time: 41_173_000 picoseconds. + Weight::from_parts(42_303_000, 10658) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -837,8 +836,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 8_396_000 picoseconds. - Weight::from_parts(8_776_000, 648) + // Minimum execution time: 8_428_000 picoseconds. + Weight::from_parts(8_817_000, 648) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -848,8 +847,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 42_661_000 picoseconds. - Weight::from_parts(44_266_000, 10658) + // Minimum execution time: 43_627_000 picoseconds. + Weight::from_parts(44_777_000, 10658) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -861,12 +860,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + o * (1 ±0)` // Estimated: `247 + o * (1 ±0)` - // Minimum execution time: 8_864_000 picoseconds. - Weight::from_parts(9_769_026, 247) - // Standard Error: 67 - .saturating_add(Weight::from_parts(81, 0).saturating_mul(n.into())) - // Standard Error: 67 - .saturating_add(Weight::from_parts(866, 0).saturating_mul(o.into())) + // Minimum execution time: 8_934_000 picoseconds. + Weight::from_parts(9_589_880, 247) + // Standard Error: 65 + .saturating_add(Weight::from_parts(667, 0).saturating_mul(n.into())) + // Standard Error: 65 + .saturating_add(Weight::from_parts(821, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(o.into())) @@ -878,10 +877,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_552_000 picoseconds. - Weight::from_parts(9_609_466, 247) - // Standard Error: 88 - .saturating_add(Weight::from_parts(789, 0).saturating_mul(n.into())) + // Minimum execution time: 8_527_000 picoseconds. + Weight::from_parts(9_507_817, 247) + // Standard Error: 73 + .saturating_add(Weight::from_parts(860, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -893,10 +892,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_101_000 picoseconds. - Weight::from_parts(9_115_278, 247) - // Standard Error: 75 - .saturating_add(Weight::from_parts(1_381, 0).saturating_mul(n.into())) + // Minimum execution time: 8_076_000 picoseconds. + Weight::from_parts(9_106_693, 247) + // Standard Error: 73 + .saturating_add(Weight::from_parts(1_668, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -907,10 +906,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 7_594_000 picoseconds. - Weight::from_parts(8_575_324, 247) - // Standard Error: 78 - .saturating_add(Weight::from_parts(635, 0).saturating_mul(n.into())) + // Minimum execution time: 7_571_000 picoseconds. + Weight::from_parts(8_454_639, 247) + // Standard Error: 69 + .saturating_add(Weight::from_parts(888, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -921,10 +920,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 9_130_000 picoseconds. - Weight::from_parts(10_301_501, 247) - // Standard Error: 85 - .saturating_add(Weight::from_parts(1_584, 0).saturating_mul(n.into())) + // Minimum execution time: 9_140_000 picoseconds. + Weight::from_parts(10_132_276, 247) + // Standard Error: 70 + .saturating_add(Weight::from_parts(1_866, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -933,36 +932,36 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_553_000 picoseconds. - Weight::from_parts(1_678_000, 0) + // Minimum execution time: 1_655_000 picoseconds. + Weight::from_parts(1_744_000, 0) } fn set_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_962_000 picoseconds. - Weight::from_parts(2_085_000, 0) + // Minimum execution time: 1_987_000 picoseconds. + Weight::from_parts(2_135_000, 0) } fn get_transient_storage_empty() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_599_000 picoseconds. - Weight::from_parts(1_715_000, 0) + // Minimum execution time: 1_641_000 picoseconds. + Weight::from_parts(1_751_000, 0) } fn get_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_837_000 picoseconds. - Weight::from_parts(1_930_000, 0) + // Minimum execution time: 1_732_000 picoseconds. + Weight::from_parts(1_891_000, 0) } fn rollback_transient_storage() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_273_000 picoseconds. - Weight::from_parts(1_356_000, 0) + // Minimum execution time: 1_237_000 picoseconds. + Weight::from_parts(1_378_000, 0) } /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. @@ -970,52 +969,50 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_307_000 picoseconds. - Weight::from_parts(2_700_633, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(264, 0).saturating_mul(n.into())) - // Standard Error: 22 - .saturating_add(Weight::from_parts(241, 0).saturating_mul(o.into())) + // Minimum execution time: 2_283_000 picoseconds. + Weight::from_parts(2_636_514, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(296, 0).saturating_mul(n.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(374, 0).saturating_mul(o.into())) } /// The range of component `n` is `[0, 416]`. fn seal_clear_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_159_000 picoseconds. - Weight::from_parts(2_531_527, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(344, 0).saturating_mul(n.into())) + // Minimum execution time: 2_171_000 picoseconds. + Weight::from_parts(2_555_844, 0) + // Standard Error: 23 + .saturating_add(Weight::from_parts(468, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. fn seal_get_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_066_000 picoseconds. - Weight::from_parts(2_317_959, 0) - // Standard Error: 19 - .saturating_add(Weight::from_parts(218, 0).saturating_mul(n.into())) + // Minimum execution time: 1_985_000 picoseconds. + Weight::from_parts(2_277_401, 0) + // Standard Error: 21 + .saturating_add(Weight::from_parts(394, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. fn seal_contains_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_772_000 picoseconds. - Weight::from_parts(2_109_656, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(127, 0).saturating_mul(n.into())) + // Minimum execution time: 1_784_000 picoseconds. + Weight::from_parts(2_034_472, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(214, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. - fn seal_take_transient_storage(n: u32, ) -> Weight { + fn seal_take_transient_storage(_n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_677_000 picoseconds. - Weight::from_parts(2_887_082, 0) - // Standard Error: 21 - .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_929_498, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1034,14 +1031,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1925` // Estimated: `5390` - // Minimum execution time: 88_854_000 picoseconds. - Weight::from_parts(71_114_290, 5390) - // Standard Error: 191_071 - .saturating_add(Weight::from_parts(18_628_762, 0).saturating_mul(t.into())) - // Standard Error: 191_071 - .saturating_add(Weight::from_parts(25_344_741, 0).saturating_mul(d.into())) + // Minimum execution time: 88_292_000 picoseconds. + Weight::from_parts(67_934_136, 5390) + // Standard Error: 161_519 + .saturating_add(Weight::from_parts(19_069_368, 0).saturating_mul(t.into())) + // Standard Error: 161_519 + .saturating_add(Weight::from_parts(25_783_515, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(2, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(4, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) @@ -1056,12 +1053,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `366 + d * (212 ±0)` // Estimated: `2021 + d * (2021 ±0)` - // Minimum execution time: 23_987_000 picoseconds. - Weight::from_parts(11_982_236, 2021) - // Standard Error: 52_781 - .saturating_add(Weight::from_parts(13_796_260, 0).saturating_mul(d.into())) + // Minimum execution time: 24_082_000 picoseconds. + Weight::from_parts(11_635_002, 2021) + // Standard Error: 32_873 + .saturating_add(Weight::from_parts(13_461_671, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(397, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(d.into()))) .saturating_add(Weight::from_parts(0, 2021).saturating_mul(d.into())) @@ -1076,8 +1073,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1363` // Estimated: `4828` - // Minimum execution time: 32_754_000 picoseconds. - Weight::from_parts(33_660_000, 4828) + // Minimum execution time: 31_965_000 picoseconds. + Weight::from_parts(33_059_000, 4828) .saturating_add(T::DbWeight::get().reads(3_u64)) } /// Storage: `Revive::CodeInfoOf` (r:1 w:1) @@ -1095,14 +1092,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1413` // Estimated: `4857 + d * (28 ±1) + t * (28 ±1)` - // Minimum execution time: 149_649_000 picoseconds. - Weight::from_parts(106_708_312, 4857) - // Standard Error: 531_299 - .saturating_add(Weight::from_parts(19_820_332, 0).saturating_mul(t.into())) - // Standard Error: 531_299 - .saturating_add(Weight::from_parts(30_026_552, 0).saturating_mul(d.into())) + // Minimum execution time: 150_124_000 picoseconds. + Weight::from_parts(100_922_263, 4857) + // Standard Error: 553_691 + .saturating_add(Weight::from_parts(21_824_333, 0).saturating_mul(t.into())) + // Standard Error: 553_691 + .saturating_add(Weight::from_parts(30_090_103, 0).saturating_mul(d.into())) // Standard Error: 6 - .saturating_add(Weight::from_parts(4_025, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(4_031, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 28).saturating_mul(d.into())) @@ -1113,118 +1110,118 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_183_000 picoseconds. - Weight::from_parts(12_193_562, 0) + // Minimum execution time: 1_198_000 picoseconds. + Weight::from_parts(5_902_477, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_286, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_301, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn identity(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 724_000 picoseconds. - Weight::from_parts(423_926, 0) + // Minimum execution time: 710_000 picoseconds. + Weight::from_parts(583_657, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(149, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(148, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn ripemd_160(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_235_000 picoseconds. - Weight::from_parts(6_941_606, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_767, 0).saturating_mul(n.into())) + // Minimum execution time: 1_145_000 picoseconds. + Weight::from_parts(5_218_490, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_770, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_148_000 picoseconds. - Weight::from_parts(12_850_349, 0) + // Minimum execution time: 1_133_000 picoseconds. + Weight::from_parts(12_018_626, 0) // Standard Error: 1 - .saturating_add(Weight::from_parts(3_590, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_591, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn hash_blake2_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_570_000 picoseconds. - Weight::from_parts(14_584_934, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_442, 0).saturating_mul(n.into())) + // Minimum execution time: 1_594_000 picoseconds. + Weight::from_parts(16_080_940, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_437, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn hash_blake2_128(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_625_000 picoseconds. - Weight::from_parts(14_771_647, 0) + // Minimum execution time: 1_493_000 picoseconds. + Weight::from_parts(12_215_603, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_440, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048321]`. fn seal_sr25519_verify(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 42_969_000 picoseconds. - Weight::from_parts(90_649_318, 0) + // Minimum execution time: 42_270_000 picoseconds. + Weight::from_parts(93_835_987, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(4_813, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(5_026, 0).saturating_mul(n.into())) } fn ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 46_096_000 picoseconds. - Weight::from_parts(46_988_000, 0) + // Minimum execution time: 45_951_000 picoseconds. + Weight::from_parts(46_894_000, 0) } fn bn128_add() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 14_848_000 picoseconds. - Weight::from_parts(17_210_000, 0) + // Minimum execution time: 14_272_000 picoseconds. + Weight::from_parts(15_204_000, 0) } fn bn128_mul() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 991_766_000 picoseconds. - Weight::from_parts(996_123_000, 0) + // Minimum execution time: 980_350_000 picoseconds. + Weight::from_parts(988_695_000, 0) } /// The range of component `n` is `[0, 20]`. fn bn128_pairing(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 848_000 picoseconds. - Weight::from_parts(4_990_945_553, 0) - // Standard Error: 10_630_771 - .saturating_add(Weight::from_parts(6_054_433_018, 0).saturating_mul(n.into())) + // Minimum execution time: 760_000 picoseconds. + Weight::from_parts(4_873_448_313, 0) + // Standard Error: 10_617_668 + .saturating_add(Weight::from_parts(5_964_183_373, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1200]`. fn blake2f(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 961_000 picoseconds. - Weight::from_parts(1_252_241, 0) - // Standard Error: 26 - .saturating_add(Weight::from_parts(30_105, 0).saturating_mul(n.into())) + // Minimum execution time: 914_000 picoseconds. + Weight::from_parts(1_152_510, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(28_870, 0).saturating_mul(n.into())) } fn seal_ecdsa_to_eth_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_095_000 picoseconds. - Weight::from_parts(13_230_000, 0) + // Minimum execution time: 12_862_000 picoseconds. + Weight::from_parts(13_004_000, 0) } /// Storage: `Revive::CodeInfoOf` (r:2 w:2) /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) @@ -1237,47 +1234,61 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `391 + r * (703 ±0)` - // Estimated: `6331 + r * (2280 ±0)` - // Minimum execution time: 14_670_000 picoseconds. - Weight::from_parts(15_744_806, 6331) - // Standard Error: 54_003 - .saturating_add(Weight::from_parts(47_474_393, 0).saturating_mul(r.into())) + // Measured: `391 + r * (468 ±0)` + // Estimated: `6331 + r * (2162 ±0)` + // Minimum execution time: 14_987_000 picoseconds. + Weight::from_parts(15_935_167, 6331) + // Standard Error: 52_524 + .saturating_add(Weight::from_parts(45_530_232, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2280).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2162).saturating_mul(r.into())) } /// The range of component `r` is `[0, 10000]`. fn evm_opcode(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_189_000 picoseconds. - Weight::from_parts(1_470_372, 0) - // Standard Error: 20 - .saturating_add(Weight::from_parts(6_508, 0).saturating_mul(r.into())) + // Minimum execution time: 1_206_000 picoseconds. + Weight::from_parts(1_895_352, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 10000]`. fn instr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_052_000 picoseconds. - Weight::from_parts(56_794_418, 0) - // Standard Error: 416 - .saturating_add(Weight::from_parts(116_801, 0).saturating_mul(r.into())) + // Minimum execution time: 12_772_000 picoseconds. + Weight::from_parts(53_405_104, 0) + // Standard Error: 346 + .saturating_add(Weight::from_parts(125_622, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 100000]`. + /// The range of component `r` is `[0, 10000]`. fn instr_empty_loop(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_321_000 picoseconds. - Weight::from_parts(8_236_588, 0) - // Standard Error: 32 - .saturating_add(Weight::from_parts(71_473, 0).saturating_mul(r.into())) + // Minimum execution time: 3_147_000 picoseconds. + Weight::from_parts(1_883_710, 0) + // Standard Error: 47 + .saturating_add(Weight::from_parts(71_984, 0).saturating_mul(r.into())) + } + /// Storage: `Revive::PristineCode` (r:1 w:0) + /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1000, 10000]`. + fn extcodecopy(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `457 + n * (1 ±0)` + // Estimated: `3922 + n * (1 ±0)` + // Minimum execution time: 14_211_000 picoseconds. + Weight::from_parts(13_786_057, 3922) + // Standard Error: 14 + .saturating_add(Weight::from_parts(1_062, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: UNKNOWN KEY `0x735f040a5d490f1107ad9c56f5ca00d2060e99e5378e562537cf3bc983e17b91` (r:2 w:1) /// Proof: UNKNOWN KEY `0x735f040a5d490f1107ad9c56f5ca00d2060e99e5378e562537cf3bc983e17b91` (r:2 w:1) @@ -1287,8 +1298,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `316` // Estimated: `6256` - // Minimum execution time: 12_137_000 picoseconds. - Weight::from_parts(12_594_000, 6256) + // Minimum execution time: 11_898_000 picoseconds. + Weight::from_parts(12_772_000, 6256) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1300,10 +1311,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `MaxEncodedLen`) fn v2_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `741` + // Measured: `439` // Estimated: `6794` - // Minimum execution time: 64_340_000 picoseconds. - Weight::from_parts(67_378_000, 6794) + // Minimum execution time: 62_964_000 picoseconds. + Weight::from_parts(64_865_000, 6794) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -1317,8 +1328,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `147` // Estimated: `1632` - // Minimum execution time: 3_146_000 picoseconds. - Weight::from_parts(3_400_000, 1632) + // Minimum execution time: 3_103_000 picoseconds. + Weight::from_parts(3_288_000, 1632) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1328,10 +1339,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `458 + k * (69 ±0)` // Estimated: `448 + k * (70 ±0)` - // Minimum execution time: 14_245_000 picoseconds. - Weight::from_parts(14_708_000, 448) - // Standard Error: 830 - .saturating_add(Weight::from_parts(1_175_004, 0).saturating_mul(k.into())) + // Minimum execution time: 14_393_000 picoseconds. + Weight::from_parts(14_689_000, 448) + // Standard Error: 1_032 + .saturating_add(Weight::from_parts(1_205_681, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1355,10 +1366,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1172 + c * (1 ±0)` // Estimated: `7107 + c * (1 ±0)` - // Minimum execution time: 86_441_000 picoseconds. - Weight::from_parts(123_780_707, 7107) - // Standard Error: 11 - .saturating_add(Weight::from_parts(1_438, 0).saturating_mul(c.into())) + // Minimum execution time: 85_415_000 picoseconds. + Weight::from_parts(120_226_734, 7107) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_539, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -1376,14 +1387,12 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// The range of component `c` is `[1, 10240]`. - fn call_with_evm_code_per_byte(c: u32, ) -> Weight { + fn call_with_evm_code_per_byte(_c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1112` // Estimated: `7051` - // Minimum execution time: 81_282_000 picoseconds. - Weight::from_parts(85_248_488, 7051) - // Standard Error: 21 - .saturating_add(Weight::from_parts(36, 0).saturating_mul(c.into())) + // Minimum execution time: 80_503_000 picoseconds. + Weight::from_parts(84_811_467, 7051) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1404,8 +1413,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4516` // Estimated: `10456` - // Minimum execution time: 124_393_000 picoseconds. - Weight::from_parts(129_685_861, 10456) + // Minimum execution time: 123_461_000 picoseconds. + Weight::from_parts(128_775_940, 10456) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1427,14 +1436,14 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 131072]`. fn instantiate_with_code(c: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1171` - // Estimated: `7104` - // Minimum execution time: 762_496_000 picoseconds. - Weight::from_parts(55_020_008, 7104) - // Standard Error: 44 - .saturating_add(Weight::from_parts(20_306, 0).saturating_mul(c.into())) + // Measured: `881` + // Estimated: `6811` + // Minimum execution time: 749_503_000 picoseconds. + Weight::from_parts(59_829_896, 6811) // Standard Error: 35 - .saturating_add(Weight::from_parts(5_068, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(20_233, 0).saturating_mul(c.into())) + // Standard Error: 27 + .saturating_add(Weight::from_parts(5_057, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1457,16 +1466,16 @@ impl WeightInfo for () { /// The range of component `d` is `[0, 1]`. fn eth_instantiate_with_code(c: u32, i: u32, d: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1185` - // Estimated: `7125 + d * (2475 ±0)` - // Minimum execution time: 284_562_000 picoseconds. - Weight::from_parts(163_089_642, 7125) - // Standard Error: 34 - .saturating_add(Weight::from_parts(15_162, 0).saturating_mul(c.into())) - // Standard Error: 27 - .saturating_add(Weight::from_parts(514, 0).saturating_mul(i.into())) - // Standard Error: 2_273_714 - .saturating_add(Weight::from_parts(38_746_748, 0).saturating_mul(d.into())) + // Measured: `881` + // Estimated: `6821 + d * (2475 ±0)` + // Minimum execution time: 277_185_000 picoseconds. + Weight::from_parts(147_220_906, 6821) + // Standard Error: 29 + .saturating_add(Weight::from_parts(15_202, 0).saturating_mul(c.into())) + // Standard Error: 23 + .saturating_add(Weight::from_parts(642, 0).saturating_mul(i.into())) + // Standard Error: 1_934_039 + .saturating_add(Weight::from_parts(34_192_978, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1490,12 +1499,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 131072]`. fn instantiate(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1913` - // Estimated: `5339` - // Minimum execution time: 171_348_000 picoseconds. - Weight::from_parts(176_612_673, 5339) - // Standard Error: 11 - .saturating_add(Weight::from_parts(4_290, 0).saturating_mul(i.into())) + // Measured: `1610` + // Estimated: `5060` + // Minimum execution time: 168_670_000 picoseconds. + Weight::from_parts(175_522_603, 5060) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_260, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1515,8 +1524,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1794` // Estimated: `7734` - // Minimum execution time: 88_764_000 picoseconds. - Weight::from_parts(93_353_000, 7734) + // Minimum execution time: 86_819_000 picoseconds. + Weight::from_parts(89_536_000, 7734) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1537,10 +1546,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1794` // Estimated: `7734 + d * (2475 ±0)` - // Minimum execution time: 86_142_000 picoseconds. - Weight::from_parts(90_482_761, 7734) - // Standard Error: 430_134 - .saturating_add(Weight::from_parts(30_624_838, 0).saturating_mul(d.into())) + // Minimum execution time: 85_649_000 picoseconds. + Weight::from_parts(90_277_271, 7734) + // Standard Error: 333_872 + .saturating_add(Weight::from_parts(26_832_228, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1556,12 +1565,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 102400]`. fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `606` - // Estimated: `4071` - // Minimum execution time: 57_080_000 picoseconds. - Weight::from_parts(49_101_825, 4071) - // Standard Error: 18 - .saturating_add(Weight::from_parts(14_610, 0).saturating_mul(c.into())) + // Measured: `303` + // Estimated: `3768` + // Minimum execution time: 56_015_000 picoseconds. + Weight::from_parts(44_756_550, 3768) + // Standard Error: 17 + .saturating_add(Weight::from_parts(14_377, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1573,10 +1582,10 @@ impl WeightInfo for () { /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `4225` - // Minimum execution time: 53_084_000 picoseconds. - Weight::from_parts(54_573_000, 4225) + // Measured: `458` + // Estimated: `3923` + // Minimum execution time: 51_807_000 picoseconds. + Weight::from_parts(53_562_000, 3923) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1592,10 +1601,10 @@ impl WeightInfo for () { /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `1095` - // Estimated: `7035` - // Minimum execution time: 65_666_000 picoseconds. - Weight::from_parts(67_373_000, 7035) + // Measured: `797` + // Estimated: `6737` + // Minimum execution time: 65_431_000 picoseconds. + Weight::from_parts(66_763_000, 6737) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1605,10 +1614,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `Measured`) fn map_account() -> Weight { // Proof Size summary in bytes: - // Measured: `813` - // Estimated: `4278` - // Minimum execution time: 55_888_000 picoseconds. - Weight::from_parts(57_747_000, 4278) + // Measured: `510` + // Estimated: `3975` + // Minimum execution time: 54_271_000 picoseconds. + Weight::from_parts(55_618_000, 3975) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1618,10 +1627,10 @@ impl WeightInfo for () { /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) fn unmap_account() -> Weight { // Proof Size summary in bytes: - // Measured: `395` - // Estimated: `3860` - // Minimum execution time: 42_171_000 picoseconds. - Weight::from_parts(43_198_000, 3860) + // Measured: `93` + // Estimated: `3558` + // Minimum execution time: 38_990_000 picoseconds. + Weight::from_parts(39_656_000, 3558) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1633,8 +1642,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 13_030_000 picoseconds. - Weight::from_parts(13_365_000, 3610) + // Minimum execution time: 13_086_000 picoseconds. + Weight::from_parts(13_681_000, 3610) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// The range of component `r` is `[0, 1600]`. @@ -1642,24 +1651,24 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_473_000 picoseconds. - Weight::from_parts(8_474_805, 0) - // Standard Error: 322 - .saturating_add(Weight::from_parts(178_929, 0).saturating_mul(r.into())) + // Minimum execution time: 7_423_000 picoseconds. + Weight::from_parts(9_149_999, 0) + // Standard Error: 227 + .saturating_add(Weight::from_parts(180_894, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 355_000 picoseconds. - Weight::from_parts(397_000, 0) + // Minimum execution time: 294_000 picoseconds. + Weight::from_parts(330_000, 0) } fn seal_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 318_000 picoseconds. - Weight::from_parts(362_000, 0) + // Minimum execution time: 270_000 picoseconds. + Weight::from_parts(317_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1667,8 +1676,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `567` // Estimated: `4032` - // Minimum execution time: 7_507_000 picoseconds. - Weight::from_parts(8_064_000, 4032) + // Minimum execution time: 7_773_000 picoseconds. + Weight::from_parts(8_282_000, 4032) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) @@ -1677,16 +1686,16 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3868` - // Minimum execution time: 9_458_000 picoseconds. - Weight::from_parts(10_105_000, 3868) + // Minimum execution time: 9_567_000 picoseconds. + Weight::from_parts(9_975_000, 3868) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn seal_own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 317_000 picoseconds. - Weight::from_parts(355_000, 0) + // Minimum execution time: 252_000 picoseconds. + Weight::from_parts(301_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -1696,51 +1705,51 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `475` // Estimated: `3940` - // Minimum execution time: 13_105_000 picoseconds. - Weight::from_parts(13_354_000, 3940) + // Minimum execution time: 13_090_000 picoseconds. + Weight::from_parts(13_527_000, 3940) .saturating_add(RocksDbWeight::get().reads(2_u64)) } fn seal_caller_is_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 331_000 picoseconds. - Weight::from_parts(381_000, 0) + // Minimum execution time: 337_000 picoseconds. + Weight::from_parts(375_000, 0) } fn seal_caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 307_000 picoseconds. - Weight::from_parts(336_000, 0) + // Minimum execution time: 258_000 picoseconds. + Weight::from_parts(300_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 323_000 picoseconds. - Weight::from_parts(368_000, 0) + // Minimum execution time: 308_000 picoseconds. + Weight::from_parts(352_000, 0) } fn seal_weight_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 701_000 picoseconds. - Weight::from_parts(785_000, 0) + // Minimum execution time: 687_000 picoseconds. + Weight::from_parts(776_000, 0) } fn seal_ref_time_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 278_000 picoseconds. - Weight::from_parts(334_000, 0) + // Minimum execution time: 247_000 picoseconds. + Weight::from_parts(278_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: // Measured: `540` // Estimated: `0` - // Minimum execution time: 12_890_000 picoseconds. - Weight::from_parts(13_471_000, 0) + // Minimum execution time: 12_447_000 picoseconds. + Weight::from_parts(13_433_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1752,8 +1761,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `791` // Estimated: `4256` - // Minimum execution time: 18_523_000 picoseconds. - Weight::from_parts(19_059_000, 4256) + // Minimum execution time: 18_806_000 picoseconds. + Weight::from_parts(19_217_000, 4256) .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `Revive::ImmutableDataOf` (r:1 w:0) @@ -1763,10 +1772,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `271 + n * (1 ±0)` // Estimated: `3736 + n * (1 ±0)` - // Minimum execution time: 6_027_000 picoseconds. - Weight::from_parts(6_736_994, 3736) - // Standard Error: 5 - .saturating_add(Weight::from_parts(592, 0).saturating_mul(n.into())) + // Minimum execution time: 5_800_000 picoseconds. + Weight::from_parts(6_657_021, 3736) + // Standard Error: 6 + .saturating_add(Weight::from_parts(595, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -1777,67 +1786,67 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_033_000 picoseconds. - Weight::from_parts(2_294_007, 0) + // Minimum execution time: 2_057_000 picoseconds. + Weight::from_parts(2_320_795, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(558, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn seal_value_transferred() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 276_000 picoseconds. - Weight::from_parts(323_000, 0) + // Minimum execution time: 260_000 picoseconds. + Weight::from_parts(293_000, 0) } fn seal_minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 273_000 picoseconds. - Weight::from_parts(325_000, 0) + // Minimum execution time: 233_000 picoseconds. + Weight::from_parts(291_000, 0) } fn seal_return_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 265_000 picoseconds. - Weight::from_parts(302_000, 0) + // Minimum execution time: 232_000 picoseconds. + Weight::from_parts(262_000, 0) } fn seal_call_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 279_000 picoseconds. - Weight::from_parts(353_000, 0) + // Minimum execution time: 234_000 picoseconds. + Weight::from_parts(273_000, 0) } fn seal_gas_limit() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 518_000 picoseconds. - Weight::from_parts(572_000, 0) + // Minimum execution time: 441_000 picoseconds. + Weight::from_parts(523_000, 0) } fn seal_gas_price() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 308_000 picoseconds. - Weight::from_parts(339_000, 0) + // Minimum execution time: 254_000 picoseconds. + Weight::from_parts(294_000, 0) } fn seal_base_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 283_000 picoseconds. - Weight::from_parts(315_000, 0) + // Minimum execution time: 229_000 picoseconds. + Weight::from_parts(269_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 300_000 picoseconds. - Weight::from_parts(334_000, 0) + // Minimum execution time: 254_000 picoseconds. + Weight::from_parts(290_000, 0) } /// Storage: `Session::Validators` (r:1 w:0) /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -1845,8 +1854,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `141` // Estimated: `1626` - // Minimum execution time: 22_163_000 picoseconds. - Weight::from_parts(22_643_000, 1626) + // Minimum execution time: 21_852_000 picoseconds. + Weight::from_parts(22_526_000, 1626) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `System::BlockHash` (r:1 w:0) @@ -1855,31 +1864,31 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `30` // Estimated: `3495` - // Minimum execution time: 3_625_000 picoseconds. - Weight::from_parts(3_850_000, 3495) + // Minimum execution time: 3_600_000 picoseconds. + Weight::from_parts(3_830_000, 3495) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 293_000 picoseconds. - Weight::from_parts(349_000, 0) + // Minimum execution time: 239_000 picoseconds. + Weight::from_parts(276_000, 0) } fn seal_weight_to_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_597_000 picoseconds. - Weight::from_parts(1_720_000, 0) + // Minimum execution time: 1_595_000 picoseconds. + Weight::from_parts(1_665_000, 0) } /// The range of component `n` is `[0, 1048572]`. fn seal_copy_to_contract(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 425_000 picoseconds. - Weight::from_parts(437_000, 0) + // Minimum execution time: 402_000 picoseconds. + Weight::from_parts(496_964, 0) // Standard Error: 0 .saturating_add(Weight::from_parts(239, 0).saturating_mul(n.into())) } @@ -1887,28 +1896,28 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 277_000 picoseconds. - Weight::from_parts(313_000, 0) + // Minimum execution time: 250_000 picoseconds. + Weight::from_parts(289_000, 0) } /// The range of component `n` is `[0, 1048576]`. fn seal_call_data_copy(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 257_000 picoseconds. - Weight::from_parts(288_000, 0) + // Minimum execution time: 230_000 picoseconds. + Weight::from_parts(255_000, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(150, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(151, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 131072]`. fn seal_return(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 315_000 picoseconds. - Weight::from_parts(476_627, 0) + // Minimum execution time: 253_000 picoseconds. + Weight::from_parts(544_296, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(238, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(237, 0).saturating_mul(n.into())) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1929,17 +1938,17 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + r * (670 ±0)` - // Estimated: `4048 + r * (2359 ±0)` - // Minimum execution time: 16_560_000 picoseconds. - Weight::from_parts(17_630_489, 4048) - // Standard Error: 66_463 - .saturating_add(Weight::from_parts(46_618_510, 0).saturating_mul(r.into())) + // Measured: `583 + r * (402 ±0)` + // Estimated: `4048 + r * (2225 ±0)` + // Minimum execution time: 16_727_000 picoseconds. + Weight::from_parts(17_739_285, 4048) + // Standard Error: 59_932 + .saturating_add(Weight::from_parts(44_553_014, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2359).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2225).saturating_mul(r.into())) } /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 416]`. @@ -1947,12 +1956,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_523_000 picoseconds. - Weight::from_parts(4_505_303, 0) - // Standard Error: 3_656 - .saturating_add(Weight::from_parts(240_684, 0).saturating_mul(t.into())) - // Standard Error: 40 - .saturating_add(Weight::from_parts(1_232, 0).saturating_mul(n.into())) + // Minimum execution time: 4_226_000 picoseconds. + Weight::from_parts(4_252_357, 0) + // Standard Error: 3_401 + .saturating_add(Weight::from_parts(233_040, 0).saturating_mul(t.into())) + // Standard Error: 37 + .saturating_add(Weight::from_parts(1_172, 0).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -1960,8 +1969,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 7_228_000 picoseconds. - Weight::from_parts(7_734_000, 648) + // Minimum execution time: 6_909_000 picoseconds. + Weight::from_parts(7_499_000, 648) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1970,8 +1979,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 41_276_000 picoseconds. - Weight::from_parts(42_310_000, 10658) + // Minimum execution time: 41_173_000 picoseconds. + Weight::from_parts(42_303_000, 10658) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1980,8 +1989,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 8_396_000 picoseconds. - Weight::from_parts(8_776_000, 648) + // Minimum execution time: 8_428_000 picoseconds. + Weight::from_parts(8_817_000, 648) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1991,8 +2000,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 42_661_000 picoseconds. - Weight::from_parts(44_266_000, 10658) + // Minimum execution time: 43_627_000 picoseconds. + Weight::from_parts(44_777_000, 10658) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2004,12 +2013,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + o * (1 ±0)` // Estimated: `247 + o * (1 ±0)` - // Minimum execution time: 8_864_000 picoseconds. - Weight::from_parts(9_769_026, 247) - // Standard Error: 67 - .saturating_add(Weight::from_parts(81, 0).saturating_mul(n.into())) - // Standard Error: 67 - .saturating_add(Weight::from_parts(866, 0).saturating_mul(o.into())) + // Minimum execution time: 8_934_000 picoseconds. + Weight::from_parts(9_589_880, 247) + // Standard Error: 65 + .saturating_add(Weight::from_parts(667, 0).saturating_mul(n.into())) + // Standard Error: 65 + .saturating_add(Weight::from_parts(821, 0).saturating_mul(o.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(o.into())) @@ -2021,10 +2030,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_552_000 picoseconds. - Weight::from_parts(9_609_466, 247) - // Standard Error: 88 - .saturating_add(Weight::from_parts(789, 0).saturating_mul(n.into())) + // Minimum execution time: 8_527_000 picoseconds. + Weight::from_parts(9_507_817, 247) + // Standard Error: 73 + .saturating_add(Weight::from_parts(860, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2036,10 +2045,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_101_000 picoseconds. - Weight::from_parts(9_115_278, 247) - // Standard Error: 75 - .saturating_add(Weight::from_parts(1_381, 0).saturating_mul(n.into())) + // Minimum execution time: 8_076_000 picoseconds. + Weight::from_parts(9_106_693, 247) + // Standard Error: 73 + .saturating_add(Weight::from_parts(1_668, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -2050,10 +2059,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 7_594_000 picoseconds. - Weight::from_parts(8_575_324, 247) - // Standard Error: 78 - .saturating_add(Weight::from_parts(635, 0).saturating_mul(n.into())) + // Minimum execution time: 7_571_000 picoseconds. + Weight::from_parts(8_454_639, 247) + // Standard Error: 69 + .saturating_add(Weight::from_parts(888, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -2064,10 +2073,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 9_130_000 picoseconds. - Weight::from_parts(10_301_501, 247) - // Standard Error: 85 - .saturating_add(Weight::from_parts(1_584, 0).saturating_mul(n.into())) + // Minimum execution time: 9_140_000 picoseconds. + Weight::from_parts(10_132_276, 247) + // Standard Error: 70 + .saturating_add(Weight::from_parts(1_866, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2076,36 +2085,36 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_553_000 picoseconds. - Weight::from_parts(1_678_000, 0) + // Minimum execution time: 1_655_000 picoseconds. + Weight::from_parts(1_744_000, 0) } fn set_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_962_000 picoseconds. - Weight::from_parts(2_085_000, 0) + // Minimum execution time: 1_987_000 picoseconds. + Weight::from_parts(2_135_000, 0) } fn get_transient_storage_empty() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_599_000 picoseconds. - Weight::from_parts(1_715_000, 0) + // Minimum execution time: 1_641_000 picoseconds. + Weight::from_parts(1_751_000, 0) } fn get_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_837_000 picoseconds. - Weight::from_parts(1_930_000, 0) + // Minimum execution time: 1_732_000 picoseconds. + Weight::from_parts(1_891_000, 0) } fn rollback_transient_storage() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_273_000 picoseconds. - Weight::from_parts(1_356_000, 0) + // Minimum execution time: 1_237_000 picoseconds. + Weight::from_parts(1_378_000, 0) } /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. @@ -2113,52 +2122,50 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_307_000 picoseconds. - Weight::from_parts(2_700_633, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(264, 0).saturating_mul(n.into())) - // Standard Error: 22 - .saturating_add(Weight::from_parts(241, 0).saturating_mul(o.into())) + // Minimum execution time: 2_283_000 picoseconds. + Weight::from_parts(2_636_514, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(296, 0).saturating_mul(n.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(374, 0).saturating_mul(o.into())) } /// The range of component `n` is `[0, 416]`. fn seal_clear_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_159_000 picoseconds. - Weight::from_parts(2_531_527, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(344, 0).saturating_mul(n.into())) + // Minimum execution time: 2_171_000 picoseconds. + Weight::from_parts(2_555_844, 0) + // Standard Error: 23 + .saturating_add(Weight::from_parts(468, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. fn seal_get_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_066_000 picoseconds. - Weight::from_parts(2_317_959, 0) - // Standard Error: 19 - .saturating_add(Weight::from_parts(218, 0).saturating_mul(n.into())) + // Minimum execution time: 1_985_000 picoseconds. + Weight::from_parts(2_277_401, 0) + // Standard Error: 21 + .saturating_add(Weight::from_parts(394, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. fn seal_contains_transient_storage(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_772_000 picoseconds. - Weight::from_parts(2_109_656, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(127, 0).saturating_mul(n.into())) + // Minimum execution time: 1_784_000 picoseconds. + Weight::from_parts(2_034_472, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(214, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 416]`. - fn seal_take_transient_storage(n: u32, ) -> Weight { + fn seal_take_transient_storage(_n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_677_000 picoseconds. - Weight::from_parts(2_887_082, 0) - // Standard Error: 21 - .saturating_add(Weight::from_parts(3, 0).saturating_mul(n.into())) + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_929_498, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -2177,14 +2184,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1925` // Estimated: `5390` - // Minimum execution time: 88_854_000 picoseconds. - Weight::from_parts(71_114_290, 5390) - // Standard Error: 191_071 - .saturating_add(Weight::from_parts(18_628_762, 0).saturating_mul(t.into())) - // Standard Error: 191_071 - .saturating_add(Weight::from_parts(25_344_741, 0).saturating_mul(d.into())) + // Minimum execution time: 88_292_000 picoseconds. + Weight::from_parts(67_934_136, 5390) + // Standard Error: 161_519 + .saturating_add(Weight::from_parts(19_069_368, 0).saturating_mul(t.into())) + // Standard Error: 161_519 + .saturating_add(Weight::from_parts(25_783_515, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(2, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(4, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) @@ -2199,12 +2206,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `366 + d * (212 ±0)` // Estimated: `2021 + d * (2021 ±0)` - // Minimum execution time: 23_987_000 picoseconds. - Weight::from_parts(11_982_236, 2021) - // Standard Error: 52_781 - .saturating_add(Weight::from_parts(13_796_260, 0).saturating_mul(d.into())) + // Minimum execution time: 24_082_000 picoseconds. + Weight::from_parts(11_635_002, 2021) + // Standard Error: 32_873 + .saturating_add(Weight::from_parts(13_461_671, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(397, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(395, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(d.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(d.into()))) .saturating_add(Weight::from_parts(0, 2021).saturating_mul(d.into())) @@ -2219,8 +2226,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1363` // Estimated: `4828` - // Minimum execution time: 32_754_000 picoseconds. - Weight::from_parts(33_660_000, 4828) + // Minimum execution time: 31_965_000 picoseconds. + Weight::from_parts(33_059_000, 4828) .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `Revive::CodeInfoOf` (r:1 w:1) @@ -2238,14 +2245,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1413` // Estimated: `4857 + d * (28 ±1) + t * (28 ±1)` - // Minimum execution time: 149_649_000 picoseconds. - Weight::from_parts(106_708_312, 4857) - // Standard Error: 531_299 - .saturating_add(Weight::from_parts(19_820_332, 0).saturating_mul(t.into())) - // Standard Error: 531_299 - .saturating_add(Weight::from_parts(30_026_552, 0).saturating_mul(d.into())) + // Minimum execution time: 150_124_000 picoseconds. + Weight::from_parts(100_922_263, 4857) + // Standard Error: 553_691 + .saturating_add(Weight::from_parts(21_824_333, 0).saturating_mul(t.into())) + // Standard Error: 553_691 + .saturating_add(Weight::from_parts(30_090_103, 0).saturating_mul(d.into())) // Standard Error: 6 - .saturating_add(Weight::from_parts(4_025, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(4_031, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 28).saturating_mul(d.into())) @@ -2256,118 +2263,118 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_183_000 picoseconds. - Weight::from_parts(12_193_562, 0) + // Minimum execution time: 1_198_000 picoseconds. + Weight::from_parts(5_902_477, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_286, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_301, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn identity(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 724_000 picoseconds. - Weight::from_parts(423_926, 0) + // Minimum execution time: 710_000 picoseconds. + Weight::from_parts(583_657, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(149, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(148, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn ripemd_160(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_235_000 picoseconds. - Weight::from_parts(6_941_606, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_767, 0).saturating_mul(n.into())) + // Minimum execution time: 1_145_000 picoseconds. + Weight::from_parts(5_218_490, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_770, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_148_000 picoseconds. - Weight::from_parts(12_850_349, 0) + // Minimum execution time: 1_133_000 picoseconds. + Weight::from_parts(12_018_626, 0) // Standard Error: 1 - .saturating_add(Weight::from_parts(3_590, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_591, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn hash_blake2_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_570_000 picoseconds. - Weight::from_parts(14_584_934, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_442, 0).saturating_mul(n.into())) + // Minimum execution time: 1_594_000 picoseconds. + Weight::from_parts(16_080_940, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_437, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn hash_blake2_128(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_625_000 picoseconds. - Weight::from_parts(14_771_647, 0) + // Minimum execution time: 1_493_000 picoseconds. + Weight::from_parts(12_215_603, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_444, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_440, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048321]`. fn seal_sr25519_verify(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 42_969_000 picoseconds. - Weight::from_parts(90_649_318, 0) + // Minimum execution time: 42_270_000 picoseconds. + Weight::from_parts(93_835_987, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(4_813, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(5_026, 0).saturating_mul(n.into())) } fn ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 46_096_000 picoseconds. - Weight::from_parts(46_988_000, 0) + // Minimum execution time: 45_951_000 picoseconds. + Weight::from_parts(46_894_000, 0) } fn bn128_add() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 14_848_000 picoseconds. - Weight::from_parts(17_210_000, 0) + // Minimum execution time: 14_272_000 picoseconds. + Weight::from_parts(15_204_000, 0) } fn bn128_mul() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 991_766_000 picoseconds. - Weight::from_parts(996_123_000, 0) + // Minimum execution time: 980_350_000 picoseconds. + Weight::from_parts(988_695_000, 0) } /// The range of component `n` is `[0, 20]`. fn bn128_pairing(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 848_000 picoseconds. - Weight::from_parts(4_990_945_553, 0) - // Standard Error: 10_630_771 - .saturating_add(Weight::from_parts(6_054_433_018, 0).saturating_mul(n.into())) + // Minimum execution time: 760_000 picoseconds. + Weight::from_parts(4_873_448_313, 0) + // Standard Error: 10_617_668 + .saturating_add(Weight::from_parts(5_964_183_373, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1200]`. fn blake2f(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 961_000 picoseconds. - Weight::from_parts(1_252_241, 0) - // Standard Error: 26 - .saturating_add(Weight::from_parts(30_105, 0).saturating_mul(n.into())) + // Minimum execution time: 914_000 picoseconds. + Weight::from_parts(1_152_510, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(28_870, 0).saturating_mul(n.into())) } fn seal_ecdsa_to_eth_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_095_000 picoseconds. - Weight::from_parts(13_230_000, 0) + // Minimum execution time: 12_862_000 picoseconds. + Weight::from_parts(13_004_000, 0) } /// Storage: `Revive::CodeInfoOf` (r:2 w:2) /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) @@ -2380,47 +2387,61 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `391 + r * (703 ±0)` - // Estimated: `6331 + r * (2280 ±0)` - // Minimum execution time: 14_670_000 picoseconds. - Weight::from_parts(15_744_806, 6331) - // Standard Error: 54_003 - .saturating_add(Weight::from_parts(47_474_393, 0).saturating_mul(r.into())) + // Measured: `391 + r * (468 ±0)` + // Estimated: `6331 + r * (2162 ±0)` + // Minimum execution time: 14_987_000 picoseconds. + Weight::from_parts(15_935_167, 6331) + // Standard Error: 52_524 + .saturating_add(Weight::from_parts(45_530_232, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2280).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2162).saturating_mul(r.into())) } /// The range of component `r` is `[0, 10000]`. fn evm_opcode(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_189_000 picoseconds. - Weight::from_parts(1_470_372, 0) - // Standard Error: 20 - .saturating_add(Weight::from_parts(6_508, 0).saturating_mul(r.into())) + // Minimum execution time: 1_206_000 picoseconds. + Weight::from_parts(1_895_352, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(6_177, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 10000]`. fn instr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_052_000 picoseconds. - Weight::from_parts(56_794_418, 0) - // Standard Error: 416 - .saturating_add(Weight::from_parts(116_801, 0).saturating_mul(r.into())) + // Minimum execution time: 12_772_000 picoseconds. + Weight::from_parts(53_405_104, 0) + // Standard Error: 346 + .saturating_add(Weight::from_parts(125_622, 0).saturating_mul(r.into())) } - /// The range of component `r` is `[0, 100000]`. + /// The range of component `r` is `[0, 10000]`. fn instr_empty_loop(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_321_000 picoseconds. - Weight::from_parts(8_236_588, 0) - // Standard Error: 32 - .saturating_add(Weight::from_parts(71_473, 0).saturating_mul(r.into())) + // Minimum execution time: 3_147_000 picoseconds. + Weight::from_parts(1_883_710, 0) + // Standard Error: 47 + .saturating_add(Weight::from_parts(71_984, 0).saturating_mul(r.into())) + } + /// Storage: `Revive::PristineCode` (r:1 w:0) + /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1000, 10000]`. + fn extcodecopy(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `457 + n * (1 ±0)` + // Estimated: `3922 + n * (1 ±0)` + // Minimum execution time: 14_211_000 picoseconds. + Weight::from_parts(13_786_057, 3922) + // Standard Error: 14 + .saturating_add(Weight::from_parts(1_062, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: UNKNOWN KEY `0x735f040a5d490f1107ad9c56f5ca00d2060e99e5378e562537cf3bc983e17b91` (r:2 w:1) /// Proof: UNKNOWN KEY `0x735f040a5d490f1107ad9c56f5ca00d2060e99e5378e562537cf3bc983e17b91` (r:2 w:1) @@ -2430,8 +2451,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `316` // Estimated: `6256` - // Minimum execution time: 12_137_000 picoseconds. - Weight::from_parts(12_594_000, 6256) + // Minimum execution time: 11_898_000 picoseconds. + Weight::from_parts(12_772_000, 6256) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2443,10 +2464,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(427), added: 2902, mode: `MaxEncodedLen`) fn v2_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `741` + // Measured: `439` // Estimated: `6794` - // Minimum execution time: 64_340_000 picoseconds. - Weight::from_parts(67_378_000, 6794) + // Minimum execution time: 62_964_000 picoseconds. + Weight::from_parts(64_865_000, 6794) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) }