diff --git a/Cargo.lock b/Cargo.lock index d129f4eea452c..75418606fa124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19926,6 +19926,7 @@ dependencies = [ "sp-blockchain", "sp-core 28.0.0", "sp-database", + "sp-externalities 0.25.0", "sp-runtime", "sp-state-machine", "sp-tracing 16.0.0", @@ -23854,6 +23855,7 @@ dependencies = [ "foldhash", "hash-db", "hashbrown 0.15.3", + "log", "memory-db", "nohash-hasher", "parity-scale-codec", diff --git a/polkadot/node/core/pvf/common/src/executor_interface.rs b/polkadot/node/core/pvf/common/src/executor_interface.rs index f2e98f79a2276..e27e392e41c17 100644 --- a/polkadot/node/core/pvf/common/src/executor_interface.rs +++ b/polkadot/node/core/pvf/common/src/executor_interface.rs @@ -219,6 +219,10 @@ impl sp_externalities::Externalities for ValidationExternalities { panic!("storage: unsupported feature for parachain validation") } + fn storage_with_status(&mut self, _: &[u8]) -> sp_externalities::StateLoad>> { + panic!("storage_with_status: unsupported feature for parachain validation") + } + fn storage_hash(&mut self, _: &[u8]) -> Option> { panic!("storage_hash: unsupported feature for parachain validation") } @@ -231,6 +235,14 @@ impl sp_externalities::Externalities for ValidationExternalities { panic!("child_storage: unsupported feature for parachain validation") } + fn child_storage_with_status( + &mut self, + _: &ChildInfo, + _: &[u8], + ) -> sp_externalities::StateLoad>> { + panic!("child_storage_with_status: unsupported feature for parachain validation") + } + fn kill_child_storage( &mut self, _child_info: &ChildInfo, diff --git a/substrate/client/db/Cargo.toml b/substrate/client/db/Cargo.toml index 2a8e2a78e11a1..7b3594fec39bc 100644 --- a/substrate/client/db/Cargo.toml +++ b/substrate/client/db/Cargo.toml @@ -40,6 +40,7 @@ sp-arithmetic = { workspace = true, default-features = true } sp-blockchain = { workspace = true, default-features = true } sp-core = { workspace = true, default-features = true } sp-database = { workspace = true, default-features = true } +sp-externalities = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } sp-state-machine = { workspace = true, default-features = true } sp-trie = { workspace = true, default-features = true } diff --git a/substrate/client/db/src/bench.rs b/substrate/client/db/src/bench.rs index 61b93a9a2314d..25703d1a3f042 100644 --- a/substrate/client/db/src/bench.rs +++ b/substrate/client/db/src/bench.rs @@ -353,6 +353,15 @@ impl StateBackend for BenchmarkingState { self.state.borrow().as_ref().ok_or_else(state_err)?.storage(key) } + fn storage_with_status( + &self, + key: &[u8], + ) -> Result>>, Self::Error> { + // Only if cold load ? + self.add_read_key(None, key); + self.state.borrow().as_ref().ok_or_else(state_err)?.storage_with_status(key) + } + fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { self.add_read_key(None, key); self.state.borrow().as_ref().ok_or_else(state_err)?.storage_hash(key) @@ -371,6 +380,20 @@ impl StateBackend for BenchmarkingState { .child_storage(child_info, key) } + fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>>, Self::Error> { + // Only if cold load ? + self.add_read_key(Some(child_info.storage_key()), key); + self.state + .borrow() + .as_ref() + .ok_or_else(state_err)? + .child_storage_with_status(child_info, key) + } + fn child_storage_hash( &self, child_info: &ChildInfo, diff --git a/substrate/client/db/src/lib.rs b/substrate/client/db/src/lib.rs index d86b722963b5b..ab7a30cab2974 100644 --- a/substrate/client/db/src/lib.rs +++ b/substrate/client/db/src/lib.rs @@ -78,6 +78,7 @@ use sp_core::{ storage::{well_known_keys, ChildInfo}, }; use sp_database::Transaction; +use sp_externalities::StateLoad; use sp_runtime::{ generic::BlockId, traits::{ @@ -199,6 +200,10 @@ impl StateBackend> for RefTrackingState { self.state.storage(key) } + fn storage_with_status(&self, key: &[u8]) -> Result>>, Self::Error> { + self.state.storage_with_status(key) + } + fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { self.state.storage_hash(key) } @@ -211,6 +216,14 @@ impl StateBackend> for RefTrackingState { self.state.child_storage(child_info, key) } + fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>>, Self::Error> { + self.state.child_storage_with_status(child_info, key) + } + fn child_storage_hash( &self, child_info: &ChildInfo, diff --git a/substrate/client/db/src/record_stats_state.rs b/substrate/client/db/src/record_stats_state.rs index d9a35c075d794..2d2d172b68cb5 100644 --- a/substrate/client/db/src/record_stats_state.rs +++ b/substrate/client/db/src/record_stats_state.rs @@ -20,6 +20,7 @@ use crate::stats::StateUsageStats; use sp_core::storage::ChildInfo; +use sp_externalities::StateLoad; use sp_runtime::{ traits::{Block as BlockT, HashingFor}, StateVersion, @@ -119,6 +120,12 @@ impl>, B: BlockT> StateBackend> Ok(value) } + fn storage_with_status(&self, key: &[u8]) -> Result>>, Self::Error> { + let result = self.state.storage_with_status(key)?; + self.usage.tally_key_read(key, result.data.as_ref(), false); + Ok(result) + } + fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { self.state.storage_hash(key) } @@ -137,6 +144,20 @@ impl>, B: BlockT> StateBackend> Ok(value) } + fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>>, Self::Error> { + let key_tuple = (child_info.storage_key().to_vec(), key.to_vec()); + let result = self.state.child_storage_with_status(child_info, &key_tuple.1)?; + + // just pass it through the usage counter + let value = self.usage.tally_child_key_read(&key_tuple, result.data, false); + + Ok(StateLoad { is_cold: result.is_cold, data: value }) + } + fn child_storage_hash( &self, child_info: &ChildInfo, diff --git a/substrate/frame/revive/src/benchmarking.rs b/substrate/frame/revive/src/benchmarking.rs index 46ff22907aac6..cc2c2c7b07edb 100644 --- a/substrate/frame/revive/src/benchmarking.rs +++ b/substrate/frame/revive/src/benchmarking.rs @@ -1407,10 +1407,12 @@ mod benchmarks { // n: new byte size // o: old byte size + // c: is_cold (0 = hot, 1 = cold) #[benchmark(skip_meta, pov_mode = Measured)] fn seal_set_storage( n: Linear<0, { limits::STORAGE_BYTES }>, o: Linear<0, { limits::STORAGE_BYTES }>, + c: Linear<0, 1>, ) -> Result<(), BenchmarkError> { let max_key_len = limits::STORAGE_KEY_BYTES; let key = Key::try_from_var(vec![0u8; max_key_len as usize]) @@ -1423,6 +1425,13 @@ mod benchmarks { info.write(&key, Some(vec![42u8; o as usize]), None, false) .map_err(|_| "Failed to write to storage during setup.")?; + // Whitelist key if c=0 (hot) + if c == 0 { + let mut full_key = info.child_trie_info().prefixed_storage_key().into_inner(); + full_key.extend_from_slice(&key.hash()); + frame_benchmarking::benchmarking::add_to_whitelist(full_key.into()); + } + let result; #[block] { @@ -1437,12 +1446,15 @@ mod benchmarks { } assert_ok!(result); - assert_eq!(info.read(&key).unwrap(), value); + assert_eq!(info.read(&key).data.unwrap(), value); Ok(()) } #[benchmark(skip_meta, pov_mode = Measured)] - fn clear_storage(n: Linear<0, { limits::STORAGE_BYTES }>) -> Result<(), BenchmarkError> { + fn clear_storage( + n: Linear<0, { limits::STORAGE_BYTES }>, + c: Linear<0, 1>, + ) -> Result<(), BenchmarkError> { let max_key_len = limits::STORAGE_KEY_BYTES; let key = Key::try_from_var(vec![0u8; max_key_len as usize]) .map_err(|_| "Key has wrong length")?; @@ -1455,6 +1467,15 @@ mod benchmarks { .abi_encode(); let mut call_setup = CallSetup::::default(); + + // Whitelist key if c=0 (hot) + if c == 0 { + let info = call_setup.contract().info()?; + let mut full_key = info.child_trie_info().prefixed_storage_key().into_inner(); + full_key.extend_from_slice(&key.hash()); + frame_benchmarking::benchmarking::add_to_whitelist(full_key.into()); + } + let (mut ext, _) = call_setup.ext(); ext.set_storage(&key, Some(vec![42u8; max_key_len as usize]), false) .map_err(|_| "Failed to write to storage during setup.")?; @@ -1465,17 +1486,21 @@ mod benchmarks { result = run_builtin_precompile( &mut ext, H160(BenchmarkStorage::::MATCHER.base_address()).as_fixed_bytes(), - input_bytes, + input_bytes.clone(), ); } assert_ok!(result); - assert!(ext.get_storage(&key).is_none()); + assert!(ext.get_storage(&key).data.is_none()); Ok(()) } + // c: is_cold (0 = hot, 1 = cold) #[benchmark(skip_meta, pov_mode = Measured)] - fn seal_get_storage(n: Linear<0, { limits::STORAGE_BYTES }>) -> Result<(), BenchmarkError> { + fn seal_get_storage( + n: Linear<0, { limits::STORAGE_BYTES }>, + c: Linear<0, 1>, + ) -> Result<(), BenchmarkError> { let max_key_len = limits::STORAGE_KEY_BYTES; let key = Key::try_from_var(vec![0u8; max_key_len as usize]) .map_err(|_| "Key has wrong length")?; @@ -1486,6 +1511,15 @@ mod benchmarks { .map_err(|_| "Failed to write to storage during setup.")?; let out_ptr = max_key_len + 4; + + // Whitelist key if c=0 (hot) + if c == 0 { + let mut full_key = info.child_trie_info().prefixed_storage_key().into_inner(); + full_key.extend_from_slice(&key.hash()); + frame_benchmarking::benchmarking::add_to_whitelist(full_key.into()); + let _ = info.read(&key); + } + let result; #[block] { @@ -1500,12 +1534,16 @@ mod benchmarks { } assert_ok!(result); - assert_eq!(&info.read(&key).unwrap(), &memory[out_ptr as usize..]); + assert_eq!(&info.read(&key).data.unwrap(), &memory[out_ptr as usize..]); Ok(()) } + // c: is_cold (0 = hot, 1 = cold) #[benchmark(skip_meta, pov_mode = Measured)] - fn contains_storage(n: Linear<0, { limits::STORAGE_BYTES }>) -> Result<(), BenchmarkError> { + fn contains_storage( + n: Linear<0, { limits::STORAGE_BYTES }>, + c: Linear<0, 1>, + ) -> Result<(), BenchmarkError> { let max_key_len = limits::STORAGE_KEY_BYTES; let key = Key::try_from_var(vec![0u8; max_key_len as usize]) .map_err(|_| "Key has wrong length")?; @@ -1517,6 +1555,15 @@ mod benchmarks { .abi_encode(); let mut call_setup = CallSetup::::default(); + + // Whitelist key if c=0 (hot) + if c == 0 { + let info = call_setup.contract().info()?; + let mut full_key = info.child_trie_info().prefixed_storage_key().into_inner(); + full_key.extend_from_slice(&key.hash()); + frame_benchmarking::benchmarking::add_to_whitelist(full_key.into()); + } + let (mut ext, _) = call_setup.ext(); ext.set_storage(&key, Some(vec![42u8; max_key_len as usize]), false) .map_err(|_| "Failed to write to storage during setup.")?; @@ -1527,17 +1574,21 @@ mod benchmarks { result = run_builtin_precompile( &mut ext, H160(BenchmarkStorage::::MATCHER.base_address()).as_fixed_bytes(), - input_bytes, + input_bytes.clone(), ); } assert_ok!(result); - assert!(ext.get_storage(&key).is_some()); + assert!(ext.get_storage(&key).data.is_some()); Ok(()) } + // c: is_cold (0 = hot, 1 = cold) #[benchmark(skip_meta, pov_mode = Measured)] - fn take_storage(n: Linear<0, { limits::STORAGE_BYTES }>) -> Result<(), BenchmarkError> { + fn take_storage( + n: Linear<0, { limits::STORAGE_BYTES }>, + c: Linear<0, 1>, + ) -> Result<(), BenchmarkError> { let max_key_len = limits::STORAGE_KEY_BYTES; let key = Key::try_from_var(vec![3u8; max_key_len as usize]) .map_err(|_| "Key has wrong length")?; @@ -1550,6 +1601,15 @@ mod benchmarks { .abi_encode(); let mut call_setup = CallSetup::::default(); + + // Whitelist key if c=0 (hot) + if c == 0 { + let info = call_setup.contract().info()?; + let mut full_key = info.child_trie_info().prefixed_storage_key().into_inner(); + full_key.extend_from_slice(&key.hash()); + frame_benchmarking::benchmarking::add_to_whitelist(full_key.into()); + } + let (mut ext, _) = call_setup.ext(); ext.set_storage(&key, Some(vec![42u8; max_key_len as usize]), false) .map_err(|_| "Failed to write to storage during setup.")?; @@ -1560,11 +1620,11 @@ mod benchmarks { result = run_builtin_precompile( &mut ext, H160(BenchmarkStorage::::MATCHER.base_address()).as_fixed_bytes(), - input_bytes, + input_bytes.clone(), ); } assert_ok!(result); - assert!(ext.get_storage(&key).is_none()); + assert!(ext.get_storage(&key).data.is_none()); Ok(()) } diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 53613a393ba99..46aca8768238d 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -527,9 +527,9 @@ pub trait PrecompileExt: sealing::Sealed { /// Returns the storage entry of the executing account by the given `key`. /// - /// Returns `None` if the `key` wasn't previously set by `set_storage` or - /// was deleted. - fn get_storage(&mut self, key: &Key) -> Option>; + /// Returns a `StateLoad` containing the value (or `None` if the key wasn't previously set + /// or was deleted) and whether it was a cold or hot load. + fn get_storage(&mut self, key: &Key) -> sp_io::StateLoad>>; /// Returns `Some(len)` (in bytes) if a storage item exists at `key`. /// @@ -544,7 +544,7 @@ pub trait PrecompileExt: sealing::Sealed { key: &Key, value: Option>, take_old: bool, - ) -> Result; + ) -> Result, DispatchError>; /// Charges `diff` from the meter. fn charge_storage(&mut self, diff: &Diff) -> DispatchResult; @@ -2461,7 +2461,7 @@ where frame.frame_meter.eth_gas_left().unwrap_or_default().saturated_into::() } - fn get_storage(&mut self, key: &Key) -> Option> { + fn get_storage(&mut self, key: &Key) -> sp_io::StateLoad>> { assert!(self.has_contract_info()); self.top_frame_mut().contract_info().read(key) } @@ -2476,7 +2476,7 @@ where key: &Key, value: Option>, take_old: bool, - ) -> Result { + ) -> Result, DispatchError> { assert!(self.has_contract_info()); let frame = self.top_frame_mut(); frame.contract_info.get(&frame.account_id).write( diff --git a/substrate/frame/revive/src/exec/mock_ext.rs b/substrate/frame/revive/src/exec/mock_ext.rs index bfe8b4cd159e8..3d7b007932243 100644 --- a/substrate/frame/revive/src/exec/mock_ext.rs +++ b/substrate/frame/revive/src/exec/mock_ext.rs @@ -239,7 +239,7 @@ impl PrecompileExt for MockExt { panic!("MockExt::gas_left") } - fn get_storage(&mut self, _key: &Key) -> Option> { + fn get_storage(&mut self, _key: &Key) -> sp_io::StateLoad>> { panic!("MockExt::get_storage") } @@ -252,7 +252,7 @@ impl PrecompileExt for MockExt { _key: &Key, _value: Option>, _take_old: bool, - ) -> Result { + ) -> Result, DispatchError> { panic!("MockExt::set_storage") } diff --git a/substrate/frame/revive/src/exec/tests.rs b/substrate/frame/revive/src/exec/tests.rs index 90e2f6e7b0420..5e87ccfca3d8e 100644 --- a/substrate/frame/revive/src/exec/tests.rs +++ b/substrate/frame/revive/src/exec/tests.rs @@ -1781,42 +1781,42 @@ fn set_storage_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { // Write assert_eq!( - ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![4, 5, 6]), true), + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![4, 5, 6]), true).map(|sl| sl.data), Ok(WriteOutcome::New) ); - assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false).map(|sl| sl.data), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true).map(|sl| sl.data), Ok(WriteOutcome::New)); assert_eq!( - ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false), + ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true), + ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true).map(|sl| sl.data), Ok(WriteOutcome::New) ); // Overwrite assert_eq!( - ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![42]), false), - Ok(WriteOutcome::Overwritten(3)) + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![42]), false).map(|sl| sl.data), + Ok(WriteOutcome::Overwritten { len: 3 }) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![48]), true), - Ok(WriteOutcome::Taken(vec![4, 5, 6])) + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![48]), true).map(|sl| sl.data), + Ok(WriteOutcome::Taken { value: vec![4, 5, 6] }) ); - assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false), Ok(WriteOutcome::New)); - assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([3; 32]), None, false).map(|sl| sl.data), Ok(WriteOutcome::New)); + assert_eq!(ctx.ext.set_storage(&Key::Fix([4; 32]), None, true).map(|sl| sl.data), Ok(WriteOutcome::New)); assert_eq!( - ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false), - Ok(WriteOutcome::Overwritten(0)) + ctx.ext.set_storage(&Key::Fix([5; 32]), Some(vec![]), false).map(|sl| sl.data), + Ok(WriteOutcome::Overwritten { len: 0 }) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true), - Ok(WriteOutcome::Taken(vec![])) + ctx.ext.set_storage(&Key::Fix([6; 32]), Some(vec![]), true).map(|sl| sl.data), + Ok(WriteOutcome::Taken { value: vec![] }) ); exec_success() @@ -1852,7 +1852,7 @@ fn set_storage_varsized_key_works() { &Key::try_from_var([1; 64].to_vec()).unwrap(), Some(vec![1, 2, 3]), false - ), + ).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( @@ -1860,25 +1860,25 @@ fn set_storage_varsized_key_works() { &Key::try_from_var([2; 19].to_vec()).unwrap(), Some(vec![4, 5, 6]), true - ), + ).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::try_from_var([3; 19].to_vec()).unwrap(), None, false), + ctx.ext.set_storage(&Key::try_from_var([3; 19].to_vec()).unwrap(), None, false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::try_from_var([4; 64].to_vec()).unwrap(), None, true), + ctx.ext.set_storage(&Key::try_from_var([4; 64].to_vec()).unwrap(), None, true).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false), + .set_storage(&Key::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true), + .set_storage(&Key::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true).map(|sl| sl.data), Ok(WriteOutcome::New) ); @@ -1888,34 +1888,34 @@ fn set_storage_varsized_key_works() { &Key::try_from_var([1; 64].to_vec()).unwrap(), Some(vec![42, 43, 44]), false - ), - Ok(WriteOutcome::Overwritten(3)) + ).map(|sl| sl.data), + Ok(WriteOutcome::Overwritten { len: 3 }) ); assert_eq!( ctx.ext.set_storage( &Key::try_from_var([2; 19].to_vec()).unwrap(), Some(vec![48]), true - ), - Ok(WriteOutcome::Taken(vec![4, 5, 6])) + ).map(|sl| sl.data), + Ok(WriteOutcome::Taken { value: vec![4, 5, 6] }) ); assert_eq!( - ctx.ext.set_storage(&Key::try_from_var([3; 19].to_vec()).unwrap(), None, false), + ctx.ext.set_storage(&Key::try_from_var([3; 19].to_vec()).unwrap(), None, false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::try_from_var([4; 64].to_vec()).unwrap(), None, true), + ctx.ext.set_storage(&Key::try_from_var([4; 64].to_vec()).unwrap(), None, true).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false), - Ok(WriteOutcome::Overwritten(0)) + .set_storage(&Key::try_from_var([5; 30].to_vec()).unwrap(), Some(vec![]), false).map(|sl| sl.data), + Ok(WriteOutcome::Overwritten { len: 0 }) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true), - Ok(WriteOutcome::Taken(vec![])) + .set_storage(&Key::try_from_var([6; 128].to_vec()).unwrap(), Some(vec![]), true).map(|sl| sl.data), + Ok(WriteOutcome::Taken { value: vec![] }) ); exec_success() @@ -1945,16 +1945,16 @@ fn set_storage_varsized_key_works() { fn get_storage_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false), + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); - assert_eq!(ctx.ext.get_storage(&Key::Fix([1; 32])), Some(vec![1, 2, 3])); - assert_eq!(ctx.ext.get_storage(&Key::Fix([2; 32])), Some(vec![])); - assert_eq!(ctx.ext.get_storage(&Key::Fix([3; 32])), None); + assert_eq!(ctx.ext.get_storage(&Key::Fix([1; 32])).data, Some(vec![1, 2, 3])); + assert_eq!(ctx.ext.get_storage(&Key::Fix([2; 32])).data, Some(vec![])); + assert_eq!(ctx.ext.get_storage(&Key::Fix([3; 32])).data, None); exec_success() }); @@ -1983,11 +1983,11 @@ fn get_storage_works() { fn get_storage_size_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { assert_eq!( - ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), + ctx.ext.set_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false), + ctx.ext.set_storage(&Key::Fix([2; 32]), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!(ctx.ext.get_storage_size(&Key::Fix([1; 32])), Some(3)); @@ -2025,23 +2025,23 @@ fn get_storage_varsized_key_works() { &Key::try_from_var([1; 19].to_vec()).unwrap(), Some(vec![1, 2, 3]), false - ), + ).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false), + .set_storage(&Key::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( - ctx.ext.get_storage(&Key::try_from_var([1; 19].to_vec()).unwrap()), + ctx.ext.get_storage(&Key::try_from_var([1; 19].to_vec()).unwrap()).data, Some(vec![1, 2, 3]) ); assert_eq!( - ctx.ext.get_storage(&Key::try_from_var([2; 16].to_vec()).unwrap()), + ctx.ext.get_storage(&Key::try_from_var([2; 16].to_vec()).unwrap()).data, Some(vec![]) ); - assert_eq!(ctx.ext.get_storage(&Key::try_from_var([3; 8].to_vec()).unwrap()), None); + assert_eq!(ctx.ext.get_storage(&Key::try_from_var([3; 8].to_vec()).unwrap()).data, None); exec_success() }); @@ -2074,12 +2074,12 @@ fn get_storage_size_varsized_key_works() { &Key::try_from_var([1; 19].to_vec()).unwrap(), Some(vec![1, 2, 3]), false - ), + ).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( ctx.ext - .set_storage(&Key::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false), + .set_storage(&Key::try_from_var([2; 16].to_vec()).unwrap(), Some(vec![]), false).map(|sl| sl.data), Ok(WriteOutcome::New) ); assert_eq!( @@ -2147,11 +2147,11 @@ fn set_transient_storage_works() { // Overwrite assert_eq!( ctx.ext.set_transient_storage(&Key::Fix([1; 32]), Some(vec![42]), false), - Ok(WriteOutcome::Overwritten(3)) + Ok(WriteOutcome::Overwritten { len: 3 }) ); assert_eq!( ctx.ext.set_transient_storage(&Key::Fix([2; 32]), Some(vec![48]), true), - Ok(WriteOutcome::Taken(vec![4, 5, 6])) + Ok(WriteOutcome::Taken { value: vec![4, 5, 6] }) ); assert_eq!( ctx.ext.set_transient_storage(&Key::Fix([3; 32]), None, false), @@ -2163,11 +2163,11 @@ fn set_transient_storage_works() { ); assert_eq!( ctx.ext.set_transient_storage(&Key::Fix([5; 32]), Some(vec![]), false), - Ok(WriteOutcome::Overwritten(0)) + Ok(WriteOutcome::Overwritten { len: 0 }) ); assert_eq!( ctx.ext.set_transient_storage(&Key::Fix([6; 32]), Some(vec![]), true), - Ok(WriteOutcome::Taken(vec![])) + Ok(WriteOutcome::Taken { value: vec![] }) ); exec_success() @@ -2221,7 +2221,7 @@ fn get_transient_storage_works() { } else { assert_eq!( ctx.ext.set_transient_storage(storage_key_1, Some(vec![3]), true), - Ok(WriteOutcome::Taken(vec![1, 2])) + Ok(WriteOutcome::Taken { value: vec![1, 2] }) ); assert_eq!( ctx.ext.set_transient_storage(storage_key_2, Some(vec![]), false), @@ -2330,7 +2330,7 @@ fn rollback_transient_storage_works() { let overwritten_length = ctx.ext.get_transient_storage_size(storage_key).unwrap(); assert_eq!( ctx.ext.set_transient_storage(storage_key, Some(vec![3]), false), - Ok(WriteOutcome::Overwritten(overwritten_length)) + Ok(WriteOutcome::Overwritten { len: overwritten_length }) ); assert_eq!(ctx.ext.get_transient_storage(storage_key), Some(vec![3])); } diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index b47caf6f98aff..b8b305ce26c9a 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1049,6 +1049,7 @@ pub mod pallet { &>::weight(&RuntimeCosts::SetStorage { new_bytes: limits::STORAGE_BYTES, old_bytes: 0, + is_cold: true, }) .saturating_mul(u64::from(limits::STORAGE_BYTES).saturating_add(max_key_size)), ) @@ -2650,7 +2651,7 @@ sp_api::decl_runtime_apis! { fn get_storage( address: H160, key: [u8; 32], - ) -> GetStorageResult; + ) -> GetStorageResult>>; /// Query a given variable-sized storage key in a given contract. /// @@ -2660,7 +2661,7 @@ sp_api::decl_runtime_apis! { fn get_storage_var_key( address: H160, key: Vec, - ) -> GetStorageResult; + ) -> GetStorageResult>>; /// Traces the execution of an entire block and returns call traces. /// @@ -2885,12 +2886,12 @@ macro_rules! impl_runtime_apis_plus_revive_traits { fn get_storage_var_key( address: $crate::H160, key: Vec, - ) -> $crate::GetStorageResult { - $crate::Pallet::::get_storage_var_key(address, key) + ) -> $crate::GetStorageResult>> { + $crate::Pallet::::get_storage_var_key(address, key).map(|s| s.data) } - fn get_storage(address: $crate::H160, key: [u8; 32]) -> $crate::GetStorageResult { - $crate::Pallet::::get_storage(address, key) + fn get_storage(address: $crate::H160, key: [u8; 32]) -> $crate::GetStorageResult>> { + $crate::Pallet::::get_storage(address, key).map(|s| s.data) } fn trace_block( diff --git a/substrate/frame/revive/src/precompiles/builtin/storage.rs b/substrate/frame/revive/src/precompiles/builtin/storage.rs index 6049fcdcec0c8..d09bf602f9ea2 100644 --- a/substrate/frame/revive/src/precompiles/builtin/storage.rs +++ b/substrate/frame/revive/src/precompiles/builtin/storage.rs @@ -61,26 +61,28 @@ impl BuiltinPrecompile for Storage { IStorageCalls::clearStorage(IStorage::clearStorageCall { flags, key, isFixedKey }) => { let transient = is_transient(*flags) .map_err(|_| Error::Revert("invalid storage flag".into()))?; - let costs = |len| { + let costs = |len, is_cold: bool| { if transient { RuntimeCosts::ClearTransientStorage(len) } else { - RuntimeCosts::ClearStorage(len) + RuntimeCosts::ClearStorage { len, is_cold } } }; - let charged = env.frame_meter_mut().charge_weight_token(costs(max_size))?; + let charged = env.frame_meter_mut().charge_weight_token(costs(max_size, true))?; let key = decode_key(key.as_bytes_ref(), *isFixedKey) .map_err(|_| Error::Revert("failed decoding key".into()))?; let outcome = if transient { env.set_transient_storage(&key, None, false) + .map(|data| sp_io::StateLoad { data, is_cold: false }) .map_err(|_| Error::Revert("failed setting transient storage".into()))? } else { env.set_storage(&key, None, false) .map_err(|_| Error::Revert("failed setting storage".into()))? }; - let contained_key = outcome != WriteOutcome::New; - let ret = (contained_key, outcome.old_len()); - env.frame_meter_mut().adjust_weight(charged, costs(outcome.old_len())); + let contained_key = !matches!(outcome.data, WriteOutcome::New { .. }); + let ret = (contained_key, outcome.data.old_len()); + env.frame_meter_mut() + .adjust_weight(charged, costs(outcome.data.old_len(), outcome.is_cold)); Ok(ret.abi_encode()) }, IStorageCalls::containsStorage(IStorage::containsStorageCall { @@ -94,7 +96,7 @@ impl BuiltinPrecompile for Storage { if transient { RuntimeCosts::ContainsTransientStorage(len) } else { - RuntimeCosts::ContainsStorage(len) + RuntimeCosts::ContainsStorage { len, is_cold: false } } }; let charged = env.frame_meter_mut().charge_weight_token(costs(max_size))?; @@ -113,27 +115,29 @@ impl BuiltinPrecompile for Storage { IStorageCalls::takeStorage(IStorage::takeStorageCall { flags, key, isFixedKey }) => { let transient = is_transient(*flags) .map_err(|_| Error::Revert("invalid storage flag".into()))?; - let costs = |len| { + let costs = |len, is_cold: bool| { if transient { RuntimeCosts::TakeTransientStorage(len) } else { - RuntimeCosts::TakeStorage(len) + RuntimeCosts::TakeStorage { len, is_cold } } }; - let charged = env.frame_meter_mut().charge_weight_token(costs(max_size))?; + let charged = env.frame_meter_mut().charge_weight_token(costs(max_size, true))?; let key = decode_key(key.as_bytes_ref(), *isFixedKey) .map_err(|_| Error::Revert("failed decoding key".into()))?; let outcome = if transient { - env.set_transient_storage(&key, None, true)? + env.set_transient_storage(&key, None, true) + .map(|data| sp_io::StateLoad { data, is_cold: false })? } else { env.set_storage(&key, None, true)? }; - if let crate::storage::WriteOutcome::Taken(value) = outcome { - env.frame_meter_mut().adjust_weight(charged, costs(value.len() as u32)); + if let crate::storage::WriteOutcome::Taken { value, .. } = outcome.data { + env.frame_meter_mut() + .adjust_weight(charged, costs(value.len() as u32, outcome.is_cold)); Ok(value.abi_encode()) } else { - env.frame_meter_mut().adjust_weight(charged, costs(0)); + env.frame_meter_mut().adjust_weight(charged, costs(0, outcome.is_cold)); Ok(Vec::::new().abi_encode()) } }, diff --git a/substrate/frame/revive/src/primitives.rs b/substrate/frame/revive/src/primitives.rs index c5154d7055aea..b1370ff1b7205 100644 --- a/substrate/frame/revive/src/primitives.rs +++ b/substrate/frame/revive/src/primitives.rs @@ -183,10 +183,10 @@ impl BalanceWithDust { pub type CodeUploadResult = Result, DispatchError>; /// Result type of a `get_storage` call. -pub type GetStorageResult = Result>, ContractAccessError>; +pub type GetStorageResult>>> = Result; /// Result type of a `set_storage` call. -pub type SetStorageResult = Result; +pub type SetStorageResult> = Result; /// The possible errors that can happen querying the storage of a contract. #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, MaxEncodedLen, RuntimeDebug, TypeInfo)] diff --git a/substrate/frame/revive/src/storage.rs b/substrate/frame/revive/src/storage.rs index 77110178c9d3e..5739fa0030ada 100644 --- a/substrate/frame/revive/src/storage.rs +++ b/substrate/frame/revive/src/storage.rs @@ -263,13 +263,15 @@ impl ContractInfo { /// /// The read is performed from the `trie_id` only. The `address` is not necessary. If the /// contract doesn't store under the given `key` `None` is returned. - pub fn read(&self, key: &Key) -> Option> { - let value = child::get_raw(&self.child_trie_info(), key.hash().as_slice()); - log::trace!(target: crate::LOG_TARGET, "contract storage: read value {:?} for key {:x?}", value, key); + /// + /// Returns a `StateLoad` containing the value and whether it was a cold or hot load. + pub fn read(&self, key: &Key) -> sp_io::StateLoad>> { + let result = child::get_raw_with_status(&self.child_trie_info(), key.hash().as_slice()); + log::trace!(target: crate::LOG_TARGET, "contract storage: read value {:?} for key {:x?}", result.data, key); if_tracing(|t| { - t.storage_read(key, value.as_deref()); + t.storage_read(key, result.data.as_deref()); }); - return value + result } /// Returns `Some(len)` (in bytes) if a storage item exists at `key`. @@ -293,7 +295,7 @@ impl ContractInfo { new_value: Option>, frame_meter: Option<&mut FrameMeter>, take: bool, - ) -> Result { + ) -> Result, DispatchError> { log::trace!(target: crate::LOG_TARGET, "contract storage: writing value {:?} for key {:x?}", new_value, key); let hashed_key = key.hash(); if_tracing(|t| { @@ -313,7 +315,7 @@ impl ContractInfo { new_value: Option>, take: bool, ) -> Result { - self.write_raw(key, new_value.as_deref(), None, take) + self.write_raw(key, new_value.as_deref(), None, take).map(|state_load| state_load.data) } fn write_raw( @@ -322,13 +324,14 @@ impl ContractInfo { new_value: Option<&[u8]>, frame_meter: Option<&mut FrameMeter>, take: bool, - ) -> Result { + ) -> Result, DispatchError> { let child_trie_info = &self.child_trie_info(); - let (old_len, old_value) = if take { - let val = child::get_raw(child_trie_info, key); - (val.as_ref().map(|v| v.len() as u32), val) + let (old_len, old_value, is_cold) = if take { + let state_load = child::get_raw_with_status(child_trie_info, key); + (state_load.data.as_ref().map(|v| v.len() as u32), state_load.data, state_load.is_cold) } else { - (child::len(child_trie_info, key), None) + let state_load = child::get_raw_with_status(child_trie_info, key); + (state_load.data.as_ref().map(|v| v.len() as u32), None, state_load.is_cold) }; if let Some(frame_meter) = frame_meter { @@ -359,11 +362,12 @@ impl ContractInfo { None => child::kill(child_trie_info, key), } - Ok(match (old_len, old_value) { + let outcome = match (old_len, old_value) { (None, _) => WriteOutcome::New, - (Some(old_len), None) => WriteOutcome::Overwritten(old_len), - (Some(_), Some(old_value)) => WriteOutcome::Taken(old_value), - }) + (Some(old_len), None) => WriteOutcome::Overwritten { len: old_len }, + (Some(_), Some(old_value)) => WriteOutcome::Taken { value: old_value }, + }; + Ok(sp_io::StateLoad { data: outcome, is_cold }) } /// Sets and returns the contract base deposit. @@ -478,13 +482,13 @@ pub enum WriteOutcome { /// No value existed at the specified key. New, /// A value of the returned length was overwritten. - Overwritten(u32), + Overwritten { len: u32 }, /// The returned value was taken out of storage before being overwritten. /// /// This is only returned when specifically requested because it causes additional work /// depending on the size of the pre-existing value. When not requested [`Self::Overwritten`] /// is returned instead. - Taken(Vec), + Taken { value: Vec }, } impl WriteOutcome { @@ -493,8 +497,8 @@ impl WriteOutcome { pub fn old_len(&self) -> u32 { match self { Self::New => 0, - Self::Overwritten(len) => *len, - Self::Taken(value) => value.len() as u32, + Self::Overwritten { len } => *len, + Self::Taken { value } => value.len() as u32, } } @@ -508,8 +512,8 @@ impl WriteOutcome { pub fn old_len_with_sentinel(&self) -> u32 { match self { Self::New => SENTINEL, - Self::Overwritten(len) => *len, - Self::Taken(value) => value.len() as u32, + Self::Overwritten { len } => *len, + Self::Taken { value } => value.len() as u32, } } } diff --git a/substrate/frame/revive/src/tests.rs b/substrate/frame/revive/src/tests.rs index 0af794f6ec7e3..d859a4a9eb601 100644 --- a/substrate/frame/revive/src/tests.rs +++ b/substrate/frame/revive/src/tests.rs @@ -641,7 +641,7 @@ fn ext_builder_with_genesis_config_works() { for (key, value) in contract_data.storage.iter() { assert_eq!( Pallet::::get_storage(contract.address, key.0), - Ok(Some(value.0.to_vec())) + Ok(sp_io::StateLoad { data: Some(value.0.to_vec()), is_cold: true }) ); } diff --git a/substrate/frame/revive/src/tests/pvm.rs b/substrate/frame/revive/src/tests/pvm.rs index dbeffcab840fb..90f14dff676ef 100644 --- a/substrate/frame/revive/src/tests/pvm.rs +++ b/substrate/frame/revive/src/tests/pvm.rs @@ -5181,15 +5181,15 @@ fn get_set_storage_key_works() { let contract_key_to_test = [1; 32]; // Checking non-existing keys gets created. let storage_value = Pallet::::get_storage(addr, contract_key_to_test).unwrap(); - assert_eq!(storage_value, None); + assert_eq!(storage_value.data, None); let value_to_write = Some(vec![1, 2, 3]); let write_result = Pallet::::set_storage(addr, contract_key_to_test, value_to_write.clone()) .unwrap(); - assert_eq!(write_result, WriteOutcome::New); + assert_eq!(write_result.data, WriteOutcome::New); let storage_value = Pallet::::get_storage(addr, contract_key_to_test).unwrap(); - assert_eq!(storage_value, value_to_write); + assert_eq!(storage_value.data, value_to_write); // Check existing keys overwrite @@ -5198,11 +5198,11 @@ fn get_set_storage_key_works() { Pallet::::set_storage(addr, contract_key_to_test, new_value_to_write.clone()) .unwrap(); assert_eq!( - write_result, - WriteOutcome::Overwritten(value_to_write.map(|v| v.len()).unwrap_or_default() as u32) + write_result.data, + WriteOutcome::Overwritten { len: value_to_write.map(|v| v.len()).unwrap_or_default() as u32 } ); let storage_value = Pallet::::get_storage(addr, contract_key_to_test).unwrap(); - assert_eq!(storage_value, new_value_to_write); + assert_eq!(storage_value.data, new_value_to_write); }); } @@ -5220,7 +5220,7 @@ fn get_set_storage_var_key_works() { // Checking non-existing keys gets created. let storage_value = Pallet::::get_storage_var_key(addr, contract_key_to_test.clone()).unwrap(); - assert_eq!(storage_value, None); + assert_eq!(storage_value.data, None); let value_to_write = Some(vec![1, 2, 3]); let write_result = Pallet::::set_storage_var_key( @@ -5229,10 +5229,10 @@ fn get_set_storage_var_key_works() { value_to_write.clone(), ) .unwrap(); - assert_eq!(write_result, WriteOutcome::New); + assert_eq!(write_result.data, WriteOutcome::New); let storage_value = Pallet::::get_storage_var_key(addr, contract_key_to_test.clone()).unwrap(); - assert_eq!(storage_value, value_to_write); + assert_eq!(storage_value.data, value_to_write); // Check existing keys overwrite @@ -5244,12 +5244,12 @@ fn get_set_storage_var_key_works() { ) .unwrap(); assert_eq!( - write_result, - WriteOutcome::Overwritten(value_to_write.map(|v| v.len()).unwrap_or_default() as u32) + write_result.data, + WriteOutcome::Overwritten { len: value_to_write.map(|v| v.len()).unwrap_or_default() as u32 } ); let storage_value = Pallet::::get_storage_var_key(addr, contract_key_to_test.clone()).unwrap(); - assert_eq!(storage_value, new_value_to_write); + assert_eq!(storage_value.data, new_value_to_write); }); } diff --git a/substrate/frame/revive/src/tests/sol/host.rs b/substrate/frame/revive/src/tests/sol/host.rs index f6a54e6b0a364..22bff0b7b780a 100644 --- a/substrate/frame/revive/src/tests/sol/host.rs +++ b/substrate/frame/revive/src/tests/sol/host.rs @@ -443,7 +443,7 @@ fn sstore_works(fixture_type: FixtureType) { let written_value = { let contract_info = test_utils::get_contract(&addr); let key = Key::Fix(U256::from(index).to_big_endian()); - let result = contract_info.read(&key).unwrap(); + let result = contract_info.read(&key).data.unwrap(); U256::from_big_endian(&result) }; assert_eq!( diff --git a/substrate/frame/revive/src/transient_storage.rs b/substrate/frame/revive/src/transient_storage.rs index d88adc4373590..249cf20c4d26e 100644 --- a/substrate/frame/revive/src/transient_storage.rs +++ b/substrate/frame/revive/src/transient_storage.rs @@ -272,8 +272,8 @@ impl TransientStorage { Ok(match (take, prev_value) { (_, None) => WriteOutcome::New, - (false, Some(prev_value)) => WriteOutcome::Overwritten(prev_value.len() as _), - (true, Some(prev_value)) => WriteOutcome::Taken(prev_value), + (false, Some(prev_value)) => WriteOutcome::Overwritten { len: prev_value.len() as _ }, + (true, Some(prev_value)) => WriteOutcome::Taken { value: prev_value }, }) } @@ -373,11 +373,11 @@ mod tests { // Overwrite values. assert_eq!( storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![4, 5]), false), - Ok(WriteOutcome::Overwritten(1)) + Ok(WriteOutcome::Overwritten { len: 1 }) ); assert_eq!( storage.write(&BOB, &Key::Fix([3; 32]), Some(vec![6, 7]), true), - Ok(WriteOutcome::Taken(vec![3])) + Ok(WriteOutcome::Taken { value: vec![3] }) ); assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])); assert_eq!(storage.read(&ALICE, &Key::Fix([2; 32])), Some(vec![4, 5])); @@ -386,13 +386,13 @@ mod tests { // Check for an empty value. assert_eq!( storage.write(&BOB, &Key::Fix([3; 32]), Some(vec![]), true), - Ok(WriteOutcome::Taken(vec![6, 7])) + Ok(WriteOutcome::Taken { value: vec![6, 7] }) ); assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), Some(vec![])); assert_eq!( storage.write(&BOB, &Key::Fix([3; 32]), None, true), - Ok(WriteOutcome::Taken(vec![])) + Ok(WriteOutcome::Taken { value: vec![] }) ); assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), None); } @@ -434,7 +434,7 @@ mod tests { Some(vec![4, 5]), false ), - Ok(WriteOutcome::Overwritten(1)) + Ok(WriteOutcome::Overwritten { len: 1 }) ); assert_eq!( storage.read(&ALICE, &Key::try_from_var([1; 64].to_vec()).unwrap()), @@ -478,7 +478,7 @@ mod tests { ); assert_eq!( storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1, 2]), false), - Ok(WriteOutcome::Overwritten(1)) + Ok(WriteOutcome::Overwritten { len: 1 }) ); storage.commit_transaction(); assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1, 2])) diff --git a/substrate/frame/revive/src/vm/evm/instructions/host.rs b/substrate/frame/revive/src/vm/evm/instructions/host.rs index d3cb9c77a5462..34960335aec6a 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/host.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/host.rs @@ -111,12 +111,17 @@ pub fn blockhash(interpreter: &mut Interpreter) -> ControlFlow /// Loads a word from storage. pub fn sload(interpreter: &mut Interpreter) -> ControlFlow { let ([], index) = interpreter.stack.popn_top()?; - // NB: SLOAD loads 32 bytes from storage (i.e. U256). - interpreter.ext.charge_or_halt(RuntimeCosts::GetStorage(32))?; let key = Key::Fix(index.to_big_endian()); - let value = interpreter.ext.get_storage(&key); + let sp_io::StateLoad { data, is_cold } = interpreter.ext.get_storage(&key); + interpreter.ext.charge_or_halt(RuntimeCosts::GetStorage { len: 32, is_cold })?; - *index = if let Some(storage_value) = value { + log::debug!( + target: LOG_TARGET, + "sload key={} is_cold={is_cold}", + sp_core::hexdisplay::HexDisplay::from(&key.hash()), + ); + + *index = if let Some(storage_value) = data { // sload always reads a word let Ok::<[u8; 32], _>(bytes) = storage_value.try_into() else { log::debug!(target: crate::LOG_TARGET, "sload read invalid storage value length. Expected 32."); @@ -132,31 +137,27 @@ pub fn sload(interpreter: &mut Interpreter) -> ControlFlow { fn store_helper<'ext, E: Ext>( interpreter: &mut Interpreter<'ext, E>, - cost_before: RuntimeCosts, - set_function: fn(&mut E, &Key, Option>, bool) -> Result, - adjust_cost: fn(new_bytes: u32, old_bytes: u32) -> RuntimeCosts, + set_function: fn( + &mut E, + &Key, + Option>, + ) -> Result, DispatchError>, + cost: fn(new_bytes: u32, sp_io::StateLoad) -> RuntimeCosts, ) -> ControlFlow { if interpreter.ext.is_read_only() { return ControlFlow::Break(Error::::StateChangeDenied.into()); } let [index, value] = interpreter.stack.popn()?; - - // Charge gas before set_storage and later adjust it down to the true gas cost - let charged_amount = interpreter.ext.charge_or_halt(cost_before)?; let key = Key::Fix(index.to_big_endian()); - let take_old = false; - let value_to_store = if value.is_zero() { None } else { Some(value.to_big_endian().to_vec()) }; - let Ok(write_outcome) = set_function(interpreter.ext, &key, value_to_store.clone(), take_old) - else { + let (value_to_store, len) = + if value.is_zero() { (None, 0) } else { (Some(value.to_big_endian().to_vec()), 32) }; + + let Ok(write_outcome) = set_function(interpreter.ext, &key, value_to_store) else { return ControlFlow::Break(Error::::ContractTrapped.into()); }; - interpreter.ext.frame_meter_mut().adjust_weight( - charged_amount, - adjust_cost(value_to_store.unwrap_or_default().len() as u32, write_outcome.old_len()), - ); - + interpreter.ext.charge_or_halt(cost(len, write_outcome))?; ControlFlow::Continue(()) } @@ -164,24 +165,30 @@ fn store_helper<'ext, E: Ext>( /// /// Stores a word to storage. pub fn sstore(interpreter: &mut Interpreter) -> ControlFlow { - let old_bytes = limits::STORAGE_BYTES; store_helper( interpreter, - RuntimeCosts::SetStorage { new_bytes: 32, old_bytes }, - |ext, key, value, take_old| ext.set_storage(key, value, take_old), - |new_bytes, old_bytes| RuntimeCosts::SetStorage { new_bytes, old_bytes }, + |ext, key, value| ext.set_storage(key, value, false), + |new_bytes, outcome| RuntimeCosts::SetStorage { + new_bytes, + old_bytes: outcome.data.old_len(), + is_cold: outcome.is_cold, + }, ) } /// EIP-1153: Transient storage opcodes /// Store value to transient storage pub fn tstore(interpreter: &mut Interpreter) -> ControlFlow { - let old_bytes = limits::STORAGE_BYTES; store_helper( interpreter, - RuntimeCosts::SetTransientStorage { new_bytes: 32, old_bytes }, - |ext, key, value, take_old| ext.set_transient_storage(key, value, take_old), - |new_bytes, old_bytes| RuntimeCosts::SetTransientStorage { new_bytes, old_bytes }, + |ext, key, value| { + ext.set_transient_storage(key, value, false) + .map(|data| sp_io::StateLoad { data, is_cold: false }) + }, + |new_bytes, outcome| RuntimeCosts::SetTransientStorage { + new_bytes, + old_bytes: outcome.data.old_len(), + }, ) } diff --git a/substrate/frame/revive/src/vm/pvm.rs b/substrate/frame/revive/src/vm/pvm.rs index 73a6c712ed3b2..9f774661935d4 100644 --- a/substrate/frame/revive/src/vm/pvm.rs +++ b/substrate/frame/revive/src/vm/pvm.rs @@ -489,11 +489,11 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { value: StorageValue, ) -> Result { let transient = Self::is_transient(flags)?; - let costs = |new_bytes: u32, old_bytes: u32| { + let costs = |new_bytes: u32, old_bytes: u32, is_cold: bool| { if transient { RuntimeCosts::SetTransientStorage { new_bytes, old_bytes } } else { - RuntimeCosts::SetStorage { new_bytes, old_bytes } + RuntimeCosts::SetStorage { new_bytes, old_bytes, is_cold } } }; @@ -503,7 +503,7 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { }; let max_size = limits::STORAGE_BYTES; - let charged = self.charge_gas(costs(value_len, max_size))?; + let charged = self.charge_gas(costs(value_len, max_size, true))?; if value_len > max_size { return Err(Error::::ValueTooLarge.into()); } @@ -516,13 +516,18 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { }; let write_outcome = if transient { - self.ext.set_transient_storage(&key, value, false)? + self.ext + .set_transient_storage(&key, value, false) + .map(|data| sp_io::StateLoad { data, is_cold: false })? } else { self.ext.set_storage(&key, value, false)? }; - self.adjust_gas(charged, costs(value_len, write_outcome.old_len())); - Ok(write_outcome.old_len_with_sentinel()) + self.adjust_gas( + charged, + costs(value_len, write_outcome.data.old_len(), write_outcome.is_cold), + ); + Ok(write_outcome.data.old_len_with_sentinel()) } fn clear_storage( @@ -533,22 +538,24 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { key_len: u32, ) -> Result { let transient = Self::is_transient(flags)?; - let costs = |len| { + let costs = |len, is_cold: bool| { if transient { RuntimeCosts::ClearTransientStorage(len) } else { - RuntimeCosts::ClearStorage(len) + RuntimeCosts::ClearStorage { len, is_cold } } }; - let charged = self.charge_gas(costs(limits::STORAGE_BYTES))?; + let charged = self.charge_gas(costs(limits::STORAGE_BYTES, true))?; let key = self.decode_key(memory, key_ptr, key_len)?; let outcome = if transient { - self.ext.set_transient_storage(&key, None, false)? + self.ext + .set_transient_storage(&key, None, false) + .map(|data| sp_io::StateLoad { data, is_cold: false })? } else { self.ext.set_storage(&key, None, false)? }; - self.adjust_gas(charged, costs(outcome.old_len())); - Ok(outcome.old_len_with_sentinel()) + self.adjust_gas(charged, costs(outcome.data.old_len(), outcome.is_cold)); + Ok(outcome.data.old_len_with_sentinel()) } fn get_storage( @@ -561,23 +568,24 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { read_mode: StorageReadMode, ) -> Result { let transient = Self::is_transient(flags)?; - let costs = |len| { + let costs = |len, is_cold: bool| { if transient { RuntimeCosts::GetTransientStorage(len) } else { - RuntimeCosts::GetStorage(len) + RuntimeCosts::GetStorage { len, is_cold } } }; - let charged = self.charge_gas(costs(limits::STORAGE_BYTES))?; + let charged = self.charge_gas(costs(limits::STORAGE_BYTES, true))?; let key = self.decode_key(memory, key_ptr, key_len)?; - let outcome = if transient { - self.ext.get_transient_storage(&key) + let (outcome, is_cold) = if transient { + (self.ext.get_transient_storage(&key), false) } else { - self.ext.get_storage(&key) + let state_load = self.ext.get_storage(&key); + (state_load.data, state_load.is_cold) }; if let Some(value) = outcome { - self.adjust_gas(charged, costs(value.len() as u32)); + self.adjust_gas(charged, costs(value.len() as u32, is_cold)); match read_mode { StorageReadMode::FixedOutput32 => { @@ -607,7 +615,7 @@ impl<'a, E: Ext, M: ?Sized + Memory> Runtime<'a, E, M> { }, } } else { - self.adjust_gas(charged, costs(0)); + self.adjust_gas(charged, costs(0, is_cold)); match read_mode { StorageReadMode::FixedOutput32 => { diff --git a/substrate/frame/revive/src/vm/runtime_costs.rs b/substrate/frame/revive/src/vm/runtime_costs.rs index cf4e782cd245f..55538bb9adf0b 100644 --- a/substrate/frame/revive/src/vm/runtime_costs.rs +++ b/substrate/frame/revive/src/vm/runtime_costs.rs @@ -100,18 +100,18 @@ pub enum RuntimeCosts { /// Weight of calling `seal_deposit_event` with the given number of topics and event size. DepositEvent { num_topic: u32, len: u32 }, /// Weight of calling `seal_set_storage` for the given storage item sizes. - SetStorage { old_bytes: u32, new_bytes: u32 }, + SetStorage { old_bytes: u32, new_bytes: u32, is_cold: bool }, /// Weight of calling the `clearStorage` function of the `Storage` pre-compile /// per cleared byte. - ClearStorage(u32), + ClearStorage { len: u32, is_cold: bool }, /// Weight of calling the `containsStorage` function of the `Storage` pre-compile /// per byte of the checked item. - ContainsStorage(u32), + ContainsStorage { len: u32, is_cold: bool }, /// Weight of calling `seal_get_storage` with the specified size in storage. - GetStorage(u32), + GetStorage { len: u32, is_cold: bool }, /// Weight of calling the `takeStorage` function of the `Storage` pre-compile /// for the given size. - TakeStorage(u32), + TakeStorage { len: u32, is_cold: bool }, /// Weight of calling `seal_set_transient_storage` for the given storage item sizes. SetTransientStorage { old_bytes: u32, new_bytes: u32 }, /// Weight of calling `seal_clear_transient_storage` per cleared byte. @@ -279,13 +279,36 @@ impl Token for RuntimeCosts { limits::EXTRA_EVENT_CHARGE_PER_BYTE.saturating_mul(len.into()).into(), 0, )), - SetStorage { new_bytes, old_bytes } => { - cost_storage!(write, seal_set_storage, new_bytes, old_bytes) - }, - ClearStorage(len) => cost_storage!(write, clear_storage, len), - ContainsStorage(len) => cost_storage!(read, contains_storage, len), - GetStorage(len) => cost_storage!(read, seal_get_storage, len), - TakeStorage(len) => cost_storage!(write, take_storage, len), + SetStorage { new_bytes, old_bytes, is_cold } => + if is_cold { + cost_storage!(write, seal_set_storage, new_bytes, old_bytes, is_cold as u32) + } else { + T::WeightInfo::seal_set_storage(new_bytes, old_bytes, 0) + }, + ClearStorage { len, is_cold } => + if is_cold { + cost_storage!(write, clear_storage, len, is_cold as u32) + } else { + T::WeightInfo::clear_storage(len, 0) + }, + ContainsStorage { len, is_cold } => + if is_cold { + cost_storage!(read, contains_storage, len, is_cold as u32) + } else { + T::WeightInfo::contains_storage(len, 0) + }, + GetStorage { len, is_cold } => + if is_cold { + cost_storage!(read, seal_get_storage, len, is_cold as u32) + } else { + T::WeightInfo::seal_get_storage(len, 0) + }, + TakeStorage { len, is_cold } => + if is_cold { + cost_storage!(write, take_storage, len, is_cold as u32) + } else { + T::WeightInfo::take_storage(len, 0) + }, SetTransientStorage { new_bytes, old_bytes } => { cost_storage!(write_transient, seal_set_transient_storage, new_bytes, old_bytes) }, diff --git a/substrate/frame/revive/src/weights.rs b/substrate/frame/revive/src/weights.rs index e13b67edc4fd8..7508efc024fa2 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-11-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `44a3520f326f`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `09a5ffbc135a`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: @@ -127,11 +127,11 @@ pub trait WeightInfo { fn get_storage_full() -> Weight; fn set_storage_empty() -> Weight; fn set_storage_full() -> Weight; - fn seal_set_storage(n: u32, o: u32, ) -> Weight; - fn clear_storage(n: u32, ) -> Weight; - fn seal_get_storage(n: u32, ) -> Weight; - fn contains_storage(n: u32, ) -> Weight; - fn take_storage(n: u32, ) -> Weight; + fn seal_set_storage(n: u32, o: u32, c: u32, ) -> Weight; + fn clear_storage(n: u32, c: u32, ) -> Weight; + fn seal_get_storage(n: u32, c: u32, ) -> Weight; + fn contains_storage(n: u32, c: u32, ) -> Weight; + fn take_storage(n: u32, c: u32, ) -> Weight; fn set_transient_storage_empty() -> Weight; fn set_transient_storage_full() -> Weight; fn get_transient_storage_empty() -> Weight; @@ -183,8 +183,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `213` // Estimated: `1698` - // Minimum execution time: 3_325_000 picoseconds. - Weight::from_parts(3_509_000, 1698) + // Minimum execution time: 3_172_000 picoseconds. + Weight::from_parts(3_405_000, 1698) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -194,10 +194,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `491 + k * (69 ±0)` // Estimated: `481 + k * (70 ±0)` - // Minimum execution time: 14_389_000 picoseconds. - Weight::from_parts(15_127_000, 481) - // Standard Error: 1_039 - .saturating_add(Weight::from_parts(1_209_966, 0).saturating_mul(k.into())) + // Minimum execution time: 14_342_000 picoseconds. + Weight::from_parts(14_928_000, 481) + // Standard Error: 1_398 + .saturating_add(Weight::from_parts(1_214_263, 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)) @@ -221,10 +221,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1265 + c * (1 ±0)` // Estimated: `7200 + c * (1 ±0)` - // Minimum execution time: 100_357_000 picoseconds. - Weight::from_parts(143_652_444, 7200) - // Standard Error: 12 - .saturating_add(Weight::from_parts(1_441, 0).saturating_mul(c.into())) + // Minimum execution time: 100_504_000 picoseconds. + Weight::from_parts(148_244_010, 7200) + // Standard Error: 15 + .saturating_add(Weight::from_parts(1_566, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -242,14 +242,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: `1205` // Estimated: `7144` - // Minimum execution time: 92_748_000 picoseconds. - Weight::from_parts(97_747_165, 7144) - // Standard Error: 24 - .saturating_add(Weight::from_parts(46, 0).saturating_mul(c.into())) + // Minimum execution time: 92_006_000 picoseconds. + Weight::from_parts(97_368_589, 7144) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -270,10 +268,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4609` // Estimated: `10549` - // Minimum execution time: 144_014_000 picoseconds. - Weight::from_parts(149_812_683, 10549) - // Standard Error: 724_905 - .saturating_add(Weight::from_parts(1_749_116, 0).saturating_mul(b.into())) + // Minimum execution time: 150_612_000 picoseconds. + Weight::from_parts(156_471_593, 10549) + // Standard Error: 666_004 + .saturating_add(Weight::from_parts(354_506, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -297,12 +295,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `994` // Estimated: `6924` - // Minimum execution time: 773_080_000 picoseconds. - Weight::from_parts(70_290_148, 6924) - // Standard Error: 37 - .saturating_add(Weight::from_parts(20_365, 0).saturating_mul(c.into())) + // Minimum execution time: 785_616_000 picoseconds. + Weight::from_parts(53_380_306, 6924) + // Standard Error: 38 + .saturating_add(Weight::from_parts(20_886, 0).saturating_mul(c.into())) // Standard Error: 29 - .saturating_add(Weight::from_parts(5_006, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(5_224, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -331,14 +329,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `994` // Estimated: `6934` - // Minimum execution time: 405_718_000 picoseconds. - Weight::from_parts(270_737_149, 6934) - // Standard Error: 44 - .saturating_add(Weight::from_parts(15_826, 0).saturating_mul(c.into())) - // Standard Error: 34 - .saturating_add(Weight::from_parts(660, 0).saturating_mul(i.into())) - // Standard Error: 2_902_398 - .saturating_add(Weight::from_parts(8_450_702, 0).saturating_mul(d.into())) + // Minimum execution time: 406_081_000 picoseconds. + Weight::from_parts(222_392_381, 6934) + // Standard Error: 42 + .saturating_add(Weight::from_parts(16_556, 0).saturating_mul(c.into())) + // Standard Error: 32 + .saturating_add(Weight::from_parts(891, 0).saturating_mul(i.into())) + // Standard Error: 2_758_958 + .saturating_add(Weight::from_parts(34_243_932, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -346,8 +344,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_011_000 picoseconds. - Weight::from_parts(3_274_000, 0) + // Minimum execution time: 3_102_000 picoseconds. + Weight::from_parts(3_291_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:2 w:1) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -367,11 +365,11 @@ impl WeightInfo for SubstrateWeight { fn instantiate(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1735` - // Estimated: `7665` - // Minimum execution time: 187_515_000 picoseconds. - Weight::from_parts(194_934_584, 7665) - // Standard Error: 11 - .saturating_add(Weight::from_parts(4_151, 0).saturating_mul(i.into())) + // Estimated: `7668` + // Minimum execution time: 189_793_000 picoseconds. + Weight::from_parts(197_777_915, 7668) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_259, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -391,8 +389,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1947` // Estimated: `7887` - // Minimum execution time: 104_210_000 picoseconds. - Weight::from_parts(110_220_000, 7887) + // Minimum execution time: 101_360_000 picoseconds. + Weight::from_parts(105_253_000, 7887) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -417,10 +415,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1947` // Estimated: `7887` - // Minimum execution time: 179_230_000 picoseconds. - Weight::from_parts(189_040_259, 7887) - // Standard Error: 869_758 - .saturating_add(Weight::from_parts(4_172_840, 0).saturating_mul(d.into())) + // Minimum execution time: 179_650_000 picoseconds. + Weight::from_parts(188_389_730, 7887) + // Standard Error: 814_865 + .saturating_add(Weight::from_parts(1_969_669, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -437,10 +435,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `358` // Estimated: `3823` - // Minimum execution time: 28_233_000 picoseconds. - Weight::from_parts(22_905_261, 3823) - // Standard Error: 12 - .saturating_add(Weight::from_parts(6_274, 0).saturating_mul(c.into())) + // Minimum execution time: 28_012_000 picoseconds. + Weight::from_parts(22_159_986, 3823) + // Standard Error: 13 + .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -457,10 +455,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `392` // Estimated: `3857` - // Minimum execution time: 59_732_000 picoseconds. - Weight::from_parts(53_002_061, 3857) - // Standard Error: 17 - .saturating_add(Weight::from_parts(14_107, 0).saturating_mul(c.into())) + // Minimum execution time: 62_487_000 picoseconds. + Weight::from_parts(50_869_690, 3857) + // Standard Error: 20 + .saturating_add(Weight::from_parts(14_688, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -474,8 +472,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `524` // Estimated: `3989` - // Minimum execution time: 53_247_000 picoseconds. - Weight::from_parts(54_239_000, 3989) + // Minimum execution time: 53_252_000 picoseconds. + Weight::from_parts(54_982_000, 3989) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -491,10 +489,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: `833` - // Estimated: `6773` - // Minimum execution time: 67_638_000 picoseconds. - Weight::from_parts(69_822_000, 6773) + // Measured: `867` + // Estimated: `6807` + // Minimum execution time: 67_932_000 picoseconds. + Weight::from_parts(69_295_000, 6807) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -508,8 +506,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `623` // Estimated: `4088` - // Minimum execution time: 60_308_000 picoseconds. - Weight::from_parts(61_865_000, 4088) + // Minimum execution time: 61_077_000 picoseconds. + Weight::from_parts(62_440_000, 4088) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -521,8 +519,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `93` // Estimated: `3558` - // Minimum execution time: 40_748_000 picoseconds. - Weight::from_parts(41_916_000, 3558) + // Minimum execution time: 39_997_000 picoseconds. + Weight::from_parts(40_977_000, 3558) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -536,8 +534,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `381` // Estimated: `3846` - // Minimum execution time: 19_441_000 picoseconds. - Weight::from_parts(19_775_000, 3846) + // Minimum execution time: 19_305_000 picoseconds. + Weight::from_parts(20_046_000, 3846) .saturating_add(T::DbWeight::get().reads(3_u64)) } /// The range of component `r` is `[0, 1600]`. @@ -545,24 +543,24 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_031_000 picoseconds. - Weight::from_parts(9_266_076, 0) - // Standard Error: 205 - .saturating_add(Weight::from_parts(186_444, 0).saturating_mul(r.into())) + // Minimum execution time: 7_715_000 picoseconds. + Weight::from_parts(9_010_748, 0) + // Standard Error: 236 + .saturating_add(Weight::from_parts(188_696, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 377_000 picoseconds. - Weight::from_parts(403_000, 0) + // Minimum execution time: 378_000 picoseconds. + Weight::from_parts(457_000, 0) } fn seal_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 351_000 picoseconds. - Weight::from_parts(395_000, 0) + // Minimum execution time: 322_000 picoseconds. + Weight::from_parts(394_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -570,8 +568,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `623` // Estimated: `4088` - // Minimum execution time: 11_287_000 picoseconds. - Weight::from_parts(12_022_000, 4088) + // Minimum execution time: 11_336_000 picoseconds. + Weight::from_parts(11_892_000, 4088) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) @@ -580,16 +578,16 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `473` // Estimated: `3938` - // Minimum execution time: 9_933_000 picoseconds. - Weight::from_parts(10_470_000, 3938) + // Minimum execution time: 9_875_000 picoseconds. + Weight::from_parts(10_680_000, 3938) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `436` // Estimated: `0` - // Minimum execution time: 9_614_000 picoseconds. - Weight::from_parts(10_109_000, 0) + // Minimum execution time: 9_685_000 picoseconds. + Weight::from_parts(10_366_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -599,8 +597,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `545` // Estimated: `4010` - // Minimum execution time: 13_599_000 picoseconds. - Weight::from_parts(14_148_000, 4010) + // Minimum execution time: 13_680_000 picoseconds. + Weight::from_parts(14_225_000, 4010) .saturating_add(T::DbWeight::get().reads(2_u64)) } fn caller_is_origin() -> Weight { @@ -608,42 +606,42 @@ impl WeightInfo for SubstrateWeight { // Measured: `0` // Estimated: `0` // Minimum execution time: 1_161_000 picoseconds. - Weight::from_parts(1_257_000, 0) + Weight::from_parts(1_305_000, 0) } fn caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_061_000 picoseconds. - Weight::from_parts(1_188_000, 0) + // Minimum execution time: 1_134_000 picoseconds. + Weight::from_parts(1_266_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 303_000 picoseconds. - Weight::from_parts(349_000, 0) + // Minimum execution time: 329_000 picoseconds. + Weight::from_parts(378_000, 0) } fn weight_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_143_000 picoseconds. - Weight::from_parts(1_283_000, 0) + // Minimum execution time: 1_124_000 picoseconds. + Weight::from_parts(1_206_000, 0) } fn seal_ref_time_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_827_000 picoseconds. - Weight::from_parts(1_929_000, 0) + // Minimum execution time: 1_929_000 picoseconds. + Weight::from_parts(2_086_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `610` + // Measured: `576` // Estimated: `0` - // Minimum execution time: 13_541_000 picoseconds. - Weight::from_parts(14_240_000, 0) + // Minimum execution time: 13_400_000 picoseconds. + Weight::from_parts(13_848_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -655,8 +653,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `884` // Estimated: `4349` - // Minimum execution time: 20_559_000 picoseconds. - Weight::from_parts(21_367_000, 4349) + // Minimum execution time: 20_750_000 picoseconds. + Weight::from_parts(21_441_000, 4349) .saturating_add(T::DbWeight::get().reads(3_u64)) } /// Storage: `Revive::ImmutableDataOf` (r:1 w:0) @@ -666,10 +664,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `304 + n * (1 ±0)` // Estimated: `3769 + n * (1 ±0)` - // Minimum execution time: 5_923_000 picoseconds. - Weight::from_parts(6_753_149, 3769) + // Minimum execution time: 6_166_000 picoseconds. + Weight::from_parts(6_765_990, 3769) // Standard Error: 5 - .saturating_add(Weight::from_parts(523, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(585, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -680,67 +678,67 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_101_000 picoseconds. - Weight::from_parts(2_465_888, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(472, 0).saturating_mul(n.into())) + // Minimum execution time: 2_062_000 picoseconds. + Weight::from_parts(2_354_186, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(560, 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: 293_000 picoseconds. - Weight::from_parts(319_000, 0) + // Minimum execution time: 258_000 picoseconds. + Weight::from_parts(304_000, 0) } fn minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_322_000 picoseconds. - Weight::from_parts(1_476_000, 0) + // Minimum execution time: 1_265_000 picoseconds. + Weight::from_parts(1_399_000, 0) } fn seal_return_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 287_000 picoseconds. - Weight::from_parts(319_000, 0) + // Minimum execution time: 266_000 picoseconds. + Weight::from_parts(310_000, 0) } fn seal_call_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 287_000 picoseconds. + // Minimum execution time: 260_000 picoseconds. Weight::from_parts(330_000, 0) } fn seal_gas_limit() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 293_000 picoseconds. - Weight::from_parts(339_000, 0) + // Minimum execution time: 242_000 picoseconds. + Weight::from_parts(272_000, 0) } fn seal_gas_price() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 986_000 picoseconds. - Weight::from_parts(1_085_000, 0) + // Minimum execution time: 1_084_000 picoseconds. + Weight::from_parts(1_219_000, 0) } fn seal_base_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 974_000 picoseconds. - Weight::from_parts(1_057_000, 0) + // Minimum execution time: 967_000 picoseconds. + Weight::from_parts(1_080_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` // Minimum execution time: 285_000 picoseconds. - Weight::from_parts(330_000, 0) + Weight::from_parts(331_000, 0) } /// Storage: `Session::Validators` (r:1 w:0) /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -748,8 +746,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `141` // Estimated: `1626` - // Minimum execution time: 21_803_000 picoseconds. - Weight::from_parts(22_360_000, 1626) + // Minimum execution time: 21_377_000 picoseconds. + Weight::from_parts(21_980_000, 1626) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Revive::BlockHash` (r:1 w:0) @@ -758,72 +756,77 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `318` // Estimated: `3783` - // Minimum execution time: 5_906_000 picoseconds. - Weight::from_parts(6_201_000, 3783) + // Minimum execution time: 5_605_000 picoseconds. + Weight::from_parts(6_164_000, 3783) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 307_000 picoseconds. - Weight::from_parts(347_000, 0) + // Minimum execution time: 285_000 picoseconds. + Weight::from_parts(330_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: 453_000 picoseconds. - Weight::from_parts(489_000, 0) + // Minimum execution time: 461_000 picoseconds. + Weight::from_parts(573_695, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(203, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(238, 0).saturating_mul(n.into())) } fn seal_call_data_load() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 289_000 picoseconds. - Weight::from_parts(343_000, 0) + // Minimum execution time: 268_000 picoseconds. + Weight::from_parts(305_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: 280_000 picoseconds. - Weight::from_parts(496_576, 0) + // Minimum execution time: 283_000 picoseconds. + Weight::from_parts(137_385, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(113, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(149, 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: 305_000 picoseconds. - Weight::from_parts(529_465, 0) + // Minimum execution time: 309_000 picoseconds. + Weight::from_parts(546_911, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(200, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(234, 0).saturating_mul(n.into())) } + /// Storage: `Revive::OriginalAccount` (r:2 w:0) + /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 927_000 picoseconds. - Weight::from_parts(1_059_312, 0) - // Standard Error: 6_858 - .saturating_add(Weight::from_parts(13_287, 0).saturating_mul(r.into())) + // Measured: `924` + // Estimated: `6864` + // Minimum execution time: 20_544_000 picoseconds. + Weight::from_parts(21_645_167, 6864) + // Standard Error: 67_218 + .saturating_add(Weight::from_parts(66_332, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) } - /// Storage: `Revive::DeletionQueueCounter` (r:1 w:1) - /// Proof: `Revive::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `Revive::CodeInfoOf` (r:1 w:1) - /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) - /// Storage: `Balances::Holds` (r:1 w:1) + /// Storage: `Balances::Holds` (r:2 w:2) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(463), added: 2938, mode: `Measured`) + /// Storage: `Revive::OriginalAccount` (r:1 w:0) + /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Revive::CodeInfoOf` (r:1 w:1) + /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) + /// Storage: `Revive::DeletionQueueCounter` (r:1 w:1) + /// Proof: `Revive::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Revive::DeletionQueue` (r:0 w:1) /// Proof: `Revive::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) /// Storage: `Revive::PristineCode` (r:0 w:1) @@ -832,12 +835,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Revive::ImmutableDataOf` (`max_values`: None, `max_size`: Some(4118), added: 6593, mode: `Measured`) fn seal_terminate_logic() -> Weight { // Proof Size summary in bytes: - // Measured: `1050` - // Estimated: `6990` - // Minimum execution time: 118_234_000 picoseconds. - Weight::from_parts(122_191_000, 6990) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Measured: `1440` + // Estimated: `7380` + // Minimum execution time: 240_341_000 picoseconds. + Weight::from_parts(248_030_000, 7380) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) } /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 65536]`. @@ -845,10 +848,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_221_000 picoseconds. - Weight::from_parts(5_319_000, 0) + // Minimum execution time: 5_424_000 picoseconds. + Weight::from_parts(5_668_000, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(1_209, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_290, 0).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -856,8 +859,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 7_453_000 picoseconds. - Weight::from_parts(7_862_000, 648) + // Minimum execution time: 7_428_000 picoseconds. + Weight::from_parts(7_906_000, 648) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -866,8 +869,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 41_255_000 picoseconds. - Weight::from_parts(42_397_000, 10658) + // Minimum execution time: 41_352_000 picoseconds. + Weight::from_parts(42_064_000, 10658) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -876,8 +879,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 8_727_000 picoseconds. - Weight::from_parts(9_104_000, 648) + // Minimum execution time: 8_461_000 picoseconds. + Weight::from_parts(8_788_000, 648) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -887,8 +890,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 43_313_000 picoseconds. - Weight::from_parts(44_570_000, 10658) + // Minimum execution time: 43_054_000 picoseconds. + Weight::from_parts(43_904_000, 10658) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -896,16 +899,19 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. - fn seal_set_storage(n: u32, o: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn seal_set_storage(n: u32, o: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `248 + o * (1 ±0)` - // Estimated: `247 + o * (1 ±0)` - // Minimum execution time: 9_291_000 picoseconds. - Weight::from_parts(10_116_310, 247) - // Standard Error: 56 - .saturating_add(Weight::from_parts(562, 0).saturating_mul(n.into())) - // Standard Error: 56 - .saturating_add(Weight::from_parts(766, 0).saturating_mul(o.into())) + // Estimated: `246 + o * (1 ±0)` + // Minimum execution time: 9_548_000 picoseconds. + Weight::from_parts(10_147_173, 246) + // Standard Error: 67 + .saturating_add(Weight::from_parts(474, 0).saturating_mul(n.into())) + // Standard Error: 67 + .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(o.into())) + // Standard Error: 18_056 + .saturating_add(Weight::from_parts(190_232, 0).saturating_mul(c.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())) @@ -913,50 +919,56 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn clear_storage(_n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn clear_storage(_n: u32, _c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `376` // Estimated: `376` - // Minimum execution time: 11_317_000 picoseconds. - Weight::from_parts(12_313_550, 376) + // Minimum execution time: 11_348_000 picoseconds. + Weight::from_parts(12_653_422, 376) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn seal_get_storage(n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn seal_get_storage(n: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` - // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_259_000 picoseconds. - Weight::from_parts(9_579_511, 247) - // Standard Error: 89 - .saturating_add(Weight::from_parts(1_569, 0).saturating_mul(n.into())) + // Estimated: `246 + n * (1 ±0)` + // Minimum execution time: 8_523_000 picoseconds. + Weight::from_parts(9_259_930, 246) + // Standard Error: 59 + .saturating_add(Weight::from_parts(1_211, 0).saturating_mul(n.into())) + // Standard Error: 16_061 + .saturating_add(Weight::from_parts(122_836, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn contains_storage(_n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn contains_storage(_n: u32, _c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_296_000 picoseconds. - Weight::from_parts(3_670_971, 0) + // Minimum execution time: 3_179_000 picoseconds. + Weight::from_parts(3_575_637, 0) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn take_storage(n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn take_storage(_n: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `376` // Estimated: `376` - // Minimum execution time: 11_660_000 picoseconds. - Weight::from_parts(12_798_428, 376) - // Standard Error: 94 - .saturating_add(Weight::from_parts(571, 0).saturating_mul(n.into())) + // Minimum execution time: 11_620_000 picoseconds. + Weight::from_parts(12_644_961, 376) + // Standard Error: 16_852 + .saturating_add(Weight::from_parts(31_531, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -964,36 +976,36 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_652_000 picoseconds. - Weight::from_parts(1_749_000, 0) + // Minimum execution time: 1_528_000 picoseconds. + Weight::from_parts(1_626_000, 0) } fn set_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_986_000 picoseconds. - Weight::from_parts(2_063_000, 0) + // Minimum execution time: 1_924_000 picoseconds. + Weight::from_parts(2_060_000, 0) } fn get_transient_storage_empty() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_596_000 picoseconds. - Weight::from_parts(1_702_000, 0) + // Minimum execution time: 1_544_000 picoseconds. + Weight::from_parts(1_636_000, 0) } fn get_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_786_000 picoseconds. - Weight::from_parts(1_893_000, 0) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(1_792_000, 0) } fn rollback_transient_storage() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_252_000 picoseconds. - Weight::from_parts(1_339_000, 0) + // Minimum execution time: 1_230_000 picoseconds. + Weight::from_parts(1_351_000, 0) } /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. @@ -1001,48 +1013,48 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_331_000 picoseconds. - Weight::from_parts(2_642_531, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(234, 0).saturating_mul(n.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(356, 0).saturating_mul(o.into())) + // Minimum execution time: 2_293_000 picoseconds. + Weight::from_parts(2_696_431, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(281, 0).saturating_mul(n.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(319, 0).saturating_mul(o.into())) } /// The range of component `n` is `[0, 416]`. - fn seal_clear_transient_storage(n: u32, ) -> Weight { + fn seal_clear_transient_storage(_n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_897_000 picoseconds. - Weight::from_parts(4_214_505, 0) - // Standard Error: 34 - .saturating_add(Weight::from_parts(192, 0).saturating_mul(n.into())) + // Minimum execution time: 3_700_000 picoseconds. + Weight::from_parts(4_092_551, 0) } /// 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_008_000 picoseconds. - Weight::from_parts(2_260_857, 0) - // Standard Error: 19 - .saturating_add(Weight::from_parts(334, 0).saturating_mul(n.into())) + // Minimum execution time: 1_964_000 picoseconds. + Weight::from_parts(2_273_182, 0) + // Standard Error: 20 + .saturating_add(Weight::from_parts(244, 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: 3_387_000 picoseconds. - Weight::from_parts(3_823_784, 0) + // Minimum execution time: 3_154_000 picoseconds. + Weight::from_parts(3_479_990, 0) } /// 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: 4_105_000 picoseconds. - Weight::from_parts(4_590_927, 0) + // Minimum execution time: 3_937_000 picoseconds. + Weight::from_parts(4_306_712, 0) + // Standard Error: 62 + .saturating_add(Weight::from_parts(507, 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`) @@ -1059,16 +1071,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1048576]`. fn seal_call(t: u32, d: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2129` - // Estimated: `5594` - // Minimum execution time: 96_945_000 picoseconds. - Weight::from_parts(82_723_058, 5594) - // Standard Error: 197_185 - .saturating_add(Weight::from_parts(17_112_972, 0).saturating_mul(t.into())) - // Standard Error: 197_185 - .saturating_add(Weight::from_parts(23_554_105, 0).saturating_mul(d.into())) + // Measured: `2006` + // Estimated: `5471` + // Minimum execution time: 98_806_000 picoseconds. + Weight::from_parts(81_854_063, 5471) + // Standard Error: 196_041 + .saturating_add(Weight::from_parts(19_063_085, 0).saturating_mul(t.into())) + // Standard Error: 196_041 + .saturating_add(Weight::from_parts(23_385_511, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(1, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(2, 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()))) @@ -1083,12 +1095,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `436 + d * (212 ±0)` // Estimated: `2056 + d * (2056 ±0)` - // Minimum execution time: 26_713_000 picoseconds. - Weight::from_parts(15_979_369, 2056) - // Standard Error: 53_691 - .saturating_add(Weight::from_parts(11_856_790, 0).saturating_mul(d.into())) + // Minimum execution time: 26_166_000 picoseconds. + Weight::from_parts(15_522_272, 2056) + // Standard Error: 53_032 + .saturating_add(Weight::from_parts(12_019_439, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(326, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(401, 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, 2056).saturating_mul(d.into())) @@ -1103,8 +1115,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1434` // Estimated: `4899` - // Minimum execution time: 35_156_000 picoseconds. - Weight::from_parts(36_008_000, 4899) + // Minimum execution time: 34_614_000 picoseconds. + Weight::from_parts(36_426_000, 4899) .saturating_add(T::DbWeight::get().reads(3_u64)) } /// Storage: `Revive::CodeInfoOf` (r:1 w:1) @@ -1120,20 +1132,20 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 131072]`. fn seal_instantiate(t: u32, d: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1484` - // Estimated: `4921 + d * (31 ±1) + t * (31 ±1)` - // Minimum execution time: 158_623_000 picoseconds. - Weight::from_parts(119_635_514, 4921) - // Standard Error: 509_096 - .saturating_add(Weight::from_parts(17_183_470, 0).saturating_mul(t.into())) - // Standard Error: 509_096 - .saturating_add(Weight::from_parts(27_676_190, 0).saturating_mul(d.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(3_929, 0).saturating_mul(i.into())) + // Measured: `1450` + // Estimated: `4900 + d * (27 ±1) + t * (27 ±1)` + // Minimum execution time: 161_763_000 picoseconds. + Weight::from_parts(115_993_493, 4900) + // Standard Error: 591_582 + .saturating_add(Weight::from_parts(22_154_256, 0).saturating_mul(t.into())) + // Standard Error: 591_582 + .saturating_add(Weight::from_parts(31_214_747, 0).saturating_mul(d.into())) + // Standard Error: 6 + .saturating_add(Weight::from_parts(4_024, 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, 31).saturating_mul(d.into())) - .saturating_add(Weight::from_parts(0, 31).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 27).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 27).saturating_mul(t.into())) } /// Storage: `Revive::AccountInfoOf` (r:1 w:1) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -1152,14 +1164,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `869` // Estimated: `6829` - // Minimum execution time: 375_311_000 picoseconds. - Weight::from_parts(238_984_394, 6829) - // Standard Error: 687_857 - .saturating_add(Weight::from_parts(21_371_046, 0).saturating_mul(t.into())) - // Standard Error: 687_857 - .saturating_add(Weight::from_parts(28_395_391, 0).saturating_mul(d.into())) + // Minimum execution time: 374_535_000 picoseconds. + Weight::from_parts(255_769_803, 6829) + // Standard Error: 683_204 + .saturating_add(Weight::from_parts(17_094_987, 0).saturating_mul(t.into())) + // Standard Error: 683_204 + .saturating_add(Weight::from_parts(24_517_603, 0).saturating_mul(d.into())) // Standard Error: 27 - .saturating_add(Weight::from_parts(8_472, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(8_450, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -1168,125 +1180,125 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_346_000 picoseconds. - Weight::from_parts(9_536_684, 0) + // Minimum execution time: 1_304_000 picoseconds. + Weight::from_parts(10_729_812, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_239, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_265, 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: 799_000 picoseconds. - Weight::from_parts(759_415, 0) + // Minimum execution time: 849_000 picoseconds. + Weight::from_parts(794_629, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(113, 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_377_000 picoseconds. - Weight::from_parts(6_797_388, 0) - // Standard Error: 0 - .saturating_add(Weight::from_parts(3_733, 0).saturating_mul(n.into())) + // Minimum execution time: 1_345_000 picoseconds. + Weight::from_parts(1_397_000, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(3_811, 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_129_000 picoseconds. - Weight::from_parts(14_992_965, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_543, 0).saturating_mul(n.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(14_574_860, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(3_570, 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_873_000 picoseconds. - Weight::from_parts(13_180_808, 0) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(11_809_111, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_398, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_432, 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_854_000 picoseconds. - Weight::from_parts(12_306_060, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_400, 0).saturating_mul(n.into())) + // Minimum execution time: 1_694_000 picoseconds. + Weight::from_parts(11_839_658, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_429, 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: 47_104_000 picoseconds. - Weight::from_parts(80_861_678, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(4_830, 0).saturating_mul(n.into())) + // Minimum execution time: 43_212_000 picoseconds. + Weight::from_parts(100_227_639, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(4_833, 0).saturating_mul(n.into())) } fn ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 46_698_000 picoseconds. - Weight::from_parts(47_673_000, 0) + // Minimum execution time: 46_760_000 picoseconds. + Weight::from_parts(47_635_000, 0) } fn p256_verify() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_791_033_000 picoseconds. - Weight::from_parts(1_801_147_000, 0) + // Minimum execution time: 1_794_747_000 picoseconds. + Weight::from_parts(1_803_009_000, 0) } fn bn128_add() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 14_836_000 picoseconds. - Weight::from_parts(16_004_000, 0) + // Minimum execution time: 15_061_000 picoseconds. + Weight::from_parts(16_030_000, 0) } fn bn128_mul() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 979_455_000 picoseconds. - Weight::from_parts(988_686_000, 0) + // Minimum execution time: 983_121_000 picoseconds. + Weight::from_parts(987_925_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: 938_000 picoseconds. - Weight::from_parts(4_848_308_436, 0) - // Standard Error: 10_255_035 - .saturating_add(Weight::from_parts(5_920_112_189, 0).saturating_mul(n.into())) + // Minimum execution time: 931_000 picoseconds. + Weight::from_parts(4_976_631_682, 0) + // Standard Error: 10_697_026 + .saturating_add(Weight::from_parts(5_989_624_807, 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: 1_070_000 picoseconds. - Weight::from_parts(1_284_385, 0) - // Standard Error: 54 - .saturating_add(Weight::from_parts(28_398, 0).saturating_mul(n.into())) + // Minimum execution time: 994_000 picoseconds. + Weight::from_parts(1_323_648, 0) + // Standard Error: 75 + .saturating_add(Weight::from_parts(28_891, 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_180_000 picoseconds. - Weight::from_parts(13_387_000, 0) + // Minimum execution time: 13_043_000 picoseconds. + Weight::from_parts(13_220_000, 0) } /// Storage: `Revive::CodeInfoOf` (r:2 w:2) /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) @@ -1299,47 +1311,47 @@ 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: `424 + r * (434 ±0)` - // Estimated: `6364 + r * (2162 ±0)` - // Minimum execution time: 14_799_000 picoseconds. - Weight::from_parts(15_922_167, 6364) - // Standard Error: 52_549 - .saturating_add(Weight::from_parts(47_258_332, 0).saturating_mul(r.into())) + // Measured: `420 + r * (401 ±0)` + // Estimated: `6360 + r * (2143 ±0)` + // Minimum execution time: 14_503_000 picoseconds. + Weight::from_parts(15_601_979, 6360) + // Standard Error: 70_755 + .saturating_add(Weight::from_parts(46_884_220, 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, 2162).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2143).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: 550_000 picoseconds. - Weight::from_parts(1_050_932, 0) - // Standard Error: 21 - .saturating_add(Weight::from_parts(15_280, 0).saturating_mul(r.into())) + // Minimum execution time: 640_000 picoseconds. + Weight::from_parts(904_145, 0) + // Standard Error: 15 + .saturating_add(Weight::from_parts(15_305, 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_061_000 picoseconds. - Weight::from_parts(62_740_927, 0) - // Standard Error: 361 - .saturating_add(Weight::from_parts(123_285, 0).saturating_mul(r.into())) + // Minimum execution time: 14_538_000 picoseconds. + Weight::from_parts(61_845_182, 0) + // Standard Error: 949 + .saturating_add(Weight::from_parts(140_478, 0).saturating_mul(r.into())) } /// 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_326_000 picoseconds. - Weight::from_parts(3_151_099, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(74_055, 0).saturating_mul(r.into())) + // Minimum execution time: 3_525_000 picoseconds. + Weight::from_parts(2_922_756, 0) + // Standard Error: 59 + .saturating_add(Weight::from_parts(72_777, 0).saturating_mul(r.into())) } /// Storage: `Revive::PristineCode` (r:1 w:0) /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -1348,10 +1360,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `527 + n * (1 ±0)` // Estimated: `3992 + n * (1 ±0)` - // Minimum execution time: 14_656_000 picoseconds. - Weight::from_parts(14_686_037, 3992) - // Standard Error: 4 - .saturating_add(Weight::from_parts(724, 0).saturating_mul(n.into())) + // Minimum execution time: 14_735_000 picoseconds. + Weight::from_parts(14_539_156, 3992) + // Standard Error: 6 + .saturating_add(Weight::from_parts(844, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -1363,8 +1375,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `382` // Estimated: `6322` - // Minimum execution time: 12_331_000 picoseconds. - Weight::from_parts(12_868_000, 6322) + // Minimum execution time: 12_387_000 picoseconds. + Weight::from_parts(13_088_000, 6322) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1378,8 +1390,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `505` // Estimated: `6866` - // Minimum execution time: 63_102_000 picoseconds. - Weight::from_parts(65_300_000, 6866) + // Minimum execution time: 63_539_000 picoseconds. + Weight::from_parts(64_674_000, 6866) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -1400,10 +1412,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3012 + n * (97 ±0)` // Estimated: `6303 + n * (104 ±0)` - // Minimum execution time: 26_639_000 picoseconds. - Weight::from_parts(56_482_010, 6303) - // Standard Error: 4_704 - .saturating_add(Weight::from_parts(522_203, 0).saturating_mul(n.into())) + // Minimum execution time: 27_202_000 picoseconds. + Weight::from_parts(56_073_594, 6303) + // Standard Error: 4_495 + .saturating_add(Weight::from_parts(520_798, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 104).saturating_mul(n.into())) @@ -1425,10 +1437,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3577 + d * (3 ±0)` // Estimated: `7036 + d * (3 ±0)` - // Minimum execution time: 59_432_000 picoseconds. - Weight::from_parts(61_955_716, 7036) - // Standard Error: 157 - .saturating_add(Weight::from_parts(12_327, 0).saturating_mul(d.into())) + // Minimum execution time: 60_326_000 picoseconds. + Weight::from_parts(62_065_323, 7036) + // Standard Error: 178 + .saturating_add(Weight::from_parts(12_721, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(d.into())) @@ -1452,10 +1464,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1546` // Estimated: `5011` - // Minimum execution time: 44_652_000 picoseconds. - Weight::from_parts(46_489_107, 5011) - // Standard Error: 1_089 - .saturating_add(Weight::from_parts(4_596, 0).saturating_mul(e.into())) + // Minimum execution time: 44_920_000 picoseconds. + Weight::from_parts(47_159_031, 5011) + // Standard Error: 1_344 + .saturating_add(Weight::from_parts(1_022, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -1474,14 +1486,12 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Revive::ReceiptInfoData` (r:0 w:1) /// Proof: `Revive::ReceiptInfoData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `d` is `[0, 16384]`. - fn on_finalize_per_event_data(d: u32, ) -> Weight { + fn on_finalize_per_event_data(_d: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1546` // Estimated: `5011` - // Minimum execution time: 44_400_000 picoseconds. - Weight::from_parts(46_629_995, 5011) - // Standard Error: 6 - .saturating_add(Weight::from_parts(21, 0).saturating_mul(d.into())) + // Minimum execution time: 44_423_000 picoseconds. + Weight::from_parts(47_321_642, 5011) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -1495,8 +1505,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `213` // Estimated: `1698` - // Minimum execution time: 3_325_000 picoseconds. - Weight::from_parts(3_509_000, 1698) + // Minimum execution time: 3_172_000 picoseconds. + Weight::from_parts(3_405_000, 1698) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1506,10 +1516,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `491 + k * (69 ±0)` // Estimated: `481 + k * (70 ±0)` - // Minimum execution time: 14_389_000 picoseconds. - Weight::from_parts(15_127_000, 481) - // Standard Error: 1_039 - .saturating_add(Weight::from_parts(1_209_966, 0).saturating_mul(k.into())) + // Minimum execution time: 14_342_000 picoseconds. + Weight::from_parts(14_928_000, 481) + // Standard Error: 1_398 + .saturating_add(Weight::from_parts(1_214_263, 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)) @@ -1533,10 +1543,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1265 + c * (1 ±0)` // Estimated: `7200 + c * (1 ±0)` - // Minimum execution time: 100_357_000 picoseconds. - Weight::from_parts(143_652_444, 7200) - // Standard Error: 12 - .saturating_add(Weight::from_parts(1_441, 0).saturating_mul(c.into())) + // Minimum execution time: 100_504_000 picoseconds. + Weight::from_parts(148_244_010, 7200) + // Standard Error: 15 + .saturating_add(Weight::from_parts(1_566, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -1554,14 +1564,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: `1205` // Estimated: `7144` - // Minimum execution time: 92_748_000 picoseconds. - Weight::from_parts(97_747_165, 7144) - // Standard Error: 24 - .saturating_add(Weight::from_parts(46, 0).saturating_mul(c.into())) + // Minimum execution time: 92_006_000 picoseconds. + Weight::from_parts(97_368_589, 7144) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1582,10 +1590,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4609` // Estimated: `10549` - // Minimum execution time: 144_014_000 picoseconds. - Weight::from_parts(149_812_683, 10549) - // Standard Error: 724_905 - .saturating_add(Weight::from_parts(1_749_116, 0).saturating_mul(b.into())) + // Minimum execution time: 150_612_000 picoseconds. + Weight::from_parts(156_471_593, 10549) + // Standard Error: 666_004 + .saturating_add(Weight::from_parts(354_506, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1609,12 +1617,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `994` // Estimated: `6924` - // Minimum execution time: 773_080_000 picoseconds. - Weight::from_parts(70_290_148, 6924) - // Standard Error: 37 - .saturating_add(Weight::from_parts(20_365, 0).saturating_mul(c.into())) + // Minimum execution time: 785_616_000 picoseconds. + Weight::from_parts(53_380_306, 6924) + // Standard Error: 38 + .saturating_add(Weight::from_parts(20_886, 0).saturating_mul(c.into())) // Standard Error: 29 - .saturating_add(Weight::from_parts(5_006, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(5_224, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1643,14 +1651,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `994` // Estimated: `6934` - // Minimum execution time: 405_718_000 picoseconds. - Weight::from_parts(270_737_149, 6934) - // Standard Error: 44 - .saturating_add(Weight::from_parts(15_826, 0).saturating_mul(c.into())) - // Standard Error: 34 - .saturating_add(Weight::from_parts(660, 0).saturating_mul(i.into())) - // Standard Error: 2_902_398 - .saturating_add(Weight::from_parts(8_450_702, 0).saturating_mul(d.into())) + // Minimum execution time: 406_081_000 picoseconds. + Weight::from_parts(222_392_381, 6934) + // Standard Error: 42 + .saturating_add(Weight::from_parts(16_556, 0).saturating_mul(c.into())) + // Standard Error: 32 + .saturating_add(Weight::from_parts(891, 0).saturating_mul(i.into())) + // Standard Error: 2_758_958 + .saturating_add(Weight::from_parts(34_243_932, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -1658,8 +1666,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_011_000 picoseconds. - Weight::from_parts(3_274_000, 0) + // Minimum execution time: 3_102_000 picoseconds. + Weight::from_parts(3_291_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:2 w:1) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -1679,11 +1687,11 @@ impl WeightInfo for () { fn instantiate(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1735` - // Estimated: `7665` - // Minimum execution time: 187_515_000 picoseconds. - Weight::from_parts(194_934_584, 7665) - // Standard Error: 11 - .saturating_add(Weight::from_parts(4_151, 0).saturating_mul(i.into())) + // Estimated: `7668` + // Minimum execution time: 189_793_000 picoseconds. + Weight::from_parts(197_777_915, 7668) + // Standard Error: 12 + .saturating_add(Weight::from_parts(4_259, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1703,8 +1711,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1947` // Estimated: `7887` - // Minimum execution time: 104_210_000 picoseconds. - Weight::from_parts(110_220_000, 7887) + // Minimum execution time: 101_360_000 picoseconds. + Weight::from_parts(105_253_000, 7887) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1729,10 +1737,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1947` // Estimated: `7887` - // Minimum execution time: 179_230_000 picoseconds. - Weight::from_parts(189_040_259, 7887) - // Standard Error: 869_758 - .saturating_add(Weight::from_parts(4_172_840, 0).saturating_mul(d.into())) + // Minimum execution time: 179_650_000 picoseconds. + Weight::from_parts(188_389_730, 7887) + // Standard Error: 814_865 + .saturating_add(Weight::from_parts(1_969_669, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1749,10 +1757,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `358` // Estimated: `3823` - // Minimum execution time: 28_233_000 picoseconds. - Weight::from_parts(22_905_261, 3823) - // Standard Error: 12 - .saturating_add(Weight::from_parts(6_274, 0).saturating_mul(c.into())) + // Minimum execution time: 28_012_000 picoseconds. + Weight::from_parts(22_159_986, 3823) + // Standard Error: 13 + .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1769,10 +1777,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `392` // Estimated: `3857` - // Minimum execution time: 59_732_000 picoseconds. - Weight::from_parts(53_002_061, 3857) - // Standard Error: 17 - .saturating_add(Weight::from_parts(14_107, 0).saturating_mul(c.into())) + // Minimum execution time: 62_487_000 picoseconds. + Weight::from_parts(50_869_690, 3857) + // Standard Error: 20 + .saturating_add(Weight::from_parts(14_688, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1786,8 +1794,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `524` // Estimated: `3989` - // Minimum execution time: 53_247_000 picoseconds. - Weight::from_parts(54_239_000, 3989) + // Minimum execution time: 53_252_000 picoseconds. + Weight::from_parts(54_982_000, 3989) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1803,10 +1811,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: `833` - // Estimated: `6773` - // Minimum execution time: 67_638_000 picoseconds. - Weight::from_parts(69_822_000, 6773) + // Measured: `867` + // Estimated: `6807` + // Minimum execution time: 67_932_000 picoseconds. + Weight::from_parts(69_295_000, 6807) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1820,8 +1828,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `623` // Estimated: `4088` - // Minimum execution time: 60_308_000 picoseconds. - Weight::from_parts(61_865_000, 4088) + // Minimum execution time: 61_077_000 picoseconds. + Weight::from_parts(62_440_000, 4088) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1833,8 +1841,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `93` // Estimated: `3558` - // Minimum execution time: 40_748_000 picoseconds. - Weight::from_parts(41_916_000, 3558) + // Minimum execution time: 39_997_000 picoseconds. + Weight::from_parts(40_977_000, 3558) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1848,8 +1856,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `381` // Estimated: `3846` - // Minimum execution time: 19_441_000 picoseconds. - Weight::from_parts(19_775_000, 3846) + // Minimum execution time: 19_305_000 picoseconds. + Weight::from_parts(20_046_000, 3846) .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// The range of component `r` is `[0, 1600]`. @@ -1857,24 +1865,24 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_031_000 picoseconds. - Weight::from_parts(9_266_076, 0) - // Standard Error: 205 - .saturating_add(Weight::from_parts(186_444, 0).saturating_mul(r.into())) + // Minimum execution time: 7_715_000 picoseconds. + Weight::from_parts(9_010_748, 0) + // Standard Error: 236 + .saturating_add(Weight::from_parts(188_696, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 377_000 picoseconds. - Weight::from_parts(403_000, 0) + // Minimum execution time: 378_000 picoseconds. + Weight::from_parts(457_000, 0) } fn seal_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 351_000 picoseconds. - Weight::from_parts(395_000, 0) + // Minimum execution time: 322_000 picoseconds. + Weight::from_parts(394_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1882,8 +1890,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `623` // Estimated: `4088` - // Minimum execution time: 11_287_000 picoseconds. - Weight::from_parts(12_022_000, 4088) + // Minimum execution time: 11_336_000 picoseconds. + Weight::from_parts(11_892_000, 4088) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) @@ -1892,16 +1900,16 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `473` // Estimated: `3938` - // Minimum execution time: 9_933_000 picoseconds. - Weight::from_parts(10_470_000, 3938) + // Minimum execution time: 9_875_000 picoseconds. + Weight::from_parts(10_680_000, 3938) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `436` // Estimated: `0` - // Minimum execution time: 9_614_000 picoseconds. - Weight::from_parts(10_109_000, 0) + // Minimum execution time: 9_685_000 picoseconds. + Weight::from_parts(10_366_000, 0) } /// Storage: `Revive::AccountInfoOf` (r:1 w:0) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -1911,8 +1919,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `545` // Estimated: `4010` - // Minimum execution time: 13_599_000 picoseconds. - Weight::from_parts(14_148_000, 4010) + // Minimum execution time: 13_680_000 picoseconds. + Weight::from_parts(14_225_000, 4010) .saturating_add(RocksDbWeight::get().reads(2_u64)) } fn caller_is_origin() -> Weight { @@ -1920,42 +1928,42 @@ impl WeightInfo for () { // Measured: `0` // Estimated: `0` // Minimum execution time: 1_161_000 picoseconds. - Weight::from_parts(1_257_000, 0) + Weight::from_parts(1_305_000, 0) } fn caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_061_000 picoseconds. - Weight::from_parts(1_188_000, 0) + // Minimum execution time: 1_134_000 picoseconds. + Weight::from_parts(1_266_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 303_000 picoseconds. - Weight::from_parts(349_000, 0) + // Minimum execution time: 329_000 picoseconds. + Weight::from_parts(378_000, 0) } fn weight_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_143_000 picoseconds. - Weight::from_parts(1_283_000, 0) + // Minimum execution time: 1_124_000 picoseconds. + Weight::from_parts(1_206_000, 0) } fn seal_ref_time_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_827_000 picoseconds. - Weight::from_parts(1_929_000, 0) + // Minimum execution time: 1_929_000 picoseconds. + Weight::from_parts(2_086_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `610` + // Measured: `576` // Estimated: `0` - // Minimum execution time: 13_541_000 picoseconds. - Weight::from_parts(14_240_000, 0) + // Minimum execution time: 13_400_000 picoseconds. + Weight::from_parts(13_848_000, 0) } /// Storage: `Revive::OriginalAccount` (r:1 w:0) /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) @@ -1967,8 +1975,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `884` // Estimated: `4349` - // Minimum execution time: 20_559_000 picoseconds. - Weight::from_parts(21_367_000, 4349) + // Minimum execution time: 20_750_000 picoseconds. + Weight::from_parts(21_441_000, 4349) .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `Revive::ImmutableDataOf` (r:1 w:0) @@ -1978,10 +1986,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `304 + n * (1 ±0)` // Estimated: `3769 + n * (1 ±0)` - // Minimum execution time: 5_923_000 picoseconds. - Weight::from_parts(6_753_149, 3769) + // Minimum execution time: 6_166_000 picoseconds. + Weight::from_parts(6_765_990, 3769) // Standard Error: 5 - .saturating_add(Weight::from_parts(523, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(585, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -1992,67 +2000,67 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_101_000 picoseconds. - Weight::from_parts(2_465_888, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(472, 0).saturating_mul(n.into())) + // Minimum execution time: 2_062_000 picoseconds. + Weight::from_parts(2_354_186, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(560, 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: 293_000 picoseconds. - Weight::from_parts(319_000, 0) + // Minimum execution time: 258_000 picoseconds. + Weight::from_parts(304_000, 0) } fn minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_322_000 picoseconds. - Weight::from_parts(1_476_000, 0) + // Minimum execution time: 1_265_000 picoseconds. + Weight::from_parts(1_399_000, 0) } fn seal_return_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 287_000 picoseconds. - Weight::from_parts(319_000, 0) + // Minimum execution time: 266_000 picoseconds. + Weight::from_parts(310_000, 0) } fn seal_call_data_size() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 287_000 picoseconds. + // Minimum execution time: 260_000 picoseconds. Weight::from_parts(330_000, 0) } fn seal_gas_limit() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 293_000 picoseconds. - Weight::from_parts(339_000, 0) + // Minimum execution time: 242_000 picoseconds. + Weight::from_parts(272_000, 0) } fn seal_gas_price() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 986_000 picoseconds. - Weight::from_parts(1_085_000, 0) + // Minimum execution time: 1_084_000 picoseconds. + Weight::from_parts(1_219_000, 0) } fn seal_base_fee() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 974_000 picoseconds. - Weight::from_parts(1_057_000, 0) + // Minimum execution time: 967_000 picoseconds. + Weight::from_parts(1_080_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` // Minimum execution time: 285_000 picoseconds. - Weight::from_parts(330_000, 0) + Weight::from_parts(331_000, 0) } /// Storage: `Session::Validators` (r:1 w:0) /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -2060,8 +2068,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `141` // Estimated: `1626` - // Minimum execution time: 21_803_000 picoseconds. - Weight::from_parts(22_360_000, 1626) + // Minimum execution time: 21_377_000 picoseconds. + Weight::from_parts(21_980_000, 1626) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Revive::BlockHash` (r:1 w:0) @@ -2070,72 +2078,77 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `318` // Estimated: `3783` - // Minimum execution time: 5_906_000 picoseconds. - Weight::from_parts(6_201_000, 3783) + // Minimum execution time: 5_605_000 picoseconds. + Weight::from_parts(6_164_000, 3783) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 307_000 picoseconds. - Weight::from_parts(347_000, 0) + // Minimum execution time: 285_000 picoseconds. + Weight::from_parts(330_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: 453_000 picoseconds. - Weight::from_parts(489_000, 0) + // Minimum execution time: 461_000 picoseconds. + Weight::from_parts(573_695, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(203, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(238, 0).saturating_mul(n.into())) } fn seal_call_data_load() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 289_000 picoseconds. - Weight::from_parts(343_000, 0) + // Minimum execution time: 268_000 picoseconds. + Weight::from_parts(305_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: 280_000 picoseconds. - Weight::from_parts(496_576, 0) + // Minimum execution time: 283_000 picoseconds. + Weight::from_parts(137_385, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(113, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(149, 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: 305_000 picoseconds. - Weight::from_parts(529_465, 0) + // Minimum execution time: 309_000 picoseconds. + Weight::from_parts(546_911, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(200, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(234, 0).saturating_mul(n.into())) } + /// Storage: `Revive::OriginalAccount` (r:2 w:0) + /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 927_000 picoseconds. - Weight::from_parts(1_059_312, 0) - // Standard Error: 6_858 - .saturating_add(Weight::from_parts(13_287, 0).saturating_mul(r.into())) + // Measured: `924` + // Estimated: `6864` + // Minimum execution time: 20_544_000 picoseconds. + Weight::from_parts(21_645_167, 6864) + // Standard Error: 67_218 + .saturating_add(Weight::from_parts(66_332, 0).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) } - /// Storage: `Revive::DeletionQueueCounter` (r:1 w:1) - /// Proof: `Revive::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `Revive::CodeInfoOf` (r:1 w:1) - /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) - /// Storage: `Balances::Holds` (r:1 w:1) + /// Storage: `Balances::Holds` (r:2 w:2) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(463), added: 2938, mode: `Measured`) + /// Storage: `Revive::OriginalAccount` (r:1 w:0) + /// Proof: `Revive::OriginalAccount` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `Measured`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Revive::CodeInfoOf` (r:1 w:1) + /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) + /// Storage: `Revive::DeletionQueueCounter` (r:1 w:1) + /// Proof: `Revive::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Revive::DeletionQueue` (r:0 w:1) /// Proof: `Revive::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) /// Storage: `Revive::PristineCode` (r:0 w:1) @@ -2144,12 +2157,12 @@ impl WeightInfo for () { /// Proof: `Revive::ImmutableDataOf` (`max_values`: None, `max_size`: Some(4118), added: 6593, mode: `Measured`) fn seal_terminate_logic() -> Weight { // Proof Size summary in bytes: - // Measured: `1050` - // Estimated: `6990` - // Minimum execution time: 118_234_000 picoseconds. - Weight::from_parts(122_191_000, 6990) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Measured: `1440` + // Estimated: `7380` + // Minimum execution time: 240_341_000 picoseconds. + Weight::from_parts(248_030_000, 7380) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(9_u64)) } /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 65536]`. @@ -2157,10 +2170,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_221_000 picoseconds. - Weight::from_parts(5_319_000, 0) + // Minimum execution time: 5_424_000 picoseconds. + Weight::from_parts(5_668_000, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(1_209, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_290, 0).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -2168,8 +2181,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 7_453_000 picoseconds. - Weight::from_parts(7_862_000, 648) + // Minimum execution time: 7_428_000 picoseconds. + Weight::from_parts(7_906_000, 648) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -2178,8 +2191,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 41_255_000 picoseconds. - Weight::from_parts(42_397_000, 10658) + // Minimum execution time: 41_352_000 picoseconds. + Weight::from_parts(42_064_000, 10658) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -2188,8 +2201,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `648` // Estimated: `648` - // Minimum execution time: 8_727_000 picoseconds. - Weight::from_parts(9_104_000, 648) + // Minimum execution time: 8_461_000 picoseconds. + Weight::from_parts(8_788_000, 648) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2199,8 +2212,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `10658` // Estimated: `10658` - // Minimum execution time: 43_313_000 picoseconds. - Weight::from_parts(44_570_000, 10658) + // Minimum execution time: 43_054_000 picoseconds. + Weight::from_parts(43_904_000, 10658) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2208,16 +2221,19 @@ impl WeightInfo for () { /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. - fn seal_set_storage(n: u32, o: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn seal_set_storage(n: u32, o: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `248 + o * (1 ±0)` - // Estimated: `247 + o * (1 ±0)` - // Minimum execution time: 9_291_000 picoseconds. - Weight::from_parts(10_116_310, 247) - // Standard Error: 56 - .saturating_add(Weight::from_parts(562, 0).saturating_mul(n.into())) - // Standard Error: 56 - .saturating_add(Weight::from_parts(766, 0).saturating_mul(o.into())) + // Estimated: `246 + o * (1 ±0)` + // Minimum execution time: 9_548_000 picoseconds. + Weight::from_parts(10_147_173, 246) + // Standard Error: 67 + .saturating_add(Weight::from_parts(474, 0).saturating_mul(n.into())) + // Standard Error: 67 + .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(o.into())) + // Standard Error: 18_056 + .saturating_add(Weight::from_parts(190_232, 0).saturating_mul(c.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())) @@ -2225,50 +2241,56 @@ impl WeightInfo for () { /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn clear_storage(_n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn clear_storage(_n: u32, _c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `376` // Estimated: `376` - // Minimum execution time: 11_317_000 picoseconds. - Weight::from_parts(12_313_550, 376) + // Minimum execution time: 11_348_000 picoseconds. + Weight::from_parts(12_653_422, 376) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn seal_get_storage(n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn seal_get_storage(n: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `248 + n * (1 ±0)` - // Estimated: `247 + n * (1 ±0)` - // Minimum execution time: 8_259_000 picoseconds. - Weight::from_parts(9_579_511, 247) - // Standard Error: 89 - .saturating_add(Weight::from_parts(1_569, 0).saturating_mul(n.into())) + // Estimated: `246 + n * (1 ±0)` + // Minimum execution time: 8_523_000 picoseconds. + Weight::from_parts(9_259_930, 246) + // Standard Error: 59 + .saturating_add(Weight::from_parts(1_211, 0).saturating_mul(n.into())) + // Standard Error: 16_061 + .saturating_add(Weight::from_parts(122_836, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn contains_storage(_n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn contains_storage(_n: u32, _c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_296_000 picoseconds. - Weight::from_parts(3_670_971, 0) + // Minimum execution time: 3_179_000 picoseconds. + Weight::from_parts(3_575_637, 0) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 416]`. - fn take_storage(n: u32, ) -> Weight { + /// The range of component `c` is `[0, 1]`. + fn take_storage(_n: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `376` // Estimated: `376` - // Minimum execution time: 11_660_000 picoseconds. - Weight::from_parts(12_798_428, 376) - // Standard Error: 94 - .saturating_add(Weight::from_parts(571, 0).saturating_mul(n.into())) + // Minimum execution time: 11_620_000 picoseconds. + Weight::from_parts(12_644_961, 376) + // Standard Error: 16_852 + .saturating_add(Weight::from_parts(31_531, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2276,36 +2298,36 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_652_000 picoseconds. - Weight::from_parts(1_749_000, 0) + // Minimum execution time: 1_528_000 picoseconds. + Weight::from_parts(1_626_000, 0) } fn set_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_986_000 picoseconds. - Weight::from_parts(2_063_000, 0) + // Minimum execution time: 1_924_000 picoseconds. + Weight::from_parts(2_060_000, 0) } fn get_transient_storage_empty() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_596_000 picoseconds. - Weight::from_parts(1_702_000, 0) + // Minimum execution time: 1_544_000 picoseconds. + Weight::from_parts(1_636_000, 0) } fn get_transient_storage_full() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_786_000 picoseconds. - Weight::from_parts(1_893_000, 0) + // Minimum execution time: 1_681_000 picoseconds. + Weight::from_parts(1_792_000, 0) } fn rollback_transient_storage() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_252_000 picoseconds. - Weight::from_parts(1_339_000, 0) + // Minimum execution time: 1_230_000 picoseconds. + Weight::from_parts(1_351_000, 0) } /// The range of component `n` is `[0, 416]`. /// The range of component `o` is `[0, 416]`. @@ -2313,48 +2335,48 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_331_000 picoseconds. - Weight::from_parts(2_642_531, 0) - // Standard Error: 17 - .saturating_add(Weight::from_parts(234, 0).saturating_mul(n.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(356, 0).saturating_mul(o.into())) + // Minimum execution time: 2_293_000 picoseconds. + Weight::from_parts(2_696_431, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(281, 0).saturating_mul(n.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(319, 0).saturating_mul(o.into())) } /// The range of component `n` is `[0, 416]`. - fn seal_clear_transient_storage(n: u32, ) -> Weight { + fn seal_clear_transient_storage(_n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_897_000 picoseconds. - Weight::from_parts(4_214_505, 0) - // Standard Error: 34 - .saturating_add(Weight::from_parts(192, 0).saturating_mul(n.into())) + // Minimum execution time: 3_700_000 picoseconds. + Weight::from_parts(4_092_551, 0) } /// 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_008_000 picoseconds. - Weight::from_parts(2_260_857, 0) - // Standard Error: 19 - .saturating_add(Weight::from_parts(334, 0).saturating_mul(n.into())) + // Minimum execution time: 1_964_000 picoseconds. + Weight::from_parts(2_273_182, 0) + // Standard Error: 20 + .saturating_add(Weight::from_parts(244, 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: 3_387_000 picoseconds. - Weight::from_parts(3_823_784, 0) + // Minimum execution time: 3_154_000 picoseconds. + Weight::from_parts(3_479_990, 0) } /// 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: 4_105_000 picoseconds. - Weight::from_parts(4_590_927, 0) + // Minimum execution time: 3_937_000 picoseconds. + Weight::from_parts(4_306_712, 0) + // Standard Error: 62 + .saturating_add(Weight::from_parts(507, 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`) @@ -2371,16 +2393,16 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1048576]`. fn seal_call(t: u32, d: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2129` - // Estimated: `5594` - // Minimum execution time: 96_945_000 picoseconds. - Weight::from_parts(82_723_058, 5594) - // Standard Error: 197_185 - .saturating_add(Weight::from_parts(17_112_972, 0).saturating_mul(t.into())) - // Standard Error: 197_185 - .saturating_add(Weight::from_parts(23_554_105, 0).saturating_mul(d.into())) + // Measured: `2006` + // Estimated: `5471` + // Minimum execution time: 98_806_000 picoseconds. + Weight::from_parts(81_854_063, 5471) + // Standard Error: 196_041 + .saturating_add(Weight::from_parts(19_063_085, 0).saturating_mul(t.into())) + // Standard Error: 196_041 + .saturating_add(Weight::from_parts(23_385_511, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(1, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(2, 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()))) @@ -2395,12 +2417,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `436 + d * (212 ±0)` // Estimated: `2056 + d * (2056 ±0)` - // Minimum execution time: 26_713_000 picoseconds. - Weight::from_parts(15_979_369, 2056) - // Standard Error: 53_691 - .saturating_add(Weight::from_parts(11_856_790, 0).saturating_mul(d.into())) + // Minimum execution time: 26_166_000 picoseconds. + Weight::from_parts(15_522_272, 2056) + // Standard Error: 53_032 + .saturating_add(Weight::from_parts(12_019_439, 0).saturating_mul(d.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(326, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(401, 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, 2056).saturating_mul(d.into())) @@ -2415,8 +2437,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1434` // Estimated: `4899` - // Minimum execution time: 35_156_000 picoseconds. - Weight::from_parts(36_008_000, 4899) + // Minimum execution time: 34_614_000 picoseconds. + Weight::from_parts(36_426_000, 4899) .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `Revive::CodeInfoOf` (r:1 w:1) @@ -2432,20 +2454,20 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 131072]`. fn seal_instantiate(t: u32, d: u32, i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1484` - // Estimated: `4921 + d * (31 ±1) + t * (31 ±1)` - // Minimum execution time: 158_623_000 picoseconds. - Weight::from_parts(119_635_514, 4921) - // Standard Error: 509_096 - .saturating_add(Weight::from_parts(17_183_470, 0).saturating_mul(t.into())) - // Standard Error: 509_096 - .saturating_add(Weight::from_parts(27_676_190, 0).saturating_mul(d.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(3_929, 0).saturating_mul(i.into())) + // Measured: `1450` + // Estimated: `4900 + d * (27 ±1) + t * (27 ±1)` + // Minimum execution time: 161_763_000 picoseconds. + Weight::from_parts(115_993_493, 4900) + // Standard Error: 591_582 + .saturating_add(Weight::from_parts(22_154_256, 0).saturating_mul(t.into())) + // Standard Error: 591_582 + .saturating_add(Weight::from_parts(31_214_747, 0).saturating_mul(d.into())) + // Standard Error: 6 + .saturating_add(Weight::from_parts(4_024, 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, 31).saturating_mul(d.into())) - .saturating_add(Weight::from_parts(0, 31).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 27).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 27).saturating_mul(t.into())) } /// Storage: `Revive::AccountInfoOf` (r:1 w:1) /// Proof: `Revive::AccountInfoOf` (`max_values`: None, `max_size`: Some(247), added: 2722, mode: `Measured`) @@ -2464,14 +2486,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `869` // Estimated: `6829` - // Minimum execution time: 375_311_000 picoseconds. - Weight::from_parts(238_984_394, 6829) - // Standard Error: 687_857 - .saturating_add(Weight::from_parts(21_371_046, 0).saturating_mul(t.into())) - // Standard Error: 687_857 - .saturating_add(Weight::from_parts(28_395_391, 0).saturating_mul(d.into())) + // Minimum execution time: 374_535_000 picoseconds. + Weight::from_parts(255_769_803, 6829) + // Standard Error: 683_204 + .saturating_add(Weight::from_parts(17_094_987, 0).saturating_mul(t.into())) + // Standard Error: 683_204 + .saturating_add(Weight::from_parts(24_517_603, 0).saturating_mul(d.into())) // Standard Error: 27 - .saturating_add(Weight::from_parts(8_472, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(8_450, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2480,125 +2502,125 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_346_000 picoseconds. - Weight::from_parts(9_536_684, 0) + // Minimum execution time: 1_304_000 picoseconds. + Weight::from_parts(10_729_812, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_239, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_265, 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: 799_000 picoseconds. - Weight::from_parts(759_415, 0) + // Minimum execution time: 849_000 picoseconds. + Weight::from_parts(794_629, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(113, 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_377_000 picoseconds. - Weight::from_parts(6_797_388, 0) - // Standard Error: 0 - .saturating_add(Weight::from_parts(3_733, 0).saturating_mul(n.into())) + // Minimum execution time: 1_345_000 picoseconds. + Weight::from_parts(1_397_000, 0) + // Standard Error: 10 + .saturating_add(Weight::from_parts(3_811, 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_129_000 picoseconds. - Weight::from_parts(14_992_965, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_543, 0).saturating_mul(n.into())) + // Minimum execution time: 1_163_000 picoseconds. + Weight::from_parts(14_574_860, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(3_570, 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_873_000 picoseconds. - Weight::from_parts(13_180_808, 0) + // Minimum execution time: 1_714_000 picoseconds. + Weight::from_parts(11_809_111, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_398, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_432, 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_854_000 picoseconds. - Weight::from_parts(12_306_060, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_400, 0).saturating_mul(n.into())) + // Minimum execution time: 1_694_000 picoseconds. + Weight::from_parts(11_839_658, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_429, 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: 47_104_000 picoseconds. - Weight::from_parts(80_861_678, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(4_830, 0).saturating_mul(n.into())) + // Minimum execution time: 43_212_000 picoseconds. + Weight::from_parts(100_227_639, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(4_833, 0).saturating_mul(n.into())) } fn ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 46_698_000 picoseconds. - Weight::from_parts(47_673_000, 0) + // Minimum execution time: 46_760_000 picoseconds. + Weight::from_parts(47_635_000, 0) } fn p256_verify() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_791_033_000 picoseconds. - Weight::from_parts(1_801_147_000, 0) + // Minimum execution time: 1_794_747_000 picoseconds. + Weight::from_parts(1_803_009_000, 0) } fn bn128_add() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 14_836_000 picoseconds. - Weight::from_parts(16_004_000, 0) + // Minimum execution time: 15_061_000 picoseconds. + Weight::from_parts(16_030_000, 0) } fn bn128_mul() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 979_455_000 picoseconds. - Weight::from_parts(988_686_000, 0) + // Minimum execution time: 983_121_000 picoseconds. + Weight::from_parts(987_925_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: 938_000 picoseconds. - Weight::from_parts(4_848_308_436, 0) - // Standard Error: 10_255_035 - .saturating_add(Weight::from_parts(5_920_112_189, 0).saturating_mul(n.into())) + // Minimum execution time: 931_000 picoseconds. + Weight::from_parts(4_976_631_682, 0) + // Standard Error: 10_697_026 + .saturating_add(Weight::from_parts(5_989_624_807, 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: 1_070_000 picoseconds. - Weight::from_parts(1_284_385, 0) - // Standard Error: 54 - .saturating_add(Weight::from_parts(28_398, 0).saturating_mul(n.into())) + // Minimum execution time: 994_000 picoseconds. + Weight::from_parts(1_323_648, 0) + // Standard Error: 75 + .saturating_add(Weight::from_parts(28_891, 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_180_000 picoseconds. - Weight::from_parts(13_387_000, 0) + // Minimum execution time: 13_043_000 picoseconds. + Weight::from_parts(13_220_000, 0) } /// Storage: `Revive::CodeInfoOf` (r:2 w:2) /// Proof: `Revive::CodeInfoOf` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `Measured`) @@ -2611,47 +2633,47 @@ 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: `424 + r * (434 ±0)` - // Estimated: `6364 + r * (2162 ±0)` - // Minimum execution time: 14_799_000 picoseconds. - Weight::from_parts(15_922_167, 6364) - // Standard Error: 52_549 - .saturating_add(Weight::from_parts(47_258_332, 0).saturating_mul(r.into())) + // Measured: `420 + r * (401 ±0)` + // Estimated: `6360 + r * (2143 ±0)` + // Minimum execution time: 14_503_000 picoseconds. + Weight::from_parts(15_601_979, 6360) + // Standard Error: 70_755 + .saturating_add(Weight::from_parts(46_884_220, 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, 2162).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2143).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: 550_000 picoseconds. - Weight::from_parts(1_050_932, 0) - // Standard Error: 21 - .saturating_add(Weight::from_parts(15_280, 0).saturating_mul(r.into())) + // Minimum execution time: 640_000 picoseconds. + Weight::from_parts(904_145, 0) + // Standard Error: 15 + .saturating_add(Weight::from_parts(15_305, 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_061_000 picoseconds. - Weight::from_parts(62_740_927, 0) - // Standard Error: 361 - .saturating_add(Weight::from_parts(123_285, 0).saturating_mul(r.into())) + // Minimum execution time: 14_538_000 picoseconds. + Weight::from_parts(61_845_182, 0) + // Standard Error: 949 + .saturating_add(Weight::from_parts(140_478, 0).saturating_mul(r.into())) } /// 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_326_000 picoseconds. - Weight::from_parts(3_151_099, 0) - // Standard Error: 50 - .saturating_add(Weight::from_parts(74_055, 0).saturating_mul(r.into())) + // Minimum execution time: 3_525_000 picoseconds. + Weight::from_parts(2_922_756, 0) + // Standard Error: 59 + .saturating_add(Weight::from_parts(72_777, 0).saturating_mul(r.into())) } /// Storage: `Revive::PristineCode` (r:1 w:0) /// Proof: `Revive::PristineCode` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -2660,10 +2682,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `527 + n * (1 ±0)` // Estimated: `3992 + n * (1 ±0)` - // Minimum execution time: 14_656_000 picoseconds. - Weight::from_parts(14_686_037, 3992) - // Standard Error: 4 - .saturating_add(Weight::from_parts(724, 0).saturating_mul(n.into())) + // Minimum execution time: 14_735_000 picoseconds. + Weight::from_parts(14_539_156, 3992) + // Standard Error: 6 + .saturating_add(Weight::from_parts(844, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -2675,8 +2697,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `382` // Estimated: `6322` - // Minimum execution time: 12_331_000 picoseconds. - Weight::from_parts(12_868_000, 6322) + // Minimum execution time: 12_387_000 picoseconds. + Weight::from_parts(13_088_000, 6322) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2690,8 +2712,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `505` // Estimated: `6866` - // Minimum execution time: 63_102_000 picoseconds. - Weight::from_parts(65_300_000, 6866) + // Minimum execution time: 63_539_000 picoseconds. + Weight::from_parts(64_674_000, 6866) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2712,10 +2734,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3012 + n * (97 ±0)` // Estimated: `6303 + n * (104 ±0)` - // Minimum execution time: 26_639_000 picoseconds. - Weight::from_parts(56_482_010, 6303) - // Standard Error: 4_704 - .saturating_add(Weight::from_parts(522_203, 0).saturating_mul(n.into())) + // Minimum execution time: 27_202_000 picoseconds. + Weight::from_parts(56_073_594, 6303) + // Standard Error: 4_495 + .saturating_add(Weight::from_parts(520_798, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 104).saturating_mul(n.into())) @@ -2737,10 +2759,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3577 + d * (3 ±0)` // Estimated: `7036 + d * (3 ±0)` - // Minimum execution time: 59_432_000 picoseconds. - Weight::from_parts(61_955_716, 7036) - // Standard Error: 157 - .saturating_add(Weight::from_parts(12_327, 0).saturating_mul(d.into())) + // Minimum execution time: 60_326_000 picoseconds. + Weight::from_parts(62_065_323, 7036) + // Standard Error: 178 + .saturating_add(Weight::from_parts(12_721, 0).saturating_mul(d.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(d.into())) @@ -2764,10 +2786,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1546` // Estimated: `5011` - // Minimum execution time: 44_652_000 picoseconds. - Weight::from_parts(46_489_107, 5011) - // Standard Error: 1_089 - .saturating_add(Weight::from_parts(4_596, 0).saturating_mul(e.into())) + // Minimum execution time: 44_920_000 picoseconds. + Weight::from_parts(47_159_031, 5011) + // Standard Error: 1_344 + .saturating_add(Weight::from_parts(1_022, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -2786,14 +2808,12 @@ impl WeightInfo for () { /// Storage: `Revive::ReceiptInfoData` (r:0 w:1) /// Proof: `Revive::ReceiptInfoData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `d` is `[0, 16384]`. - fn on_finalize_per_event_data(d: u32, ) -> Weight { + fn on_finalize_per_event_data(_d: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1546` // Estimated: `5011` - // Minimum execution time: 44_400_000 picoseconds. - Weight::from_parts(46_629_995, 5011) - // Standard Error: 6 - .saturating_add(Weight::from_parts(21, 0).saturating_mul(d.into())) + // Minimum execution time: 44_423_000 picoseconds. + Weight::from_parts(47_321_642, 5011) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } diff --git a/substrate/frame/support/src/storage/child.rs b/substrate/frame/support/src/storage/child.rs index 7109e9213b0f6..0fb0055db2e3d 100644 --- a/substrate/frame/support/src/storage/child.rs +++ b/substrate/frame/support/src/storage/child.rs @@ -212,6 +212,17 @@ pub fn get_raw(child_info: &ChildInfo, key: &[u8]) -> Option> { } } +/// Get a Vec of bytes from storage, tracking whether it was a cold load. +/// +/// Similar to [`get_raw`], but returns a [`sp_io::StateLoad`] that indicates whether the value +/// was loaded from the database backend (cold load) or from the storage overlay (hot load). +pub fn get_raw_with_status(child_info: &ChildInfo, key: &[u8]) -> sp_io::StateLoad>> { + match child_info.child_type() { + ChildType::ParentKeyId => + sp_io::default_child_storage::get_with_status(child_info.storage_key(), key), + } +} + /// Put a raw byte slice into storage. pub fn put_raw(child_info: &ChildInfo, key: &[u8], value: &[u8]) { match child_info.child_type() { diff --git a/substrate/primitives/externalities/src/lib.rs b/substrate/primitives/externalities/src/lib.rs index a543b6758ee4f..d1385af0fd1fa 100644 --- a/substrate/primitives/externalities/src/lib.rs +++ b/substrate/primitives/externalities/src/lib.rs @@ -38,6 +38,17 @@ pub use scope_limited::{set_and_run_with_externalities, with_externalities}; mod extensions; mod scope_limited; +/// Result of a storage load operation that tracks whether the value was loaded from +/// the storage overlay (hot/cached) or from the database backend (cold). +#[derive(Debug, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +pub struct StateLoad { + /// The returned data + pub data: T, + /// `true` if the value was loaded from the database backend (cold load), + /// `false` if it was loaded from the storage overlay (hot/cached load) + pub is_cold: bool, +} + /// Externalities error. #[derive(Debug)] pub enum Error { @@ -85,6 +96,12 @@ pub trait Externalities: ExtensionStore { /// Read runtime storage. fn storage(&mut self, key: &[u8]) -> Option>; + /// Read runtime storage, tracking whether it was a cold load. + /// + /// Returns a `StateLoad` containing the value and whether it was loaded + /// from the database backend (cold) or storage overlay (hot). + fn storage_with_status(&mut self, key: &[u8]) -> StateLoad>>; + /// Get storage value hash. /// /// This may be optimized for large values. @@ -102,6 +119,16 @@ pub trait Externalities: ExtensionStore { /// Returns an `Option` that holds the SCALE encoded hash. fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option>; + /// Read child runtime storage, tracking whether it was a cold load. + /// + /// Returns a `StateLoad` containing the value and whether it was loaded + /// from the database backend (cold) or storage overlay (hot). + fn child_storage_with_status( + &mut self, + child_info: &ChildInfo, + key: &[u8], + ) -> StateLoad>>; + /// Set storage entry `key` of current contract being called (effective immediately). fn set_storage(&mut self, key: Vec, value: Vec) { self.place_storage(key, Some(value)); diff --git a/substrate/primitives/io/src/lib.rs b/substrate/primitives/io/src/lib.rs index 3c42c2672f609..a94955ef6d395 100644 --- a/substrate/primitives/io/src/lib.rs +++ b/substrate/primitives/io/src/lib.rs @@ -133,7 +133,7 @@ use secp256k1::{ #[cfg(not(substrate_runtime))] use sp_externalities::{Externalities, ExternalitiesExt}; -pub use sp_externalities::MultiRemovalResults; +pub use sp_externalities::{MultiRemovalResults, StateLoad}; #[cfg(all(not(feature = "disable_allocator"), substrate_runtime, target_family = "wasm"))] mod global_alloc_wasm; @@ -194,6 +194,18 @@ pub trait Storage { self.storage(key).map(|s| bytes::Bytes::from(s.to_vec())) } + /// Returns the data for `key` in the storage, tracking whether it was a cold load. + /// + /// Similar to `get`, but returns a `StateLoad` that indicates whether the value was loaded + /// from the database backend (cold load) or from the storage overlay (hot load). + fn get_with_status( + &mut self, + key: PassFatPointerAndRead<&[u8]>, + ) -> AllocateAndReturnByCodec>> { + let StateLoad { data, is_cold } = self.storage_with_status(key); + StateLoad { data: data.map(|s| bytes::Bytes::from(s.to_vec())), is_cold } + } + /// Get `key` from storage, placing the value into `value_out` and return the number of /// bytes that the entry in storage has beyond the offset or `None` if the storage entry /// doesn't exist at all. @@ -421,6 +433,24 @@ pub trait DefaultChildStorage { self.child_storage(&child_info, key).map(|s| s.to_vec()) } + /// Get a default child storage value for a given key, tracking whether it was a cold load. + /// + /// Similar to `get`, but returns a `StateLoad` that indicates whether the value was loaded + /// from the database backend (cold load) or from the storage overlay (hot load). + /// + /// Parameter `storage_key` is the unprefixed location of the root of the child trie in the + /// parent trie. Result contains `None` if the value for `key` in the child storage can not be + /// found. + fn get_with_status( + &mut self, + storage_key: PassFatPointerAndRead<&[u8]>, + key: PassFatPointerAndRead<&[u8]>, + ) -> AllocateAndReturnByCodec>>> { + let child_info = ChildInfo::new_default(storage_key); + let StateLoad { data, is_cold } = self.child_storage_with_status(&child_info, key); + StateLoad { data: data.map(|s| s.to_vec()), is_cold } + } + /// Allocation efficient variant of `get`. /// /// Get `key` from child storage, placing the value into `value_out` and return the number @@ -2057,6 +2087,89 @@ mod tests { }); } + #[test] + fn storage_with_status_tracking_works() { + let mut t = BasicExternalities::new(Storage { + top: map![b"existing".to_vec() => b"value".to_vec()], + children_default: map![], + }); + + t.execute_with(|| { + // Note: BasicExternalities doesn't have a real backend, so all reads + // are considered "cold" as there's no hot/cold distinction. + // This test mainly verifies the API works correctly. + + // Read existing value + let result = storage::get_with_status(b"existing"); + assert_eq!(result.data, Some(b"value".to_vec().into())); + assert_eq!(result.is_cold, true); + + // Write to overlay + storage::set(b"new_key", b"new_value"); + + // Read the newly written value + let result = storage::get_with_status(b"new_key"); + assert_eq!(result.data, Some(b"new_value".to_vec().into())); + // BasicExternalities treats all reads as cold + assert_eq!(result.is_cold, true); + + // Read non-existent key + let result = storage::get_with_status(b"non_existent"); + assert_eq!(result.data, None); + assert_eq!(result.is_cold, true); + + // Overwrite existing key + storage::set(b"existing", b"updated"); + let result = storage::get_with_status(b"existing"); + assert_eq!(result.data, Some(b"updated".to_vec().into())); + assert_eq!(result.is_cold, true); + }); + } + + #[test] + fn child_storage_with_status_tracking_works() { + use sp_core::storage::ChildInfo; + + let child_info = ChildInfo::new_default(b"child_storage_key"); + let mut t = BasicExternalities::new(Storage { + top: map![], + children_default: map![ + child_info.storage_key().to_vec() => sp_core::storage::StorageChild { + data: map![b"existing_child".to_vec() => b"child_value".to_vec()], + child_info: child_info.clone(), + } + ], + }); + + t.execute_with(|| { + // Note: BasicExternalities doesn't have a real backend, so all reads + // are considered "cold" as there's no hot/cold distinction. + // This test mainly verifies the API works correctly. + + // Read existing child value + let result = + default_child_storage::get_with_status(b"child_storage_key", b"existing_child"); + assert_eq!(result.data, Some(b"child_value".to_vec())); + assert_eq!(result.is_cold, true); + + // Write to child storage + default_child_storage::set(b"child_storage_key", b"new_child_key", b"new_child_value"); + + // Read the newly written value + let result = + default_child_storage::get_with_status(b"child_storage_key", b"new_child_key"); + assert_eq!(result.data, Some(b"new_child_value".to_vec())); + // BasicExternalities treats all reads as cold + assert_eq!(result.is_cold, true); + + // Read non-existent child key + let result = + default_child_storage::get_with_status(b"child_storage_key", b"non_existent_child"); + assert_eq!(result.data, None); + assert_eq!(result.is_cold, true); + }); + } + #[test] fn read_storage_works() { let value = b"\x0b\0\0\0Hello world".to_vec(); diff --git a/substrate/primitives/state-machine/src/backend.rs b/substrate/primitives/state-machine/src/backend.rs index 734fc60251dac..085f00cf8c68d 100644 --- a/substrate/primitives/state-machine/src/backend.rs +++ b/substrate/primitives/state-machine/src/backend.rs @@ -30,6 +30,7 @@ use hash_db::Hasher; use sp_core::storage::{ChildInfo, StateVersion, TrackedStorageKey}; #[cfg(feature = "std")] use sp_core::traits::RuntimeCode; +use sp_externalities::StateLoad; use sp_trie::{MerkleValue, PrefixedMemoryDB, RandomState}; /// A struct containing arguments for iterating over the storage. @@ -192,6 +193,15 @@ pub trait Backend: core::fmt::Debug { /// Get keyed storage or None if there is nothing associated. fn storage(&self, key: &[u8]) -> Result, Self::Error>; + /// Get keyed storage with status tracking (cold/warm) or None if there is nothing associated. + /// + /// Returns `is_cold: true` if the value was read from the database (cache miss), + /// `is_cold: false` if the value was read from the cache (cache hit). + fn storage_with_status( + &self, + key: &[u8], + ) -> Result>, Self::Error>; + /// Get keyed storage value hash or None if there is nothing associated. fn storage_hash(&self, key: &[u8]) -> Result, Self::Error>; @@ -212,6 +222,17 @@ pub trait Backend: core::fmt::Debug { key: &[u8], ) -> Result, Self::Error>; + /// Get child keyed storage with status tracking (cold/warm) or None if there is nothing + /// associated. + /// + /// Returns `is_cold: true` if the value was read from the database (cache miss), + /// `is_cold: false` if the value was read from the cache (cache hit). + fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>, Self::Error>; + /// Get child keyed storage value hash or None if there is nothing associated. fn child_storage_hash( &self, diff --git a/substrate/primitives/state-machine/src/basic.rs b/substrate/primitives/state-machine/src/basic.rs index 7edf9b6f96823..159f938416f25 100644 --- a/substrate/primitives/state-machine/src/basic.rs +++ b/substrate/primitives/state-machine/src/basic.rs @@ -33,7 +33,7 @@ use sp_core::{ traits::Externalities, Blake2Hasher, }; -use sp_externalities::{Extension, Extensions, MultiRemovalResults}; +use sp_externalities::{Extension, Extensions, MultiRemovalResults, StateLoad}; use sp_trie::{empty_child_trie_root, LayoutV0, LayoutV1, TrieConfiguration}; /// Simple Map-based Externalities impl. @@ -184,6 +184,11 @@ impl Externalities for BasicExternalities { self.overlay.storage(key).and_then(|v| v.map(|v| v.to_vec())) } + fn storage_with_status(&mut self, key: &[u8]) -> StateLoad> { + let data = self.overlay.storage(key).and_then(|v| v.map(|v| v.to_vec())); + StateLoad { data, is_cold: true } + } + fn storage_hash(&mut self, key: &[u8]) -> Option> { self.storage(key).map(|v| Blake2Hasher::hash(&v).encode()) } @@ -192,6 +197,15 @@ impl Externalities for BasicExternalities { self.overlay.child_storage(child_info, key).and_then(|v| v.map(|v| v.to_vec())) } + fn child_storage_with_status( + &mut self, + child_info: &ChildInfo, + key: &[u8], + ) -> StateLoad> { + let data = self.overlay.child_storage(child_info, key).and_then(|v| v.map(|v| v.to_vec())); + StateLoad { data, is_cold: true } + } + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { self.child_storage(child_info, key).map(|v| Blake2Hasher::hash(&v).encode()) } diff --git a/substrate/primitives/state-machine/src/ext.rs b/substrate/primitives/state-machine/src/ext.rs index 62f76124a9564..dae9193f08d60 100644 --- a/substrate/primitives/state-machine/src/ext.rs +++ b/substrate/primitives/state-machine/src/ext.rs @@ -31,7 +31,7 @@ use sp_core::storage::{ }; #[cfg(feature = "std")] use sp_externalities::TransactionType; -use sp_externalities::{Extension, ExtensionStore, Externalities, MultiRemovalResults}; +use sp_externalities::{Extension, ExtensionStore, Externalities, MultiRemovalResults, StateLoad}; use crate::{trace, warn}; use alloc::{boxed::Box, vec::Vec}; @@ -160,6 +160,33 @@ where result } + fn storage_with_status(&mut self, key: &[u8]) -> StateLoad> { + let _guard = guard(); + let result = self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).map_or_else( + || self.backend.storage_with_status(key).expect(EXT_NOT_ALLOWED_TO_FAIL), + |data| StateLoad { is_cold: false, data }, + ); + + // NOTE: be careful about touching the key names – used outside substrate! + trace!( + target: "state", + method = "GetWithStatus", + ext_id = %HexDisplay::from(&self.id.to_le_bytes()), + key = %HexDisplay::from(&key), + is_cold = %result.is_cold, + result = ?result.data.as_ref().map(HexDisplay::from), + result_encoded = %HexDisplay::from( + &result + .data.as_ref() + .map(|v| EncodeOpaqueValue(v.clone())) + .encode() + ), + ); + + log::debug!(target: "runtim::revive", "storage_with_status key={:?} is_cold={}", sp_core::hexdisplay::HexDisplay::from(&key), result.is_cold); + result + } + fn storage_hash(&mut self, key: &[u8]) -> Option> { let _guard = guard(); let result = self @@ -200,6 +227,39 @@ where result } + fn child_storage_with_status( + &mut self, + child_info: &ChildInfo, + key: &[u8], + ) -> StateLoad> { + let _guard = guard(); + + let result = self + .overlay + .child_storage(child_info, key) + .map(|x| x.map(|x| x.to_vec())) + .map_or_else( + || { + self.backend + .child_storage_with_status(child_info, key) + .expect(EXT_NOT_ALLOWED_TO_FAIL) + }, + |data| StateLoad { is_cold: false, data }, + ); + + trace!( + target: "state", + method = "ChildGetWithStatus", + ext_id = %HexDisplay::from(&self.id.to_le_bytes()), + child_info = %HexDisplay::from(&child_info.storage_key()), + key = %HexDisplay::from(&key), + is_cold = %result.is_cold, + result = ?result.data.as_ref().map(HexDisplay::from), + ); + + result + } + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { let _guard = guard(); let result = self diff --git a/substrate/primitives/state-machine/src/read_only.rs b/substrate/primitives/state-machine/src/read_only.rs index e5da2fde1fd55..557126af443e6 100644 --- a/substrate/primitives/state-machine/src/read_only.rs +++ b/substrate/primitives/state-machine/src/read_only.rs @@ -29,7 +29,7 @@ use sp_core::{ storage::{ChildInfo, StateVersion, TrackedStorageKey}, traits::Externalities, }; -use sp_externalities::MultiRemovalResults; +use sp_externalities::{MultiRemovalResults, StateLoad}; /// Trait for inspecting state in any backend. /// @@ -95,6 +95,14 @@ where .expect("Backed failed for storage in ReadOnlyExternalities") } + fn storage_with_status(&mut self, key: &[u8]) -> StateLoad> { + let data = self + .backend + .storage(key) + .expect("Backed failed for storage_with_status in ReadOnlyExternalities"); + StateLoad { data, is_cold: true } + } + fn storage_hash(&mut self, key: &[u8]) -> Option> { self.backend .storage_hash(key) @@ -108,6 +116,18 @@ where .expect("Backed failed for child_storage in ReadOnlyExternalities") } + fn child_storage_with_status( + &mut self, + child_info: &ChildInfo, + key: &[u8], + ) -> StateLoad> { + let data = self + .backend + .child_storage(child_info, key) + .expect("Backed failed for child_storage_with_status in ReadOnlyExternalities"); + StateLoad { data, is_cold: true } + } + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { self.backend .child_storage_hash(child_info, key) diff --git a/substrate/primitives/state-machine/src/trie_backend.rs b/substrate/primitives/state-machine/src/trie_backend.rs index f7bfa72c575aa..5107204899378 100644 --- a/substrate/primitives/state-machine/src/trie_backend.rs +++ b/substrate/primitives/state-machine/src/trie_backend.rs @@ -30,6 +30,7 @@ use codec::Codec; use hash_db::HashDB; use hash_db::Hasher; use sp_core::storage::{ChildInfo, StateVersion}; +use sp_externalities::StateLoad; #[cfg(feature = "std")] use sp_trie::{ cache::{LocalTrieCache, TrieCache}, @@ -430,6 +431,13 @@ where self.essence.storage(key) } + fn storage_with_status( + &self, + key: &[u8], + ) -> Result>, Self::Error> { + self.essence.storage_with_status(key) + } + fn child_storage_hash( &self, child_info: &ChildInfo, @@ -446,6 +454,14 @@ where self.essence.child_storage(child_info, key) } + fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.essence.child_storage_with_status(child_info, key) + } + fn closest_merkle_value(&self, key: &[u8]) -> Result>, Self::Error> { self.essence.closest_merkle_value(key) } diff --git a/substrate/primitives/state-machine/src/trie_backend_essence.rs b/substrate/primitives/state-machine/src/trie_backend_essence.rs index 4ecfca0c85ad0..ec9731a0d1732 100644 --- a/substrate/primitives/state-machine/src/trie_backend_essence.rs +++ b/substrate/primitives/state-machine/src/trie_backend_essence.rs @@ -32,10 +32,12 @@ use hash_db::{self, AsHashDB, HashDB, HashDBRef, Hasher, Prefix}; #[cfg(feature = "std")] use parking_lot::RwLock; use sp_core::storage::{ChildInfo, ChildType, StateVersion}; +use sp_externalities::StateLoad; use sp_trie::{ child_delta_trie_root, delta_trie_root, empty_child_trie_root, read_child_trie_first_descendant_value, read_child_trie_hash, read_child_trie_value, - read_trie_first_descendant_value, read_trie_value, + read_child_trie_value_with_status, read_trie_first_descendant_value, read_trie_value, + read_trie_value_with_status, trie_types::{TrieDBBuilder, TrieError}, DBValue, KeySpacedDB, MerkleValue, NodeCodec, PrefixedMemoryDB, RandomState, Trie, TrieCache, TrieDBRawIterator, TrieRecorder, TrieRecorderProvider, @@ -501,6 +503,19 @@ where }) } + /// Get the value of storage at given key with cache status tracking. + /// + /// Returns `is_cold: true` if the value was not in the cache (cache miss), + /// `is_cold: false` if the value was in the cache (cache hit). + pub fn storage_with_status(&self, key: &[u8]) -> Result>> { + let map_e = |e| format!("Trie lookup error: {}", e); + + self.with_recorder_and_cache(None, |recorder, cache| { + read_trie_value_with_status::, _>(self, &self.root, key, recorder, cache) + .map_err(map_e) + }) + } + /// Returns the hash value pub fn child_storage_hash(&self, child_info: &ChildInfo, key: &[u8]) -> Result> { let child_root = match self.child_root(child_info)? { @@ -549,6 +564,35 @@ where }) } + /// Get the value of child storage at given key with cache status tracking. + /// + /// Returns `is_cold: true` if the value was not in the cache (cache miss), + /// `is_cold: false` if the value was in the cache (cache hit). + pub fn child_storage_with_status( + &self, + child_info: &ChildInfo, + key: &[u8], + ) -> Result>> { + let child_root = match self.child_root(child_info)? { + Some(root) => root, + None => return Ok(StateLoad { data: None, is_cold: true }), + }; + + let map_e = |e| format!("Trie lookup error: {}", e); + + self.with_recorder_and_cache(Some(child_root), |recorder, cache| { + read_child_trie_value_with_status::, _>( + child_info.keyspace(), + self, + &child_root, + key, + recorder, + cache, + ) + .map_err(map_e) + }) + } + /// Get the closest merkle value at given key. pub fn closest_merkle_value(&self, key: &[u8]) -> Result>> { let map_e = |e| format!("Trie lookup error: {}", e); diff --git a/substrate/primitives/trie/Cargo.toml b/substrate/primitives/trie/Cargo.toml index 1d34f0fce0329..b891eb6fe174d 100644 --- a/substrate/primitives/trie/Cargo.toml +++ b/substrate/primitives/trie/Cargo.toml @@ -23,6 +23,7 @@ harness = false [dependencies] ahash = { optional = true, workspace = true } codec = { workspace = true } +log = { workspace = true } foldhash = { workspace = true } hash-db = { workspace = true } hashbrown = { workspace = true } diff --git a/substrate/primitives/trie/src/lib.rs b/substrate/primitives/trie/src/lib.rs index 46d4f4cde41c4..65470b00a0b48 100644 --- a/substrate/primitives/trie/src/lib.rs +++ b/substrate/primitives/trie/src/lib.rs @@ -56,6 +56,7 @@ use hash_db::{Hasher, Prefix}; pub use memory_db::{prefixed_key, HashKey, KeyFunction, PrefixedKey}; /// The Substrate format implementation of `NodeCodec`. pub use node_codec::NodeCodec; +use sp_externalities::StateLoad; pub use storage_proof::{CompactProof, StorageProof, StorageProofError}; /// Trie codec reexport, mainly child trie support /// for trie compact proof. @@ -367,6 +368,34 @@ pub fn read_trie_value, +>( + db: &DB, + root: &TrieHash, + key: &[u8], + mut recorder: Option<&mut dyn TrieRecorder>>, + cache: Option<&mut dyn TrieCache>, +) -> Result>>, Box>> { + let is_cold = recorder + .as_mut() + .and_then(|r| Some(r.trie_nodes_recorded_for_key(key).is_none())) + .unwrap_or(true); + + let data = TrieDBBuilder::::new(db, root) + .with_optional_cache(cache) + .with_optional_recorder(recorder) + .build() + .get(key)?; + + Ok(StateLoad { data, is_cold }) +} + /// Read the [`trie_db::MerkleValue`] of the node that is the closest descendant for /// the provided key. pub fn read_trie_first_descendant_value( @@ -468,6 +497,38 @@ where .map(|x| x.map(|val| val.to_vec())) } +/// Read a value from a child trie with cache status tracking. +/// +/// Returns a `StateLoad` containing the value and whether it was loaded +/// from the database backend (cold) or cache (hot). +pub fn read_child_trie_value_with_status( + keyspace: &[u8], + db: &DB, + root: &TrieHash, + key: &[u8], + mut recorder: Option<&mut dyn TrieRecorder>>, + cache: Option<&mut dyn TrieCache>, +) -> Result>>, Box>> +where + DB: hash_db::HashDBRef, +{ + log::debug!(target: "revive::runtime", "has_recorder: {}", recorder.is_some()); + let is_cold = recorder + .as_mut() + .and_then(|r| Some(r.trie_nodes_recorded_for_key(key).is_none())) + .unwrap_or(true); + + let db = KeySpacedDB::new(db, keyspace); + let data = TrieDBBuilder::::new(&db, &root) + .with_optional_recorder(recorder) + .with_optional_cache(cache) + .build() + .get(key)? + .map(|val| val.to_vec()); + + Ok(StateLoad { data, is_cold }) +} + /// Read a hash from the child trie. pub fn read_child_trie_hash( keyspace: &[u8],