diff --git a/Cargo.lock b/Cargo.lock index 6201d776e35b4..0a9e201290a50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,7 @@ dependencies = [ "ark-ff", "ark-std", "tracing", - "tracing-subscriber 0.2.25", + "tracing-subscriber", ] [[package]] @@ -2945,22 +2945,21 @@ name = "frame-remote-externalities" version = "0.10.0-dev" dependencies = [ "async-recursion", - "frame-support", "futures", "indicatif", "jsonrpsee", "log", - "pallet-elections-phragmen", "parity-scale-codec", "serde", "sp-core", "sp-io", "sp-runtime", + "sp-state-machine", + "sp-tracing", "spinners", "substrate-rpc-client", "tokio", "tokio-retry", - "tracing-subscriber 0.3.17", ] [[package]] @@ -5102,15 +5101,6 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - [[package]] name = "matches" version = "0.1.10" @@ -5908,16 +5898,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num" version = "0.4.0" @@ -6096,12 +6076,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "p256" version = "0.11.1" @@ -9772,7 +9746,7 @@ dependencies = [ "substrate-test-runtime", "tempfile", "tracing", - "tracing-subscriber 0.2.25", + "tracing-subscriber", "wat", ] @@ -10470,7 +10444,7 @@ dependencies = [ "thiserror", "tracing", "tracing-log", - "tracing-subscriber 0.2.25", + "tracing-subscriber", ] [[package]] @@ -11867,7 +11841,7 @@ dependencies = [ "sp-std", "tracing", "tracing-core", - "tracing-subscriber 0.2.25", + "tracing-subscriber", ] [[package]] @@ -12961,7 +12935,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers 0.0.1", + "matchers", "parking_lot 0.11.2", "regex", "serde", @@ -12975,24 +12949,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers 0.1.0", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - [[package]] name = "trie-bench" version = "0.37.0" diff --git a/bin/node-template/node/src/cli.rs b/bin/node-template/node/src/cli.rs index 15ceaa06230d1..98037eb886a8e 100644 --- a/bin/node-template/node/src/cli.rs +++ b/bin/node-template/node/src/cli.rs @@ -41,12 +41,9 @@ pub enum Subcommand { #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), - /// Try some command against runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Try some command against runtime state. Note: `try-runtime` feature must be enabled. - #[cfg(not(feature = "try-runtime"))] + /// Try-runtime has migrated to a standalone CLI + /// (). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after Janurary 2024. TryRuntime, /// Db meta columns information. diff --git a/bin/node-template/node/src/command.rs b/bin/node-template/node/src/command.rs index 8fc697b5f9c14..a25157693cd43 100644 --- a/bin/node-template/node/src/command.rs +++ b/bin/node-template/node/src/command.rs @@ -10,9 +10,6 @@ use sc_cli::SubstrateCli; use sc_service::PartialComponents; use sp_keyring::Sr25519Keyring; -#[cfg(feature = "try-runtime")] -use try_runtime_cli::block_building_info::timestamp_with_aura_info; - impl SubstrateCli for Cli { fn impl_name() -> String { "Substrate Node".into() @@ -172,28 +169,7 @@ pub fn run() -> sc_cli::Result<()> { }) }, #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - use crate::service::ExecutorDispatch; - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.tokio_handle.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - let info_provider = timestamp_with_aura_info(6000); - - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) - }) - }, + Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()), #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ You can enable it with `--features try-runtime`." diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 36be0b1a938bd..7303f5cd6dd6d 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -49,7 +49,7 @@ pub fn new_partial( FullClient, FullBackend, FullSelectChain, - sc_consensus::DefaultImportQueue, + sc_consensus::DefaultImportQueue, sc_transaction_pool::FullPool, ( sc_consensus_grandpa::GrandpaBlockImport< diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index 5ee538d18d6a8..b877aa7350228 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -112,13 +112,7 @@ fn extrinsic_set_time(now: u64) -> OpaqueExtrinsic { .into() } -fn import_block( - mut client: &FullClient, - built: BuiltBlock< - node_primitives::Block, - >::StateBackend, - >, -) { +fn import_block(mut client: &FullClient, built: BuiltBlock) { let mut params = BlockImportParams::new(BlockOrigin::File, built.block.header); params.state_action = StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(built.storage_changes)); diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index 35b949831141d..4e0d6303870cb 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -57,12 +57,9 @@ pub enum Subcommand { #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), - /// Try some command against runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Try some command against runtime state. Note: `try-runtime` feature must be enabled. - #[cfg(not(feature = "try-runtime"))] + /// Try-runtime has migrated to a standalone CLI + /// (). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after Janurary 2024. TryRuntime, /// Key management cli utilities diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index b138b397eff6f..8fb413dba1778 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -32,12 +32,6 @@ use sp_keyring::Sr25519Keyring; use std::sync::Arc; -#[cfg(feature = "try-runtime")] -use { - kitchensink_runtime::constants::time::SLOT_DURATION, - try_runtime_cli::block_building_info::substrate_info, -}; - impl SubstrateCli for Cli { fn impl_name() -> String { "Substrate Node".into() @@ -227,28 +221,7 @@ pub fn run() -> Result<()> { }) }, #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.tokio_handle.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - - let info_provider = substrate_info(SLOT_DURATION); - - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) - }) - }, + Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()), #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ You can enable it with `--features try-runtime`." diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index e857f96f0056a..ecca5c60db515 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -140,7 +140,7 @@ pub fn new_partial( FullClient, FullBackend, FullSelectChain, - sc_consensus::DefaultImportQueue, + sc_consensus::DefaultImportQueue, sc_transaction_pool::FullPool, ( impl Fn( diff --git a/bin/node/testing/src/client.rs b/bin/node/testing/src/client.rs index 01495525a9c8c..c55867360bd62 100644 --- a/bin/node/testing/src/client.rs +++ b/bin/node/testing/src/client.rs @@ -36,9 +36,6 @@ pub type Client = client::Client< kitchensink_runtime::RuntimeApi, >; -/// Transaction for kitchensink-runtime. -pub type Transaction = sc_client_api::backend::TransactionFor; - /// Genesis configuration parameters for `TestClient`. #[derive(Default)] pub struct GenesisParameters; diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 465e1988478d7..2d8fdef77cdb9 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -36,17 +36,11 @@ use sp_storage::{ChildInfo, StorageData, StorageKey}; use crate::{blockchain::Backend as BlockchainBackend, UsageInfo}; -pub use sp_state_machine::{Backend as StateBackend, KeyValueStates}; +pub use sp_state_machine::{Backend as StateBackend, BackendTransaction, KeyValueStates}; /// Extracts the state backend type for the given backend. pub type StateBackendFor = >::State; -/// Extracts the transaction for the given state backend. -pub type TransactionForSB = >>::Transaction; - -/// Extracts the transaction for the given backend. -pub type TransactionFor = TransactionForSB, Block>; - /// Describes which block import notification stream should be notified. #[derive(Debug, Clone, Copy)] pub enum ImportNotificationAction { @@ -181,7 +175,7 @@ pub trait BlockImportOperation { /// Inject storage data into the database. fn update_db_storage( &mut self, - update: TransactionForSB, + update: BackendTransaction>, ) -> sp_blockchain::Result<()>; /// Set genesis state. If `commit` is `false` the state is saved in memory, but is not written diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs index cecc1053d1b9d..49b51ccc943ed 100644 --- a/client/api/src/call_executor.rs +++ b/client/api/src/call_executor.rs @@ -26,7 +26,7 @@ use sp_state_machine::{OverlayedChanges, StorageProof}; use std::cell::RefCell; use crate::execution_extensions::ExecutionExtensions; -use sp_api::{ProofRecorder, StorageTransactionCache}; +use sp_api::{HashingFor, ProofRecorder}; /// Executor Provider pub trait ExecutorProvider { @@ -72,12 +72,7 @@ pub trait CallExecutor: RuntimeVersionOf { at_hash: B::Hash, method: &str, call_data: &[u8], - changes: &RefCell, - storage_transaction_cache: Option< - &RefCell< - StorageTransactionCache>::State>, - >, - >, + changes: &RefCell>>, proof_recorder: &Option>, call_context: CallContext, extensions: &RefCell, diff --git a/client/api/src/in_mem.rs b/client/api/src/in_mem.rs index 711d739c16711..807bdf0e33472 100644 --- a/client/api/src/in_mem.rs +++ b/client/api/src/in_mem.rs @@ -29,8 +29,8 @@ use sp_runtime::{ Justification, Justifications, StateVersion, Storage, }; use sp_state_machine::{ - Backend as StateBackend, ChildStorageCollection, InMemoryBackend, IndexOperation, - StorageCollection, + Backend as StateBackend, BackendTransaction, ChildStorageCollection, InMemoryBackend, + IndexOperation, StorageCollection, }; use std::{ collections::{HashMap, HashSet}, @@ -480,9 +480,7 @@ impl backend::AuxStore for Blockchain { pub struct BlockImportOperation { pending_block: Option>, old_state: InMemoryBackend>, - new_state: Option< - > as StateBackend>>::Transaction, - >, + new_state: Option>>, aux: Vec<(Vec, Option>)>, finalized_blocks: Vec<(Block::Hash, Option)>, set_head: Option, @@ -540,7 +538,7 @@ impl backend::BlockImportOperation for BlockImportOperatio fn update_db_storage( &mut self, - update: > as StateBackend>>::Transaction, + update: BackendTransaction>, ) -> sp_blockchain::Result<()> { self.new_state = Some(update); Ok(()) diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 55aadb07e6756..b3a8f0d8970b6 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -187,8 +187,7 @@ where + Send + Sync + 'static, - C::Api: - ApiExt> + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { fn init_with_now( &mut self, @@ -229,8 +228,7 @@ where + Send + Sync + 'static, - C::Api: - ApiExt> + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, PR: ProofRecording, { type CreateProposer = future::Ready>; @@ -269,17 +267,11 @@ where + Send + Sync + 'static, - C::Api: - ApiExt> + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, PR: ProofRecording, { - type Transaction = backend::TransactionFor; - type Proposal = Pin< - Box< - dyn Future, Self::Error>> - + Send, - >, - >; + type Proposal = + Pin, Self::Error>> + Send>>; type Error = sp_blockchain::Error; type ProofRecording = PR; type Proof = PR::Proof; @@ -332,8 +324,7 @@ where + Send + Sync + 'static, - C::Api: - ApiExt> + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, PR: ProofRecording, { async fn propose_with( @@ -342,8 +333,7 @@ where inherent_digests: Digest, deadline: time::Instant, block_size_limit: Option, - ) -> Result, PR::Proof>, sp_blockchain::Error> - { + ) -> Result, sp_blockchain::Error> { let propose_with_timer = time::Instant::now(); let mut block_builder = self.client.new_block_at(self.parent_hash, inherent_digests, PR::ENABLED)?; diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index 5d692c4bda18c..1878e76274804 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -85,20 +85,18 @@ impl From for RecordProof { /// backend to get the state of the block. Furthermore an optional `proof` is included which /// can be used to proof that the build block contains the expected data. The `proof` will /// only be set when proof recording was activated. -pub struct BuiltBlock>> { +pub struct BuiltBlock { /// The actual block that was build. pub block: Block, /// The changes that need to be applied to the backend to get the state of the build block. - pub storage_changes: StorageChanges, + pub storage_changes: StorageChanges, /// An optional proof that was recorded while building the block. pub proof: Option, } -impl>> - BuiltBlock -{ +impl BuiltBlock { /// Convert into the inner values. - pub fn into_inner(self) -> (Block, StorageChanges, Option) { + pub fn into_inner(self) -> (Block, StorageChanges, Option) { (self.block, self.storage_changes, self.proof) } } @@ -145,8 +143,7 @@ impl<'a, Block, A, B> BlockBuilder<'a, Block, A, B> where Block: BlockT, A: ProvideRuntimeApi + 'a, - A::Api: - BlockBuilderApi + ApiExt>, + A::Api: BlockBuilderApi + ApiExt, B: backend::Backend, { /// Create a new instance of builder based on the given `parent_hash` and `parent_number`. @@ -231,7 +228,7 @@ where /// Returns the build `Block`, the changes to the storage and an optional `StorageProof` /// supplied by `self.api`, combined as [`BuiltBlock`]. /// The storage proof will be `Some(_)` when proof recording was enabled. - pub fn build(mut self) -> Result>, Error> { + pub fn build(mut self) -> Result, Error> { let header = self.api.finalize_block(self.parent_hash)?; debug_assert_eq!( diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index ad9599d4b0243..a8777ef8788cc 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -175,8 +175,8 @@ where { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { // Skip checks that include execution, if being told so or when importing only state. // // This is done for example when gap syncing and it is expected that the block after the gap @@ -348,7 +348,7 @@ pub fn import_queue( telemetry, compatibility_mode, }: ImportQueueParams, -) -> Result, sp_consensus::Error> +) -> Result, sp_consensus::Error> where Block: BlockT, C::Api: BlockBuilderApi + AuraApi> + ApiExt, @@ -360,10 +360,7 @@ where + AuxStore + UsageProvider + HeaderBackend, - I: BlockImport> - + Send - + Sync - + 'static, + I: BlockImport + Send + Sync + 'static, P: Pair + 'static, P::Public: Codec + Debug, P::Signature: Codec, diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index a611006716c69..a77f00d08d3e0 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -178,9 +178,9 @@ where C: ProvideRuntimeApi + BlockOf + AuxStore + HeaderBackend + Send + Sync, C::Api: AuraApi>, SC: SelectChain, - I: BlockImport> + Send + Sync + 'static, + I: BlockImport + Send + Sync + 'static, PF: Environment + Send + Sync + 'static, - PF::Proposer: Proposer>, + PF::Proposer: Proposer, SO: SyncOracle + Send + Sync + Clone, L: sc_consensus::JustificationSyncLink, CIDP: CreateInherentDataProviders + Send + 'static, @@ -279,11 +279,11 @@ where C: ProvideRuntimeApi + BlockOf + AuxStore + HeaderBackend + Send + Sync, C::Api: AuraApi>, PF: Environment + Send + Sync + 'static, - PF::Proposer: Proposer>, + PF::Proposer: Proposer, P: Pair, P::Public: AppPublic + Member, P::Signature: TryFrom> + Member + Codec, - I: BlockImport> + Send + Sync + 'static, + I: BlockImport + Send + Sync + 'static, Error: std::error::Error + Send + From + 'static, SO: SyncOracle + Send + Sync + Clone, L: sc_consensus::JustificationSyncLink, @@ -330,8 +330,8 @@ where C: ProvideRuntimeApi + BlockOf + HeaderBackend + Sync, C::Api: AuraApi>, E: Environment + Send + Sync, - E::Proposer: Proposer>, - I: BlockImport> + Send + Sync + 'static, + E::Proposer: Proposer, + I: BlockImport + Send + Sync + 'static, P: Pair, P::Public: AppPublic + Member, P::Signature: TryFrom> + Member + Codec, @@ -388,13 +388,10 @@ where header: B::Header, header_hash: &B::Hash, body: Vec, - storage_changes: StorageChanges<>::Transaction, B>, + storage_changes: StorageChanges, public: Self::Claim, _authorities: Self::AuxData, - ) -> Result< - sc_consensus::BlockImportParams>::Transaction>, - ConsensusError, - > { + ) -> Result, ConsensusError> { let signature_digest_item = crate::standalone::seal::<_, P>(header_hash, &public, &self.keystore)?; @@ -596,9 +593,7 @@ mod tests { impl Proposer for DummyProposer { type Error = Error; - type Transaction = - sc_client_api::TransactionFor; - type Proposal = future::Ready, Error>>; + type Proposal = future::Ready, Error>>; type ProofRecording = DisableProofRecording; type Proof = (); diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 76bd670c20049..b89fa8f5df65e 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -492,11 +492,8 @@ where C::Api: BabeApi, SC: SelectChain + 'static, E: Environment + Send + Sync + 'static, - E::Proposer: Proposer>, - I: BlockImport> - + Send - + Sync - + 'static, + E::Proposer: Proposer, + I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Sync + Clone + 'static, L: sc_consensus::JustificationSyncLink + 'static, CIDP: CreateInherentDataProviders + Send + Sync + 'static, @@ -727,8 +724,8 @@ where C: ProvideRuntimeApi + HeaderBackend + HeaderMetadata, C::Api: BabeApi, E: Environment + Sync, - E::Proposer: Proposer>, - I: BlockImport> + Send + Sync + 'static, + E::Proposer: Proposer, + I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Clone + Sync, L: sc_consensus::JustificationSyncLink, BS: BackoffAuthoringBlocksStrategy> + Sync, @@ -822,13 +819,10 @@ where header: B::Header, header_hash: &B::Hash, body: Vec, - storage_changes: StorageChanges<>::Transaction, B>, + storage_changes: StorageChanges, (_, public): Self::Claim, epoch_descriptor: Self::AuxData, - ) -> Result< - BlockImportParams>::Transaction>, - ConsensusError, - > { + ) -> Result, ConsensusError> { let signature = self .keystore .sr25519_sign(::ID, public.as_ref(), header_hash.as_ref()) @@ -1137,8 +1131,8 @@ where { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { trace!( target: LOG_TARGET, "Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}", @@ -1336,7 +1330,7 @@ impl BabeBlockImport { impl BabeBlockImport where Block: BlockT, - Inner: BlockImport> + Send + Sync, + Inner: BlockImport + Send + Sync, Inner::Error: Into, Client: HeaderBackend + HeaderMetadata @@ -1351,7 +1345,7 @@ where // end up in an inconsistent state and have to resync. async fn import_state( &mut self, - mut block: BlockImportParams>, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let parent_hash = *block.header.parent_hash(); @@ -1400,7 +1394,7 @@ where impl BlockImport for BabeBlockImport where Block: BlockT, - Inner: BlockImport> + Send + Sync, + Inner: BlockImport + Send + Sync, Inner::Error: Into, Client: HeaderBackend + HeaderMetadata @@ -1411,11 +1405,10 @@ where Client::Api: BabeApi + ApiExt, { type Error = ConsensusError; - type Transaction = sp_api::TransactionFor; async fn import_block( &mut self, - mut block: BlockImportParams, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); @@ -1827,15 +1820,9 @@ pub fn import_queue( telemetry, offchain_tx_pool_factory, }: ImportQueueParams<'_, Block, BI, Client, CIDP, SelectChain, Spawn>, -) -> ClientResult<(DefaultImportQueue, BabeWorkerHandle)> +) -> ClientResult<(DefaultImportQueue, BabeWorkerHandle)> where - BI: BlockImport< - Block, - Error = ConsensusError, - Transaction = sp_api::TransactionFor, - > + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, Client: ProvideRuntimeApi + HeaderBackend + HeaderMetadata diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 384e45228b599..b3843f8acfa0a 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -21,7 +21,7 @@ use super::*; use authorship::claim_slot; use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; -use sc_client_api::{backend::TransactionFor, BlockchainEvents, Finalizer}; +use sc_client_api::{BlockchainEvents, Finalizer}; use sc_consensus::{BoxBlockImport, BoxJustificationImport}; use sc_consensus_epochs::{EpochIdentifier, EpochIdentifierPosition}; use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging; @@ -97,16 +97,7 @@ impl DummyProposer { fn propose_with( &mut self, pre_digests: Digest, - ) -> future::Ready< - Result< - Proposal< - TestBlock, - sc_client_api::TransactionFor, - (), - >, - Error, - >, - > { + ) -> future::Ready, Error>> { let block_builder = self.factory.client.new_block_at(self.parent_hash, pre_digests, false).unwrap(); @@ -124,9 +115,7 @@ impl DummyProposer { impl Proposer for DummyProposer { type Error = Error; - type Transaction = - sc_client_api::TransactionFor; - type Proposal = future::Ready, Error>>; + type Proposal = future::Ready, Error>>; type ProofRecording = DisableProofRecording; type Proof = (); @@ -151,15 +140,13 @@ pub struct PanickingBlockImport(B); #[async_trait::async_trait] impl> BlockImport for PanickingBlockImport where - B::Transaction: Send, B: Send, { type Error = B::Error; - type Transaction = B::Transaction; async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { Ok(self.0.import_block(block).await.expect("importing block failed")) } @@ -207,8 +194,8 @@ impl Verifier for TestVerifier { /// presented to the User in the logs. async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { // apply post-sealing mutations (i.e. stripping seal, if desired). (self.mutator)(&mut block.header, Stage::PostSeal); self.inner.verify(block).await @@ -217,14 +204,7 @@ impl Verifier for TestVerifier { pub struct PeerData { link: BabeLink, - block_import: Mutex< - Option< - BoxBlockImport< - TestBlock, - TransactionFor, - >, - >, - >, + block_import: Mutex>>, } impl TestNetFactory for BabeTestNet { @@ -249,7 +229,7 @@ impl TestNetFactory for BabeTestNet { let block_import = PanickingBlockImport(block_import); let data_block_import = - Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_, _>)); + Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_>)); ( BlockImportAdapter::new(block_import), None, @@ -630,11 +610,11 @@ fn claim_vrf_check() { } // Propose and import a new BABE block on top of the given parent. -async fn propose_and_import_block( +async fn propose_and_import_block( parent: &TestHeader, slot: Option, proposer_factory: &mut DummyFactory, - block_import: &mut BoxBlockImport, + block_import: &mut BoxBlockImport, ) -> Hash { let mut proposer = proposer_factory.init(parent).await.unwrap(); @@ -701,10 +681,10 @@ async fn propose_and_import_block( // Propose and import n valid BABE blocks that are built on top of the given parent. // The proposer takes care of producing epoch change digests according to the epoch // duration (which is set to 6 slots in the test runtime). -async fn propose_and_import_blocks( +async fn propose_and_import_blocks( client: &PeersFullClient, proposer_factory: &mut DummyFactory, - block_import: &mut BoxBlockImport, + block_import: &mut BoxBlockImport, parent_hash: Hash, n: usize, ) -> Vec { diff --git a/client/consensus/beefy/src/import.rs b/client/consensus/beefy/src/import.rs index 80f8cebe48880..5b2abb20acede 100644 --- a/client/consensus/beefy/src/import.rs +++ b/client/consensus/beefy/src/import.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use log::debug; -use sp_api::{ProvideRuntimeApi, TransactionFor}; +use sp_api::ProvideRuntimeApi; use sp_consensus::Error as ConsensusError; use sp_consensus_beefy::{ecdsa_crypto::AuthorityId, BeefyApi, BEEFY_ENGINE_ID}; use sp_runtime::{ @@ -118,21 +118,15 @@ impl BlockImport for BeefyBlockImport, - I: BlockImport< - Block, - Error = ConsensusError, - Transaction = sp_api::TransactionFor, - > + Send - + Sync, + I: BlockImport + Send + Sync, Runtime: ProvideRuntimeApi + Send + Sync, Runtime::Api: BeefyApi, { type Error = ConsensusError; - type Transaction = TransactionFor; async fn import_block( &mut self, - mut block: BlockImportParams, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); diff --git a/client/consensus/beefy/src/lib.rs b/client/consensus/beefy/src/lib.rs index 52a4550cda4f1..da339dae7e1f5 100644 --- a/client/consensus/beefy/src/lib.rs +++ b/client/consensus/beefy/src/lib.rs @@ -139,9 +139,7 @@ pub fn beefy_block_import_and_links( where B: Block, BE: Backend, - I: BlockImport> - + Send - + Sync, + I: BlockImport + Send + Sync, RuntimeApi: ProvideRuntimeApi + Send + Sync, RuntimeApi::Api: BeefyApi, { diff --git a/client/consensus/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs index 1109a22638221..3bb65e9d57f43 100644 --- a/client/consensus/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -83,7 +83,7 @@ type BeefyBlockImport = crate::BeefyBlockImport< Block, substrate_test_runtime_client::Backend, TestApi, - BlockImportAdapter>, + BlockImportAdapter, >; pub(crate) type BeefyValidatorSet = ValidatorSet; diff --git a/client/consensus/common/src/block_import.rs b/client/consensus/common/src/block_import.rs index b84a45d533d46..a451692ad478e 100644 --- a/client/consensus/common/src/block_import.rs +++ b/client/consensus/common/src/block_import.rs @@ -119,9 +119,9 @@ pub struct BlockCheckParams { } /// Precomputed storage. -pub enum StorageChanges { +pub enum StorageChanges { /// Changes coming from block execution. - Changes(sp_state_machine::StorageChanges>), + Changes(sp_state_machine::StorageChanges>), /// Whole new state. Import(ImportedState), } @@ -142,9 +142,9 @@ impl std::fmt::Debug for ImportedState { } /// Defines how a new state is computed for a given imported block. -pub enum StateAction { +pub enum StateAction { /// Apply precomputed changes coming from block execution or state sync. - ApplyChanges(StorageChanges), + ApplyChanges(StorageChanges), /// Execute block body (required) and compute state. Execute, /// Execute block body if parent state is available and compute state. @@ -153,7 +153,7 @@ pub enum StateAction { Skip, } -impl StateAction { +impl StateAction { /// Check if execution checks that require runtime calls should be skipped. pub fn skip_execution_checks(&self) -> bool { match self { @@ -167,7 +167,7 @@ impl StateAction { /// Data required to import a Block. #[non_exhaustive] -pub struct BlockImportParams { +pub struct BlockImportParams { /// Origin of the Block pub origin: BlockOrigin, /// The header, without consensus post-digests applied. This should be in the same @@ -192,7 +192,7 @@ pub struct BlockImportParams { /// Indexed transaction body of the block. pub indexed_body: Option>>, /// Specify how the new state is computed. - pub state_action: StateAction, + pub state_action: StateAction, /// Is this block finalized already? /// `true` implies instant finality. pub finalized: bool, @@ -218,7 +218,7 @@ pub struct BlockImportParams { pub post_hash: Option, } -impl BlockImportParams { +impl BlockImportParams { /// Create a new block import params. pub fn new(origin: BlockOrigin, header: Block::Header) -> Self { Self { @@ -261,39 +261,6 @@ impl BlockImportParams { } } - /// Auxiliary function for "converting" the transaction type. - /// - /// Actually this just sets `StorageChanges::Changes` to `None` and makes rustc think that - /// `Self` now uses a different transaction type. - pub fn clear_storage_changes_and_mutate( - self, - ) -> BlockImportParams { - // Preserve imported state. - let state_action = match self.state_action { - StateAction::ApplyChanges(StorageChanges::Import(state)) => - StateAction::ApplyChanges(StorageChanges::Import(state)), - StateAction::ApplyChanges(StorageChanges::Changes(_)) => StateAction::Skip, - StateAction::Execute => StateAction::Execute, - StateAction::ExecuteIfPossible => StateAction::ExecuteIfPossible, - StateAction::Skip => StateAction::Skip, - }; - BlockImportParams { - origin: self.origin, - header: self.header, - justifications: self.justifications, - post_digests: self.post_digests, - body: self.body, - indexed_body: self.indexed_body, - state_action, - finalized: self.finalized, - auxiliary: self.auxiliary, - intermediates: self.intermediates, - fork_choice: self.fork_choice, - import_existing: self.import_existing, - post_hash: self.post_hash, - } - } - /// Insert intermediate by given key. pub fn insert_intermediate(&mut self, key: &'static [u8], value: T) { self.intermediates.insert(Cow::from(key), Box::new(value)); @@ -338,8 +305,6 @@ impl BlockImportParams { pub trait BlockImport { /// The error type. type Error: std::error::Error + Send + 'static; - /// The transaction type used by the backend. - type Transaction: Send + 'static; /// Check block preconditions. async fn check_block( @@ -350,17 +315,13 @@ pub trait BlockImport { /// Import a block. async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result; } #[async_trait::async_trait] -impl BlockImport for crate::import_queue::BoxBlockImport -where - Transaction: Send + 'static, -{ +impl BlockImport for crate::import_queue::BoxBlockImport { type Error = sp_consensus::error::Error; - type Transaction = Transaction; /// Check block preconditions. async fn check_block( @@ -373,21 +334,19 @@ where /// Import a block. async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { (**self).import_block(block).await } } #[async_trait::async_trait] -impl BlockImport for Arc +impl BlockImport for Arc where - for<'r> &'r T: BlockImport, + for<'r> &'r T: BlockImport, T: Send + Sync, - Transaction: Send + 'static, { type Error = E; - type Transaction = Transaction; async fn check_block( &mut self, @@ -398,7 +357,7 @@ where async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { (&**self).import_block(block).await } diff --git a/client/consensus/common/src/import_queue.rs b/client/consensus/common/src/import_queue.rs index bffc06df07076..39d5bf8ed35d1 100644 --- a/client/consensus/common/src/import_queue.rs +++ b/client/consensus/common/src/import_queue.rs @@ -50,16 +50,14 @@ const LOG_TARGET: &str = "sync::import-queue"; /// A commonly-used Import Queue type. /// /// This defines the transaction type of the `BasicQueue` to be the transaction type for a client. -pub type DefaultImportQueue = - BasicQueue>; +pub type DefaultImportQueue = BasicQueue; mod basic_queue; pub mod buffered_link; pub mod mock; /// Shared block import struct used by the queue. -pub type BoxBlockImport = - Box + Send + Sync>; +pub type BoxBlockImport = Box + Send + Sync>; /// Shared justification import struct used by the queue. pub type BoxJustificationImport = @@ -98,10 +96,8 @@ pub struct IncomingBlock { pub trait Verifier: Send { /// Verify the given block data and return the `BlockImportParams` to /// continue the block import process. - async fn verify( - &mut self, - block: BlockImportParams, - ) -> Result, String>; + async fn verify(&mut self, block: BlockImportParams) + -> Result, String>; } /// Blocks import queue API. @@ -221,8 +217,8 @@ pub enum BlockImportError { type BlockImportResult = Result>, BlockImportError>; /// Single block import function. -pub async fn import_single_block, Transaction: Send + 'static>( - import_handle: &mut impl BlockImport, +pub async fn import_single_block>( + import_handle: &mut impl BlockImport, block_origin: BlockOrigin, block: IncomingBlock, verifier: &mut V, @@ -231,12 +227,8 @@ pub async fn import_single_block, Transaction: Send + } /// Single block import function with metering. -pub(crate) async fn import_single_block_metered< - B: BlockT, - V: Verifier, - Transaction: Send + 'static, ->( - import_handle: &mut impl BlockImport, +pub(crate) async fn import_single_block_metered>( + import_handle: &mut impl BlockImport, block_origin: BlockOrigin, block: IncomingBlock, verifier: &mut V, @@ -350,7 +342,6 @@ pub(crate) async fn import_single_block_metered< metrics.report_verification(true, started.elapsed()); } - let import_block = import_block.clear_storage_changes_and_mutate(); let imported = import_handle.import_block(import_block).await; if let Some(metrics) = metrics.as_ref() { metrics.report_verification_and_import(started.elapsed()); diff --git a/client/consensus/common/src/import_queue/basic_queue.rs b/client/consensus/common/src/import_queue/basic_queue.rs index b93913703d39f..1cc7ec26fd193 100644 --- a/client/consensus/common/src/import_queue/basic_queue.rs +++ b/client/consensus/common/src/import_queue/basic_queue.rs @@ -28,7 +28,7 @@ use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT, NumberFor}, Justification, Justifications, }; -use std::{marker::PhantomData, pin::Pin, time::Duration}; +use std::{pin::Pin, time::Duration}; use crate::{ import_queue::{ @@ -42,15 +42,14 @@ use crate::{ /// Interface to a basic block import queue that is importing blocks sequentially in a separate /// task, with plugable verification. -pub struct BasicQueue { +pub struct BasicQueue { /// Handle for sending justification and block import messages to the background task. handle: BasicQueueHandle, /// Results coming from the worker task. result_port: BufferedLinkReceiver, - _phantom: PhantomData, } -impl Drop for BasicQueue { +impl Drop for BasicQueue { fn drop(&mut self) { // Flush the queue and close the receiver to terminate the future. self.handle.close(); @@ -58,13 +57,13 @@ impl Drop for BasicQueue { } } -impl BasicQueue { +impl BasicQueue { /// Instantiate a new basic queue, with given verifier. /// /// This creates a background task, and calls `on_start` on the justification importer. pub fn new>( verifier: V, - block_import: BoxBlockImport, + block_import: BoxBlockImport, justification_import: Option>, spawner: &impl sp_core::traits::SpawnEssentialNamed, prometheus_registry: Option<&Registry>, @@ -96,7 +95,6 @@ impl BasicQueue { Self { handle: BasicQueueHandle::new(justification_sender, block_import_sender), result_port, - _phantom: PhantomData, } } } @@ -165,7 +163,7 @@ impl ImportQueueService for BasicQueueHandle { } #[async_trait::async_trait] -impl ImportQueue for BasicQueue { +impl ImportQueue for BasicQueue { /// Get handle to [`ImportQueueService`]. fn service(&self) -> Box> { Box::new(self.handle.clone()) @@ -220,8 +218,8 @@ mod worker_messages { /// to give other futures the possibility to be run. /// /// Returns when `block_import` ended. -async fn block_import_process( - mut block_import: BoxBlockImport, +async fn block_import_process( + mut block_import: BoxBlockImport, mut verifier: impl Verifier, mut result_sender: BufferedLinkSender, mut block_import_receiver: TracingUnboundedReceiver>, @@ -262,10 +260,10 @@ struct BlockImportWorker { } impl BlockImportWorker { - fn new, Transaction: Send + 'static>( + fn new>( result_sender: BufferedLinkSender, verifier: V, - block_import: BoxBlockImport, + block_import: BoxBlockImport, justification_import: Option>, metrics: Option, ) -> ( @@ -391,8 +389,8 @@ struct ImportManyBlocksResult { /// /// This will yield after each imported block once, to ensure that other futures can /// be called as well. -async fn import_many_blocks, Transaction: Send + 'static>( - import_handle: &mut BoxBlockImport, +async fn import_many_blocks>( + import_handle: &mut BoxBlockImport, blocks_origin: BlockOrigin, blocks: Vec>, verifier: &mut V, @@ -507,14 +505,14 @@ mod tests { import_queue::Verifier, }; use futures::{executor::block_on, Future}; - use sp_test_primitives::{Block, BlockNumber, Extrinsic, Hash, Header}; + use sp_test_primitives::{Block, BlockNumber, Hash, Header}; #[async_trait::async_trait] impl Verifier for () { async fn verify( &mut self, - block: BlockImportParams, - ) -> Result, String> { + block: BlockImportParams, + ) -> Result, String> { Ok(BlockImportParams::new(block.origin, block.header)) } } @@ -522,7 +520,6 @@ mod tests { #[async_trait::async_trait] impl BlockImport for () { type Error = sp_consensus::Error; - type Transaction = Extrinsic; async fn check_block( &mut self, @@ -533,7 +530,7 @@ mod tests { async fn import_block( &mut self, - _block: BlockImportParams, + _block: BlockImportParams, ) -> Result { Ok(ImportResult::imported(true)) } diff --git a/client/consensus/grandpa/src/import.rs b/client/consensus/grandpa/src/import.rs index 760cb2da0484d..8481b39584729 100644 --- a/client/consensus/grandpa/src/import.rs +++ b/client/consensus/grandpa/src/import.rs @@ -28,7 +28,7 @@ use sc_consensus::{ }; use sc_telemetry::TelemetryHandle; use sc_utils::mpsc::TracingUnboundedSender; -use sp_api::{Core, RuntimeApiInfo, TransactionFor}; +use sp_api::{Core, RuntimeApiInfo}; use sp_blockchain::BlockStatus; use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain}; use sp_consensus_grandpa::{ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID}; @@ -234,9 +234,7 @@ where BE: Backend, Client: ClientForGrandpa, Client::Api: GrandpaApi, - for<'a> &'a Client: - BlockImport>, - TransactionFor: 'static, + for<'a> &'a Client: BlockImport, { // check for a new authority set change. fn check_new_change( @@ -273,7 +271,7 @@ where fn make_authorities_changes( &self, - block: &mut BlockImportParams>, + block: &mut BlockImportParams, hash: Block::Hash, initial_sync: bool, ) -> Result, ConsensusError> { @@ -461,7 +459,7 @@ where /// Import whole new state and reset authority set. async fn import_state( &mut self, - mut block: BlockImportParams>, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); @@ -516,17 +514,14 @@ where BE: Backend, Client: ClientForGrandpa, Client::Api: GrandpaApi, - for<'a> &'a Client: - BlockImport>, - TransactionFor: 'static, + for<'a> &'a Client: BlockImport, SC: Send, { type Error = ConsensusError; - type Transaction = TransactionFor; async fn import_block( &mut self, - mut block: BlockImportParams, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); diff --git a/client/consensus/grandpa/src/lib.rs b/client/consensus/grandpa/src/lib.rs index ff0412aeb314c..da621abd254ca 100644 --- a/client/consensus/grandpa/src/lib.rs +++ b/client/consensus/grandpa/src/lib.rs @@ -65,7 +65,6 @@ use sc_client_api::{ backend::{AuxStore, Backend}, utils::is_descendent_of, BlockchainEvents, CallExecutor, ExecutorProvider, Finalizer, LockImportRun, StorageProvider, - TransactionFor, }; use sc_consensus::BlockImport; use sc_network::types::ProtocolName; @@ -309,7 +308,7 @@ pub trait ClientForGrandpa: + BlockchainEvents + ProvideRuntimeApi + ExecutorProvider - + BlockImport, Error = sp_consensus::Error> + + BlockImport + StorageProvider where BE: Backend, @@ -329,7 +328,7 @@ where + BlockchainEvents + ProvideRuntimeApi + ExecutorProvider - + BlockImport, Error = sp_consensus::Error> + + BlockImport + StorageProvider, { } diff --git a/client/consensus/manual-seal/src/consensus.rs b/client/consensus/manual-seal/src/consensus.rs index b54ec5e41b750..2cc2b902b1ce9 100644 --- a/client/consensus/manual-seal/src/consensus.rs +++ b/client/consensus/manual-seal/src/consensus.rs @@ -30,9 +30,6 @@ pub mod timestamp; /// Consensus data provider, manual seal uses this trait object for authoring blocks valid /// for any runtime. pub trait ConsensusDataProvider: Send + Sync { - /// Block import transaction type - type Transaction; - /// The proof type. type Proof; @@ -43,7 +40,7 @@ pub trait ConsensusDataProvider: Send + Sync { fn append_block_import( &self, parent: &B::Header, - params: &mut BlockImportParams, + params: &mut BlockImportParams, inherents: &InherentData, proof: Self::Proof, ) -> Result<(), Error>; diff --git a/client/consensus/manual-seal/src/consensus/aura.rs b/client/consensus/manual-seal/src/consensus/aura.rs index 92203f91826f0..566a2266c701b 100644 --- a/client/consensus/manual-seal/src/consensus/aura.rs +++ b/client/consensus/manual-seal/src/consensus/aura.rs @@ -22,7 +22,7 @@ use crate::{ConsensusDataProvider, Error}; use sc_client_api::{AuxStore, UsageProvider}; use sc_consensus::BlockImportParams; -use sp_api::{ProvideRuntimeApi, TransactionFor}; +use sp_api::ProvideRuntimeApi; use sp_blockchain::{HeaderBackend, HeaderMetadata}; use sp_consensus_aura::{ digests::CompatibleDigestItem, @@ -69,7 +69,6 @@ where C::Api: AuraApi, P: Send + Sync, { - type Transaction = TransactionFor; type Proof = P; fn create_digest( @@ -92,7 +91,7 @@ where fn append_block_import( &self, _parent: &B::Header, - _params: &mut BlockImportParams, + _params: &mut BlockImportParams, _inherents: &InherentData, _proof: Self::Proof, ) -> Result<(), Error> { diff --git a/client/consensus/manual-seal/src/consensus/babe.rs b/client/consensus/manual-seal/src/consensus/babe.rs index 2485bd603e785..26fa81459808c 100644 --- a/client/consensus/manual-seal/src/consensus/babe.rs +++ b/client/consensus/manual-seal/src/consensus/babe.rs @@ -33,7 +33,7 @@ use sp_keystore::KeystorePtr; use std::{marker::PhantomData, sync::Arc}; use sc_consensus::{BlockImportParams, ForkChoiceStrategy, Verifier}; -use sp_api::{ProvideRuntimeApi, TransactionFor}; +use sp_api::ProvideRuntimeApi; use sp_blockchain::{HeaderBackend, HeaderMetadata}; use sp_consensus_babe::{ digests::{NextEpochDescriptor, PreDigest, SecondaryPlainPreDigest}, @@ -97,8 +97,8 @@ where { async fn verify( &mut self, - mut import_params: BlockImportParams, - ) -> Result, String> { + mut import_params: BlockImportParams, + ) -> Result, String> { import_params.finalized = false; import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain); @@ -197,7 +197,6 @@ where C::Api: BabeApi, P: Send + Sync, { - type Transaction = TransactionFor; type Proof = P; fn create_digest(&self, parent: &B::Header, inherents: &InherentData) -> Result { @@ -264,7 +263,7 @@ where fn append_block_import( &self, parent: &B::Header, - params: &mut BlockImportParams, + params: &mut BlockImportParams, inherents: &InherentData, _proof: Self::Proof, ) -> Result<(), Error> { diff --git a/client/consensus/manual-seal/src/lib.rs b/client/consensus/manual-seal/src/lib.rs index 03c9418b5c560..c3b891b84e893 100644 --- a/client/consensus/manual-seal/src/lib.rs +++ b/client/consensus/manual-seal/src/lib.rs @@ -52,7 +52,7 @@ pub use self::{ seal_block::{seal_block, SealBlockParams, MAX_PROPOSAL_DURATION}, }; use sc_transaction_pool_api::TransactionPool; -use sp_api::{ProvideRuntimeApi, TransactionFor}; +use sp_api::ProvideRuntimeApi; const LOG_TARGET: &str = "manual-seal"; @@ -66,8 +66,8 @@ struct ManualSealVerifier; impl Verifier for ManualSealVerifier { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { block.finalized = false; block.fork_choice = Some(ForkChoiceStrategy::LongestChain); Ok(block) @@ -75,14 +75,13 @@ impl Verifier for ManualSealVerifier { } /// Instantiate the import queue for the manual seal consensus engine. -pub fn import_queue( - block_import: BoxBlockImport, +pub fn import_queue( + block_import: BoxBlockImport, spawner: &impl sp_core::traits::SpawnEssentialNamed, registry: Option<&Registry>, -) -> BasicQueue +) -> BasicQueue where Block: BlockT, - Transaction: Send + Sync + 'static, { BasicQueue::new(ManualSealVerifier, block_import, None, spawner, registry) } @@ -109,8 +108,7 @@ pub struct ManualSealParams, TP, SC, C pub select_chain: SC, /// Digest provider for inclusion in blocks. - pub consensus_data_provider: - Option>>>, + pub consensus_data_provider: Option>>, /// Something that can create the inherent data providers. pub create_inherent_data_providers: CIDP, @@ -134,8 +132,7 @@ pub struct InstantSealParams, TP, SC, pub select_chain: SC, /// Digest provider for inclusion in blocks. - pub consensus_data_provider: - Option>>>, + pub consensus_data_provider: Option>>, /// Something that can create the inherent data providers. pub create_inherent_data_providers: CIDP, @@ -167,17 +164,13 @@ pub async fn run_manual_seal( }: ManualSealParams, ) where B: BlockT + 'static, - BI: BlockImport> - + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, C: HeaderBackend + Finalizer + ProvideRuntimeApi + 'static, CB: ClientBackend + 'static, E: Environment + 'static, - E::Proposer: Proposer>, + E::Proposer: Proposer, CS: Stream::Hash>> + Unpin + 'static, SC: SelectChain + 'static, - TransactionFor: 'static, TP: TransactionPool, CIDP: CreateInherentDataProviders, P: Send + Sync + 'static, @@ -230,16 +223,12 @@ pub async fn run_instant_seal( }: InstantSealParams, ) where B: BlockT + 'static, - BI: BlockImport> - + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, C: HeaderBackend + Finalizer + ProvideRuntimeApi + 'static, CB: ClientBackend + 'static, E: Environment + 'static, - E::Proposer: Proposer>, + E::Proposer: Proposer, SC: SelectChain + 'static, - TransactionFor: 'static, TP: TransactionPool, CIDP: CreateInherentDataProviders, P: Send + Sync + 'static, @@ -284,16 +273,12 @@ pub async fn run_instant_seal_and_finalize( }: InstantSealParams, ) where B: BlockT + 'static, - BI: BlockImport> - + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, C: HeaderBackend + Finalizer + ProvideRuntimeApi + 'static, CB: ClientBackend + 'static, E: Environment + 'static, - E::Proposer: Proposer>, + E::Proposer: Proposer, SC: SelectChain + 'static, - TransactionFor: 'static, TP: TransactionPool, CIDP: CreateInherentDataProviders, P: Send + Sync + 'static, @@ -386,7 +371,6 @@ mod tests { B: BlockT, C: ProvideRuntimeApi + Send + Sync, { - type Transaction = TransactionFor; type Proof = (); fn create_digest( @@ -400,7 +384,7 @@ mod tests { fn append_block_import( &self, _parent: &B::Header, - params: &mut BlockImportParams, + params: &mut BlockImportParams, _inherents: &InherentData, _proof: Self::Proof, ) -> Result<(), Error> { diff --git a/client/consensus/manual-seal/src/seal_block.rs b/client/consensus/manual-seal/src/seal_block.rs index e6133bccae885..4b6230c3efc3d 100644 --- a/client/consensus/manual-seal/src/seal_block.rs +++ b/client/consensus/manual-seal/src/seal_block.rs @@ -22,7 +22,7 @@ use crate::{rpc, ConsensusDataProvider, CreatedBlock, Error}; use futures::prelude::*; use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, StateAction}; use sc_transaction_pool_api::TransactionPool; -use sp_api::{ProvideRuntimeApi, TransactionFor}; +use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_consensus::{self, BlockOrigin, Environment, Proposer, SelectChain}; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; @@ -52,8 +52,7 @@ pub struct SealBlockParams<'a, B: BlockT, BI, SC, C: ProvideRuntimeApi, E, TP /// SelectChain object pub select_chain: &'a SC, /// Digest provider for inclusion in blocks. - pub consensus_data_provider: - Option<&'a dyn ConsensusDataProvider>>, + pub consensus_data_provider: Option<&'a dyn ConsensusDataProvider>, /// block import object pub block_import: &'a mut BI, /// Something that can create the inherent data providers. @@ -77,16 +76,12 @@ pub async fn seal_block( }: SealBlockParams<'_, B, BI, SC, C, E, TP, CIDP, P>, ) where B: BlockT, - BI: BlockImport> - + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, C: HeaderBackend + ProvideRuntimeApi, E: Environment, - E::Proposer: Proposer>, + E::Proposer: Proposer, TP: TransactionPool, SC: SelectChain, - TransactionFor: 'static, CIDP: CreateInherentDataProviders, P: Send + Sync + 'static, { diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 763cf10e6cd4f..ee5c1dfc6f11a 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -237,7 +237,7 @@ impl Clone impl PowBlockImport where B: BlockT, - I: BlockImport> + Send + Sync, + I: BlockImport + Send + Sync, I::Error: Into, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + BlockOf, C::Api: BlockBuilderApi, @@ -301,7 +301,7 @@ where impl BlockImport for PowBlockImport where B: BlockT, - I: BlockImport> + Send + Sync, + I: BlockImport + Send + Sync, I::Error: Into, S: SelectChain, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + BlockOf, @@ -311,7 +311,6 @@ where CIDP: CreateInherentDataProviders + Send + Sync, { type Error = ConsensusError; - type Transaction = sp_api::TransactionFor; async fn check_block( &mut self, @@ -322,7 +321,7 @@ where async fn import_block( &mut self, - mut block: BlockImportParams, + mut block: BlockImportParams, ) -> Result { let best_header = self .select_chain @@ -444,8 +443,8 @@ where { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { let hash = block.header.hash(); let (checked_header, seal) = self.check_header(block.header)?; @@ -460,19 +459,18 @@ where } /// The PoW import queue type. -pub type PowImportQueue = BasicQueue; +pub type PowImportQueue = BasicQueue; /// Import queue for PoW engine. -pub fn import_queue( - block_import: BoxBlockImport, +pub fn import_queue( + block_import: BoxBlockImport, justification_import: Option>, algorithm: Algorithm, spawner: &impl sp_core::traits::SpawnEssentialNamed, registry: Option<&Registry>, -) -> Result, sp_consensus::Error> +) -> Result, sp_consensus::Error> where B: BlockT, - Transaction: Send + Sync + 'static, Algorithm: PowAlgorithm + Clone + Send + Sync + 'static, Algorithm::Difficulty: Send, { @@ -491,7 +489,7 @@ where /// `pre_runtime` is a parameter that allows a custom additional pre-runtime digest to be inserted /// for blocks being built. This can encode authorship information, or just be a graffiti. pub fn start_mining_worker( - block_import: BoxBlockImport>, + block_import: BoxBlockImport, client: Arc, select_chain: S, algorithm: Algorithm, @@ -503,18 +501,18 @@ pub fn start_mining_worker( timeout: Duration, build_time: Duration, ) -> ( - MiningHandle>::Proof>, + MiningHandle>::Proof>, impl Future, ) where Block: BlockT, - C: ProvideRuntimeApi + BlockchainEvents + 'static, + C: BlockchainEvents + 'static, S: SelectChain + 'static, Algorithm: PowAlgorithm + Clone, Algorithm::Difficulty: Send + 'static, E: Environment + Send + Sync + 'static, E::Error: std::fmt::Debug, - E::Proposer: Proposer>, + E::Proposer: Proposer, SO: SyncOracle + Clone + Send + Sync + 'static, L: sc_consensus::JustificationSyncLink, CIDP: CreateInherentDataProviders, @@ -632,7 +630,7 @@ where }, }; - let build = MiningBuild:: { + let build = MiningBuild:: { metadata: MiningMetadata { best_hash, pre_hash: proposal.block.header().hash(), diff --git a/client/consensus/pow/src/worker.rs b/client/consensus/pow/src/worker.rs index 3cb5dfcc09260..9e9c4fc137d86 100644 --- a/client/consensus/pow/src/worker.rs +++ b/client/consensus/pow/src/worker.rs @@ -56,16 +56,11 @@ pub struct MiningMetadata { } /// A build of mining, containing the metadata and the block proposal. -pub struct MiningBuild< - Block: BlockT, - Algorithm: PowAlgorithm, - C: sp_api::ProvideRuntimeApi, - Proof, -> { +pub struct MiningBuild, Proof> { /// Mining metadata. pub metadata: MiningMetadata, /// Mining proposal. - pub proposal: Proposal, Proof>, + pub proposal: Proposal, } /// Version of the mining worker. @@ -76,25 +71,22 @@ pub struct Version(usize); pub struct MiningHandle< Block: BlockT, Algorithm: PowAlgorithm, - C: sp_api::ProvideRuntimeApi, L: sc_consensus::JustificationSyncLink, Proof, > { version: Arc, algorithm: Arc, justification_sync_link: Arc, - build: Arc>>>, - block_import: Arc>>>, + build: Arc>>>, + block_import: Arc>>, } -impl MiningHandle +impl MiningHandle where Block: BlockT, - C: sp_api::ProvideRuntimeApi, Algorithm: PowAlgorithm, Algorithm::Difficulty: 'static + Send, L: sc_consensus::JustificationSyncLink, - sp_api::TransactionFor: Send + 'static, { fn increment_version(&self) { self.version.fetch_add(1, Ordering::SeqCst); @@ -102,7 +94,7 @@ where pub(crate) fn new( algorithm: Algorithm, - block_import: BoxBlockImport>, + block_import: BoxBlockImport, justification_sync_link: L, ) -> Self { Self { @@ -120,7 +112,7 @@ where self.increment_version(); } - pub(crate) fn on_build(&self, value: MiningBuild) { + pub(crate) fn on_build(&self, value: MiningBuild) { let mut build = self.build.lock(); *build = Some(value); self.increment_version(); @@ -224,11 +216,10 @@ where } } -impl Clone for MiningHandle +impl Clone for MiningHandle where Block: BlockT, Algorithm: PowAlgorithm, - C: sp_api::ProvideRuntimeApi, L: sc_consensus::JustificationSyncLink, { fn clone(&self) -> Self { diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 533ddb54e899d..5ee93d1686437 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -53,8 +53,7 @@ const LOG_TARGET: &str = "slots"; /// The changes that need to applied to the storage to create the state for a block. /// /// See [`sp_state_machine::StorageChanges`] for more information. -pub type StorageChanges = - sp_state_machine::StorageChanges>; +pub type StorageChanges = sp_state_machine::StorageChanges>; /// The result of [`SlotWorker::on_slot`]. #[derive(Debug, Clone)] @@ -84,9 +83,7 @@ pub trait SlotWorker { #[async_trait::async_trait] pub trait SimpleSlotWorker { /// A handle to a `BlockImport`. - type BlockImport: BlockImport>::Transaction> - + Send - + 'static; + type BlockImport: BlockImport + Send + 'static; /// A handle to a `SyncOracle`. type SyncOracle: SyncOracle; @@ -148,13 +145,10 @@ pub trait SimpleSlotWorker { header: B::Header, header_hash: &B::Hash, body: Vec, - storage_changes: StorageChanges<>::Transaction, B>, + storage_changes: StorageChanges, public: Self::Claim, aux_data: Self::AuxData, - ) -> Result< - sc_consensus::BlockImportParams>::Transaction>, - sp_consensus::Error, - >; + ) -> Result, sp_consensus::Error>; /// Whether to force authoring if offline. fn force_authoring(&self) -> bool; @@ -191,13 +185,7 @@ pub trait SimpleSlotWorker { claim: &Self::Claim, slot_info: SlotInfo, end_proposing_at: Instant, - ) -> Option< - Proposal< - B, - >::Transaction, - >::Proof, - >, - > { + ) -> Option>::Proof>> { let slot = slot_info.slot; let telemetry = self.telemetry(); let log_target = self.logging_target(); diff --git a/client/db/src/bench.rs b/client/db/src/bench.rs index 9307a63ad444e..38c37a42ede79 100644 --- a/client/db/src/bench.rs +++ b/client/db/src/bench.rs @@ -32,8 +32,8 @@ use sp_runtime::{ StateVersion, Storage, }; use sp_state_machine::{ - backend::Backend as StateBackend, ChildStorageCollection, DBValue, IterArgs, StorageCollection, - StorageIterator, StorageKey, StorageValue, + backend::Backend as StateBackend, BackendTransaction, ChildStorageCollection, DBValue, + IterArgs, StorageCollection, StorageIterator, StorageKey, StorageValue, }; use sp_trie::{ cache::{CacheSize, SharedTrieCache}, @@ -343,7 +343,6 @@ fn state_err() -> String { impl StateBackend> for BenchmarkingState { type Error = as StateBackend>>::Error; - type Transaction = as StateBackend>>::Transaction; type TrieBackendStorage = as StateBackend>>::TrieBackendStorage; type RawIter = RawIter; @@ -423,7 +422,7 @@ impl StateBackend> for BenchmarkingState { &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, Self::Transaction) { + ) -> (B::Hash, BackendTransaction>) { self.state .borrow() .as_ref() @@ -435,7 +434,7 @@ impl StateBackend> for BenchmarkingState { child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, bool, Self::Transaction) { + ) -> (B::Hash, bool, BackendTransaction>) { self.state .borrow() .as_ref() @@ -460,7 +459,7 @@ impl StateBackend> for BenchmarkingState { fn commit( &self, storage_root: as Hasher>::Out, - mut transaction: Self::Transaction, + mut transaction: BackendTransaction>, main_storage_changes: StorageCollection, child_storage_changes: ChildStorageCollection, ) -> Result<(), Self::Error> { diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index aba5b0829b5bb..73fb4f8ce6db3 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -86,9 +86,9 @@ use sp_runtime::{ }; use sp_state_machine::{ backend::{AsTrieBackend, Backend as StateBackend}, - ChildStorageCollection, DBValue, IndexOperation, IterArgs, OffchainChangesCollection, - StateMachineStats, StorageCollection, StorageIterator, StorageKey, StorageValue, - UsageInfo as StateUsageInfo, + BackendTransaction, ChildStorageCollection, DBValue, IndexOperation, IterArgs, + OffchainChangesCollection, StateMachineStats, StorageCollection, StorageIterator, StorageKey, + StorageValue, UsageInfo as StateUsageInfo, }; use sp_trie::{cache::SharedTrieCache, prefixed_key, MemoryDB, PrefixedMemoryDB}; @@ -187,7 +187,6 @@ impl StorageIterator> for RawIter { impl StateBackend> for RefTrackingState { type Error = as StateBackend>>::Error; - type Transaction = as StateBackend>>::Transaction; type TrieBackendStorage = as StateBackend>>::TrieBackendStorage; type RawIter = RawIter; @@ -243,7 +242,7 @@ impl StateBackend> for RefTrackingState { &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, Self::Transaction) { + ) -> (B::Hash, BackendTransaction>) { self.state.storage_root(delta, state_version) } @@ -252,7 +251,7 @@ impl StateBackend> for RefTrackingState { child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, bool, Self::Transaction) { + ) -> (B::Hash, bool, BackendTransaction>) { self.state.child_storage_root(child_info, delta, state_version) } diff --git a/client/db/src/record_stats_state.rs b/client/db/src/record_stats_state.rs index 005315ce9f458..29ece84f97e57 100644 --- a/client/db/src/record_stats_state.rs +++ b/client/db/src/record_stats_state.rs @@ -26,7 +26,7 @@ use sp_runtime::{ }; use sp_state_machine::{ backend::{AsTrieBackend, Backend as StateBackend}, - IterArgs, StorageIterator, StorageKey, StorageValue, TrieBackend, + BackendTransaction, IterArgs, StorageIterator, StorageKey, StorageValue, TrieBackend, }; use std::sync::Arc; @@ -109,7 +109,6 @@ impl>, B: BlockT> StateBackend> for RecordStatsState { type Error = S::Error; - type Transaction = S::Transaction; type TrieBackendStorage = S::TrieBackendStorage; type RawIter = RawIter; @@ -173,7 +172,7 @@ impl>, B: BlockT> StateBackend> &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, Self::Transaction) { + ) -> (B::Hash, BackendTransaction>) { self.state.storage_root(delta, state_version) } @@ -182,7 +181,7 @@ impl>, B: BlockT> StateBackend> child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (B::Hash, bool, Self::Transaction) { + ) -> (B::Hash, bool, BackendTransaction>) { self.state.child_storage_root(child_info, delta, state_version) } diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index 05ed3ddb79800..2a20da5a556b7 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -28,7 +28,6 @@ mod sync; use std::{ collections::HashMap, - marker::PhantomData, pin::Pin, sync::Arc, task::{Context as FutureContext, Poll}, @@ -41,7 +40,7 @@ use log::trace; use parking_lot::Mutex; use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sc_client_api::{ - backend::{AuxStore, Backend, Finalizer, TransactionFor}, + backend::{AuxStore, Backend, Finalizer}, BlockBackend, BlockImportNotification, BlockchainEvents, FinalityNotification, FinalityNotifications, ImportNotifications, }; @@ -117,8 +116,8 @@ impl PassThroughVerifier { impl Verifier for PassThroughVerifier { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { if block.fork_choice.is_none() { block.fork_choice = Some(ForkChoiceStrategy::LongestChain); }; @@ -210,7 +209,6 @@ impl PeersClient { #[async_trait::async_trait] impl BlockImport for PeersClient { type Error = ConsensusError; - type Transaction = (); async fn check_block( &mut self, @@ -221,9 +219,9 @@ impl BlockImport for PeersClient { async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { - self.client.import_block(block.clear_storage_changes_and_mutate()).await + self.client.import_block(block).await } } @@ -248,7 +246,6 @@ pub struct Peer { impl Peer where B: BlockImport + Send + Sync, - B::Transaction: Send, { /// Get this peer ID. pub fn id(&self) -> PeerId { @@ -556,24 +553,12 @@ where } pub trait BlockImportAdapterFull: - BlockImport< - Block, - Transaction = TransactionFor, - Error = ConsensusError, - > + Send - + Sync - + Clone + BlockImport + Send + Sync + Clone { } impl BlockImportAdapterFull for T where - T: BlockImport< - Block, - Transaction = TransactionFor, - Error = ConsensusError, - > + Send - + Sync - + Clone + T: BlockImport + Send + Sync + Clone { } @@ -583,27 +568,23 @@ impl BlockImportAdapterFull for T where /// This is required as the `TestNetFactory` trait does not distinguish between /// full and light nodes. #[derive(Clone)] -pub struct BlockImportAdapter { +pub struct BlockImportAdapter { inner: I, - _phantom: PhantomData, } -impl BlockImportAdapter { +impl BlockImportAdapter { /// Create a new instance of `Self::Full`. pub fn new(inner: I) -> Self { - Self { inner, _phantom: PhantomData } + Self { inner } } } #[async_trait::async_trait] -impl BlockImport for BlockImportAdapter +impl BlockImport for BlockImportAdapter where I: BlockImport + Send + Sync, - I::Transaction: Send, - Transaction: Send + 'static, { type Error = ConsensusError; - type Transaction = Transaction; async fn check_block( &mut self, @@ -614,9 +595,9 @@ where async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { - self.inner.import_block(block.clear_storage_changes_and_mutate()).await + self.inner.import_block(block).await } } @@ -630,8 +611,8 @@ struct VerifierAdapter { impl Verifier for VerifierAdapter { async fn verify( &mut self, - block: BlockImportParams, - ) -> Result, String> { + block: BlockImportParams, + ) -> Result, String> { let hash = block.header.hash(); self.verifier.lock().await.verify(block).await.map_err(|e| { self.failed_verifications.lock().insert(hash, e.clone()); @@ -714,10 +695,7 @@ pub struct FullPeerConfig { } #[async_trait::async_trait] -pub trait TestNetFactory: Default + Sized + Send -where - >::Transaction: Send, -{ +pub trait TestNetFactory: Default + Sized + Send { type Verifier: 'static + Verifier; type BlockImport: BlockImport + Clone + Send + Sync + 'static; type PeerData: Default + Send; diff --git a/client/network/test/src/service.rs b/client/network/test/src/service.rs index e2a9cb5f3bafd..68e780545bb17 100644 --- a/client/network/test/src/service.rs +++ b/client/network/test/src/service.rs @@ -135,8 +135,8 @@ impl TestNetworkBuilder { impl sc_consensus::Verifier for PassThroughVerifier { async fn verify( &mut self, - mut block: sc_consensus::BlockImportParams, - ) -> Result, String> { + mut block: sc_consensus::BlockImportParams, + ) -> Result, String> { block.finalized = self.0; block.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); Ok(block) diff --git a/client/rpc-spec-v2/src/chain_head/test_utils.rs b/client/rpc-spec-v2/src/chain_head/test_utils.rs index 54c585932a744..6e92e87608b44 100644 --- a/client/rpc-spec-v2/src/chain_head/test_utils.rs +++ b/client/rpc-spec-v2/src/chain_head/test_utils.rs @@ -203,10 +203,7 @@ impl< impl> CallApiAt for ChainHeadMockClient { type StateBackend = >::StateBackend; - fn call_api_at( - &self, - params: CallApiAtParams>::StateBackend>, - ) -> Result, sp_api::ApiError> { + fn call_api_at(&self, params: CallApiAtParams) -> Result, sp_api::ApiError> { self.client.call_api_at(params) } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index b942ac58aa99b..fe18d1d002d56 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -380,7 +380,7 @@ where >::Api: sp_api::Metadata + sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_session::SessionKeys - + sp_api::ApiExt, + + sp_api::ApiExt, TBl: BlockT, TBl::Hash: Unpin, TBl::Header: Unpin, diff --git a/client/service/src/client/call_executor.rs b/client/service/src/client/call_executor.rs index facde72321db4..86b5c7c61fcd2 100644 --- a/client/service/src/client/call_executor.rs +++ b/client/service/src/client/call_executor.rs @@ -21,10 +21,13 @@ use sc_client_api::{ backend, call_executor::CallExecutor, execution_extensions::ExecutionExtensions, HeaderBackend, }; use sc_executor::{RuntimeVersion, RuntimeVersionOf}; -use sp_api::{ProofRecorder, StorageTransactionCache}; +use sp_api::ProofRecorder; use sp_core::traits::{CallContext, CodeExecutor, RuntimeCode}; use sp_externalities::Extensions; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, HashingFor}, +}; use sp_state_machine::{backend::AsTrieBackend, Ext, OverlayedChanges, StateMachine, StorageProof}; use std::{cell::RefCell, sync::Arc}; @@ -119,8 +122,7 @@ where ) -> sp_blockchain::Result { let mut overlay = OverlayedChanges::default(); - let mut cache = StorageTransactionCache::::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, state, None); + let mut ext = Ext::new(&mut overlay, state, None); self.executor .runtime_version(&mut ext, code) @@ -197,14 +199,11 @@ where at_hash: Block::Hash, method: &str, call_data: &[u8], - changes: &RefCell, - storage_transaction_cache: Option<&RefCell>>, + changes: &RefCell>>, recorder: &Option>, call_context: CallContext, extensions: &RefCell, ) -> Result, sp_blockchain::Error> { - let mut storage_transaction_cache = storage_transaction_cache.map(|c| c.borrow_mut()); - let state = self.backend.state_at(at_hash)?; let changes = &mut *changes.borrow_mut(); @@ -237,7 +236,6 @@ where &runtime_code, call_context, ) - .with_storage_transaction_cache(storage_transaction_cache.as_deref_mut()) .set_parent_hash(at_hash); state_machine.execute() }, @@ -252,7 +250,6 @@ where &runtime_code, call_context, ) - .with_storage_transaction_cache(storage_transaction_cache.as_deref_mut()) .set_parent_hash(at_hash); state_machine.execute() }, diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index d0a46ab2c0118..a0983d823e5b1 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -148,9 +148,9 @@ impl PrePostHeader { } } -enum PrepareStorageChangesResult, Block: BlockT> { +enum PrepareStorageChangesResult { Discard(ImportResult), - Import(Option>>), + Import(Option>), } /// Create an instance of in-memory client. @@ -489,15 +489,12 @@ where fn apply_block( &self, operation: &mut ClientImportOperation, - import_block: BlockImportParams>, - storage_changes: Option< - sc_consensus::StorageChanges>, - >, + import_block: BlockImportParams, + storage_changes: Option>, ) -> sp_blockchain::Result where Self: ProvideRuntimeApi, - >::Api: - CoreApi + ApiExt, + >::Api: CoreApi + ApiExt, { let BlockImportParams { origin, @@ -580,9 +577,7 @@ where justifications: Option, body: Option>, indexed_body: Option>>, - storage_changes: Option< - sc_consensus::StorageChanges>, - >, + storage_changes: Option>, finalized: bool, aux: Vec<(Vec, Option>)>, fork_choice: ForkChoiceStrategy, @@ -590,8 +585,7 @@ where ) -> sp_blockchain::Result where Self: ProvideRuntimeApi, - >::Api: - CoreApi + ApiExt, + >::Api: CoreApi + ApiExt, { let parent_hash = *import_headers.post().parent_hash(); let status = self.backend.blockchain().status(hash)?; @@ -830,12 +824,11 @@ where /// provided, the block is re-executed to get the storage changes. fn prepare_block_storage_changes( &self, - import_block: &mut BlockImportParams>, - ) -> sp_blockchain::Result> + import_block: &mut BlockImportParams, + ) -> sp_blockchain::Result> where Self: ProvideRuntimeApi, - >::Api: - CoreApi + ApiExt, + >::Api: CoreApi + ApiExt, { let parent_hash = import_block.header.parent_hash(); let state_action = std::mem::replace(&mut import_block.state_action, StateAction::Skip); @@ -1418,8 +1411,7 @@ where E: CallExecutor + Send + Sync + 'static, Block: BlockT, Self: ChainHeaderBackend + ProvideRuntimeApi, - >::Api: - ApiExt> + BlockBuilderApi, + >::Api: ApiExt + BlockBuilderApi, { fn new_block_at>( &self, @@ -1705,17 +1697,13 @@ where { type StateBackend = B::State; - fn call_api_at( - &self, - params: CallApiAtParams, - ) -> Result, sp_api::ApiError> { + fn call_api_at(&self, params: CallApiAtParams) -> Result, sp_api::ApiError> { self.executor .contextual_call( params.at, params.function, ¶ms.arguments, params.overlayed_changes, - Some(params.storage_transaction_cache), params.recorder, params.call_context, params.extensions, @@ -1754,13 +1742,10 @@ where E: CallExecutor + Send + Sync, Block: BlockT, Client: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - CoreApi + ApiExt, + as ProvideRuntimeApi>::Api: CoreApi + ApiExt, RA: Sync + Send, - backend::TransactionFor: Send + 'static, { type Error = ConsensusError; - type Transaction = backend::TransactionFor; /// Import a checked and validated block. If a justification is provided in /// `BlockImportParams` then `finalized` *must* be true. @@ -1773,7 +1758,7 @@ where /// algorithm, don't use this function. async fn import_block( &mut self, - mut import_block: BlockImportParams>, + mut import_block: BlockImportParams, ) -> Result { let span = tracing::span!(tracing::Level::DEBUG, "import_block"); let _enter = span.enter(); @@ -1867,17 +1852,14 @@ where E: CallExecutor + Send + Sync, Block: BlockT, Self: ProvideRuntimeApi, - >::Api: - CoreApi + ApiExt, + >::Api: CoreApi + ApiExt, RA: Sync + Send, - backend::TransactionFor: Send + 'static, { type Error = ConsensusError; - type Transaction = backend::TransactionFor; async fn import_block( &mut self, - import_block: BlockImportParams, + import_block: BlockImportParams, ) -> Result { (&*self).import_block(import_block).await } diff --git a/frame/contracts/src/address.rs b/frame/contracts/src/address.rs index e36fc6fffd6f7..5758daf7b1ff8 100644 --- a/frame/contracts/src/address.rs +++ b/frame/contracts/src/address.rs @@ -40,12 +40,6 @@ pub trait AddressGenerator { input_data: &[u8], salt: &[u8], ) -> T::AccountId; - - /// The address of the deposit account of `contract_addr`. - /// - /// The address is generated once on instantiation and then stored in the contracts - /// metadata. Hence changes do only affect newly created contracts. - fn deposit_address(contract_addr: &T::AccountId) -> T::AccountId; } /// Default address generator. @@ -71,11 +65,4 @@ impl AddressGenerator for DefaultAddressGenerator { Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) .expect("infinite length input; no invalid inputs for type; qed") } - - /// Formula: `hash("contract_depo_v1" ++ contract_addr)` - fn deposit_address(contract_addr: &T::AccountId) -> T::AccountId { - let entropy = (b"contract_depo_v1", contract_addr).using_encoded(T::Hashing::hash); - Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) - .expect("infinite length input; no invalid inputs for type; qed") - } } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 84e46e47b609f..ac5787e234041 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -30,7 +30,9 @@ use self::{ }; use crate::{ exec::{AccountIdOf, Key}, - migration::{codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, MigrationStep}, + migration::{ + codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, v15, MigrationStep, + }, wasm::CallFlags, Pallet as Contracts, *, }; @@ -296,6 +298,19 @@ benchmarks! { m.step(); } + // This benchmarks the v15 migration step (remove deposit account). + #[pov_mode = Measured] + v15_migration_step { + let contract = >::with_caller( + whitelisted_caller(), WasmModule::dummy(), vec![], + )?; + + v15::store_old_contract_info::(contract.account_id.clone(), contract.info()?); + let mut m = v15::Migration::::default(); + }: { + m.step(); + } + // This benchmarks the weight of executing Migration::migrate to execute a noop migration. #[pov_mode = Measured] migration_noop { @@ -397,10 +412,9 @@ benchmarks! { let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); }: _(origin, value, Weight::MAX, None, code, input, salt) verify { - let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::balance(&deposit_account); + let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); // uploading the code reserves some balance in the callers account - let code_deposit = T::Currency::total_balance_on_hold(&caller); + let code_deposit = T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &caller); assert_eq!( T::Currency::balance(&caller), caller_funding::() - value - deposit - code_deposit - Pallet::::min_balance(), @@ -427,8 +441,7 @@ benchmarks! { Contracts::::store_code_raw(code, caller.clone())?; }: _(origin, value, Weight::MAX, None, hash, input, salt) verify { - let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::balance(&deposit_account); + let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr); // value was removed from the caller assert_eq!( T::Currency::balance(&caller), @@ -451,15 +464,13 @@ benchmarks! { let instance = Contract::::with_caller( whitelisted_caller(), WasmModule::dummy(), vec![], )?; - let deposit_account = instance.info()?.deposit_account().clone(); let value = Pallet::::min_balance(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); let before = T::Currency::balance(&instance.account_id); - let before_deposit = T::Currency::balance(&deposit_account); }: _(origin, callee, value, Weight::MAX, None, data) verify { - let deposit = T::Currency::balance(&deposit_account); + let deposit = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id); // value and value transferred via call should be removed from the caller assert_eq!( T::Currency::balance(&instance.caller), @@ -930,15 +941,14 @@ benchmarks! { }); let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); - let deposit_account = instance.info()?.deposit_account().clone(); assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into()); assert_eq!(T::Currency::balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); - assert_ne!(T::Currency::balance(&deposit_account), 0u32.into()); + assert_ne!(T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(T::Currency::total_balance(&deposit_account), 0u32.into()); + assert_eq!(T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into()); assert_eq!(T::Currency::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 6d1f3df90f23e..664504d207f3a 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -79,7 +79,7 @@ use frame_support::weights::Weight; use sp_runtime::DispatchError; use sp_std::{marker::PhantomData, vec::Vec}; -pub use crate::{exec::Ext, gas::ChargedAmount, Config}; +pub use crate::{exec::Ext, gas::ChargedAmount, storage::meter::Diff, Config}; pub use frame_system::Config as SysConfig; pub use pallet_contracts_primitives::ReturnFlags; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 9e5fd780ac6ca..a4d0760e6c0ac 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -19,10 +19,10 @@ use crate::unsafe_debug::ExecutionObserver; use crate::{ gas::GasMeter, - storage::{self, DepositAccount, WriteOutcome}, + storage::{self, meter::Diff, WriteOutcome}, BalanceOf, CodeHash, CodeInfo, CodeInfoOf, Config, ContractInfo, ContractInfoOf, DebugBufferVec, Determinism, Error, Event, Nonce, Origin, Pallet as Contracts, Schedule, - System, WasmBlob, LOG_TARGET, + WasmBlob, LOG_TARGET, }; use frame_support::{ crypto::ecdsa::ECDSAExt, @@ -33,7 +33,7 @@ use frame_support::{ storage::{with_transaction, TransactionOutcome}, traits::{ fungible::{Inspect, Mutate}, - tokens::{Fortitude::Polite, Preservation}, + tokens::Preservation, Contains, OriginTrait, Randomness, Time, }, weights::Weight, @@ -274,6 +274,9 @@ pub trait Ext: sealing::Sealed { /// Get a mutable reference to the nested gas meter. fn gas_meter_mut(&mut self) -> &mut GasMeter; + /// Charges `diff` from the meter. + fn charge_storage(&mut self, diff: &Diff); + /// Append a string to the debug buffer. /// /// It is added as-is without any additional new line. @@ -544,7 +547,7 @@ enum CachedContract { /// /// In this case a reload is neither allowed nor possible. Please note that recursive /// calls cannot remove a contract as this is checked and denied. - Terminated(DepositAccount), + Terminated, } impl CachedContract { @@ -565,15 +568,6 @@ impl CachedContract { None } } - - /// Returns `Some` iff the contract is not `Cached::Invalidated`. - fn deposit_account(&self) -> Option<&DepositAccount> { - match self { - CachedContract::Cached(contract) => Some(contract.deposit_account()), - CachedContract::Terminated(deposit_account) => Some(&deposit_account), - CachedContract::Invalidated => None, - } - } } impl Frame { @@ -652,9 +646,7 @@ impl CachedContract { /// Terminate and return the contract info. fn terminate(&mut self, account_id: &T::AccountId) -> ContractInfo { self.load(account_id); - let contract = get_cached_or_panic_after_load!(self); - let deposit_account = contract.deposit_account().clone(); - get_cached_or_panic_after_load!(mem::replace(self, Self::Terminated(deposit_account))) + get_cached_or_panic_after_load!(mem::replace(self, Self::Terminated)) } } @@ -952,7 +944,7 @@ where match (entry_point, delegated_code_hash) { (ExportedFunction::Constructor, _) => { // It is not allowed to terminate a contract inside its constructor. - if matches!(frame.contract_info, CachedContract::Terminated(_)) { + if matches!(frame.contract_info, CachedContract::Terminated) { return Err(Error::::TerminatedInConstructor.into()) } @@ -1056,18 +1048,8 @@ where // in its contract info. The load is necessary to pull it from storage in case // it was invalidated. frame.contract_info.load(account_id); - let deposit_account = frame - .contract_info - .deposit_account() - .expect( - "Is only `None` when the info is invalidated. - We just re-loaded from storage which either makes the state `Cached` or `Terminated`. - qed", - ) - .clone(); let mut contract = frame.contract_info.into_contract(); - prev.nested_storage - .absorb(frame.nested_storage, deposit_account, contract.as_mut()); + prev.nested_storage.absorb(frame.nested_storage, account_id, contract.as_mut()); // In case the contract wasn't terminated we need to persist changes made to it. if let Some(contract) = contract { @@ -1102,14 +1084,10 @@ where if !persist { return } - let deposit_account = self.first_frame.contract_info.deposit_account().expect( - "Is only `None` when the info is invalidated. The first frame can't be invalidated. - qed", - ).clone(); let mut contract = self.first_frame.contract_info.as_contract(); self.storage_meter.absorb( mem::take(&mut self.first_frame.nested_storage), - deposit_account, + &self.first_frame.account_id, contract.as_deref_mut(), ); if let Some(contract) = contract { @@ -1308,14 +1286,8 @@ where } let frame = self.top_frame_mut(); let info = frame.terminate(); - frame.nested_storage.terminate(&info); - System::::dec_consumers(&frame.account_id); - Self::transfer( - Preservation::Expendable, - &frame.account_id, - beneficiary, - T::Currency::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), - )?; + frame.nested_storage.terminate(&info, beneficiary.clone()); + info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); E::decrement_refcount(info.code_hash); @@ -1324,7 +1296,7 @@ where E::decrement_refcount(*code_hash); frame .nested_storage - .charge_deposit(info.deposit_account().clone(), StorageDeposit::Refund(*deposit)); + .charge_deposit(frame.account_id.clone(), StorageDeposit::Refund(*deposit)); } Contracts::::deposit_event( @@ -1451,6 +1423,10 @@ where &mut self.top_frame_mut().nested_gas } + fn charge_storage(&mut self, diff: &Diff) { + self.top_frame_mut().nested_storage.charge(diff) + } + fn append_debug_buffer(&mut self, msg: &str) -> bool { if let Some(buffer) = &mut self.debug_message { buffer @@ -1514,8 +1490,7 @@ where let deposit = StorageDeposit::Charge(new_base_deposit) .saturating_sub(&StorageDeposit::Charge(old_base_deposit)); - let deposit_account = info.deposit_account().clone(); - frame.nested_storage.charge_deposit(deposit_account, deposit); + frame.nested_storage.charge_deposit(frame.account_id.clone(), deposit); E::increment_refcount(hash)?; E::decrement_refcount(prev_hash); @@ -1566,7 +1541,7 @@ where >::increment_refcount(code_hash)?; frame .nested_storage - .charge_deposit(info.deposit_account().clone(), StorageDeposit::Charge(deposit)); + .charge_deposit(frame.account_id.clone(), StorageDeposit::Charge(deposit)); Ok(()) } @@ -1582,7 +1557,7 @@ where frame .nested_storage - .charge_deposit(info.deposit_account().clone(), StorageDeposit::Refund(deposit)); + .charge_deposit(frame.account_id.clone(), StorageDeposit::Refund(deposit)); Ok(()) } } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 37b79c2d585ad..a511ac81a73b7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -187,7 +187,7 @@ pub mod pallet { use sp_runtime::Perbill; /// The current storage version. - pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(14); + pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(15); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -899,6 +899,20 @@ pub mod pallet { /// The code hash that was delegate called. code_hash: CodeHash, }, + + /// Some funds have been transferred and held as storage deposit. + StorageDepositTransferredAndHeld { + from: T::AccountId, + to: T::AccountId, + amount: BalanceOf, + }, + + /// Some storage deposit funds have been transferred and released. + StorageDepositTransferredAndReleased { + from: T::AccountId, + to: T::AccountId, + amount: BalanceOf, + }, } #[pallet::error] @@ -999,6 +1013,8 @@ pub mod pallet { pub enum HoldReason { /// The Pallet has reserved it for storing code on-chain. CodeUploadDepositReserve, + /// The Pallet has reserved it for storage deposit. + StorageDepositReserve, } /// A mapping from a contract's code hash to its code. diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 106b68dc4416e..d8ebc25ed9a22 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -63,6 +63,7 @@ pub mod v11; pub mod v12; pub mod v13; pub mod v14; +pub mod v15; include!(concat!(env!("OUT_DIR"), "/migration_codegen.rs")); use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 3fc7cabe94942..e33c8d080ad9f 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -19,7 +19,6 @@ //! See . use crate::{ - address::AddressGenerator, exec::AccountIdOf, migration::{IsFinished, MigrationStep}, weights::WeightInfo, @@ -40,7 +39,10 @@ use frame_support::{ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; -use sp_runtime::{traits::Zero, Perbill, Saturating}; +use sp_runtime::{ + traits::{Hash, TrailingZeroInput, Zero}, + Perbill, Saturating, +}; use sp_std::{ops::Deref, prelude::*}; mod old { @@ -135,6 +137,16 @@ type ContractInfoOf = StorageMap< ContractInfo, >; +/// Formula: `hash("contract_depo_v1" ++ contract_addr)` +fn deposit_address( + contract_addr: &::AccountId, +) -> ::AccountId { + let entropy = (b"contract_depo_v1", contract_addr) + .using_encoded(::Hashing::hash); + Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) + .expect("infinite length input; no invalid inputs for type; qed") +} + impl MigrationStep for Migration where OldCurrency: ReservableCurrency<::AccountId> @@ -162,8 +174,7 @@ where log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); // Get the new deposit account address - let deposit_account: DepositAccount = - DepositAccount(T::AddressGenerator::deposit_address(&account)); + let deposit_account: DepositAccount = DepositAccount(deposit_address::(&account)); // Calculate the existing deposit, that should be reserved on the contract account let old_deposit = contract diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index ade837f46e9b1..774b04a9c65d7 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -20,9 +20,8 @@ use crate::{ migration::{IsFinished, MigrationStep}, - storage::DepositAccount, weights::WeightInfo, - BalanceOf, CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, + AccountIdOf, BalanceOf, CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; use frame_support::{codec, pallet_prelude::*, storage_alias, DefaultNoBound}; @@ -30,15 +29,13 @@ use sp_runtime::BoundedBTreeMap; use sp_std::prelude::*; mod old { - use crate::storage::DepositAccount; - use super::*; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] pub struct ContractInfo { pub trie_id: TrieId, - pub deposit_account: DepositAccount, + pub deposit_account: AccountIdOf, pub code_hash: CodeHash, pub storage_bytes: u32, pub storage_items: u32, @@ -58,9 +55,13 @@ mod old { #[cfg(feature = "runtime-benchmarks")] pub fn store_old_contract_info(account: T::AccountId, info: crate::ContractInfo) { + use sp_runtime::traits::{Hash, TrailingZeroInput}; + let entropy = (b"contract_depo_v1", account.clone()).using_encoded(T::Hashing::hash); + let deposit_account = Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) + .expect("infinite length input; no invalid inputs for type; qed"); let info = old::ContractInfo { trie_id: info.trie_id.clone(), - deposit_account: info.deposit_account().clone(), + deposit_account, code_hash: info.code_hash, storage_bytes: Default::default(), storage_items: Default::default(), @@ -79,7 +80,7 @@ pub type ContractInfoOf = #[scale_info(skip_type_params(T))] pub struct ContractInfo { trie_id: TrieId, - deposit_account: DepositAccount, + deposit_account: AccountIdOf, code_hash: CodeHash, storage_bytes: u32, storage_items: u32, diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index ebf97af562ed4..0daa0ceb5548a 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -15,7 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Update the code owner balance, make the storage deposit reserved balance to be held instead. +//! Update the code owner balance, make the code upload deposit balance to be held instead of +//! reserved. Since [`Currency`](frame_support::traits::Currency) has been +//! [deprecated](https://github.com/paritytech/substrate/pull/12951), we need the deposits to be +//! handled by the [`frame_support::traits::fungible`] traits. use crate::{ exec::AccountIdOf, @@ -102,7 +105,7 @@ where T: Config, OldCurrency: ReservableCurrency<::AccountId>, { - /// Total reserved balance as storage deposit for the owner. + /// Total reserved balance as code upload deposit for the owner. reserved: old::BalanceOf, /// Total balance of the owner. total: old::BalanceOf, @@ -140,7 +143,7 @@ where }; if let Some((hash, code_info)) = iter.next() { - log::debug!(target: LOG_TARGET, "Migrating storage deposit for 0x{:?}", HexDisplay::from(&code_info.owner.encode())); + log::debug!(target: LOG_TARGET, "Migrating code upload deposit for 0x{:?}", HexDisplay::from(&code_info.owner.encode())); let remaining = OldCurrency::unreserve(&code_info.owner, code_info.deposit); @@ -185,7 +188,7 @@ where self.last_code_hash = Some(hash); (IsFinished::No, T::WeightInfo::v14_migration_step()) } else { - log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); + log::debug!(target: LOG_TARGET, "No more code upload deposit to migrate"); (IsFinished::Yes, T::WeightInfo::v14_migration_step()) } } @@ -197,8 +200,8 @@ where let mut owner_balance_allocation = BTreeMap::, BalanceAllocation>::new(); - // Calculates the balance allocation by accumulating the storage deposits of all codes owned - // by an owner. + // Calculates the balance allocation by accumulating the code upload deposits of all codes + // owned by an owner. for (_, code_info) in info { owner_balance_allocation .entry(code_info.owner.clone()) @@ -229,7 +232,7 @@ where T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &owner); log::debug!( target: LOG_TARGET, - "Validating storage deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", + "Validating code upload deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", HexDisplay::from(&owner.encode()), old_balance_allocation.reserved, held @@ -260,7 +263,7 @@ where log::info!( target: LOG_TARGET, - "Total held amount for storage deposit: {:?}", + "Total held amount for code upload deposit: {:?}", total_held ); diff --git a/frame/contracts/src/migration/v15.rs b/frame/contracts/src/migration/v15.rs new file mode 100644 index 0000000000000..efece62905ff8 --- /dev/null +++ b/frame/contracts/src/migration/v15.rs @@ -0,0 +1,327 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Move contracts' _reserved_ balance from the `deposit_account` to be _held_ in the contract's +//! account instead. Since [`Currency`](frame_support::traits::Currency) has been +//! [deprecated](https://github.com/paritytech/substrate/pull/12951), we need the deposits to be +//! handled by the [`frame_support::traits::fungible`] traits instead. For this transfer the +//! balance from the deposit account to the contract's account and hold it in there. +//! Then the deposit account is not needed anymore and we can get rid of it. + +use crate::{ + migration::{IsFinished, MigrationStep}, + weights::WeightInfo, + AccountIdOf, BalanceOf, CodeHash, Config, HoldReason, Pallet, TrieId, Weight, LOG_TARGET, +}; +#[cfg(feature = "try-runtime")] +use frame_support::{dispatch::Vec, traits::fungible::InspectHold}; +use frame_support::{ + pallet_prelude::*, + storage_alias, + traits::{ + fungible::{Mutate, MutateHold}, + tokens::{fungible::Inspect, Fortitude, Preservation}, + }, + BoundedBTreeMap, DefaultNoBound, +}; +use frame_system::Pallet as System; +use sp_core::hexdisplay::HexDisplay; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; +use sp_runtime::{traits::Zero, Saturating}; + +mod old { + use super::*; + + #[derive( + Encode, Decode, CloneNoBound, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen, + )] + #[scale_info(skip_type_params(T))] + pub struct ContractInfo { + pub trie_id: TrieId, + pub deposit_account: AccountIdOf, + pub code_hash: CodeHash, + pub storage_bytes: u32, + pub storage_items: u32, + pub storage_byte_deposit: BalanceOf, + pub storage_item_deposit: BalanceOf, + pub storage_base_deposit: BalanceOf, + pub delegate_dependencies: + BoundedBTreeMap, BalanceOf, T::MaxDelegateDependencies>, + } + + #[storage_alias] + pub type ContractInfoOf = StorageMap< + Pallet, + Twox64Concat, + ::AccountId, + ContractInfo, + >; +} + +#[cfg(feature = "runtime-benchmarks")] +pub fn store_old_contract_info(account: T::AccountId, info: crate::ContractInfo) { + use sp_runtime::traits::{Hash, TrailingZeroInput}; + let entropy = (b"contract_depo_v1", account.clone()).using_encoded(T::Hashing::hash); + let deposit_account = Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) + .expect("infinite length input; no invalid inputs for type; qed"); + let info = old::ContractInfo { + trie_id: info.trie_id.clone(), + deposit_account, + code_hash: info.code_hash, + storage_bytes: Default::default(), + storage_items: Default::default(), + storage_byte_deposit: info.storage_byte_deposit, + storage_item_deposit: Default::default(), + storage_base_deposit: info.storage_base_deposit(), + delegate_dependencies: info.delegate_dependencies().clone(), + }; + old::ContractInfoOf::::insert(account, info); +} + +#[derive(Encode, Decode, CloneNoBound, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +#[scale_info(skip_type_params(T))] +struct ContractInfo { + pub trie_id: TrieId, + pub code_hash: CodeHash, + pub storage_bytes: u32, + pub storage_items: u32, + pub storage_byte_deposit: BalanceOf, + pub storage_item_deposit: BalanceOf, + pub storage_base_deposit: BalanceOf, + pub delegate_dependencies: + BoundedBTreeMap, BalanceOf, T::MaxDelegateDependencies>, +} + +#[storage_alias] +type ContractInfoOf = + StorageMap, Twox64Concat, ::AccountId, ContractInfo>; + +#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] +pub struct Migration { + last_account: Option, +} + +impl MigrationStep for Migration { + const VERSION: u16 = 15; + + fn max_step_weight() -> Weight { + T::WeightInfo::v15_migration_step() + } + + fn step(&mut self) -> (IsFinished, Weight) { + let mut iter = if let Some(last_account) = self.last_account.take() { + old::ContractInfoOf::::iter_from(old::ContractInfoOf::::hashed_key_for( + last_account, + )) + } else { + old::ContractInfoOf::::iter() + }; + + if let Some((account, old_contract)) = iter.next() { + let deposit_account = &old_contract.deposit_account; + System::::dec_consumers(deposit_account); + + // Get the deposit balance to transfer. + let total_deposit_balance = T::Currency::total_balance(deposit_account); + let reducible_deposit_balance = T::Currency::reducible_balance( + deposit_account, + Preservation::Expendable, + Fortitude::Force, + ); + + if total_deposit_balance > reducible_deposit_balance { + // This should never happen, as by design all balance in the deposit account is + // storage deposit and therefore reducible after decrementing the consumer + // reference. + log::warn!( + target: LOG_TARGET, + "Deposit account 0x{:?} for contract 0x{:?} has some non-reducible balance {:?} from a total of {:?} that will remain in there.", + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()), + total_deposit_balance.saturating_sub(reducible_deposit_balance), + total_deposit_balance + ); + } + + // Move balance reserved from the deposit account back to the contract account. + // Let the deposit account die. + log::debug!( + target: LOG_TARGET, + "Transferring {:?} from the deposit account 0x{:?} to the contract 0x{:?}.", + reducible_deposit_balance, + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()) + ); + let transferred_deposit_balance = T::Currency::transfer( + deposit_account, + &account, + reducible_deposit_balance, + Preservation::Expendable, + ) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to transfer {:?} from the deposit account 0x{:?} to the contract 0x{:?}, reason: {:?}.", + reducible_deposit_balance, + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()), + err + ); + Zero::zero() + }); + + // Hold the reserved balance. + if transferred_deposit_balance == Zero::zero() { + log::warn!( + target: LOG_TARGET, + "No balance to hold as storage deposit on the contract 0x{:?}.", + HexDisplay::from(&account.encode()) + ); + } else { + log::debug!( + target: LOG_TARGET, + "Holding {:?} as storage deposit on the contract 0x{:?}.", + transferred_deposit_balance, + HexDisplay::from(&account.encode()) + ); + + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &account, + transferred_deposit_balance, + ) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} as storage deposit on the contract 0x{:?}, reason: {:?}.", + transferred_deposit_balance, + HexDisplay::from(&account.encode()), + err + ); + }); + } + + log::debug!(target: LOG_TARGET, "==="); + let info = ContractInfo { + trie_id: old_contract.trie_id, + code_hash: old_contract.code_hash, + storage_bytes: old_contract.storage_bytes, + storage_items: old_contract.storage_items, + storage_byte_deposit: old_contract.storage_byte_deposit, + storage_item_deposit: old_contract.storage_item_deposit, + storage_base_deposit: old_contract.storage_base_deposit, + delegate_dependencies: old_contract.delegate_dependencies, + }; + ContractInfoOf::::insert(account.clone(), info); + + // Store last key for next migration step + self.last_account = Some(account); + + (IsFinished::No, T::WeightInfo::v15_migration_step()) + } else { + log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); + (IsFinished::Yes, T::WeightInfo::v15_migration_step()) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade_step() -> Result, TryRuntimeError> { + let sample: Vec<_> = old::ContractInfoOf::::iter().take(100).collect(); + + log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); + + let state: Vec<(T::AccountId, old::ContractInfo, BalanceOf, BalanceOf)> = sample + .iter() + .map(|(account, contract)| { + ( + account.clone(), + contract.clone(), + T::Currency::total_balance(&account), + T::Currency::total_balance(&contract.deposit_account), + ) + }) + .collect(); + + Ok(state.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { + let sample = + , BalanceOf, BalanceOf)> as Decode>::decode( + &mut &state[..], + ) + .expect("pre_upgrade_step provides a valid state; qed"); + + log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); + for (account, old_contract, old_account_balance, old_deposit_balance) in sample { + log::debug!(target: LOG_TARGET, "==="); + log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); + + let on_hold = + T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &account); + let account_balance = T::Currency::total_balance(&account); + + log::debug!( + target: LOG_TARGET, + "Validating balances match. Old deposit account's balance: {:?}. Contract's on hold: {:?}. Old contract's total balance: {:?}, Contract's total balance: {:?}.", + old_deposit_balance, + on_hold, + old_account_balance, + account_balance + ); + ensure!( + old_account_balance.saturating_add(old_deposit_balance) == account_balance, + "total balance mismatch" + ); + ensure!(old_deposit_balance == on_hold, "deposit mismatch"); + ensure!( + !System::::account_exists(&old_contract.deposit_account), + "deposit account still exists" + ); + + let migration_contract_info = ContractInfoOf::::try_get(&account).unwrap(); + let crate_contract_info = crate::ContractInfoOf::::try_get(&account).unwrap(); + ensure!( + migration_contract_info.trie_id == crate_contract_info.trie_id, + "trie_id mismatch" + ); + ensure!( + migration_contract_info.code_hash == crate_contract_info.code_hash, + "code_hash mismatch" + ); + ensure!( + migration_contract_info.storage_byte_deposit == + crate_contract_info.storage_byte_deposit, + "storage_byte_deposit mismatch" + ); + ensure!( + migration_contract_info.storage_base_deposit == + crate_contract_info.storage_base_deposit(), + "storage_base_deposit mismatch" + ); + ensure!( + &migration_contract_info.delegate_dependencies == + crate_contract_info.delegate_dependencies(), + "delegate_dependencies mismatch" + ); + } + + Ok(()) + } +} diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 7fbd697e509dc..d58fd0fe9dbdf 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -22,15 +22,15 @@ pub mod meter; use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, - AddressGenerator, BalanceOf, CodeHash, CodeInfo, Config, ContractInfoOf, DeletionQueue, - DeletionQueueCounter, Error, Pallet, TrieId, SENTINEL, + BalanceOf, CodeHash, CodeInfo, Config, ContractInfoOf, DeletionQueue, DeletionQueueCounter, + Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::DispatchError, storage::child::{self, ChildInfo}, weights::Weight, - CloneNoBound, DefaultNoBound, RuntimeDebugNoBound, + CloneNoBound, DefaultNoBound, }; use scale_info::TypeInfo; use sp_core::Get; @@ -39,7 +39,7 @@ use sp_runtime::{ traits::{Hash, Saturating, Zero}, BoundedBTreeMap, DispatchResult, RuntimeDebug, }; -use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; +use sp_std::{marker::PhantomData, prelude::*}; use self::meter::Diff; @@ -50,10 +50,6 @@ use self::meter::Diff; pub struct ContractInfo { /// Unique ID for the subtree encoded as a bytes vector. pub trie_id: TrieId, - /// The account that holds this contracts storage deposit. - /// - /// This is held in a separate account to prevent the contract from spending it. - deposit_account: DepositAccount, /// The code associated with a given account. pub code_hash: CodeHash, /// How many bytes of storage are accumulated in this contract's child trie. @@ -99,11 +95,8 @@ impl ContractInfo { .expect("Runtime uses a reasonable hash size. Hence sizeof(T::Hash) <= 128; qed") }; - let deposit_account = DepositAccount(T::AddressGenerator::deposit_address(account)); - let contract = Self { trie_id, - deposit_account, code_hash, storage_bytes: 0, storage_items: 0, @@ -133,11 +126,6 @@ impl ContractInfo { .saturating_sub(Pallet::::min_balance()) } - /// Returns the account that storage deposits should be deposited into. - pub fn deposit_account(&self) -> &DepositAccount { - &self.deposit_account - } - /// Returns the storage base deposit of the contract. pub fn storage_base_deposit(&self) -> BalanceOf { self.storage_base_deposit @@ -233,9 +221,9 @@ impl ContractInfo { let upload_deposit = T::CodeHashLockupDepositPercent::get().mul_ceil(code_info.deposit()); // Instantiate needs to transfer at least the minimum balance in order to pull the - // deposit account into existence. - // We also add another `ed` here which goes to the contract's own account into existence. - let deposit = info_deposit.saturating_add(upload_deposit).max(ed).saturating_add(ed); + // contract's own account into existence, as the deposit itself does not contribute to the + // `ed`. + let deposit = info_deposit.saturating_add(upload_deposit).saturating_add(ed); self.storage_base_deposit = deposit; deposit @@ -391,18 +379,6 @@ impl WriteOutcome { } } -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen)] -#[scale_info(skip_type_params(T))] -pub struct DepositAccount(AccountIdOf); - -impl Deref for DepositAccount { - type Target = AccountIdOf; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - /// Manage the removal of contracts storage that are marked for deletion. /// /// When a contract is deleted by calling `seal_terminate` it becomes inaccessible diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 93885b37b4795..2a9a083412b00 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -18,25 +18,28 @@ //! This module contains functions to meter the storage deposit. use crate::{ - storage::{ContractInfo, DepositAccount}, - BalanceOf, CodeInfo, Config, Error, Inspect, Origin, Pallet, StorageDeposit as Deposit, System, + storage::ContractInfo, AccountIdOf, BalanceOf, CodeInfo, Config, Error, Event, HoldReason, + Inspect, Origin, Pallet, StorageDeposit as Deposit, System, LOG_TARGET, }; use frame_support::{ dispatch::{fmt::Debug, DispatchError}, ensure, traits::{ - fungible::Mutate, - tokens::{Fortitude::Polite, Preservation, WithdrawConsequence}, + fungible::{Mutate, MutateHold}, + tokens::{ + Fortitude, Fortitude::Polite, Precision, Preservation, Restriction, WithdrawConsequence, + }, Get, }, DefaultNoBound, RuntimeDebugNoBound, }; +use sp_api::HashT; use sp_runtime::{ traits::{Saturating, Zero}, FixedPointNumber, FixedU128, }; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::{marker::PhantomData, vec, vec::Vec}; /// Deposit that uses the native fungible's balance type. pub type DepositOf = Deposit>; @@ -75,16 +78,15 @@ pub trait Ext { /// This is called to inform the implementer that some balance should be charged due to /// some interaction of the `origin` with a `contract`. /// - /// The balance transfer can either flow from `origin` to `deposit_account` or the other way + /// The balance transfer can either flow from `origin` to `contract` or the other way /// around depending on whether `amount` constitutes a `Charge` or a `Refund`. - /// It is guaranteed that this succeeds because no more balance than returned by - /// `check_limit` is ever charged. This is why this function is infallible. - /// `terminated` designates whether the `contract` was terminated. + /// It should be used in combination with `check_limit` to check that no more balance than this + /// limit is ever charged. fn charge( origin: &T::AccountId, - deposit_account: &DepositAccount, + contract: &T::AccountId, amount: &DepositOf, - terminated: bool, + state: &ContractState, ) -> Result<(), DispatchError>; } @@ -220,6 +222,15 @@ impl Diff { } } +/// The state of a contract. +/// +/// In case of termination the beneficiary is indicated. +#[derive(RuntimeDebugNoBound, Clone, PartialEq, Eq)] +pub enum ContractState { + Alive, + Terminated { beneficiary: AccountIdOf }, +} + /// Records information to charge or refund a plain account. /// /// All the charges are deferred to the end of a whole call stack. Reason is that by doing @@ -231,9 +242,9 @@ impl Diff { /// exhausted. #[derive(RuntimeDebugNoBound, Clone)] struct Charge { - deposit_account: DepositAccount, + contract: T::AccountId, amount: DepositOf, - terminated: bool, + state: ContractState, } /// Records the storage changes of a storage meter. @@ -245,8 +256,9 @@ enum Contribution { /// its execution. In this process the [`Diff`] was converted into a [`Deposit`]. Checked(DepositOf), /// The contract was terminated. In this process the [`Diff`] was converted into a [`Deposit`] - /// in order to calculate the refund. - Terminated(DepositOf), + /// in order to calculate the refund. Upon termination the `reducible_balance` in the + /// contract's account is transferred to the [`beneficiary`]. + Terminated { deposit: DepositOf, beneficiary: AccountIdOf }, } impl Contribution { @@ -254,7 +266,8 @@ impl Contribution { fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { match self { Self::Alive(diff) => diff.update_contract::(info), - Self::Terminated(deposit) | Self::Checked(deposit) => deposit.clone(), + Self::Terminated { deposit, beneficiary: _ } | Self::Checked(deposit) => + deposit.clone(), } } } @@ -279,7 +292,7 @@ where /// usage for this sub call separately. This is necessary because we want to exchange balance /// with the current contract we are interacting with. pub fn nested(&self, limit: BalanceOf) -> RawMeter { - debug_assert!(self.is_alive()); + debug_assert!(matches!(self.contract_state(), ContractState::Alive)); // If a special limit is specified higher than it is available, // we want to enforce the lesser limit to the nested meter, to fail in the sub-call. let limit = self.available().min(limit); @@ -293,7 +306,7 @@ where /// Absorb a child that was spawned to handle a sub call. /// /// This should be called whenever a sub call comes to its end and it is **not** reverted. - /// This does the actual balance transfer from/to `origin` and `deposit_account` based on the + /// This does the actual balance transfer from/to `origin` and `contract` based on the /// overall storage consumption of the call. It also updates the supplied contract info. /// /// In case a contract reverted the child meter should just be dropped in order to revert @@ -303,12 +316,12 @@ where /// /// - `absorbed`: The child storage meter that should be absorbed. /// - `origin`: The origin that spawned the original root meter. - /// - `deposit_account`: The contract's deposit account that this sub call belongs to. + /// - `contract`: The contract's account that this sub call belongs to. /// - `info`: The info of the contract in question. `None` if the contract was terminated. pub fn absorb( &mut self, absorbed: RawMeter, - deposit_account: DepositAccount, + contract: &T::AccountId, info: Option<&mut ContractInfo>, ) { let own_deposit = absorbed.own_contribution.update_contract(info); @@ -319,9 +332,9 @@ where self.charges.extend_from_slice(&absorbed.charges); if !own_deposit.is_zero() { self.charges.push(Charge { - deposit_account, + contract: contract.clone(), amount: own_deposit, - terminated: absorbed.is_terminated(), + state: absorbed.contract_state(), }); } } @@ -331,14 +344,13 @@ where self.total_deposit.available(&self.limit) } - /// True if the contract is alive. - fn is_alive(&self) -> bool { - matches!(self.own_contribution, Contribution::Alive(_)) - } - - /// True if the contract is terminated. - fn is_terminated(&self) -> bool { - matches!(self.own_contribution, Contribution::Terminated(_)) + /// Returns the state of the currently executed contract. + fn contract_state(&self) -> ContractState { + match &self.own_contribution { + Contribution::Terminated { deposit: _, beneficiary } => + ContractState::Terminated { beneficiary: beneficiary.clone() }, + _ => ContractState::Alive, + } } } @@ -375,7 +387,6 @@ where /// /// This drops the root meter in order to make sure it is only called when the whole /// execution did finish. - pub fn try_into_deposit(self, origin: &Origin) -> Result, DispatchError> { // Only refund or charge deposit if the origin is not root. let origin = match origin { @@ -383,10 +394,10 @@ where Origin::Signed(o) => o, }; for charge in self.charges.iter().filter(|c| matches!(c.amount, Deposit::Refund(_))) { - E::charge(origin, &charge.deposit_account, &charge.amount, charge.terminated)?; + E::charge(origin, &charge.contract, &charge.amount, &charge.state)?; } for charge in self.charges.iter().filter(|c| matches!(c.amount, Deposit::Charge(_))) { - E::charge(origin, &charge.deposit_account, &charge.amount, charge.terminated)?; + E::charge(origin, &charge.contract, &charge.amount, &charge.state)?; } Ok(self.total_deposit) } @@ -412,9 +423,9 @@ where /// change. This is the case when a `delegate_dependency` is added or removed, or when the /// `code_hash` is updated. [`Self::charge`] cannot be used here because we keep track of the /// deposit charge separately from the storage charge. - pub fn charge_deposit(&mut self, deposit_account: DepositAccount, amount: DepositOf) { + pub fn charge_deposit(&mut self, contract: T::AccountId, amount: DepositOf) { self.total_deposit = self.total_deposit.saturating_add(&amount); - self.charges.push(Charge { deposit_account, amount, terminated: false }); + self.charges.push(Charge { contract, amount, state: ContractState::Alive }); } /// Charges from `origin` a storage deposit for contract instantiation. @@ -427,7 +438,7 @@ where contract_info: &mut ContractInfo, code_info: &CodeInfo, ) -> Result, DispatchError> { - debug_assert!(self.is_alive()); + debug_assert!(matches!(self.contract_state(), ContractState::Alive)); let ed = Pallet::::min_balance(); let deposit = contract_info.update_base_deposit(&code_info); @@ -439,34 +450,32 @@ where // We do not increase `own_contribution` because this will be charged later when the // contract execution does conclude and hence would lead to a double charge. - self.total_deposit = deposit.clone(); + self.total_deposit = Deposit::Charge(ed); - // Normally, deposit charges are deferred to be able to coalesce them with refunds. - // However, we need to charge immediately so that the account is created before - // charges possibly below the ed are collected and fail. - E::charge( - origin, - contract_info.deposit_account(), - &deposit.saturating_sub(&Deposit::Charge(ed)), - false, - )?; - - System::::inc_consumers(contract_info.deposit_account())?; - - // We also need to make sure that the contract's account itself exists. + // We need to make sure that the contract's account exists. T::Currency::transfer(origin, contract, ed, Preservation::Preserve)?; + + // A consumer is added at account creation and removed it on termination, otherwise the + // runtime could remove the account. As long as a contract exists its account must exist. + // With the consumer, a correct runtime cannot remove the account. System::::inc_consumers(contract)?; + self.charge_deposit(contract.clone(), deposit.saturating_sub(&Deposit::Charge(ed))); + Ok(deposit) } - /// Call to tell the meter that the currently executing contract was executed. + /// Call to tell the meter that the currently executing contract was terminated. /// /// This will manipulate the meter so that all storage deposit accumulated in - /// `contract_info` will be refunded to the `origin` of the meter. - pub fn terminate(&mut self, info: &ContractInfo) { - debug_assert!(self.is_alive()); - self.own_contribution = Contribution::Terminated(Deposit::Refund(info.total_deposit())); + /// `contract_info` will be refunded to the `origin` of the meter. And the free + /// (`reducible_balance`) will be sent to the `beneficiary`. + pub fn terminate(&mut self, info: &ContractInfo, beneficiary: T::AccountId) { + debug_assert!(matches!(self.contract_state(), ContractState::Alive)); + self.own_contribution = Contribution::Terminated { + deposit: Deposit::Refund(info.total_deposit()), + beneficiary, + }; } /// [`Self::charge`] does not enforce the storage limit since we want to do this check as late @@ -485,7 +494,7 @@ where let deposit = self.own_contribution.update_contract(info); let total_deposit = self.total_deposit.saturating_add(&deposit); // We don't want to override a `Terminated` with a `Checked`. - if self.is_alive() { + if matches!(self.contract_state(), ContractState::Alive) { self.own_contribution = Contribution::Checked(deposit); } if let Deposit::Charge(amount) = total_deposit { @@ -533,31 +542,77 @@ impl Ext for ReservingExt { fn charge( origin: &T::AccountId, - deposit_account: &DepositAccount, + contract: &T::AccountId, amount: &DepositOf, - terminated: bool, + state: &ContractState, ) -> Result<(), DispatchError> { match amount { Deposit::Charge(amount) | Deposit::Refund(amount) if amount.is_zero() => return Ok(()), Deposit::Charge(amount) => { - T::Currency::transfer(origin, deposit_account, *amount, Preservation::Preserve)?; - Ok(()) + // This could fail if the `origin` does not have enough liquidity. Ideally, though, + // this should have been checked before with `check_limit`. + T::Currency::transfer_and_hold( + &HoldReason::StorageDepositReserve.into(), + origin, + contract, + *amount, + Precision::Exact, + Preservation::Preserve, + Fortitude::Polite, + )?; + + Pallet::::deposit_event( + vec![T::Hashing::hash_of(&origin), T::Hashing::hash_of(&contract)], + Event::StorageDepositTransferredAndHeld { + from: origin.clone(), + to: contract.clone(), + amount: *amount, + }, + ); }, Deposit::Refund(amount) => { - if terminated { - System::::dec_consumers(&deposit_account); - } - T::Currency::transfer( - deposit_account, + let transferred = T::Currency::transfer_on_hold( + &HoldReason::StorageDepositReserve.into(), + contract, origin, *amount, - // We can safely make it `Expendable` because our own consumer prevents a - // removal. - Preservation::Expendable, + Precision::BestEffort, + Restriction::Free, + Fortitude::Polite, )?; - Ok(()) + + Pallet::::deposit_event( + vec![T::Hashing::hash_of(&contract), T::Hashing::hash_of(&origin)], + Event::StorageDepositTransferredAndReleased { + from: contract.clone(), + to: origin.clone(), + amount: transferred, + }, + ); + + if transferred < *amount { + // This should never happen, if it does it means that there is a bug in the + // runtime logic. In the rare case this happens we try to refund as much as we + // can, thus the `Precision::BestEffort`. + log::error!( + target: LOG_TARGET, + "Failed to repatriate full storage deposit {:?} from contract {:?} to origin {:?}. Transferred {:?}.", + amount, contract, origin, transferred, + ); + } }, } + if let ContractState::::Terminated { beneficiary } = state { + System::::dec_consumers(&contract); + // Whatever is left in the contract is sent to the termination beneficiary. + T::Currency::transfer( + &contract, + &beneficiary, + T::Currency::reducible_balance(&contract, Preservation::Expendable, Polite), + Preservation::Expendable, + )?; + } + Ok(()) } } @@ -593,9 +648,9 @@ mod tests { #[derive(Debug, PartialEq, Eq, Clone)] struct Charge { origin: AccountIdOf, - contract: DepositAccount, + contract: AccountIdOf, amount: DepositOf, - terminated: bool, + state: ContractState, } #[derive(Default, Debug, PartialEq, Eq, Clone)] @@ -627,16 +682,16 @@ mod tests { fn charge( origin: &AccountIdOf, - contract: &DepositAccount, + contract: &AccountIdOf, amount: &DepositOf, - terminated: bool, + state: &ContractState, ) -> Result<(), DispatchError> { TestExtTestValue::mutate(|ext| { ext.charges.push(Charge { origin: origin.clone(), contract: contract.clone(), amount: amount.clone(), - terminated, + state: state.clone(), }) }); Ok(()) @@ -664,7 +719,6 @@ mod tests { fn new_info(info: StorageInfo) -> ContractInfo { ContractInfo:: { trie_id: Default::default(), - deposit_account: DepositAccount([0u8; 32].into()), code_hash: Default::default(), storage_bytes: info.bytes, storage_items: info.items, @@ -700,7 +754,7 @@ mod tests { // an empty charge does not create a `Charge` entry let mut nested0 = meter.nested(BalanceOf::::zero()); nested0.charge(&Default::default()); - meter.absorb(nested0, DepositAccount(BOB), None); + meter.absorb(nested0, &BOB, None); assert_eq!( TestExtTestValue::get(), @@ -722,21 +776,21 @@ mod tests { charges: vec![ Charge { origin: ALICE, - contract: DepositAccount(CHARLIE), + contract: CHARLIE, amount: Deposit::Refund(10), - terminated: false, + state: ContractState::Alive, }, Charge { origin: ALICE, - contract: DepositAccount(CHARLIE), + contract: CHARLIE, amount: Deposit::Refund(20), - terminated: false, + state: ContractState::Alive, }, Charge { origin: ALICE, - contract: DepositAccount(BOB), + contract: BOB, amount: Deposit::Charge(2), - terminated: false, + state: ContractState::Alive, }, ], }, @@ -777,7 +831,7 @@ mod tests { }); let mut nested1 = nested0.nested(BalanceOf::::zero()); nested1.charge(&Diff { items_removed: 5, ..Default::default() }); - nested0.absorb(nested1, DepositAccount(CHARLIE), Some(&mut nested1_info)); + nested0.absorb(nested1, &CHARLIE, Some(&mut nested1_info)); let mut nested2_info = new_info(StorageInfo { bytes: 100, @@ -787,10 +841,10 @@ mod tests { }); let mut nested2 = nested0.nested(BalanceOf::::zero()); nested2.charge(&Diff { items_removed: 7, ..Default::default() }); - nested0.absorb(nested2, DepositAccount(CHARLIE), Some(&mut nested2_info)); + nested0.absorb(nested2, &CHARLIE, Some(&mut nested2_info)); nested0.enforce_limit(Some(&mut nested0_info)).unwrap(); - meter.absorb(nested0, DepositAccount(BOB), Some(&mut nested0_info)); + meter.absorb(nested0, &BOB, Some(&mut nested0_info)); assert_eq!(meter.try_into_deposit(&test_case.origin).unwrap(), test_case.deposit); @@ -813,15 +867,15 @@ mod tests { charges: vec![ Charge { origin: ALICE, - contract: DepositAccount(CHARLIE), + contract: CHARLIE, amount: Deposit::Refund(119), - terminated: true, + state: ContractState::Terminated { beneficiary: CHARLIE }, }, Charge { origin: ALICE, - contract: DepositAccount(BOB), + contract: BOB, amount: Deposit::Charge(12), - terminated: false, + state: ContractState::Alive, }, ], }, @@ -857,11 +911,11 @@ mod tests { let mut nested1 = nested0.nested(BalanceOf::::zero()); nested1.charge(&Diff { items_removed: 5, ..Default::default() }); nested1.charge(&Diff { bytes_added: 20, ..Default::default() }); - nested1.terminate(&nested1_info); + nested1.terminate(&nested1_info, CHARLIE); nested0.enforce_limit(Some(&mut nested1_info)).unwrap(); - nested0.absorb(nested1, DepositAccount(CHARLIE), None); + nested0.absorb(nested1, &CHARLIE, None); - meter.absorb(nested0, DepositAccount(BOB), None); + meter.absorb(nested0, &BOB, None); assert_eq!(meter.try_into_deposit(&test_case.origin).unwrap(), test_case.deposit); assert_eq!(TestExtTestValue::get(), test_case.expected) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3132b8e39f7da..5c8fca43ab746 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -43,7 +43,7 @@ use frame_support::{ parameter_types, storage::child, traits::{ - fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateHold}, + fungible::{BalancedHold, Inspect, Mutate, MutateHold}, tokens::Preservation, ConstU32, ConstU64, Contains, OnIdle, OnInitialize, StorageVersion, }, @@ -60,7 +60,6 @@ use sp_runtime::{ traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, AccountId32, BuildStorage, Perbill, TokenError, }; -use std::ops::Deref; type Block = frame_system::mocking::MockBlock; @@ -93,20 +92,20 @@ macro_rules! assert_refcount { pub mod test_utils { - use super::{DepositPerByte, DepositPerItem, Hash, SysConfig, Test}; + use super::{Contracts, DepositPerByte, DepositPerItem, Hash, SysConfig, Test}; use crate::{ exec::AccountIdOf, BalanceOf, CodeHash, CodeInfo, CodeInfoOf, Config, ContractInfo, ContractInfoOf, Nonce, PristineCode, }; use codec::{Encode, MaxEncodedLen}; - use frame_support::traits::{fungible::Mutate, Currency}; + use frame_support::traits::fungible::{InspectHold, Mutate}; pub fn place_contract(address: &AccountIdOf, code_hash: CodeHash) { let nonce = >::mutate(|counter| { *counter += 1; *counter }); - set_balance(address, ::Currency::minimum_balance() * 10); + set_balance(address, Contracts::min_balance() * 10); >::insert(code_hash, CodeInfo::new(address.clone())); let contract = >::new(&address, nonce, code_hash).unwrap(); >::insert(address, contract); @@ -117,6 +116,12 @@ pub mod test_utils { pub fn get_balance(who: &AccountIdOf) -> u64 { ::Currency::free_balance(who) } + pub fn get_balance_on_hold( + reason: &::RuntimeHoldReason, + who: &AccountIdOf, + ) -> u64 { + ::Currency::balance_on_hold(reason.into(), who) + } pub fn get_contract(addr: &AccountIdOf) -> ContractInfo { get_contract_checked(addr).unwrap() } @@ -126,6 +131,15 @@ pub mod test_utils { pub fn get_code_deposit(code_hash: &CodeHash) -> BalanceOf { crate::CodeInfoOf::::get(code_hash).unwrap().deposit() } + pub fn contract_info_storage_deposit( + addr: &::AccountId, + ) -> BalanceOf { + let contract_info = self::get_contract(&addr); + let info_size = contract_info.encoded_size() as u64; + DepositPerByte::get() + .saturating_mul(info_size) + .saturating_add(DepositPerItem::get()) + } pub fn hash(s: &S) -> <::Hashing as Hash>::Output { <::Hashing as Hash>::hash_of(s) } @@ -696,7 +710,7 @@ fn instantiate_and_call_and_deposit_event() { ExtBuilder::default().existential_deposit(1).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let value = 100; // We determine the storage deposit limit after uploading because it depends on ALICEs free @@ -728,36 +742,9 @@ fn instantiate_and_call_and_deposit_event() { .account_id; assert!(ContractInfoOf::::contains_key(&addr)); - let contract = get_contract(&addr); - let deposit_account = contract.deposit_account().deref(); - assert_eq!( System::events(), vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { - account: deposit_account.clone(), - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { - account: deposit_account.clone(), - free_balance: 132, - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: 132, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::NewAccount { @@ -807,6 +794,17 @@ fn instantiate_and_call_and_deposit_event() { }), topics: vec![hash(&ALICE), hash(&addr)], }, + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: addr.clone(), + amount: test_utils::contract_info_storage_deposit(&addr), + } + ), + topics: vec![hash(&ALICE), hash(&addr)], + }, ] ); }); @@ -864,7 +862,7 @@ fn deposit_event_max_value_limit() { fn run_out_of_fuel_engine() { let (wasm, _code_hash) = compile_module::("run_out_of_gas").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( @@ -903,7 +901,7 @@ fn run_out_of_fuel_engine() { fn run_out_of_fuel_host() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -1169,7 +1167,7 @@ fn deploy_and_call_other_contract() { let (callee_wasm, callee_code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Create let _ = ::Currency::set_balance(&ALICE, 1_000_000); @@ -1210,36 +1208,9 @@ fn deploy_and_call_other_contract() { callee_code_hash.as_ref().to_vec(), )); - let callee = get_contract(&callee_addr); - let deposit_account = callee.deposit_account().deref(); - assert_eq!( System::events(), vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { - account: deposit_account.clone(), - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { - account: deposit_account.clone(), - free_balance: 132, - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: 132, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::NewAccount { @@ -1309,6 +1280,17 @@ fn deploy_and_call_other_contract() { }), topics: vec![hash(&Origin::::from_account_id(ALICE)), hash(&caller_addr)], }, + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: callee_addr.clone(), + amount: test_utils::contract_info_storage_deposit(&callee_addr), + } + ), + topics: vec![hash(&ALICE), hash(&callee_addr)], + }, ] ); }); @@ -1357,7 +1339,7 @@ fn delegate_call() { } #[test] -fn transfer_allow_death_cannot_kill_account() { +fn transfer_expendable_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); @@ -1383,6 +1365,12 @@ fn transfer_allow_death_cannot_kill_account() { let total_balance = ::Currency::total_balance(&addr); + assert_eq!( + test_utils::get_balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr), + test_utils::contract_info_storage_deposit(&addr) + ); + + // Some ot the total balance is held, so it can't be transferred. assert_err!( <::Currency as Mutate>::transfer( &addr, @@ -1390,7 +1378,7 @@ fn transfer_allow_death_cannot_kill_account() { total_balance, Preservation::Expendable, ), - TokenError::Frozen, + TokenError::FundsUnavailable, ); assert_eq!(::Currency::total_balance(&addr), total_balance); @@ -1402,11 +1390,13 @@ fn cannot_self_destruct_through_draning() { let (wasm, _code_hash) = compile_module::("drain").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let value = 1_000; + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, - 1_000, + value, GAS_LIMIT, None, Code::Upload(wasm), @@ -1436,7 +1426,7 @@ fn cannot_self_destruct_through_draning() { // Make sure the account wasn't remove by sending all free balance away. assert_eq!( ::Currency::total_balance(&addr), - 1_000 + ::Currency::minimum_balance(), + value + test_utils::contract_info_storage_deposit(&addr) + min_balance, ); }); } @@ -1446,7 +1436,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1464,10 +1454,12 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { .unwrap() .account_id; - // Check that the BOB contract has been instantiated and has the minimum balance - assert_eq!(get_contract(&addr).total_deposit(), min_balance); + let info_deposit = test_utils::contract_info_storage_deposit(&addr); + + // Check that the contract has been instantiated and has the minimum balance + assert_eq!(get_contract(&addr).total_deposit(), info_deposit); assert_eq!(get_contract(&addr).extra_deposit(), 0); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), info_deposit + min_balance); // Create 100 bytes of storage with a price of per byte and a single storage item of price 2 assert_ok!(Contracts::call( @@ -1478,7 +1470,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { None, 100u32.to_le_bytes().to_vec() )); - assert_eq!(get_contract(&addr).total_deposit(), min_balance + 102); + assert_eq!(get_contract(&addr).total_deposit(), info_deposit + 102); // Increase the byte price and trigger a refund. This should not have any influence because // the removal is pro rata and exactly those 100 bytes should have been removed. @@ -1494,8 +1486,8 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { // Make sure the account wasn't removed by the refund assert_eq!( - ::Currency::total_balance(get_contract(&addr).deposit_account()), - get_contract(&addr).total_deposit(), + ::Currency::total_balance(&addr), + get_contract(&addr).total_deposit() + min_balance, ); assert_eq!(get_contract(&addr).extra_deposit(), 2); }); @@ -1551,6 +1543,7 @@ fn self_destruct_works() { ExtBuilder::default().existential_deposit(1_000).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); let _ = ::Currency::set_balance(&DJANGO, 1_000_000); + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1569,7 +1562,9 @@ fn self_destruct_works() { .account_id; // Check that the BOB contract has been instantiated. - let contract = get_contract(&addr); + let _ = get_contract(&addr); + + let info_deposit = test_utils::contract_info_storage_deposit(&addr); // Drop all previous events initialize_block(2); @@ -1587,29 +1582,22 @@ fn self_destruct_works() { assert!(get_contract_checked(&addr).is_none()); assert_eq!(::Currency::total_balance(&addr), 0); - // check that the beneficiary (django) got remaining balance - let ed = ::Currency::minimum_balance(); - assert_eq!(::Currency::free_balance(DJANGO), 1_000_000 + 100_000 + ed); + // Check that the beneficiary (django) got remaining balance. + assert_eq!( + ::Currency::free_balance(DJANGO), + 1_000_000 + 100_000 + min_balance + ); + + // Check that the Alice is missing Django's benefit. Within ALICE's total balance there's + // also the code upload deposit held. + assert_eq!( + ::Currency::total_balance(&ALICE), + 1_000_000 - (100_000 + min_balance) + ); pretty_assertions::assert_eq!( System::events(), vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::KilledAccount { - account: addr.clone() - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: addr.clone(), - to: DJANGO, - amount: 100_000 + ed, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::Terminated { @@ -1626,19 +1614,30 @@ fn self_destruct_works() { }), topics: vec![hash(&Origin::::from_account_id(ALICE)), hash(&addr)], }, + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndReleased { + from: addr.clone(), + to: ALICE, + amount: info_deposit, + } + ), + topics: vec![hash(&addr), hash(&ALICE)], + }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::KilledAccount { - account: contract.deposit_account().deref().clone(), + account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: contract.deposit_account().deref().clone(), - to: ALICE, - amount: 1_000, + from: addr.clone(), + to: DJANGO, + amount: 100_000 + min_balance, }), topics: vec![], }, @@ -1785,7 +1784,7 @@ fn crypto_hashes() { fn transfer_return_code() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -1827,7 +1826,7 @@ fn call_return_code() { let (caller_code, _caller_hash) = compile_module::("call_return_code").unwrap(); let (callee_code, _callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); @@ -1947,7 +1946,7 @@ fn instantiate_return_code() { let (caller_code, _caller_hash) = compile_module::("instantiate_return_code").unwrap(); let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); let callee_hash = callee_hash.as_ref().to_vec(); @@ -2049,7 +2048,7 @@ fn instantiate_return_code() { fn disabled_chain_extension_wont_deploy() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); TestExtension::disable(); assert_err_ignore_postinfo!( @@ -2071,7 +2070,7 @@ fn disabled_chain_extension_wont_deploy() { fn disabled_chain_extension_errors_on_call() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2099,7 +2098,7 @@ fn disabled_chain_extension_errors_on_call() { fn chain_extension_works() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2246,7 +2245,7 @@ fn chain_extension_works() { fn chain_extension_temp_storage_works() { let (code, _hash) = compile_module::("chain_extension_temp_storage").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2293,7 +2292,7 @@ fn chain_extension_temp_storage_works() { fn lazy_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -2345,7 +2344,7 @@ fn lazy_removal_works() { fn lazy_batch_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; @@ -2413,7 +2412,7 @@ fn lazy_removal_partial_remove_works() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let trie = ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -2495,7 +2494,7 @@ fn lazy_removal_partial_remove_works() { fn lazy_removal_does_no_run_on_low_remaining_weight() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -2567,7 +2566,7 @@ fn lazy_removal_does_not_use_all_weight() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let (trie, vals, weight_per_key) = ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -2655,7 +2654,7 @@ fn deletion_queue_ring_buffer_overflow() { ext.commit_all().unwrap(); ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; @@ -2716,7 +2715,7 @@ fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Create two contracts with the same code and check that they do in fact share it. let addr0 = Contracts::bare_instantiate( @@ -2924,7 +2923,7 @@ fn gas_estimation_nested_call_fixed_limit() { let (caller_code, _caller_hash) = compile_module::("call_with_limit").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( @@ -3020,7 +3019,7 @@ fn gas_estimation_call_runtime() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); @@ -3098,7 +3097,7 @@ fn call_runtime_reentrancy_guarded() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); @@ -3229,7 +3228,7 @@ fn ecdsa_recover() { fn bare_instantiate_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( @@ -3254,7 +3253,7 @@ fn bare_instantiate_returns_events() { fn bare_instantiate_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( @@ -3279,7 +3278,7 @@ fn bare_instantiate_does_not_return_events() { fn bare_call_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -3320,7 +3319,7 @@ fn bare_call_returns_events() { fn bare_call_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( @@ -3733,7 +3732,7 @@ fn instantiate_with_zero_balance_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Drop previous events initialize_block(2); @@ -3754,15 +3753,15 @@ fn instantiate_with_zero_balance_works() { .unwrap() .account_id; - // Check that the BOB contract has been instantiated. - let contract = get_contract(&addr); - let deposit_account = contract.deposit_account().deref(); // Ensure the contract was stored and get expected deposit amount to be reserved. let deposit_expected = expected_deposit(ensure_stored(code_hash)); // Make sure the account exists even though no free balance was send assert_eq!(::Currency::free_balance(&addr), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance,); + assert_eq!( + ::Currency::total_balance(&addr), + min_balance + test_utils::contract_info_storage_deposit(&addr) + ); assert_eq!( System::events(), @@ -3776,30 +3775,6 @@ fn instantiate_with_zero_balance_works() { }), topics: vec![code_hash], }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { - account: deposit_account.clone(), - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { - account: deposit_account.clone(), - free_balance: min_balance, - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: min_balance, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::NewAccount { @@ -3832,6 +3807,17 @@ fn instantiate_with_zero_balance_works() { }), topics: vec![hash(&ALICE), hash(&addr)], }, + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: addr.clone(), + amount: test_utils::contract_info_storage_deposit(&addr), + } + ), + topics: vec![hash(&ALICE), hash(&addr)], + }, ] ); }); @@ -3842,7 +3828,8 @@ fn instantiate_with_below_existential_deposit_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); + let value = 50; // Drop previous events initialize_block(2); @@ -3850,7 +3837,7 @@ fn instantiate_with_below_existential_deposit_works() { // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, - 50, + value, GAS_LIMIT, None, Code::Upload(wasm), @@ -3863,14 +3850,14 @@ fn instantiate_with_below_existential_deposit_works() { .unwrap() .account_id; - // Check that the BOB contract has been instantiated. - let contract = get_contract(&addr); - let deposit_account = contract.deposit_account().deref(); // Ensure the contract was stored and get expected deposit amount to be reserved. let deposit_expected = expected_deposit(ensure_stored(code_hash)); // Make sure the account exists even though not enough free balance was send - assert_eq!(::Currency::free_balance(&addr), min_balance + 50); - assert_eq!(::Currency::total_balance(&addr), min_balance + 50); + assert_eq!(::Currency::free_balance(&addr), min_balance + value); + assert_eq!( + ::Currency::total_balance(&addr), + min_balance + value + test_utils::contract_info_storage_deposit(&addr) + ); assert_eq!( System::events(), @@ -3884,30 +3871,6 @@ fn instantiate_with_below_existential_deposit_works() { }), topics: vec![code_hash], }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { - account: deposit_account.clone(), - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { - account: deposit_account.clone(), - free_balance: min_balance, - }), - topics: vec![], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: min_balance, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::NewAccount { @@ -3949,6 +3912,17 @@ fn instantiate_with_below_existential_deposit_works() { }), topics: vec![hash(&ALICE), hash(&addr)], }, + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: addr.clone(), + amount: test_utils::contract_info_storage_deposit(&addr), + } + ), + topics: vec![hash(&ALICE), hash(&addr)], + }, ] ); }); @@ -3959,7 +3933,6 @@ fn storage_deposit_works() { let (wasm, _code_hash) = compile_module::("multi_store").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let mut deposit = ::Currency::minimum_balance(); let addr = Contracts::bare_instantiate( ALICE, @@ -3976,6 +3949,8 @@ fn storage_deposit_works() { .unwrap() .account_id; + let mut deposit = test_utils::contract_info_storage_deposit(&addr); + // Drop previous events initialize_block(2); @@ -4020,9 +3995,6 @@ fn storage_deposit_works() { deposit -= refunded0; assert_eq!(get_contract(&addr).total_deposit(), deposit); - let contract = get_contract(&addr); - let deposit_account = contract.deposit_account().deref(); - assert_eq!( System::events(), vec![ @@ -4045,12 +4017,14 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: charged0, - }), - topics: vec![], + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: addr.clone(), + amount: charged0, + } + ), + topics: vec![hash(&ALICE), hash(&addr)], }, EventRecord { phase: Phase::Initialization, @@ -4062,12 +4036,14 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: deposit_account.clone(), - amount: charged1, - }), - topics: vec![], + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndHeld { + from: ALICE, + to: addr.clone(), + amount: charged1, + } + ), + topics: vec![hash(&ALICE), hash(&addr)], }, EventRecord { phase: Phase::Initialization, @@ -4079,12 +4055,14 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: deposit_account.clone(), - to: ALICE, - amount: refunded0, - }), - topics: vec![], + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositTransferredAndReleased { + from: addr.clone(), + to: ALICE, + amount: refunded0, + } + ), + topics: vec![hash(&addr.clone()), hash(&ALICE)], }, ] ); @@ -4095,9 +4073,9 @@ fn storage_deposit_works() { fn storage_deposit_callee_works() { let (wasm_caller, _code_hash_caller) = compile_module::("call").unwrap(); let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); - const ED: u64 = 200; - ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { + ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = Contracts::min_balance(); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -4139,10 +4117,13 @@ fn storage_deposit_callee_works() { )); let callee = get_contract(&addr_callee); - let deposit = ED + DepositPerByte::get() * 100 + DepositPerItem::get() * 1; + let deposit = DepositPerByte::get() * 100 + DepositPerItem::get() * 1; - assert_eq!(test_utils::get_balance(callee.deposit_account()), deposit); - assert_eq!(callee.total_deposit(), deposit); + assert_eq!(test_utils::get_balance(&addr_callee), min_balance); + assert_eq!( + callee.total_deposit(), + deposit + test_utils::contract_info_storage_deposit(&addr_callee) + ); }); } @@ -4238,11 +4219,10 @@ fn set_code_extrinsic() { #[test] fn slash_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); - const ED: u64 = 200; - ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { + ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let value = 700; - let balance_held = 500; let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = Contracts::min_balance(); let addr = Contracts::bare_instantiate( ALICE, @@ -4262,28 +4242,29 @@ fn slash_cannot_kill_account() { // Drop previous events initialize_block(2); - // We need to hold some balances in order to have something to slash. As slashing can only - // affect balances held under certain HoldReason. - ::Currency::hold( - &HoldReason::CodeUploadDepositReserve.into(), - &addr, - balance_held, - ) - .unwrap(); + let info_deposit = test_utils::contract_info_storage_deposit(&addr); + + assert_eq!( + test_utils::get_balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr), + info_deposit + ); - assert_eq!(::Currency::total_balance_on_hold(&addr), balance_held); + assert_eq!( + ::Currency::total_balance(&addr), + info_deposit + value + min_balance + ); // Try to destroy the account of the contract by slashing the total balance. - // The account does not get destroyed because of the consumer reference. - // Slashing can for example happen if the contract takes part in staking. + // The account does not get destroyed because slashing only affects the balance held under + // certain `reason`. Slashing can for example happen if the contract takes part in staking. let _ = ::Currency::slash( - &HoldReason::CodeUploadDepositReserve.into(), + &HoldReason::StorageDepositReserve.into(), &addr, ::Currency::total_balance(&addr), ); // Slashing only removed the balance held. - assert_eq!(::Currency::total_balance(&addr), value + ED - balance_held,); + assert_eq!(::Currency::total_balance(&addr), value + min_balance); }); } @@ -4599,11 +4580,10 @@ fn set_code_hash() { #[test] fn storage_deposit_limit_is_enforced() { - let ed = 200; let (wasm, _code_hash) = compile_module::("store_call").unwrap(); - ExtBuilder::default().existential_deposit(ed).build().execute_with(|| { + ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Setting insufficient storage_deposit should fail. assert_err!( @@ -4611,7 +4591,8 @@ fn storage_deposit_limit_is_enforced() { ALICE, 0, GAS_LIMIT, - Some((2 * ed + 3 - 1).into()), // expected deposit is 2 * ed + 3 for the call + Some((2 * min_balance + 3 - 1).into()), /* expected deposit is 2 * ed + 3 for + * the call */ Code::Upload(wasm.clone()), vec![], vec![], @@ -4638,9 +4619,10 @@ fn storage_deposit_limit_is_enforced() { .unwrap() .account_id; + let info_deposit = test_utils::contract_info_storage_deposit(&addr); // Check that the BOB contract has been instantiated and has the minimum balance - assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(get_contract(&addr).total_deposit(), info_deposit); + assert_eq!(::Currency::total_balance(&addr), info_deposit + min_balance); // Create 1 byte of storage with a price of per byte, // setting insufficient deposit limit, as it requires 3 Balance: @@ -4991,12 +4973,11 @@ fn deposit_limit_in_nested_instantiate() { #[test] fn deposit_limit_honors_liquidity_restrictions() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); - const ED: u64 = 200; - ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { + ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let bobs_balance = 1_000; let _ = ::Currency::set_balance(&ALICE, 1_000_000); let _ = ::Currency::set_balance(&BOB, bobs_balance); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -5014,15 +4995,16 @@ fn deposit_limit_honors_liquidity_restrictions() { .unwrap() .account_id; + let info_deposit = test_utils::contract_info_storage_deposit(&addr); // Check that the contract has been instantiated and has the minimum balance - assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(get_contract(&addr).total_deposit(), info_deposit); + assert_eq!(::Currency::total_balance(&addr), info_deposit + min_balance); // check that the hold is honored ::Currency::hold( &HoldReason::CodeUploadDepositReserve.into(), &BOB, - bobs_balance - ED, + bobs_balance - min_balance, ) .unwrap(); assert_err_ignore_postinfo!( @@ -5036,7 +5018,7 @@ fn deposit_limit_honors_liquidity_restrictions() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(::Currency::free_balance(&BOB), ED); + assert_eq!(::Currency::free_balance(&BOB), min_balance); }); } @@ -5046,7 +5028,7 @@ fn deposit_limit_honors_existential_deposit() { ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); let _ = ::Currency::set_balance(&BOB, 1_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -5064,9 +5046,11 @@ fn deposit_limit_honors_existential_deposit() { .unwrap() .account_id; + let info_deposit = test_utils::contract_info_storage_deposit(&addr); + // Check that the contract has been instantiated and has the minimum balance - assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(get_contract(&addr).total_deposit(), info_deposit); + assert_eq!(::Currency::total_balance(&addr), min_balance + info_deposit); // check that the deposit can't bring the account below the existential deposit assert_err_ignore_postinfo!( @@ -5090,7 +5074,7 @@ fn deposit_limit_honors_min_leftover() { ExtBuilder::default().existential_deposit(200).build().execute_with(|| { let _ = ::Currency::set_balance(&ALICE, 1_000_000); let _ = ::Currency::set_balance(&BOB, 1_000); - let min_balance = ::Currency::minimum_balance(); + let min_balance = Contracts::min_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -5108,9 +5092,12 @@ fn deposit_limit_honors_min_leftover() { .unwrap() .account_id; - // Check that the contract has been instantiated and has the minimum balance - assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + let info_deposit = test_utils::contract_info_storage_deposit(&addr); + + // Check that the contract has been instantiated and has the minimum balance and the storage + // deposit + assert_eq!(get_contract(&addr).total_deposit(), info_deposit); + assert_eq!(::Currency::total_balance(&addr), info_deposit + min_balance); // check that the minimum leftover (value send) is considered assert_err_ignore_postinfo!( @@ -5450,7 +5437,13 @@ fn add_remove_delegate_dependency_works() { let dependency_deposit = &CodeHashLockupDepositPercent::get().mul_ceil(deposit); assert_eq!(contract.delegate_dependencies().get(&code_hash), Some(dependency_deposit)); - assert_eq!(test_utils::get_balance(contract.deposit_account()), ED + dependency_deposit); + assert_eq!( + test_utils::get_balance_on_hold( + &HoldReason::StorageDepositReserve.into(), + &addr_caller + ), + dependency_deposit + contract.storage_base_deposit() - ED + ); // Removing the code should fail, since we have added a dependency. assert_err!( @@ -5483,7 +5476,13 @@ fn add_remove_delegate_dependency_works() { // Dependency should be removed, and deposit should be returned. let contract = test_utils::get_contract(&addr_caller); assert!(contract.delegate_dependencies().is_empty()); - assert_eq!(test_utils::get_balance(contract.deposit_account()), ED); + assert_eq!( + test_utils::get_balance_on_hold( + &HoldReason::StorageDepositReserve.into(), + &addr_caller + ), + contract.storage_base_deposit() - ED + ); // Removing an unexisting dependency should fail. assert_err!( @@ -5512,7 +5511,10 @@ fn add_remove_delegate_dependency_works() { // Call terminate should work, and return the deposit. let balance_before = test_utils::get_balance(&ALICE); assert_ok!(call(&addr_caller, &terminate_input).result); - assert_eq!(test_utils::get_balance(&ALICE), balance_before + 2 * ED + dependency_deposit); + assert_eq!( + test_utils::get_balance(&ALICE), + balance_before + contract.storage_base_deposit() + dependency_deposit + ); // Terminate should also remove the dependency, so we can remove the code. assert_ok!(Contracts::remove_code(RuntimeOrigin::signed(ALICE), code_hash)); @@ -5536,8 +5538,6 @@ fn native_dependency_deposit_works() { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let _ = Balances::set_balance(&ALICE, 1_000_000); let lockup_deposit_percent = CodeHashLockupDepositPercent::get(); - let per_byte = DepositPerByte::get(); - let per_item = DepositPerItem::get(); // Upload the dummy contract, Contracts::upload_code( @@ -5577,14 +5577,12 @@ fn native_dependency_deposit_works() { ); let addr = res.result.unwrap().account_id; - let info = ContractInfoOf::::get(&addr).unwrap(); - let info_len = info.encoded_size() as u64; - let base_deposit = ED + per_byte * info_len + per_item * 1; + let base_deposit = ED + test_utils::contract_info_storage_deposit(&addr); let upload_deposit = test_utils::get_code_deposit(&code_hash); let extra_deposit = add_upload_deposit.then(|| upload_deposit).unwrap_or_default(); // Check initial storage_deposit - // The base deposit should be: ED + info_len * per_byte + 1 * per_item + 30% * deposit + // The base deposit should be: ED + contract_info_storage_deposit + 30% * deposit let deposit = extra_deposit + base_deposit + lockup_deposit_percent.mul_ceil(upload_deposit); @@ -5609,7 +5607,10 @@ fn native_dependency_deposit_works() { let code_deposit = test_utils::get_code_deposit(&dummy_code_hash); let deposit = base_deposit + lockup_deposit_percent.mul_ceil(code_deposit); assert_eq!(test_utils::get_contract(&addr).storage_base_deposit(), deposit); - assert_eq!(test_utils::get_balance(&info.deposit_account()), deposit - ED); + assert_eq!( + test_utils::get_balance_on_hold(&HoldReason::StorageDepositReserve.into(), &addr), + deposit - ED + ); }); } } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 551bfba3fbe6f..291f39f7fa797 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -701,6 +701,7 @@ mod tests { fn gas_meter_mut(&mut self) -> &mut GasMeter { &mut self.gas_meter } + fn charge_storage(&mut self, _diff: &crate::storage::meter::Diff) {} fn append_debug_buffer(&mut self, msg: &str) -> bool { self.debug_buffer.extend(msg.as_bytes()); true diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index d8f873b0615be..34bea8ff0a30f 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_contracts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `runner-ynta1nyy-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` @@ -57,6 +57,7 @@ pub trait WeightInfo { fn v12_migration_step(c: u32, ) -> Weight; fn v13_migration_step() -> Weight; fn v14_migration_step() -> Weight; + fn v15_migration_step() -> Weight; fn migration_noop() -> Weight; fn migrate() -> Weight; fn on_runtime_upgrade_noop() -> Weight; @@ -140,8 +141,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 2_527_000 picoseconds. - Weight::from_parts(2_651_000, 1627) + // Minimum execution time: 2_410_000 picoseconds. + Weight::from_parts(2_581_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -151,10 +152,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `451 + k * (69 ±0)` // Estimated: `441 + k * (70 ±0)` - // Minimum execution time: 13_291_000 picoseconds. - Weight::from_parts(13_825_000, 441) - // Standard Error: 1_137 - .saturating_add(Weight::from_parts(1_244_309, 0).saturating_mul(k.into())) + // Minimum execution time: 13_278_000 picoseconds. + Weight::from_parts(13_944_000, 441) + // Standard Error: 1_643 + .saturating_add(Weight::from_parts(1_194_404, 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)) @@ -168,25 +169,25 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `211 + c * (1 ±0)` // Estimated: `6149 + c * (1 ±0)` - // Minimum execution time: 8_359_000 picoseconds. - Weight::from_parts(9_179_121, 6149) + // Minimum execution time: 8_533_000 picoseconds. + Weight::from_parts(9_141_899, 6149) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_312, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_327, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: `Contracts::ContractInfoOf` (r:3 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) fn v10_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `709` - // Estimated: `9124` - // Minimum execution time: 42_457_000 picoseconds. - Weight::from_parts(44_556_000, 9124) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `510` + // Estimated: `6450` + // Minimum execution time: 16_998_000 picoseconds. + Weight::from_parts(17_776_000, 6450) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Contracts::DeletionQueue` (r:1 w:1025) @@ -198,10 +199,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `171 + k * (1 ±0)` // Estimated: `3635 + k * (1 ±0)` - // Minimum execution time: 3_839_000 picoseconds. - Weight::from_parts(3_462_337, 3635) - // Standard Error: 1_384 - .saturating_add(Weight::from_parts(1_166_522, 0).saturating_mul(k.into())) + // Minimum execution time: 3_919_000 picoseconds. + Weight::from_parts(4_057_153, 3635) + // Standard Error: 1_252 + .saturating_add(Weight::from_parts(1_151_419, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -220,38 +221,52 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `325 + c * (1 ±0)` // Estimated: `6263 + c * (1 ±0)` - // Minimum execution time: 17_001_000 picoseconds. - Weight::from_parts(17_095_380, 6263) + // Minimum execution time: 17_730_000 picoseconds. + Weight::from_parts(17_540_884, 6263) // Standard Error: 1 - .saturating_add(Weight::from_parts(411, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(417, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: `Contracts::ContractInfoOf` (r:3 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) fn v13_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `639` - // Estimated: `9054` - // Minimum execution time: 35_342_000 picoseconds. - Weight::from_parts(36_839_000, 9054) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `440` + // Estimated: `6380` + // Minimum execution time: 13_089_000 picoseconds. + Weight::from_parts(13_727_000, 6380) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) - /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) - /// Storage: `System::Account` (r:1 w:0) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:0) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) fn v14_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `260` - // Estimated: `6200` - // Minimum execution time: 27_995_000 picoseconds. - Weight::from_parts(28_661_000, 6200) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `360` + // Estimated: `6300` + // Minimum execution time: 49_083_000 picoseconds. + Weight::from_parts(50_462_000, 6300) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + fn v15_migration_step() -> Weight { + // Proof Size summary in bytes: + // Measured: `594` + // Estimated: `6534` + // Minimum execution time: 49_299_000 picoseconds. + Weight::from_parts(50_805_000, 6534) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -259,8 +274,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 3_272_000 picoseconds. - Weight::from_parts(3_553_000, 1627) + // Minimum execution time: 3_305_000 picoseconds. + Weight::from_parts(3_489_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -272,8 +287,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 12_788_000 picoseconds. - Weight::from_parts(13_163_000, 3631) + // Minimum execution time: 12_657_000 picoseconds. + Weight::from_parts(13_100_000, 3631) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -283,8 +298,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_794_000 picoseconds. - Weight::from_parts(5_086_000, 3607) + // Minimum execution time: 4_784_000 picoseconds. + Weight::from_parts(4_994_000, 3607) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -295,8 +310,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 6_616_000 picoseconds. - Weight::from_parts(7_034_000, 3632) + // Minimum execution time: 6_762_000 picoseconds. + Weight::from_parts(6_945_000, 3632) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -307,15 +322,15 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 6_985_000 picoseconds. - Weight::from_parts(7_477_000, 3607) + // Minimum execution time: 6_999_000 picoseconds. + Weight::from_parts(7_372_000, 3607) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -329,12 +344,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `783` - // Estimated: `6732 + c * (1 ±0)` - // Minimum execution time: 306_088_000 picoseconds. - Weight::from_parts(268_361_911, 6732) - // Standard Error: 76 - .saturating_add(Weight::from_parts(38_334, 0).saturating_mul(c.into())) + // Measured: `759` + // Estimated: `6710 + c * (1 ±0)` + // Minimum execution time: 304_121_000 picoseconds. + Weight::from_parts(288_627_840, 6710) + // Standard Error: 83 + .saturating_add(Weight::from_parts(37_343, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -343,15 +358,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:3 w:3) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) @@ -360,18 +377,18 @@ impl WeightInfo for SubstrateWeight { /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `303` - // Estimated: `8745` - // Minimum execution time: 4_224_657_000 picoseconds. - Weight::from_parts(451_557_864, 8745) - // Standard Error: 216 - .saturating_add(Weight::from_parts(111_761, 0).saturating_mul(c.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(1_794, 0).saturating_mul(i.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(2_013, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(9_u64)) + // Measured: `290` + // Estimated: `8714` + // Minimum execution time: 4_101_589_000 picoseconds. + Weight::from_parts(694_193_047, 8714) + // Standard Error: 334 + .saturating_add(Weight::from_parts(108_847, 0).saturating_mul(c.into())) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_677, 0).saturating_mul(i.into())) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_783, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -382,11 +399,13 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:2 w:2) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. @@ -394,20 +413,20 @@ impl WeightInfo for SubstrateWeight { fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `527` - // Estimated: `6517` - // Minimum execution time: 2_029_313_000 picoseconds. - Weight::from_parts(353_077_600, 6517) - // Standard Error: 8 - .saturating_add(Weight::from_parts(1_781, 0).saturating_mul(i.into())) - // Standard Error: 8 - .saturating_add(Weight::from_parts(1_729, 0).saturating_mul(s.into())) + // Estimated: `6471` + // Minimum execution time: 2_011_580_000 picoseconds. + Weight::from_parts(397_415_227, 6471) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_689, 0).saturating_mul(i.into())) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_679, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -420,10 +439,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `817` - // Estimated: `6757` - // Minimum execution time: 204_086_000 picoseconds. - Weight::from_parts(216_738_000, 6757) + // Measured: `793` + // Estimated: `6733` + // Minimum execution time: 204_975_000 picoseconds. + Weight::from_parts(214_770_000, 6733) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -431,6 +450,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) @@ -440,44 +461,46 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 269_337_000 picoseconds. - Weight::from_parts(220_186_006, 3607) - // Standard Error: 106 - .saturating_add(Weight::from_parts(74_291, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Minimum execution time: 269_545_000 picoseconds. + Weight::from_parts(256_054_650, 3607) + // Standard Error: 91 + .saturating_add(Weight::from_parts(72_743, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `259` - // Estimated: `3724` - // Minimum execution time: 35_127_000 picoseconds. - Weight::from_parts(36_180_000, 3724) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `315` + // Estimated: `3780` + // Minimum execution time: 47_880_000 picoseconds. + Weight::from_parts(49_427_000, 3780) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `System::EventTopics` (r:3 w:3) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `576` - // Estimated: `8991` - // Minimum execution time: 37_550_000 picoseconds. - Weight::from_parts(39_149_000, 8991) + // Measured: `552` + // Estimated: `8967` + // Minimum execution time: 37_898_000 picoseconds. + Weight::from_parts(39_826_000, 8967) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -486,7 +509,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -498,12 +521,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6798 + r * (6 ±0)` - // Minimum execution time: 269_991_000 picoseconds. - Weight::from_parts(293_993_592, 6798) - // Standard Error: 665 - .saturating_add(Weight::from_parts(343_796, 0).saturating_mul(r.into())) + // Measured: `833 + r * (6 ±0)` + // Estimated: `6773 + r * (6 ±0)` + // Minimum execution time: 260_916_000 picoseconds. + Weight::from_parts(295_521_846, 6773) + // Standard Error: 1_126 + .saturating_add(Weight::from_parts(348_317, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -513,7 +536,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -525,23 +548,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `924 + r * (232 ±0)` - // Estimated: `6831 + r * (2707 ±0)` - // Minimum execution time: 274_151_000 picoseconds. - Weight::from_parts(83_529_206, 6831) - // Standard Error: 8_452 - .saturating_add(Weight::from_parts(3_534_024, 0).saturating_mul(r.into())) + // Measured: `889 + r * (209 ±0)` + // Estimated: `6793 + r * (2684 ±0)` + // Minimum execution time: 274_335_000 picoseconds. + Weight::from_parts(132_998_512, 6793) + // Standard Error: 7_396 + .saturating_add(Weight::from_parts(3_602_287, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2707).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -553,23 +576,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `910 + r * (236 ±0)` - // Estimated: `6835 + r * (2711 ±0)` - // Minimum execution time: 276_689_000 picoseconds. - Weight::from_parts(110_268_281, 6835) - // Standard Error: 8_106 - .saturating_add(Weight::from_parts(4_376_136, 0).saturating_mul(r.into())) + // Measured: `888 + r * (213 ±0)` + // Estimated: `6797 + r * (2688 ±0)` + // Minimum execution time: 272_514_000 picoseconds. + Weight::from_parts(104_825_618, 6797) + // Standard Error: 10_038 + .saturating_add(Weight::from_parts(4_520_258, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2711).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2688).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -581,12 +604,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (6 ±0)` - // Estimated: `6806 + r * (6 ±0)` - // Minimum execution time: 274_079_000 picoseconds. - Weight::from_parts(282_258_090, 6806) - // Standard Error: 1_343 - .saturating_add(Weight::from_parts(464_680, 0).saturating_mul(r.into())) + // Measured: `840 + r * (6 ±0)` + // Estimated: `6782 + r * (6 ±0)` + // Minimum execution time: 264_593_000 picoseconds. + Weight::from_parts(294_139_363, 6782) + // Standard Error: 907 + .saturating_add(Weight::from_parts(432_964, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -596,7 +619,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -608,12 +631,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 270_960_000 picoseconds. - Weight::from_parts(281_985_584, 6799) - // Standard Error: 378 - .saturating_add(Weight::from_parts(184_462, 0).saturating_mul(r.into())) + // Measured: `830 + r * (3 ±0)` + // Estimated: `6771 + r * (3 ±0)` + // Minimum execution time: 260_412_000 picoseconds. + Weight::from_parts(284_371_703, 6771) + // Standard Error: 433 + .saturating_add(Weight::from_parts(182_952, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -621,7 +644,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -633,12 +656,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_root(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `744 + r * (3 ±0)` - // Estimated: `6684 + r * (3 ±0)` - // Minimum execution time: 244_835_000 picoseconds. - Weight::from_parts(270_660_753, 6684) - // Standard Error: 390 - .saturating_add(Weight::from_parts(164_232, 0).saturating_mul(r.into())) + // Measured: `720 + r * (3 ±0)` + // Estimated: `6660 + r * (3 ±0)` + // Minimum execution time: 255_112_000 picoseconds. + Weight::from_parts(273_052_488, 6660) + // Standard Error: 376 + .saturating_add(Weight::from_parts(166_644, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -648,7 +671,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -660,12 +683,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (6 ±0)` - // Estimated: `6800 + r * (6 ±0)` - // Minimum execution time: 273_269_000 picoseconds. - Weight::from_parts(274_468_168, 6800) - // Standard Error: 2_246 - .saturating_add(Weight::from_parts(386_838, 0).saturating_mul(r.into())) + // Measured: `834 + r * (6 ±0)` + // Estimated: `6774 + r * (6 ±0)` + // Minimum execution time: 270_426_000 picoseconds. + Weight::from_parts(289_240_775, 6774) + // Standard Error: 748 + .saturating_add(Weight::from_parts(344_791, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -675,7 +698,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -687,12 +710,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (6 ±0)` - // Estimated: `6795 + r * (6 ±0)` - // Minimum execution time: 275_244_000 picoseconds. - Weight::from_parts(281_299_739, 6795) - // Standard Error: 2_890 - .saturating_add(Weight::from_parts(600_498, 0).saturating_mul(r.into())) + // Measured: `830 + r * (6 ±0)` + // Estimated: `6773 + r * (6 ±0)` + // Minimum execution time: 260_217_000 picoseconds. + Weight::from_parts(288_660_978, 6773) + // Standard Error: 1_199 + .saturating_add(Weight::from_parts(550_304, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -702,7 +725,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:2 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -714,12 +737,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `998 + r * (6 ±0)` - // Estimated: `6922 + r * (6 ±0)` - // Minimum execution time: 271_540_000 picoseconds. - Weight::from_parts(298_456_935, 6922) - // Standard Error: 2_881 - .saturating_add(Weight::from_parts(1_719_337, 0).saturating_mul(r.into())) + // Measured: `974 + r * (6 ±0)` + // Estimated: `6898 + r * (6 ±0)` + // Minimum execution time: 273_473_000 picoseconds. + Weight::from_parts(298_889_279, 6898) + // Standard Error: 4_604 + .saturating_add(Weight::from_parts(1_630_175, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -729,7 +752,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -741,12 +764,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `868 + r * (6 ±0)` - // Estimated: `6817 + r * (6 ±0)` - // Minimum execution time: 274_832_000 picoseconds. - Weight::from_parts(286_078_648, 6817) - // Standard Error: 695 - .saturating_add(Weight::from_parts(345_045, 0).saturating_mul(r.into())) + // Measured: `844 + r * (6 ±0)` + // Estimated: `6790 + r * (6 ±0)` + // Minimum execution time: 262_033_000 picoseconds. + Weight::from_parts(284_293_851, 6790) + // Standard Error: 591 + .saturating_add(Weight::from_parts(369_240, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -756,7 +779,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -768,12 +791,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866 + r * (6 ±0)` - // Estimated: `6815 + r * (6 ±0)` - // Minimum execution time: 267_337_000 picoseconds. - Weight::from_parts(283_693_170, 6815) - // Standard Error: 580 - .saturating_add(Weight::from_parts(345_350, 0).saturating_mul(r.into())) + // Measured: `842 + r * (6 ±0)` + // Estimated: `6783 + r * (6 ±0)` + // Minimum execution time: 274_568_000 picoseconds. + Weight::from_parts(294_688_466, 6783) + // Standard Error: 768 + .saturating_add(Weight::from_parts(349_584, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -783,7 +806,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -795,12 +818,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (6 ±0)` - // Estimated: `6813 + r * (6 ±0)` - // Minimum execution time: 276_313_000 picoseconds. - Weight::from_parts(287_689_703, 6813) - // Standard Error: 1_251 - .saturating_add(Weight::from_parts(342_536, 0).saturating_mul(r.into())) + // Measured: `839 + r * (6 ±0)` + // Estimated: `6786 + r * (6 ±0)` + // Minimum execution time: 264_061_000 picoseconds. + Weight::from_parts(287_964_188, 6786) + // Standard Error: 490 + .saturating_add(Weight::from_parts(356_273, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -810,7 +833,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -822,12 +845,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (6 ±0)` - // Estimated: `6799 + r * (6 ±0)` - // Minimum execution time: 274_196_000 picoseconds. - Weight::from_parts(288_641_687, 6799) - // Standard Error: 530 - .saturating_add(Weight::from_parts(336_194, 0).saturating_mul(r.into())) + // Measured: `830 + r * (6 ±0)` + // Estimated: `6771 + r * (6 ±0)` + // Minimum execution time: 275_707_000 picoseconds. + Weight::from_parts(290_797_828, 6771) + // Standard Error: 967 + .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -837,7 +860,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -851,12 +874,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `928 + r * (14 ±0)` - // Estimated: `6861 + r * (14 ±0)` - // Minimum execution time: 254_997_000 picoseconds. - Weight::from_parts(292_260_891, 6861) - // Standard Error: 1_019 - .saturating_add(Weight::from_parts(1_447_021, 0).saturating_mul(r.into())) + // Measured: `904 + r * (14 ±0)` + // Estimated: `6839 + r * (14 ±0)` + // Minimum execution time: 272_492_000 picoseconds. + Weight::from_parts(295_010_878, 6839) + // Standard Error: 2_549 + .saturating_add(Weight::from_parts(1_426_715, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 14).saturating_mul(r.into())) @@ -866,7 +889,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -878,12 +901,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (6 ±0)` - // Estimated: `6800 + r * (6 ±0)` - // Minimum execution time: 272_720_000 picoseconds. - Weight::from_parts(287_125_181, 6800) - // Standard Error: 491 - .saturating_add(Weight::from_parts(294_488, 0).saturating_mul(r.into())) + // Measured: `832 + r * (6 ±0)` + // Estimated: `6774 + r * (6 ±0)` + // Minimum execution time: 257_981_000 picoseconds. + Weight::from_parts(285_824_773, 6774) + // Standard Error: 704 + .saturating_add(Weight::from_parts(301_327, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -893,7 +916,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -905,12 +928,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `860` - // Estimated: `6800` - // Minimum execution time: 280_665_000 picoseconds. - Weight::from_parts(233_022_448, 6800) - // Standard Error: 23 - .saturating_add(Weight::from_parts(996, 0).saturating_mul(n.into())) + // Measured: `836` + // Estimated: `6776` + // Minimum execution time: 259_470_000 picoseconds. + Weight::from_parts(232_759_442, 6776) + // Standard Error: 24 + .saturating_add(Weight::from_parts(981, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -919,7 +942,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -931,12 +954,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `844 + r * (45 ±0)` - // Estimated: `6784 + r * (45 ±0)` - // Minimum execution time: 250_335_000 picoseconds. - Weight::from_parts(278_774_071, 6784) - // Standard Error: 873_509 - .saturating_add(Weight::from_parts(4_562_628, 0).saturating_mul(r.into())) + // Measured: `820 + r * (45 ±0)` + // Estimated: `6760 + r * (45 ±0)` + // Minimum execution time: 252_740_000 picoseconds. + Weight::from_parts(278_155_436, 6760) + // Standard Error: 882_420 + .saturating_add(Weight::from_parts(755_063, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 45).saturating_mul(r.into())) @@ -946,7 +969,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -958,21 +981,21 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854` - // Estimated: `6807` - // Minimum execution time: 278_402_000 picoseconds. - Weight::from_parts(285_491_021, 6807) - // Standard Error: 0 - .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) + // Measured: `830` + // Estimated: `6777` + // Minimum execution time: 257_318_000 picoseconds. + Weight::from_parts(285_765_697, 6777) + // Standard Error: 1 + .saturating_add(Weight::from_parts(322, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:4 w:4) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -981,31 +1004,33 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::DeletionQueueCounter` (r:1 w:1) /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:3 w:3) + /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `Contracts::DeletionQueue` (r:0 w:1) /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2963 + r * (400 ±0)` - // Estimated: `8903 + r * (7825 ±0)` - // Minimum execution time: 281_030_000 picoseconds. - Weight::from_parts(305_435_226, 8903) - // Standard Error: 816_824 - .saturating_add(Weight::from_parts(131_691_873, 0).saturating_mul(r.into())) + // Measured: `2939 + r * (316 ±0)` + // Estimated: `8879 + r * (5266 ±0)` + // Minimum execution time: 280_392_000 picoseconds. + Weight::from_parts(310_023_381, 8879) + // Standard Error: 1_008_026 + .saturating_add(Weight::from_parts(130_208_818, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((9_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 7825).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((10_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 5266).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1019,12 +1044,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (10 ±0)` - // Estimated: `6876 + r * (10 ±0)` - // Minimum execution time: 261_369_000 picoseconds. - Weight::from_parts(300_458_315, 6876) - // Standard Error: 3_506 - .saturating_add(Weight::from_parts(1_971_733, 0).saturating_mul(r.into())) + // Measured: `911 + r * (10 ±0)` + // Estimated: `6852 + r * (10 ±0)` + // Minimum execution time: 270_547_000 picoseconds. + Weight::from_parts(295_931_189, 6852) + // Standard Error: 3_280 + .saturating_add(Weight::from_parts(1_941_248, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) @@ -1034,7 +1059,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1046,12 +1071,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (10 ±0)` - // Estimated: `6799 + r * (10 ±0)` - // Minimum execution time: 262_894_000 picoseconds. - Weight::from_parts(285_321_838, 6799) - // Standard Error: 6_585 - .saturating_add(Weight::from_parts(3_998_744, 0).saturating_mul(r.into())) + // Measured: `830 + r * (10 ±0)` + // Estimated: `6772 + r * (10 ±0)` + // Minimum execution time: 255_730_000 picoseconds. + Weight::from_parts(301_859_471, 6772) + // Standard Error: 5_401 + .saturating_add(Weight::from_parts(3_887_632, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) @@ -1061,7 +1086,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1074,14 +1099,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + t * (32 ±0)` - // Estimated: `6820 + t * (2508 ±0)` - // Minimum execution time: 275_909_000 picoseconds. - Weight::from_parts(289_251_568, 6820) - // Standard Error: 94_431 - .saturating_add(Weight::from_parts(3_007_409, 0).saturating_mul(t.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(815, 0).saturating_mul(n.into())) + // Measured: `847 + t * (32 ±0)` + // Estimated: `6792 + t * (2508 ±0)` + // Minimum execution time: 276_643_000 picoseconds. + Weight::from_parts(294_275_838, 6792) + // Standard Error: 106_745 + .saturating_add(Weight::from_parts(2_831_489, 0).saturating_mul(t.into())) + // Standard Error: 29 + .saturating_add(Weight::from_parts(624, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1093,7 +1118,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1105,12 +1130,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `853 + r * (7 ±0)` - // Estimated: `6797 + r * (7 ±0)` - // Minimum execution time: 168_482_000 picoseconds. - Weight::from_parts(178_065_606, 6797) - // Standard Error: 371 - .saturating_add(Weight::from_parts(242_851, 0).saturating_mul(r.into())) + // Measured: `829 + r * (7 ±0)` + // Estimated: `6774 + r * (7 ±0)` + // Minimum execution time: 169_012_000 picoseconds. + Weight::from_parts(179_567_029, 6774) + // Standard Error: 534 + .saturating_add(Weight::from_parts(249_500, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 7).saturating_mul(r.into())) @@ -1120,7 +1145,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `MaxEncodedLen`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1132,12 +1157,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125804` - // Estimated: `131746` - // Minimum execution time: 407_401_000 picoseconds. - Weight::from_parts(426_585_443, 131746) - // Standard Error: 22 - .saturating_add(Weight::from_parts(986, 0).saturating_mul(i.into())) + // Measured: `125780` + // Estimated: `131722` + // Minimum execution time: 408_647_000 picoseconds. + Weight::from_parts(387_678_006, 131722) + // Standard Error: 12 + .saturating_add(Weight::from_parts(1_045, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1146,12 +1171,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (292 ±0)` - // Estimated: `919 + r * (293 ±0)` - // Minimum execution time: 275_800_000 picoseconds. - Weight::from_parts(161_230_700, 919) - // Standard Error: 12_908 - .saturating_add(Weight::from_parts(6_965_844, 0).saturating_mul(r.into())) + // Measured: `891 + r * (292 ±0)` + // Estimated: `892 + r * (293 ±0)` + // Minimum execution time: 279_315_000 picoseconds. + Weight::from_parts(171_270_899, 892) + // Standard Error: 15_492 + .saturating_add(Weight::from_parts(6_776_878, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1163,26 +1188,26 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1380` - // Estimated: `1356` - // Minimum execution time: 289_258_000 picoseconds. - Weight::from_parts(334_318_402, 1356) - // Standard Error: 59 - .saturating_add(Weight::from_parts(808, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `1413` + // Estimated: `1396` + // Minimum execution time: 289_666_000 picoseconds. + Weight::from_parts(348_062_625, 1396) + // Standard Error: 79 + .saturating_add(Weight::from_parts(532, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(8_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, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1243 + n * (1 ±0)` - // Estimated: `1243 + n * (1 ±0)` - // Minimum execution time: 277_874_000 picoseconds. - Weight::from_parts(303_956_600, 1243) - // Standard Error: 33 - .saturating_add(Weight::from_parts(58, 0).saturating_mul(n.into())) + // Measured: `1219 + n * (1 ±0)` + // Estimated: `1219 + n * (1 ±0)` + // Minimum execution time: 273_840_000 picoseconds. + Weight::from_parts(297_024_621, 1219) + // Standard Error: 55 + .saturating_add(Weight::from_parts(945, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1192,12 +1217,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (288 ±0)` - // Estimated: `921 + r * (289 ±0)` - // Minimum execution time: 255_230_000 picoseconds. - Weight::from_parts(163_226_984, 921) - // Standard Error: 12_691 - .saturating_add(Weight::from_parts(6_808_905, 0).saturating_mul(r.into())) + // Measured: `887 + r * (288 ±0)` + // Estimated: `893 + r * (289 ±0)` + // Minimum execution time: 279_110_000 picoseconds. + Weight::from_parts(177_898_012, 893) + // Standard Error: 16_287 + .saturating_add(Weight::from_parts(6_640_103, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1209,12 +1234,10 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1239 + n * (1 ±0)` - // Estimated: `1239 + n * (1 ±0)` - // Minimum execution time: 275_780_000 picoseconds. - Weight::from_parts(301_967_262, 1239) - // Standard Error: 34 - .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) + // Measured: `1215 + n * (1 ±0)` + // Estimated: `1215 + n * (1 ±0)` + // Minimum execution time: 276_566_000 picoseconds. + Weight::from_parts(304_992_376, 1215) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1224,12 +1247,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (296 ±0)` - // Estimated: `916 + r * (297 ±0)` - // Minimum execution time: 279_295_000 picoseconds. - Weight::from_parts(208_289_066, 916) - // Standard Error: 8_330 - .saturating_add(Weight::from_parts(5_600_713, 0).saturating_mul(r.into())) + // Measured: `887 + r * (296 ±0)` + // Estimated: `889 + r * (297 ±0)` + // Minimum execution time: 266_285_000 picoseconds. + Weight::from_parts(200_488_939, 889) + // Standard Error: 11_193 + .saturating_add(Weight::from_parts(5_467_725, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1240,12 +1263,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1255 + n * (1 ±0)` - // Estimated: `1255 + n * (1 ±0)` - // Minimum execution time: 276_745_000 picoseconds. - Weight::from_parts(298_824_233, 1255) - // Standard Error: 36 - .saturating_add(Weight::from_parts(717, 0).saturating_mul(n.into())) + // Measured: `1231 + n * (1 ±0)` + // Estimated: `1231 + n * (1 ±0)` + // Minimum execution time: 278_625_000 picoseconds. + Weight::from_parts(304_319_493, 1231) + // Standard Error: 39 + .saturating_add(Weight::from_parts(415, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1255,12 +1278,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `932 + r * (288 ±0)` - // Estimated: `933 + r * (289 ±0)` - // Minimum execution time: 275_137_000 picoseconds. - Weight::from_parts(196_695_898, 933) - // Standard Error: 9_207 - .saturating_add(Weight::from_parts(5_466_071, 0).saturating_mul(r.into())) + // Measured: `898 + r * (288 ±0)` + // Estimated: `895 + r * (289 ±0)` + // Minimum execution time: 271_851_000 picoseconds. + Weight::from_parts(202_164_395, 895) + // Standard Error: 11_115 + .saturating_add(Weight::from_parts(5_273_320, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1271,12 +1294,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1242 + n * (1 ±0)` - // Estimated: `1242 + n * (1 ±0)` - // Minimum execution time: 269_315_000 picoseconds. - Weight::from_parts(296_795_271, 1242) - // Standard Error: 39 - .saturating_add(Weight::from_parts(242, 0).saturating_mul(n.into())) + // Measured: `1218 + n * (1 ±0)` + // Estimated: `1218 + n * (1 ±0)` + // Minimum execution time: 274_200_000 picoseconds. + Weight::from_parts(299_524_586, 1218) + // Standard Error: 33 + .saturating_add(Weight::from_parts(272, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1286,12 +1309,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `905 + r * (296 ±0)` - // Estimated: `912 + r * (297 ±0)` - // Minimum execution time: 256_406_000 picoseconds. - Weight::from_parts(156_850_288, 912) - // Standard Error: 12_496 - .saturating_add(Weight::from_parts(7_055_305, 0).saturating_mul(r.into())) + // Measured: `880 + r * (296 ±0)` + // Estimated: `885 + r * (297 ±0)` + // Minimum execution time: 258_535_000 picoseconds. + Weight::from_parts(190_468_808, 885) + // Standard Error: 11_940 + .saturating_add(Weight::from_parts(6_737_079, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1303,12 +1326,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1256 + n * (1 ±0)` - // Estimated: `1256 + n * (1 ±0)` - // Minimum execution time: 280_297_000 picoseconds. - Weight::from_parts(302_241_752, 1256) - // Standard Error: 34 - .saturating_add(Weight::from_parts(748, 0).saturating_mul(n.into())) + // Measured: `1232 + n * (1 ±0)` + // Estimated: `1232 + n * (1 ±0)` + // Minimum execution time: 280_536_000 picoseconds. + Weight::from_parts(304_479_477, 1232) + // Standard Error: 37 + .saturating_add(Weight::from_parts(534, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1318,7 +1341,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1602 w:1601) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1330,12 +1353,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1449 + r * (45 ±0)` - // Estimated: `7346 + r * (2520 ±0)` - // Minimum execution time: 274_834_000 picoseconds. - Weight::from_parts(176_977_557, 7346) - // Standard Error: 32_386 - .saturating_add(Weight::from_parts(39_393_162, 0).saturating_mul(r.into())) + // Measured: `1382 + r * (45 ±0)` + // Estimated: `7274 + r * (2520 ±0)` + // Minimum execution time: 260_373_000 picoseconds. + Weight::from_parts(278_290_000, 7274) + // Standard Error: 25_683 + .saturating_add(Weight::from_parts(39_264_864, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -1347,7 +1370,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -1359,24 +1382,24 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1304 + r * (268 ±0)` - // Estimated: `9485 + r * (2744 ±0)` - // Minimum execution time: 279_802_000 picoseconds. - Weight::from_parts(287_995_000, 9485) - // Standard Error: 99_110 - .saturating_add(Weight::from_parts(245_521_843, 0).saturating_mul(r.into())) + // Measured: `1227 + r * (245 ±0)` + // Estimated: `9407 + r * (2721 ±0)` + // Minimum execution time: 277_621_000 picoseconds. + Weight::from_parts(281_775_000, 9407) + // Standard Error: 110_802 + .saturating_add(Weight::from_parts(245_363_533, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2744).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2721).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:736 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:736 w:0) @@ -1389,11 +1412,11 @@ impl WeightInfo for SubstrateWeight { fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (576 ±0)` - // Estimated: `6803 + r * (2637 ±3)` - // Minimum execution time: 273_435_000 picoseconds. - Weight::from_parts(276_865_000, 6803) - // Standard Error: 148_051 - .saturating_add(Weight::from_parts(244_660_274, 0).saturating_mul(r.into())) + // Estimated: `6779 + r * (2637 ±3)` + // Minimum execution time: 267_314_000 picoseconds. + Weight::from_parts(279_888_000, 6779) + // Standard Error: 144_378 + .saturating_add(Weight::from_parts(244_606_414, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1405,7 +1428,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -1418,26 +1441,26 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1322 + t * (310 ±0)` - // Estimated: `12212 + t * (5260 ±0)` - // Minimum execution time: 477_593_000 picoseconds. - Weight::from_parts(69_887_451, 12212) - // Standard Error: 11_764_606 - .saturating_add(Weight::from_parts(373_361_977, 0).saturating_mul(t.into())) + // Measured: `1274 + t * (277 ±0)` + // Estimated: `12164 + t * (5227 ±0)` + // Minimum execution time: 477_589_000 picoseconds. + Weight::from_parts(70_712_793, 12164) + // Standard Error: 11_713_135 + .saturating_add(Weight::from_parts(375_371_698, 0).saturating_mul(t.into())) // Standard Error: 17 - .saturating_add(Weight::from_parts(1_000, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(991, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 5260).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 5227).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:1602 w:1602) + /// Storage: `System::Account` (r:802 w:802) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:801 w:800) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:801 w:0) @@ -1446,29 +1469,31 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:802 w:802) + /// Storage: `Balances::Holds` (r:800 w:800) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:803 w:803) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1380 + r * (255 ±0)` - // Estimated: `7204 + r * (5206 ±0)` - // Minimum execution time: 652_387_000 picoseconds. - Weight::from_parts(658_670_000, 7204) - // Standard Error: 363_054 - .saturating_add(Weight::from_parts(395_547_049, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) + // Measured: `1245 + r * (255 ±0)` + // Estimated: `9587 + r * (2731 ±0)` + // Minimum execution time: 662_502_000 picoseconds. + Weight::from_parts(671_726_000, 9587) + // Standard Error: 351_643 + .saturating_add(Weight::from_parts(390_457_971, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 5206).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2731).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:4 w:4) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -1477,35 +1502,37 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:3 w:3) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 983040]`. /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1233 + t * (156 ±0)` - // Estimated: `9663 + t * (2578 ±2)` - // Minimum execution time: 2_299_620_000 picoseconds. - Weight::from_parts(1_274_859_063, 9663) - // Standard Error: 12_129_871 - .saturating_add(Weight::from_parts(16_608_792, 0).saturating_mul(t.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_014, 0).saturating_mul(i.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(15_u64)) + // Measured: `1270 + t * (104 ±0)` + // Estimated: `12178 + t * (2549 ±1)` + // Minimum execution time: 2_675_525_000 picoseconds. + Weight::from_parts(851_421_242, 12178) + // Standard Error: 7_094_722 + .saturating_add(Weight::from_parts(112_457_697, 0).saturating_mul(t.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_867, 0).saturating_mul(i.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_931, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(10_u64)) + .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2578).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 2549).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1517,12 +1544,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `853 + r * (8 ±0)` - // Estimated: `6794 + r * (8 ±0)` - // Minimum execution time: 267_959_000 picoseconds. - Weight::from_parts(282_967_946, 6794) - // Standard Error: 624 - .saturating_add(Weight::from_parts(402_344, 0).saturating_mul(r.into())) + // Measured: `829 + r * (8 ±0)` + // Estimated: `6768 + r * (8 ±0)` + // Minimum execution time: 270_818_000 picoseconds. + Weight::from_parts(286_520_166, 6768) + // Standard Error: 575 + .saturating_add(Weight::from_parts(402_286, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -1532,7 +1559,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1544,12 +1571,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `861` - // Estimated: `6801` - // Minimum execution time: 274_585_000 picoseconds. - Weight::from_parts(272_480_647, 6801) + // Measured: `837` + // Estimated: `6775` + // Minimum execution time: 257_134_000 picoseconds. + Weight::from_parts(268_214_648, 6775) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_089, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_098, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1558,7 +1585,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1570,12 +1597,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6797 + r * (8 ±0)` - // Minimum execution time: 268_346_000 picoseconds. - Weight::from_parts(284_168_231, 6797) - // Standard Error: 620 - .saturating_add(Weight::from_parts(805_038, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6773 + r * (8 ±0)` + // Minimum execution time: 259_222_000 picoseconds. + Weight::from_parts(283_273_283, 6773) + // Standard Error: 967 + .saturating_add(Weight::from_parts(817_596, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -1585,7 +1612,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1597,12 +1624,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6805` - // Minimum execution time: 273_073_000 picoseconds. - Weight::from_parts(280_346_065, 6805) + // Measured: `839` + // Estimated: `6781` + // Minimum execution time: 260_040_000 picoseconds. + Weight::from_parts(283_869_860, 6781) // Standard Error: 1 - .saturating_add(Weight::from_parts(3_357, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_349, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1611,7 +1638,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1623,12 +1650,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6800 + r * (8 ±0)` - // Minimum execution time: 263_072_000 picoseconds. - Weight::from_parts(284_487_433, 6800) - // Standard Error: 668 - .saturating_add(Weight::from_parts(458_763, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6775 + r * (8 ±0)` + // Minimum execution time: 260_698_000 picoseconds. + Weight::from_parts(282_900_345, 6775) + // Standard Error: 805 + .saturating_add(Weight::from_parts(469_457, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -1638,7 +1665,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1650,12 +1677,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6809` - // Minimum execution time: 271_488_000 picoseconds. - Weight::from_parts(273_877_727, 6809) + // Measured: `839` + // Estimated: `6780` + // Minimum execution time: 256_967_000 picoseconds. + Weight::from_parts(273_024_512, 6780) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_202, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_204, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1664,7 +1691,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1676,12 +1703,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6801 + r * (8 ±0)` - // Minimum execution time: 271_365_000 picoseconds. - Weight::from_parts(285_100_883, 6801) - // Standard Error: 651 - .saturating_add(Weight::from_parts(462_754, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6772 + r * (8 ±0)` + // Minimum execution time: 272_039_000 picoseconds. + Weight::from_parts(289_853_116, 6772) + // Standard Error: 559 + .saturating_add(Weight::from_parts(459_383, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -1691,7 +1718,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1703,12 +1730,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6803` - // Minimum execution time: 272_341_000 picoseconds. - Weight::from_parts(275_388_470, 6803) + // Measured: `839` + // Estimated: `6778` + // Minimum execution time: 253_913_000 picoseconds. + Weight::from_parts(274_682_010, 6778) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_192, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_204, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1717,7 +1744,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1729,12 +1756,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `988 + n * (1 ±0)` - // Estimated: `6925 + n * (1 ±0)` - // Minimum execution time: 341_302_000 picoseconds. - Weight::from_parts(354_111_630, 6925) - // Standard Error: 8 - .saturating_add(Weight::from_parts(5_913, 0).saturating_mul(n.into())) + // Measured: `964 + n * (1 ±0)` + // Estimated: `6901 + n * (1 ±0)` + // Minimum execution time: 343_955_000 picoseconds. + Weight::from_parts(350_777_388, 6901) + // Standard Error: 14 + .saturating_add(Weight::from_parts(5_915, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1744,7 +1771,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1756,12 +1783,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 160]`. fn seal_sr25519_verify(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `804 + r * (112 ±0)` - // Estimated: `6742 + r * (112 ±0)` - // Minimum execution time: 275_325_000 picoseconds. - Weight::from_parts(333_041_903, 6742) - // Standard Error: 11_171 - .saturating_add(Weight::from_parts(56_605_218, 0).saturating_mul(r.into())) + // Measured: `774 + r * (112 ±0)` + // Estimated: `6715 + r * (112 ±0)` + // Minimum execution time: 268_698_000 picoseconds. + Weight::from_parts(336_398_814, 6715) + // Standard Error: 16_627 + .saturating_add(Weight::from_parts(56_155_384, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 112).saturating_mul(r.into())) @@ -1771,7 +1798,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1783,12 +1810,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `898 + r * (76 ±0)` - // Estimated: `6793 + r * (77 ±0)` - // Minimum execution time: 274_165_000 picoseconds. - Weight::from_parts(347_487_800, 6793) - // Standard Error: 15_398 - .saturating_add(Weight::from_parts(46_072_020, 0).saturating_mul(r.into())) + // Measured: `874 + r * (76 ±0)` + // Estimated: `6768 + r * (77 ±0)` + // Minimum execution time: 258_906_000 picoseconds. + Weight::from_parts(340_672_829, 6768) + // Standard Error: 18_295 + .saturating_add(Weight::from_parts(46_106_884, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 77).saturating_mul(r.into())) @@ -1798,7 +1825,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1810,12 +1837,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `868 + r * (42 ±0)` - // Estimated: `6807 + r * (42 ±0)` - // Minimum execution time: 270_855_000 picoseconds. - Weight::from_parts(320_777_105, 6807) - // Standard Error: 11_106 - .saturating_add(Weight::from_parts(12_053_053, 0).saturating_mul(r.into())) + // Measured: `844 + r * (42 ±0)` + // Estimated: `6783 + r * (42 ±0)` + // Minimum execution time: 275_105_000 picoseconds. + Weight::from_parts(313_700_348, 6783) + // Standard Error: 11_960 + .saturating_add(Weight::from_parts(12_050_300, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 42).saturating_mul(r.into())) @@ -1825,7 +1852,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1536 w:1536) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1536 w:0) @@ -1838,11 +1865,11 @@ impl WeightInfo for SubstrateWeight { fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (965 ±0)` - // Estimated: `6798 + r * (3090 ±10)` - // Minimum execution time: 257_732_000 picoseconds. - Weight::from_parts(280_982_000, 6798) - // Standard Error: 68_194 - .saturating_add(Weight::from_parts(27_413_991, 0).saturating_mul(r.into())) + // Estimated: `6774 + r * (3090 ±7)` + // Minimum execution time: 259_178_000 picoseconds. + Weight::from_parts(275_643_000, 6774) + // Standard Error: 54_044 + .saturating_add(Weight::from_parts(26_026_930, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1854,7 +1881,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1866,12 +1893,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 32]`. fn add_delegate_dependency(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `918 + r * (132 ±0)` - // Estimated: `6870 + r * (2606 ±0)` - // Minimum execution time: 278_285_000 picoseconds. - Weight::from_parts(298_012_554, 6870) - // Standard Error: 24_160 - .saturating_add(Weight::from_parts(6_363_118, 0).saturating_mul(r.into())) + // Measured: `895 + r * (131 ±0)` + // Estimated: `6845 + r * (2606 ±0)` + // Minimum execution time: 263_386_000 picoseconds. + Weight::from_parts(295_443_439, 6845) + // Standard Error: 24_422 + .saturating_add(Weight::from_parts(6_429_537, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1883,7 +1910,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `MaxEncodedLen`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1895,12 +1922,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 32]`. fn remove_delegate_dependency(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `965 + r * (183 ±0)` + // Measured: `936 + r * (183 ±0)` // Estimated: `129453 + r * (2568 ±0)` - // Minimum execution time: 258_198_000 picoseconds. - Weight::from_parts(290_090_206, 129453) - // Standard Error: 19_792 - .saturating_add(Weight::from_parts(6_004_811, 0).saturating_mul(r.into())) + // Minimum execution time: 261_371_000 picoseconds. + Weight::from_parts(297_493_194, 129453) + // Standard Error: 23_734 + .saturating_add(Weight::from_parts(5_673_169, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1912,7 +1939,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1924,12 +1951,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `849 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 263_315_000 picoseconds. - Weight::from_parts(284_093_748, 6799) - // Standard Error: 371 - .saturating_add(Weight::from_parts(176_949, 0).saturating_mul(r.into())) + // Measured: `825 + r * (3 ±0)` + // Estimated: `6771 + r * (3 ±0)` + // Minimum execution time: 275_558_000 picoseconds. + Weight::from_parts(287_220_765, 6771) + // Standard Error: 437 + .saturating_add(Weight::from_parts(184_125, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -1939,7 +1966,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1951,12 +1978,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2082 + r * (39 ±0)` - // Estimated: `7886 + r * (40 ±0)` - // Minimum execution time: 274_583_000 picoseconds. - Weight::from_parts(352_081_486, 7886) - // Standard Error: 1_799 - .saturating_add(Weight::from_parts(313_433, 0).saturating_mul(r.into())) + // Measured: `2076 + r * (39 ±0)` + // Estimated: `7866 + r * (40 ±0)` + // Minimum execution time: 265_752_000 picoseconds. + Weight::from_parts(331_187_665, 7866) + // Standard Error: 1_950 + .saturating_add(Weight::from_parts(312_262, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1966,7 +1993,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -1980,12 +2007,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 267_291_000 picoseconds. - Weight::from_parts(287_500_540, 6799) - // Standard Error: 393 - .saturating_add(Weight::from_parts(152_587, 0).saturating_mul(r.into())) + // Measured: `828 + r * (3 ±0)` + // Estimated: `6768 + r * (3 ±0)` + // Minimum execution time: 257_114_000 picoseconds. + Weight::from_parts(286_686_654, 6768) + // Standard Error: 426 + .saturating_add(Weight::from_parts(162_295, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -1995,10 +2022,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_440_000 picoseconds. - Weight::from_parts(1_656_631, 0) - // Standard Error: 13 - .saturating_add(Weight::from_parts(10_486, 0).saturating_mul(r.into())) + // Minimum execution time: 1_388_000 picoseconds. + Weight::from_parts(1_680_408, 0) + // Standard Error: 21 + .saturating_add(Weight::from_parts(10_564, 0).saturating_mul(r.into())) } } @@ -2010,8 +2037,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 2_527_000 picoseconds. - Weight::from_parts(2_651_000, 1627) + // Minimum execution time: 2_410_000 picoseconds. + Weight::from_parts(2_581_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -2021,10 +2048,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `451 + k * (69 ±0)` // Estimated: `441 + k * (70 ±0)` - // Minimum execution time: 13_291_000 picoseconds. - Weight::from_parts(13_825_000, 441) - // Standard Error: 1_137 - .saturating_add(Weight::from_parts(1_244_309, 0).saturating_mul(k.into())) + // Minimum execution time: 13_278_000 picoseconds. + Weight::from_parts(13_944_000, 441) + // Standard Error: 1_643 + .saturating_add(Weight::from_parts(1_194_404, 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)) @@ -2038,25 +2065,25 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `211 + c * (1 ±0)` // Estimated: `6149 + c * (1 ±0)` - // Minimum execution time: 8_359_000 picoseconds. - Weight::from_parts(9_179_121, 6149) + // Minimum execution time: 8_533_000 picoseconds. + Weight::from_parts(9_141_899, 6149) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_312, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_327, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: `Contracts::ContractInfoOf` (r:3 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) fn v10_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `709` - // Estimated: `9124` - // Minimum execution time: 42_457_000 picoseconds. - Weight::from_parts(44_556_000, 9124) - .saturating_add(RocksDbWeight::get().reads(4_u64)) + // Measured: `510` + // Estimated: `6450` + // Minimum execution time: 16_998_000 picoseconds. + Weight::from_parts(17_776_000, 6450) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Contracts::DeletionQueue` (r:1 w:1025) @@ -2068,10 +2095,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `171 + k * (1 ±0)` // Estimated: `3635 + k * (1 ±0)` - // Minimum execution time: 3_839_000 picoseconds. - Weight::from_parts(3_462_337, 3635) - // Standard Error: 1_384 - .saturating_add(Weight::from_parts(1_166_522, 0).saturating_mul(k.into())) + // Minimum execution time: 3_919_000 picoseconds. + Weight::from_parts(4_057_153, 3635) + // Standard Error: 1_252 + .saturating_add(Weight::from_parts(1_151_419, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -2090,38 +2117,52 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `325 + c * (1 ±0)` // Estimated: `6263 + c * (1 ±0)` - // Minimum execution time: 17_001_000 picoseconds. - Weight::from_parts(17_095_380, 6263) + // Minimum execution time: 17_730_000 picoseconds. + Weight::from_parts(17_540_884, 6263) // Standard Error: 1 - .saturating_add(Weight::from_parts(411, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(417, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: `Contracts::ContractInfoOf` (r:3 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) fn v13_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `639` - // Estimated: `9054` - // Minimum execution time: 35_342_000 picoseconds. - Weight::from_parts(36_839_000, 9054) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `440` + // Estimated: `6380` + // Minimum execution time: 13_089_000 picoseconds. + Weight::from_parts(13_727_000, 6380) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) - /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) - /// Storage: `System::Account` (r:1 w:0) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:0) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) fn v14_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `260` - // Estimated: `6200` - // Minimum execution time: 27_995_000 picoseconds. - Weight::from_parts(28_661_000, 6200) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `360` + // Estimated: `6300` + // Minimum execution time: 49_083_000 picoseconds. + Weight::from_parts(50_462_000, 6300) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + fn v15_migration_step() -> Weight { + // Proof Size summary in bytes: + // Measured: `594` + // Estimated: `6534` + // Minimum execution time: 49_299_000 picoseconds. + Weight::from_parts(50_805_000, 6534) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -2129,8 +2170,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 3_272_000 picoseconds. - Weight::from_parts(3_553_000, 1627) + // Minimum execution time: 3_305_000 picoseconds. + Weight::from_parts(3_489_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2142,8 +2183,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 12_788_000 picoseconds. - Weight::from_parts(13_163_000, 3631) + // Minimum execution time: 12_657_000 picoseconds. + Weight::from_parts(13_100_000, 3631) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2153,8 +2194,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_794_000 picoseconds. - Weight::from_parts(5_086_000, 3607) + // Minimum execution time: 4_784_000 picoseconds. + Weight::from_parts(4_994_000, 3607) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -2165,8 +2206,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 6_616_000 picoseconds. - Weight::from_parts(7_034_000, 3632) + // Minimum execution time: 6_762_000 picoseconds. + Weight::from_parts(6_945_000, 3632) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -2177,15 +2218,15 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 6_985_000 picoseconds. - Weight::from_parts(7_477_000, 3607) + // Minimum execution time: 6_999_000 picoseconds. + Weight::from_parts(7_372_000, 3607) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2199,12 +2240,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `783` - // Estimated: `6732 + c * (1 ±0)` - // Minimum execution time: 306_088_000 picoseconds. - Weight::from_parts(268_361_911, 6732) - // Standard Error: 76 - .saturating_add(Weight::from_parts(38_334, 0).saturating_mul(c.into())) + // Measured: `759` + // Estimated: `6710 + c * (1 ±0)` + // Minimum execution time: 304_121_000 picoseconds. + Weight::from_parts(288_627_840, 6710) + // Standard Error: 83 + .saturating_add(Weight::from_parts(37_343, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -2213,15 +2254,17 @@ impl WeightInfo for () { /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:3 w:3) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) @@ -2230,18 +2273,18 @@ impl WeightInfo for () { /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `303` - // Estimated: `8745` - // Minimum execution time: 4_224_657_000 picoseconds. - Weight::from_parts(451_557_864, 8745) - // Standard Error: 216 - .saturating_add(Weight::from_parts(111_761, 0).saturating_mul(c.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(1_794, 0).saturating_mul(i.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(2_013, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(9_u64)) + // Measured: `290` + // Estimated: `8714` + // Minimum execution time: 4_101_589_000 picoseconds. + Weight::from_parts(694_193_047, 8714) + // Standard Error: 334 + .saturating_add(Weight::from_parts(108_847, 0).saturating_mul(c.into())) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_677, 0).saturating_mul(i.into())) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_783, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(10_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -2252,11 +2295,13 @@ impl WeightInfo for () { /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:2 w:2) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. @@ -2264,20 +2309,20 @@ impl WeightInfo for () { fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `527` - // Estimated: `6517` - // Minimum execution time: 2_029_313_000 picoseconds. - Weight::from_parts(353_077_600, 6517) - // Standard Error: 8 - .saturating_add(Weight::from_parts(1_781, 0).saturating_mul(i.into())) - // Standard Error: 8 - .saturating_add(Weight::from_parts(1_729, 0).saturating_mul(s.into())) + // Estimated: `6471` + // Minimum execution time: 2_011_580_000 picoseconds. + Weight::from_parts(397_415_227, 6471) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_689, 0).saturating_mul(i.into())) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_679, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2290,10 +2335,10 @@ impl WeightInfo for () { /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `817` - // Estimated: `6757` - // Minimum execution time: 204_086_000 picoseconds. - Weight::from_parts(216_738_000, 6757) + // Measured: `793` + // Estimated: `6733` + // Minimum execution time: 204_975_000 picoseconds. + Weight::from_parts(214_770_000, 6733) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2301,6 +2346,8 @@ impl WeightInfo for () { /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) @@ -2310,44 +2357,46 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 269_337_000 picoseconds. - Weight::from_parts(220_186_006, 3607) - // Standard Error: 106 - .saturating_add(Weight::from_parts(74_291, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Minimum execution time: 269_545_000 picoseconds. + Weight::from_parts(256_054_650, 3607) + // Standard Error: 91 + .saturating_add(Weight::from_parts(72_743, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `259` - // Estimated: `3724` - // Minimum execution time: 35_127_000 picoseconds. - Weight::from_parts(36_180_000, 3724) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `315` + // Estimated: `3780` + // Minimum execution time: 47_880_000 picoseconds. + Weight::from_parts(49_427_000, 3780) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `System::EventTopics` (r:3 w:3) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `576` - // Estimated: `8991` - // Minimum execution time: 37_550_000 picoseconds. - Weight::from_parts(39_149_000, 8991) + // Measured: `552` + // Estimated: `8967` + // Minimum execution time: 37_898_000 picoseconds. + Weight::from_parts(39_826_000, 8967) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2356,7 +2405,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2368,12 +2417,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6798 + r * (6 ±0)` - // Minimum execution time: 269_991_000 picoseconds. - Weight::from_parts(293_993_592, 6798) - // Standard Error: 665 - .saturating_add(Weight::from_parts(343_796, 0).saturating_mul(r.into())) + // Measured: `833 + r * (6 ±0)` + // Estimated: `6773 + r * (6 ±0)` + // Minimum execution time: 260_916_000 picoseconds. + Weight::from_parts(295_521_846, 6773) + // Standard Error: 1_126 + .saturating_add(Weight::from_parts(348_317, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2383,7 +2432,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2395,23 +2444,23 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `924 + r * (232 ±0)` - // Estimated: `6831 + r * (2707 ±0)` - // Minimum execution time: 274_151_000 picoseconds. - Weight::from_parts(83_529_206, 6831) - // Standard Error: 8_452 - .saturating_add(Weight::from_parts(3_534_024, 0).saturating_mul(r.into())) + // Measured: `889 + r * (209 ±0)` + // Estimated: `6793 + r * (2684 ±0)` + // Minimum execution time: 274_335_000 picoseconds. + Weight::from_parts(132_998_512, 6793) + // Standard Error: 7_396 + .saturating_add(Weight::from_parts(3_602_287, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2707).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2423,23 +2472,23 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `910 + r * (236 ±0)` - // Estimated: `6835 + r * (2711 ±0)` - // Minimum execution time: 276_689_000 picoseconds. - Weight::from_parts(110_268_281, 6835) - // Standard Error: 8_106 - .saturating_add(Weight::from_parts(4_376_136, 0).saturating_mul(r.into())) + // Measured: `888 + r * (213 ±0)` + // Estimated: `6797 + r * (2688 ±0)` + // Minimum execution time: 272_514_000 picoseconds. + Weight::from_parts(104_825_618, 6797) + // Standard Error: 10_038 + .saturating_add(Weight::from_parts(4_520_258, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2711).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2688).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2451,12 +2500,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (6 ±0)` - // Estimated: `6806 + r * (6 ±0)` - // Minimum execution time: 274_079_000 picoseconds. - Weight::from_parts(282_258_090, 6806) - // Standard Error: 1_343 - .saturating_add(Weight::from_parts(464_680, 0).saturating_mul(r.into())) + // Measured: `840 + r * (6 ±0)` + // Estimated: `6782 + r * (6 ±0)` + // Minimum execution time: 264_593_000 picoseconds. + Weight::from_parts(294_139_363, 6782) + // Standard Error: 907 + .saturating_add(Weight::from_parts(432_964, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2466,7 +2515,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2478,12 +2527,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 270_960_000 picoseconds. - Weight::from_parts(281_985_584, 6799) - // Standard Error: 378 - .saturating_add(Weight::from_parts(184_462, 0).saturating_mul(r.into())) + // Measured: `830 + r * (3 ±0)` + // Estimated: `6771 + r * (3 ±0)` + // Minimum execution time: 260_412_000 picoseconds. + Weight::from_parts(284_371_703, 6771) + // Standard Error: 433 + .saturating_add(Weight::from_parts(182_952, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -2491,7 +2540,7 @@ impl WeightInfo for () { /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2503,12 +2552,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_root(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `744 + r * (3 ±0)` - // Estimated: `6684 + r * (3 ±0)` - // Minimum execution time: 244_835_000 picoseconds. - Weight::from_parts(270_660_753, 6684) - // Standard Error: 390 - .saturating_add(Weight::from_parts(164_232, 0).saturating_mul(r.into())) + // Measured: `720 + r * (3 ±0)` + // Estimated: `6660 + r * (3 ±0)` + // Minimum execution time: 255_112_000 picoseconds. + Weight::from_parts(273_052_488, 6660) + // Standard Error: 376 + .saturating_add(Weight::from_parts(166_644, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -2518,7 +2567,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2530,12 +2579,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (6 ±0)` - // Estimated: `6800 + r * (6 ±0)` - // Minimum execution time: 273_269_000 picoseconds. - Weight::from_parts(274_468_168, 6800) - // Standard Error: 2_246 - .saturating_add(Weight::from_parts(386_838, 0).saturating_mul(r.into())) + // Measured: `834 + r * (6 ±0)` + // Estimated: `6774 + r * (6 ±0)` + // Minimum execution time: 270_426_000 picoseconds. + Weight::from_parts(289_240_775, 6774) + // Standard Error: 748 + .saturating_add(Weight::from_parts(344_791, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2545,7 +2594,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2557,12 +2606,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (6 ±0)` - // Estimated: `6795 + r * (6 ±0)` - // Minimum execution time: 275_244_000 picoseconds. - Weight::from_parts(281_299_739, 6795) - // Standard Error: 2_890 - .saturating_add(Weight::from_parts(600_498, 0).saturating_mul(r.into())) + // Measured: `830 + r * (6 ±0)` + // Estimated: `6773 + r * (6 ±0)` + // Minimum execution time: 260_217_000 picoseconds. + Weight::from_parts(288_660_978, 6773) + // Standard Error: 1_199 + .saturating_add(Weight::from_parts(550_304, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2572,7 +2621,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:2 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2584,12 +2633,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `998 + r * (6 ±0)` - // Estimated: `6922 + r * (6 ±0)` - // Minimum execution time: 271_540_000 picoseconds. - Weight::from_parts(298_456_935, 6922) - // Standard Error: 2_881 - .saturating_add(Weight::from_parts(1_719_337, 0).saturating_mul(r.into())) + // Measured: `974 + r * (6 ±0)` + // Estimated: `6898 + r * (6 ±0)` + // Minimum execution time: 273_473_000 picoseconds. + Weight::from_parts(298_889_279, 6898) + // Standard Error: 4_604 + .saturating_add(Weight::from_parts(1_630_175, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2599,7 +2648,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2611,12 +2660,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `868 + r * (6 ±0)` - // Estimated: `6817 + r * (6 ±0)` - // Minimum execution time: 274_832_000 picoseconds. - Weight::from_parts(286_078_648, 6817) - // Standard Error: 695 - .saturating_add(Weight::from_parts(345_045, 0).saturating_mul(r.into())) + // Measured: `844 + r * (6 ±0)` + // Estimated: `6790 + r * (6 ±0)` + // Minimum execution time: 262_033_000 picoseconds. + Weight::from_parts(284_293_851, 6790) + // Standard Error: 591 + .saturating_add(Weight::from_parts(369_240, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2626,7 +2675,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2638,12 +2687,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866 + r * (6 ±0)` - // Estimated: `6815 + r * (6 ±0)` - // Minimum execution time: 267_337_000 picoseconds. - Weight::from_parts(283_693_170, 6815) - // Standard Error: 580 - .saturating_add(Weight::from_parts(345_350, 0).saturating_mul(r.into())) + // Measured: `842 + r * (6 ±0)` + // Estimated: `6783 + r * (6 ±0)` + // Minimum execution time: 274_568_000 picoseconds. + Weight::from_parts(294_688_466, 6783) + // Standard Error: 768 + .saturating_add(Weight::from_parts(349_584, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2653,7 +2702,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2665,12 +2714,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (6 ±0)` - // Estimated: `6813 + r * (6 ±0)` - // Minimum execution time: 276_313_000 picoseconds. - Weight::from_parts(287_689_703, 6813) - // Standard Error: 1_251 - .saturating_add(Weight::from_parts(342_536, 0).saturating_mul(r.into())) + // Measured: `839 + r * (6 ±0)` + // Estimated: `6786 + r * (6 ±0)` + // Minimum execution time: 264_061_000 picoseconds. + Weight::from_parts(287_964_188, 6786) + // Standard Error: 490 + .saturating_add(Weight::from_parts(356_273, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2680,7 +2729,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2692,12 +2741,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (6 ±0)` - // Estimated: `6799 + r * (6 ±0)` - // Minimum execution time: 274_196_000 picoseconds. - Weight::from_parts(288_641_687, 6799) - // Standard Error: 530 - .saturating_add(Weight::from_parts(336_194, 0).saturating_mul(r.into())) + // Measured: `830 + r * (6 ±0)` + // Estimated: `6771 + r * (6 ±0)` + // Minimum execution time: 275_707_000 picoseconds. + Weight::from_parts(290_797_828, 6771) + // Standard Error: 967 + .saturating_add(Weight::from_parts(352_839, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2707,7 +2756,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2721,12 +2770,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `928 + r * (14 ±0)` - // Estimated: `6861 + r * (14 ±0)` - // Minimum execution time: 254_997_000 picoseconds. - Weight::from_parts(292_260_891, 6861) - // Standard Error: 1_019 - .saturating_add(Weight::from_parts(1_447_021, 0).saturating_mul(r.into())) + // Measured: `904 + r * (14 ±0)` + // Estimated: `6839 + r * (14 ±0)` + // Minimum execution time: 272_492_000 picoseconds. + Weight::from_parts(295_010_878, 6839) + // Standard Error: 2_549 + .saturating_add(Weight::from_parts(1_426_715, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 14).saturating_mul(r.into())) @@ -2736,7 +2785,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2748,12 +2797,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (6 ±0)` - // Estimated: `6800 + r * (6 ±0)` - // Minimum execution time: 272_720_000 picoseconds. - Weight::from_parts(287_125_181, 6800) - // Standard Error: 491 - .saturating_add(Weight::from_parts(294_488, 0).saturating_mul(r.into())) + // Measured: `832 + r * (6 ±0)` + // Estimated: `6774 + r * (6 ±0)` + // Minimum execution time: 257_981_000 picoseconds. + Weight::from_parts(285_824_773, 6774) + // Standard Error: 704 + .saturating_add(Weight::from_parts(301_327, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) @@ -2763,7 +2812,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2775,12 +2824,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `860` - // Estimated: `6800` - // Minimum execution time: 280_665_000 picoseconds. - Weight::from_parts(233_022_448, 6800) - // Standard Error: 23 - .saturating_add(Weight::from_parts(996, 0).saturating_mul(n.into())) + // Measured: `836` + // Estimated: `6776` + // Minimum execution time: 259_470_000 picoseconds. + Weight::from_parts(232_759_442, 6776) + // Standard Error: 24 + .saturating_add(Weight::from_parts(981, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2789,7 +2838,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2801,12 +2850,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `844 + r * (45 ±0)` - // Estimated: `6784 + r * (45 ±0)` - // Minimum execution time: 250_335_000 picoseconds. - Weight::from_parts(278_774_071, 6784) - // Standard Error: 873_509 - .saturating_add(Weight::from_parts(4_562_628, 0).saturating_mul(r.into())) + // Measured: `820 + r * (45 ±0)` + // Estimated: `6760 + r * (45 ±0)` + // Minimum execution time: 252_740_000 picoseconds. + Weight::from_parts(278_155_436, 6760) + // Standard Error: 882_420 + .saturating_add(Weight::from_parts(755_063, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 45).saturating_mul(r.into())) @@ -2816,7 +2865,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2828,21 +2877,21 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854` - // Estimated: `6807` - // Minimum execution time: 278_402_000 picoseconds. - Weight::from_parts(285_491_021, 6807) - // Standard Error: 0 - .saturating_add(Weight::from_parts(312, 0).saturating_mul(n.into())) + // Measured: `830` + // Estimated: `6777` + // Minimum execution time: 257_318_000 picoseconds. + Weight::from_parts(285_765_697, 6777) + // Standard Error: 1 + .saturating_add(Weight::from_parts(322, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:4 w:4) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2851,31 +2900,33 @@ impl WeightInfo for () { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::DeletionQueueCounter` (r:1 w:1) /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:3 w:3) + /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) /// Storage: `Contracts::DeletionQueue` (r:0 w:1) /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2963 + r * (400 ±0)` - // Estimated: `8903 + r * (7825 ±0)` - // Minimum execution time: 281_030_000 picoseconds. - Weight::from_parts(305_435_226, 8903) - // Standard Error: 816_824 - .saturating_add(Weight::from_parts(131_691_873, 0).saturating_mul(r.into())) + // Measured: `2939 + r * (316 ±0)` + // Estimated: `8879 + r * (5266 ±0)` + // Minimum execution time: 280_392_000 picoseconds. + Weight::from_parts(310_023_381, 8879) + // Standard Error: 1_008_026 + .saturating_add(Weight::from_parts(130_208_818, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((9_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 7825).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 5266).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2889,12 +2940,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (10 ±0)` - // Estimated: `6876 + r * (10 ±0)` - // Minimum execution time: 261_369_000 picoseconds. - Weight::from_parts(300_458_315, 6876) - // Standard Error: 3_506 - .saturating_add(Weight::from_parts(1_971_733, 0).saturating_mul(r.into())) + // Measured: `911 + r * (10 ±0)` + // Estimated: `6852 + r * (10 ±0)` + // Minimum execution time: 270_547_000 picoseconds. + Weight::from_parts(295_931_189, 6852) + // Standard Error: 3_280 + .saturating_add(Weight::from_parts(1_941_248, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) @@ -2904,7 +2955,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2916,12 +2967,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + r * (10 ±0)` - // Estimated: `6799 + r * (10 ±0)` - // Minimum execution time: 262_894_000 picoseconds. - Weight::from_parts(285_321_838, 6799) - // Standard Error: 6_585 - .saturating_add(Weight::from_parts(3_998_744, 0).saturating_mul(r.into())) + // Measured: `830 + r * (10 ±0)` + // Estimated: `6772 + r * (10 ±0)` + // Minimum execution time: 255_730_000 picoseconds. + Weight::from_parts(301_859_471, 6772) + // Standard Error: 5_401 + .saturating_add(Weight::from_parts(3_887_632, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) @@ -2931,7 +2982,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2944,14 +2995,14 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + t * (32 ±0)` - // Estimated: `6820 + t * (2508 ±0)` - // Minimum execution time: 275_909_000 picoseconds. - Weight::from_parts(289_251_568, 6820) - // Standard Error: 94_431 - .saturating_add(Weight::from_parts(3_007_409, 0).saturating_mul(t.into())) - // Standard Error: 26 - .saturating_add(Weight::from_parts(815, 0).saturating_mul(n.into())) + // Measured: `847 + t * (32 ±0)` + // Estimated: `6792 + t * (2508 ±0)` + // Minimum execution time: 276_643_000 picoseconds. + Weight::from_parts(294_275_838, 6792) + // Standard Error: 106_745 + .saturating_add(Weight::from_parts(2_831_489, 0).saturating_mul(t.into())) + // Standard Error: 29 + .saturating_add(Weight::from_parts(624, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2963,7 +3014,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -2975,12 +3026,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `853 + r * (7 ±0)` - // Estimated: `6797 + r * (7 ±0)` - // Minimum execution time: 168_482_000 picoseconds. - Weight::from_parts(178_065_606, 6797) - // Standard Error: 371 - .saturating_add(Weight::from_parts(242_851, 0).saturating_mul(r.into())) + // Measured: `829 + r * (7 ±0)` + // Estimated: `6774 + r * (7 ±0)` + // Minimum execution time: 169_012_000 picoseconds. + Weight::from_parts(179_567_029, 6774) + // Standard Error: 534 + .saturating_add(Weight::from_parts(249_500, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 7).saturating_mul(r.into())) @@ -2990,7 +3041,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `MaxEncodedLen`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3002,12 +3053,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125804` - // Estimated: `131746` - // Minimum execution time: 407_401_000 picoseconds. - Weight::from_parts(426_585_443, 131746) - // Standard Error: 22 - .saturating_add(Weight::from_parts(986, 0).saturating_mul(i.into())) + // Measured: `125780` + // Estimated: `131722` + // Minimum execution time: 408_647_000 picoseconds. + Weight::from_parts(387_678_006, 131722) + // Standard Error: 12 + .saturating_add(Weight::from_parts(1_045, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3016,12 +3067,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (292 ±0)` - // Estimated: `919 + r * (293 ±0)` - // Minimum execution time: 275_800_000 picoseconds. - Weight::from_parts(161_230_700, 919) - // Standard Error: 12_908 - .saturating_add(Weight::from_parts(6_965_844, 0).saturating_mul(r.into())) + // Measured: `891 + r * (292 ±0)` + // Estimated: `892 + r * (293 ±0)` + // Minimum execution time: 279_315_000 picoseconds. + Weight::from_parts(171_270_899, 892) + // Standard Error: 15_492 + .saturating_add(Weight::from_parts(6_776_878, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3033,26 +3084,26 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1380` - // Estimated: `1356` - // Minimum execution time: 289_258_000 picoseconds. - Weight::from_parts(334_318_402, 1356) - // Standard Error: 59 - .saturating_add(Weight::from_parts(808, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + // Measured: `1413` + // Estimated: `1396` + // Minimum execution time: 289_666_000 picoseconds. + Weight::from_parts(348_062_625, 1396) + // Standard Error: 79 + .saturating_add(Weight::from_parts(532, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(8_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, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1243 + n * (1 ±0)` - // Estimated: `1243 + n * (1 ±0)` - // Minimum execution time: 277_874_000 picoseconds. - Weight::from_parts(303_956_600, 1243) - // Standard Error: 33 - .saturating_add(Weight::from_parts(58, 0).saturating_mul(n.into())) + // Measured: `1219 + n * (1 ±0)` + // Estimated: `1219 + n * (1 ±0)` + // Minimum execution time: 273_840_000 picoseconds. + Weight::from_parts(297_024_621, 1219) + // Standard Error: 55 + .saturating_add(Weight::from_parts(945, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3062,12 +3113,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `917 + r * (288 ±0)` - // Estimated: `921 + r * (289 ±0)` - // Minimum execution time: 255_230_000 picoseconds. - Weight::from_parts(163_226_984, 921) - // Standard Error: 12_691 - .saturating_add(Weight::from_parts(6_808_905, 0).saturating_mul(r.into())) + // Measured: `887 + r * (288 ±0)` + // Estimated: `893 + r * (289 ±0)` + // Minimum execution time: 279_110_000 picoseconds. + Weight::from_parts(177_898_012, 893) + // Standard Error: 16_287 + .saturating_add(Weight::from_parts(6_640_103, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3079,12 +3130,10 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1239 + n * (1 ±0)` - // Estimated: `1239 + n * (1 ±0)` - // Minimum execution time: 275_780_000 picoseconds. - Weight::from_parts(301_967_262, 1239) - // Standard Error: 34 - .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) + // Measured: `1215 + n * (1 ±0)` + // Estimated: `1215 + n * (1 ±0)` + // Minimum execution time: 276_566_000 picoseconds. + Weight::from_parts(304_992_376, 1215) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3094,12 +3143,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `911 + r * (296 ±0)` - // Estimated: `916 + r * (297 ±0)` - // Minimum execution time: 279_295_000 picoseconds. - Weight::from_parts(208_289_066, 916) - // Standard Error: 8_330 - .saturating_add(Weight::from_parts(5_600_713, 0).saturating_mul(r.into())) + // Measured: `887 + r * (296 ±0)` + // Estimated: `889 + r * (297 ±0)` + // Minimum execution time: 266_285_000 picoseconds. + Weight::from_parts(200_488_939, 889) + // Standard Error: 11_193 + .saturating_add(Weight::from_parts(5_467_725, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3110,12 +3159,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1255 + n * (1 ±0)` - // Estimated: `1255 + n * (1 ±0)` - // Minimum execution time: 276_745_000 picoseconds. - Weight::from_parts(298_824_233, 1255) - // Standard Error: 36 - .saturating_add(Weight::from_parts(717, 0).saturating_mul(n.into())) + // Measured: `1231 + n * (1 ±0)` + // Estimated: `1231 + n * (1 ±0)` + // Minimum execution time: 278_625_000 picoseconds. + Weight::from_parts(304_319_493, 1231) + // Standard Error: 39 + .saturating_add(Weight::from_parts(415, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3125,12 +3174,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `932 + r * (288 ±0)` - // Estimated: `933 + r * (289 ±0)` - // Minimum execution time: 275_137_000 picoseconds. - Weight::from_parts(196_695_898, 933) - // Standard Error: 9_207 - .saturating_add(Weight::from_parts(5_466_071, 0).saturating_mul(r.into())) + // Measured: `898 + r * (288 ±0)` + // Estimated: `895 + r * (289 ±0)` + // Minimum execution time: 271_851_000 picoseconds. + Weight::from_parts(202_164_395, 895) + // Standard Error: 11_115 + .saturating_add(Weight::from_parts(5_273_320, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3141,12 +3190,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1242 + n * (1 ±0)` - // Estimated: `1242 + n * (1 ±0)` - // Minimum execution time: 269_315_000 picoseconds. - Weight::from_parts(296_795_271, 1242) - // Standard Error: 39 - .saturating_add(Weight::from_parts(242, 0).saturating_mul(n.into())) + // Measured: `1218 + n * (1 ±0)` + // Estimated: `1218 + n * (1 ±0)` + // Minimum execution time: 274_200_000 picoseconds. + Weight::from_parts(299_524_586, 1218) + // Standard Error: 33 + .saturating_add(Weight::from_parts(272, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3156,12 +3205,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `905 + r * (296 ±0)` - // Estimated: `912 + r * (297 ±0)` - // Minimum execution time: 256_406_000 picoseconds. - Weight::from_parts(156_850_288, 912) - // Standard Error: 12_496 - .saturating_add(Weight::from_parts(7_055_305, 0).saturating_mul(r.into())) + // Measured: `880 + r * (296 ±0)` + // Estimated: `885 + r * (297 ±0)` + // Minimum execution time: 258_535_000 picoseconds. + Weight::from_parts(190_468_808, 885) + // Standard Error: 11_940 + .saturating_add(Weight::from_parts(6_737_079, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3173,12 +3222,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1256 + n * (1 ±0)` - // Estimated: `1256 + n * (1 ±0)` - // Minimum execution time: 280_297_000 picoseconds. - Weight::from_parts(302_241_752, 1256) - // Standard Error: 34 - .saturating_add(Weight::from_parts(748, 0).saturating_mul(n.into())) + // Measured: `1232 + n * (1 ±0)` + // Estimated: `1232 + n * (1 ±0)` + // Minimum execution time: 280_536_000 picoseconds. + Weight::from_parts(304_479_477, 1232) + // Standard Error: 37 + .saturating_add(Weight::from_parts(534, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3188,7 +3237,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1602 w:1601) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3200,12 +3249,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1449 + r * (45 ±0)` - // Estimated: `7346 + r * (2520 ±0)` - // Minimum execution time: 274_834_000 picoseconds. - Weight::from_parts(176_977_557, 7346) - // Standard Error: 32_386 - .saturating_add(Weight::from_parts(39_393_162, 0).saturating_mul(r.into())) + // Measured: `1382 + r * (45 ±0)` + // Estimated: `7274 + r * (2520 ±0)` + // Minimum execution time: 260_373_000 picoseconds. + Weight::from_parts(278_290_000, 7274) + // Standard Error: 25_683 + .saturating_add(Weight::from_parts(39_264_864, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -3217,7 +3266,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -3229,24 +3278,24 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1304 + r * (268 ±0)` - // Estimated: `9485 + r * (2744 ±0)` - // Minimum execution time: 279_802_000 picoseconds. - Weight::from_parts(287_995_000, 9485) - // Standard Error: 99_110 - .saturating_add(Weight::from_parts(245_521_843, 0).saturating_mul(r.into())) + // Measured: `1227 + r * (245 ±0)` + // Estimated: `9407 + r * (2721 ±0)` + // Minimum execution time: 277_621_000 picoseconds. + Weight::from_parts(281_775_000, 9407) + // Standard Error: 110_802 + .saturating_add(Weight::from_parts(245_363_533, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2744).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2721).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:736 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:736 w:0) @@ -3259,11 +3308,11 @@ impl WeightInfo for () { fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (576 ±0)` - // Estimated: `6803 + r * (2637 ±3)` - // Minimum execution time: 273_435_000 picoseconds. - Weight::from_parts(276_865_000, 6803) - // Standard Error: 148_051 - .saturating_add(Weight::from_parts(244_660_274, 0).saturating_mul(r.into())) + // Estimated: `6779 + r * (2637 ±3)` + // Minimum execution time: 267_314_000 picoseconds. + Weight::from_parts(279_888_000, 6779) + // Standard Error: 144_378 + .saturating_add(Weight::from_parts(244_606_414, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3275,7 +3324,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -3288,26 +3337,26 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1322 + t * (310 ±0)` - // Estimated: `12212 + t * (5260 ±0)` - // Minimum execution time: 477_593_000 picoseconds. - Weight::from_parts(69_887_451, 12212) - // Standard Error: 11_764_606 - .saturating_add(Weight::from_parts(373_361_977, 0).saturating_mul(t.into())) + // Measured: `1274 + t * (277 ±0)` + // Estimated: `12164 + t * (5227 ±0)` + // Minimum execution time: 477_589_000 picoseconds. + Weight::from_parts(70_712_793, 12164) + // Standard Error: 11_713_135 + .saturating_add(Weight::from_parts(375_371_698, 0).saturating_mul(t.into())) // Standard Error: 17 - .saturating_add(Weight::from_parts(1_000, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(991, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 5260).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 5227).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:1602 w:1602) + /// Storage: `System::Account` (r:802 w:802) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:801 w:800) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:801 w:0) @@ -3316,29 +3365,31 @@ impl WeightInfo for () { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:802 w:802) + /// Storage: `Balances::Holds` (r:800 w:800) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:803 w:803) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1380 + r * (255 ±0)` - // Estimated: `7204 + r * (5206 ±0)` - // Minimum execution time: 652_387_000 picoseconds. - Weight::from_parts(658_670_000, 7204) - // Standard Error: 363_054 - .saturating_add(Weight::from_parts(395_547_049, 0).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) + // Measured: `1245 + r * (255 ±0)` + // Estimated: `9587 + r * (2731 ±0)` + // Minimum execution time: 662_502_000 picoseconds. + Weight::from_parts(671_726_000, 9587) + // Standard Error: 351_643 + .saturating_add(Weight::from_parts(390_457_971, 0).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 5206).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2731).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) - /// Storage: `System::Account` (r:4 w:4) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:2 w:0) @@ -3347,35 +3398,37 @@ impl WeightInfo for () { /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) - /// Storage: `System::EventTopics` (r:3 w:3) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 983040]`. /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1233 + t * (156 ±0)` - // Estimated: `9663 + t * (2578 ±2)` - // Minimum execution time: 2_299_620_000 picoseconds. - Weight::from_parts(1_274_859_063, 9663) - // Standard Error: 12_129_871 - .saturating_add(Weight::from_parts(16_608_792, 0).saturating_mul(t.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_014, 0).saturating_mul(i.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_180, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(15_u64)) + // Measured: `1270 + t * (104 ±0)` + // Estimated: `12178 + t * (2549 ±1)` + // Minimum execution time: 2_675_525_000 picoseconds. + Weight::from_parts(851_421_242, 12178) + // Standard Error: 7_094_722 + .saturating_add(Weight::from_parts(112_457_697, 0).saturating_mul(t.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_867, 0).saturating_mul(i.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_931, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(10_u64)) + .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2578).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 2549).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3387,12 +3440,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `853 + r * (8 ±0)` - // Estimated: `6794 + r * (8 ±0)` - // Minimum execution time: 267_959_000 picoseconds. - Weight::from_parts(282_967_946, 6794) - // Standard Error: 624 - .saturating_add(Weight::from_parts(402_344, 0).saturating_mul(r.into())) + // Measured: `829 + r * (8 ±0)` + // Estimated: `6768 + r * (8 ±0)` + // Minimum execution time: 270_818_000 picoseconds. + Weight::from_parts(286_520_166, 6768) + // Standard Error: 575 + .saturating_add(Weight::from_parts(402_286, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -3402,7 +3455,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3414,12 +3467,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `861` - // Estimated: `6801` - // Minimum execution time: 274_585_000 picoseconds. - Weight::from_parts(272_480_647, 6801) + // Measured: `837` + // Estimated: `6775` + // Minimum execution time: 257_134_000 picoseconds. + Weight::from_parts(268_214_648, 6775) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_089, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_098, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3428,7 +3481,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3440,12 +3493,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6797 + r * (8 ±0)` - // Minimum execution time: 268_346_000 picoseconds. - Weight::from_parts(284_168_231, 6797) - // Standard Error: 620 - .saturating_add(Weight::from_parts(805_038, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6773 + r * (8 ±0)` + // Minimum execution time: 259_222_000 picoseconds. + Weight::from_parts(283_273_283, 6773) + // Standard Error: 967 + .saturating_add(Weight::from_parts(817_596, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -3455,7 +3508,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3467,12 +3520,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6805` - // Minimum execution time: 273_073_000 picoseconds. - Weight::from_parts(280_346_065, 6805) + // Measured: `839` + // Estimated: `6781` + // Minimum execution time: 260_040_000 picoseconds. + Weight::from_parts(283_869_860, 6781) // Standard Error: 1 - .saturating_add(Weight::from_parts(3_357, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_349, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3481,7 +3534,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3493,12 +3546,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6800 + r * (8 ±0)` - // Minimum execution time: 263_072_000 picoseconds. - Weight::from_parts(284_487_433, 6800) - // Standard Error: 668 - .saturating_add(Weight::from_parts(458_763, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6775 + r * (8 ±0)` + // Minimum execution time: 260_698_000 picoseconds. + Weight::from_parts(282_900_345, 6775) + // Standard Error: 805 + .saturating_add(Weight::from_parts(469_457, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -3508,7 +3561,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3520,12 +3573,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6809` - // Minimum execution time: 271_488_000 picoseconds. - Weight::from_parts(273_877_727, 6809) + // Measured: `839` + // Estimated: `6780` + // Minimum execution time: 256_967_000 picoseconds. + Weight::from_parts(273_024_512, 6780) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_202, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_204, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3534,7 +3587,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3546,12 +3599,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (8 ±0)` - // Estimated: `6801 + r * (8 ±0)` - // Minimum execution time: 271_365_000 picoseconds. - Weight::from_parts(285_100_883, 6801) - // Standard Error: 651 - .saturating_add(Weight::from_parts(462_754, 0).saturating_mul(r.into())) + // Measured: `831 + r * (8 ±0)` + // Estimated: `6772 + r * (8 ±0)` + // Minimum execution time: 272_039_000 picoseconds. + Weight::from_parts(289_853_116, 6772) + // Standard Error: 559 + .saturating_add(Weight::from_parts(459_383, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) @@ -3561,7 +3614,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3573,12 +3626,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6803` - // Minimum execution time: 272_341_000 picoseconds. - Weight::from_parts(275_388_470, 6803) + // Measured: `839` + // Estimated: `6778` + // Minimum execution time: 253_913_000 picoseconds. + Weight::from_parts(274_682_010, 6778) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_192, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_204, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3587,7 +3640,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3599,12 +3652,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `988 + n * (1 ±0)` - // Estimated: `6925 + n * (1 ±0)` - // Minimum execution time: 341_302_000 picoseconds. - Weight::from_parts(354_111_630, 6925) - // Standard Error: 8 - .saturating_add(Weight::from_parts(5_913, 0).saturating_mul(n.into())) + // Measured: `964 + n * (1 ±0)` + // Estimated: `6901 + n * (1 ±0)` + // Minimum execution time: 343_955_000 picoseconds. + Weight::from_parts(350_777_388, 6901) + // Standard Error: 14 + .saturating_add(Weight::from_parts(5_915, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3614,7 +3667,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3626,12 +3679,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 160]`. fn seal_sr25519_verify(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `804 + r * (112 ±0)` - // Estimated: `6742 + r * (112 ±0)` - // Minimum execution time: 275_325_000 picoseconds. - Weight::from_parts(333_041_903, 6742) - // Standard Error: 11_171 - .saturating_add(Weight::from_parts(56_605_218, 0).saturating_mul(r.into())) + // Measured: `774 + r * (112 ±0)` + // Estimated: `6715 + r * (112 ±0)` + // Minimum execution time: 268_698_000 picoseconds. + Weight::from_parts(336_398_814, 6715) + // Standard Error: 16_627 + .saturating_add(Weight::from_parts(56_155_384, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 112).saturating_mul(r.into())) @@ -3641,7 +3694,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3653,12 +3706,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `898 + r * (76 ±0)` - // Estimated: `6793 + r * (77 ±0)` - // Minimum execution time: 274_165_000 picoseconds. - Weight::from_parts(347_487_800, 6793) - // Standard Error: 15_398 - .saturating_add(Weight::from_parts(46_072_020, 0).saturating_mul(r.into())) + // Measured: `874 + r * (76 ±0)` + // Estimated: `6768 + r * (77 ±0)` + // Minimum execution time: 258_906_000 picoseconds. + Weight::from_parts(340_672_829, 6768) + // Standard Error: 18_295 + .saturating_add(Weight::from_parts(46_106_884, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 77).saturating_mul(r.into())) @@ -3668,7 +3721,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3680,12 +3733,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `868 + r * (42 ±0)` - // Estimated: `6807 + r * (42 ±0)` - // Minimum execution time: 270_855_000 picoseconds. - Weight::from_parts(320_777_105, 6807) - // Standard Error: 11_106 - .saturating_add(Weight::from_parts(12_053_053, 0).saturating_mul(r.into())) + // Measured: `844 + r * (42 ±0)` + // Estimated: `6783 + r * (42 ±0)` + // Minimum execution time: 275_105_000 picoseconds. + Weight::from_parts(313_700_348, 6783) + // Standard Error: 11_960 + .saturating_add(Weight::from_parts(12_050_300, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 42).saturating_mul(r.into())) @@ -3695,7 +3748,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1536 w:1536) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1536 w:0) @@ -3708,11 +3761,11 @@ impl WeightInfo for () { fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (965 ±0)` - // Estimated: `6798 + r * (3090 ±10)` - // Minimum execution time: 257_732_000 picoseconds. - Weight::from_parts(280_982_000, 6798) - // Standard Error: 68_194 - .saturating_add(Weight::from_parts(27_413_991, 0).saturating_mul(r.into())) + // Estimated: `6774 + r * (3090 ±7)` + // Minimum execution time: 259_178_000 picoseconds. + Weight::from_parts(275_643_000, 6774) + // Standard Error: 54_044 + .saturating_add(Weight::from_parts(26_026_930, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3724,7 +3777,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3736,12 +3789,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 32]`. fn add_delegate_dependency(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `918 + r * (132 ±0)` - // Estimated: `6870 + r * (2606 ±0)` - // Minimum execution time: 278_285_000 picoseconds. - Weight::from_parts(298_012_554, 6870) - // Standard Error: 24_160 - .saturating_add(Weight::from_parts(6_363_118, 0).saturating_mul(r.into())) + // Measured: `895 + r * (131 ±0)` + // Estimated: `6845 + r * (2606 ±0)` + // Minimum execution time: 263_386_000 picoseconds. + Weight::from_parts(295_443_439, 6845) + // Standard Error: 24_422 + .saturating_add(Weight::from_parts(6_429_537, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3753,7 +3806,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `MaxEncodedLen`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3765,12 +3818,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 32]`. fn remove_delegate_dependency(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `965 + r * (183 ±0)` + // Measured: `936 + r * (183 ±0)` // Estimated: `129453 + r * (2568 ±0)` - // Minimum execution time: 258_198_000 picoseconds. - Weight::from_parts(290_090_206, 129453) - // Standard Error: 19_792 - .saturating_add(Weight::from_parts(6_004_811, 0).saturating_mul(r.into())) + // Minimum execution time: 261_371_000 picoseconds. + Weight::from_parts(297_493_194, 129453) + // Standard Error: 23_734 + .saturating_add(Weight::from_parts(5_673_169, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3782,7 +3835,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3794,12 +3847,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `849 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 263_315_000 picoseconds. - Weight::from_parts(284_093_748, 6799) - // Standard Error: 371 - .saturating_add(Weight::from_parts(176_949, 0).saturating_mul(r.into())) + // Measured: `825 + r * (3 ±0)` + // Estimated: `6771 + r * (3 ±0)` + // Minimum execution time: 275_558_000 picoseconds. + Weight::from_parts(287_220_765, 6771) + // Standard Error: 437 + .saturating_add(Weight::from_parts(184_125, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -3809,7 +3862,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3821,12 +3874,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2082 + r * (39 ±0)` - // Estimated: `7886 + r * (40 ±0)` - // Minimum execution time: 274_583_000 picoseconds. - Weight::from_parts(352_081_486, 7886) - // Standard Error: 1_799 - .saturating_add(Weight::from_parts(313_433, 0).saturating_mul(r.into())) + // Measured: `2076 + r * (39 ±0)` + // Estimated: `7866 + r * (40 ±0)` + // Minimum execution time: 265_752_000 picoseconds. + Weight::from_parts(331_187_665, 7866) + // Standard Error: 1_950 + .saturating_add(Weight::from_parts(312_262, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3836,7 +3889,7 @@ impl WeightInfo for () { /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1819), added: 4294, mode: `Measured`) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:1 w:0) @@ -3850,12 +3903,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + r * (3 ±0)` - // Estimated: `6799 + r * (3 ±0)` - // Minimum execution time: 267_291_000 picoseconds. - Weight::from_parts(287_500_540, 6799) - // Standard Error: 393 - .saturating_add(Weight::from_parts(152_587, 0).saturating_mul(r.into())) + // Measured: `828 + r * (3 ±0)` + // Estimated: `6768 + r * (3 ±0)` + // Minimum execution time: 257_114_000 picoseconds. + Weight::from_parts(286_686_654, 6768) + // Standard Error: 426 + .saturating_add(Weight::from_parts(162_295, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -3865,9 +3918,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_440_000 picoseconds. - Weight::from_parts(1_656_631, 0) - // Standard Error: 13 - .saturating_add(Weight::from_parts(10_486, 0).saturating_mul(r.into())) + // Minimum execution time: 1_388_000 picoseconds. + Weight::from_parts(1_680_408, 0) + // Standard Error: 21 + .saturating_add(Weight::from_parts(10_564, 0).saturating_mul(r.into())) } } diff --git a/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs b/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs index f566f84e51a2b..482766ee97f54 100644 --- a/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs +++ b/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs @@ -18,18 +18,73 @@ //! A migration that unreserves all deposit and unlocks all stake held in the context of this //! pallet. -use crate::BalanceOf; use core::iter::Sum; -use frame_support::traits::{LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}; +use frame_support::{ + pallet_prelude::ValueQuery, + storage_alias, + traits::{Currency, LockIdentifier, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}, + weights::RuntimeDbWeight, + Parameter, Twox64Concat, +}; use sp_core::Get; use sp_runtime::traits::Zero; -use sp_std::collections::btree_map::BTreeMap; - -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; const LOG_TARGET: &str = "elections_phragmen::migrations::unlock_and_unreserve_all_funds"; +type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + +/// The configuration for [`UnlockAndUnreserveAllFunds`]. +pub trait UnlockConfig: 'static { + /// The account ID used in the runtime. + type AccountId: Parameter + Ord; + /// The currency type used in the runtime. + /// + /// Should match the currency type previously used for the pallet, if applicable. + type Currency: LockableCurrency + ReservableCurrency; + /// The name of the pallet as previously configured in + /// [`construct_runtime!`](frame_support::construct_runtime). + type PalletName: Get<&'static str>; + /// The maximum number of votes per voter as configured previously in the previous runtime. + type MaxVotesPerVoter: Get; + /// Identifier for the elections-phragmen pallet's lock, as previously configured in the + /// runtime. + type PalletId: Get; + /// The DB weight as configured in the runtime to calculate the correct weight. + type DbWeight: Get; +} + +#[storage_alias(dynamic)] +type Members = StorageValue< + ::PalletName, + Vec::AccountId, BalanceOf>>, + ValueQuery, +>; + +#[storage_alias(dynamic)] +type RunnersUp = StorageValue< + ::PalletName, + Vec::AccountId, BalanceOf>>, + ValueQuery, +>; + +#[storage_alias(dynamic)] +type Candidates = StorageValue< + ::PalletName, + Vec<(::AccountId, BalanceOf)>, + ValueQuery, +>; + +#[storage_alias(dynamic)] +type Voting = StorageMap< + ::PalletName, + Twox64Concat, + ::AccountId, + crate::Voter<::AccountId, BalanceOf>, + ValueQuery, +>; + /// A migration that unreserves all deposit and unlocks all stake held in the context of this /// pallet. /// @@ -38,9 +93,9 @@ const LOG_TARGET: &str = "elections_phragmen::migrations::unlock_and_unreserve_a /// The pallet should be made inoperable before this migration is run. /// /// (See also [`RemovePallet`][frame_support::migrations::RemovePallet]) -pub struct UnlockAndUnreserveAllFunds(sp_std::marker::PhantomData); +pub struct UnlockAndUnreserveAllFunds(sp_std::marker::PhantomData); -impl UnlockAndUnreserveAllFunds { +impl UnlockAndUnreserveAllFunds { /// Calculates and returns the total amounts deposited and staked by each account in the context /// of this pallet. /// @@ -66,12 +121,11 @@ impl UnlockAndUnreserveAllFunds { BTreeMap>, frame_support::weights::Weight, ) { - use crate::Voting; use sp_runtime::Saturating; - let members = crate::Members::::get(); - let runner_ups = crate::RunnersUp::::get(); - let candidates = crate::Candidates::::get(); + let members = Members::::get(); + let runner_ups = RunnersUp::::get(); + let candidates = Candidates::::get(); // Get the total amount deposited (Members, RunnerUps, Candidates and Voters all can have // deposits). @@ -115,7 +169,7 @@ impl UnlockAndUnreserveAllFunds { } } -impl OnRuntimeUpgrade for UnlockAndUnreserveAllFunds +impl OnRuntimeUpgrade for UnlockAndUnreserveAllFunds where BalanceOf: Sum, { @@ -268,14 +322,28 @@ where mod test { use super::*; use crate::{ - tests::{ExtBuilder, Test}, + tests::{Balances, ElectionsPhragmenPalletId, ExtBuilder, PhragmenMaxVoters, Test}, Candidates, Members, RunnersUp, SeatHolder, Voter, Voting, }; use frame_support::{ - assert_ok, + assert_ok, parameter_types, traits::{Currency, OnRuntimeUpgrade, ReservableCurrency, WithdrawReasons}, }; + parameter_types! { + const PalletName: &'static str = "Elections"; + } + + struct UnlockConfigImpl; + impl super::UnlockConfig for UnlockConfigImpl { + type Currency = Balances; + type AccountId = u64; + type DbWeight = (); + type PalletName = PalletName; + type MaxVotesPerVoter = PhragmenMaxVoters; + type PalletId = ElectionsPhragmenPalletId; + } + #[test] fn unreserve_works_for_candidate() { let candidate = 10; @@ -296,10 +364,10 @@ mod test { ); // Run the migration. - let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() + let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() .unwrap_or_else(|e| panic!("pre_upgrade failed: {:?}", e)); - UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); - assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); + UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); + assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); // Assert the candidate reserved balance was reduced by the expected amount. assert_eq!( @@ -329,10 +397,10 @@ mod test { ); // Run the migration. - let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() + let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() .unwrap_or_else(|e| panic!("pre_upgrade failed: {:?}", e)); - UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); - assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); + UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); + assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); // Assert the reserved balance was reduced by the expected amount. assert_eq!( @@ -362,10 +430,10 @@ mod test { ); // Run the migration. - let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() + let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() .unwrap_or_else(|e| panic!("pre_upgrade failed: {:?}", e)); - UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); - assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); + UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); + assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); // Assert the reserved balance was reduced by the expected amount. assert_eq!( @@ -422,10 +490,10 @@ mod test { ); // Run the migration. - let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() + let bytes = UnlockAndUnreserveAllFunds::::pre_upgrade() .unwrap_or_else(|e| panic!("pre_upgrade failed: {:?}", e)); - UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); - assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); + UnlockAndUnreserveAllFunds::::on_runtime_upgrade(); + assert_ok!(UnlockAndUnreserveAllFunds::::post_upgrade(bytes)); // Assert the voter lock was removed and the reserved balance was reduced by the // expected amount. diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 4cbbe17a9968b..0c416c73766c8 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -170,8 +170,8 @@ impl TypeId for PalletId { /// It requires that the given prefix type implements [`Get<'static str>`](traits::Get). /// /// 4. Let the macro "guess" what kind of prefix type to use. This only supports verbatim or -/// pallet name. The macro uses the presence of generic arguments to the prefix type as -/// an indication that it should use the pallet name as the `prefix`: +/// pallet name. The macro uses the presence of generic arguments to the prefix type as an +/// indication that it should use the pallet name as the `prefix`: #[doc = docify::embed!("src/tests/storage_alias.rs", storage_alias_guess)] pub use frame_support_procedural::storage_alias; diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index f898e2cce53d8..6163c048e75d8 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -106,7 +106,16 @@ pub trait OnRuntimeUpgrade { Weight::zero() } - /// See [`Hooks::on_runtime_upgrade`]. + /// The expected and default behavior of this method is to handle executing `pre_upgrade` -> + /// `on_runtime_upgrade` -> `post_upgrade` hooks for a migration. + /// + /// Internally, the default implementation + /// - Handles passing data from `pre_upgrade` to `post_upgrade` + /// - Ensure storage is not modified in `pre_upgrade` and `post_upgrade` hooks. + /// + /// Combining the `pre_upgrade` -> `on_runtime_upgrade` -> `post_upgrade` logic flow into a + /// single method call is helpful for scenarios like testing a tuple of migrations, where the + /// tuple contains order-dependent migrations. #[cfg(feature = "try-runtime")] fn try_on_runtime_upgrade(checks: bool) -> Result { let maybe_state = if checks { @@ -128,13 +137,13 @@ pub trait OnRuntimeUpgrade { Ok(weight) } - /// See [`Hooks::on_runtime_upgrade`]. + /// See [`Hooks::pre_upgrade`]. #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { Ok(Vec::new()) } - /// See [`Hooks::on_runtime_upgrade`]. + /// See [`Hooks::post_upgrade`]. #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { Ok(()) @@ -151,18 +160,17 @@ impl OnRuntimeUpgrade for Tuple { weight } - // We are executing pre- and post-checks sequentially in order to be able to test several - // consecutive migrations for the same pallet without errors. Therefore pre and post upgrade - // hooks for tuples are a noop. + /// Implements the default behavior of `try_on_runtime_upgrade` for tuples, logging any errors + /// that occur. #[cfg(feature = "try-runtime")] fn try_on_runtime_upgrade(checks: bool) -> Result { - let mut weight = Weight::zero(); + let mut cumulative_weight = Weight::zero(); let mut errors = Vec::new(); for_tuples!(#( match Tuple::try_on_runtime_upgrade(checks) { - Ok(weight) => { weight.saturating_add(weight); }, + Ok(weight) => { cumulative_weight.saturating_accrue(weight); }, Err(err) => { errors.push(err); }, } )*); @@ -186,7 +194,27 @@ impl OnRuntimeUpgrade for Tuple { return Err("Detected multiple errors while executing `try_on_runtime_upgrade`, check the logs!".into()) } - Ok(weight) + Ok(cumulative_weight) + } + + /// [`OnRuntimeUpgrade::pre_upgrade`] should not be used on a tuple. + /// + /// Instead, implementors should use [`OnRuntimeUpgrade::try_on_runtime_upgrade`] which + /// internally calls `pre_upgrade` -> `on_runtime_upgrade` -> `post_upgrade` for each tuple + /// member in sequence, enabling testing of order-dependent migrations. + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + Err("Usage of `pre_upgrade` with Tuples is not expected. Please use `try_on_runtime_upgrade` instead, which internally calls `pre_upgrade` -> `on_runtime_upgrade` -> `post_upgrade` for each tuple member.".into()) + } + + /// [`OnRuntimeUpgrade::post_upgrade`] should not be used on a tuple. + /// + /// Instead, implementors should use [`OnRuntimeUpgrade::try_on_runtime_upgrade`] which + /// internally calls `pre_upgrade` -> `on_runtime_upgrade` -> `post_upgrade` for each tuple + /// member in sequence, enabling testing of order-dependent migrations. + #[cfg(feature = "try-runtime")] + fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { + Err("Usage of `post_upgrade` with Tuples is not expected. Please use `try_on_runtime_upgrade` instead, which internally calls `pre_upgrade` -> `on_runtime_upgrade` -> `post_upgrade` for each tuple member.".into()) } } @@ -497,6 +525,7 @@ mod tests { impl_test_type!(Baz); TestExternalities::default().execute_with(|| { + // try_on_runtime_upgrade works Foo::try_on_runtime_upgrade(true).unwrap(); assert_eq!(Pre::take(), vec!["Foo"]); assert_eq!(Post::take(), vec!["Foo"]); @@ -512,6 +541,10 @@ mod tests { <(Foo, (Bar, Baz))>::try_on_runtime_upgrade(true).unwrap(); assert_eq!(Pre::take(), vec!["Foo", "Bar", "Baz"]); assert_eq!(Post::take(), vec!["Foo", "Bar", "Baz"]); + + // calling pre_upgrade and post_upgrade directly on tuple of pallets fails + assert!(<(Foo, (Bar, Baz))>::pre_upgrade().is_err()); + assert!(<(Foo, (Bar, Baz))>::post_upgrade(vec![]).is_err()); }); } diff --git a/frame/support/src/traits/tokens/fungible/hold.rs b/frame/support/src/traits/tokens/fungible/hold.rs index 2605d1797ed2e..3a0ff62e0965a 100644 --- a/frame/support/src/traits/tokens/fungible/hold.rs +++ b/frame/support/src/traits/tokens/fungible/hold.rs @@ -269,7 +269,7 @@ pub trait Mutate: /// Transfer held funds into a destination account. /// - /// If `on_hold` is `true`, then the destination account must already exist and the assets + /// If `mode` is `OnHold`, then the destination account must already exist and the assets /// transferred will still be on hold in the destination account. If not, then the destination /// account need not already exist, but must be creatable. /// diff --git a/frame/support/src/traits/tokens/fungibles/hold.rs b/frame/support/src/traits/tokens/fungibles/hold.rs index 2adc00bb4d05a..55f9d51c65564 100644 --- a/frame/support/src/traits/tokens/fungibles/hold.rs +++ b/frame/support/src/traits/tokens/fungibles/hold.rs @@ -332,7 +332,7 @@ pub trait Mutate: /// Transfer held funds into a destination account. /// - /// If `on_hold` is `true`, then the destination account must already exist and the assets + /// If `mode` is `OnHold`, then the destination account must already exist and the assets /// transferred will still be on hold in the destination account. If not, then the destination /// account need not already exist, but must be creatable. /// diff --git a/frame/tips/src/migrations/unreserve_deposits.rs b/frame/tips/src/migrations/unreserve_deposits.rs index 878d80fe1bb4e..16cb1a80e812b 100644 --- a/frame/tips/src/migrations/unreserve_deposits.rs +++ b/frame/tips/src/migrations/unreserve_deposits.rs @@ -19,13 +19,64 @@ //! pallet. use core::iter::Sum; -use frame_support::traits::{OnRuntimeUpgrade, ReservableCurrency}; -use pallet_treasury::BalanceOf; +use frame_support::{ + pallet_prelude::OptionQuery, + storage_alias, + traits::{Currency, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}, + weights::RuntimeDbWeight, + Parameter, Twox64Concat, +}; use sp_runtime::{traits::Zero, Saturating}; use sp_std::collections::btree_map::BTreeMap; #[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +const LOG_TARGET: &str = "runtime::tips::migrations::unreserve_deposits"; + +type BalanceOf = + <>::Currency as Currency<>::AccountId>>::Balance; + +/// The configuration for [`UnreserveDeposits`]. +pub trait UnlockConfig: 'static { + /// The hash used in the runtime. + type Hash: Parameter; + /// The account ID used in the runtime. + type AccountId: Parameter + Ord; + /// The currency type used in the runtime. + /// + /// Should match the currency type previously used for the pallet, if applicable. + type Currency: LockableCurrency + ReservableCurrency; + /// Base deposit to report a tip. + /// + /// Should match the currency type previously used for the pallet, if applicable. + type TipReportDepositBase: sp_core::Get>; + /// Deposit per byte to report a tip. + /// + /// Should match the currency type previously used for the pallet, if applicable. + type DataDepositPerByte: sp_core::Get>; + /// The name of the pallet as previously configured in + /// [`construct_runtime!`](frame_support::construct_runtime). + type PalletName: sp_core::Get<&'static str>; + /// The DB weight as configured in the runtime to calculate the correct weight. + type DbWeight: sp_core::Get; + /// The block number as configured in the runtime. + type BlockNumber: Parameter + Zero + Copy + Ord; +} + +/// An open tipping "motion". Retains all details of a tip including information on the finder +/// and the members who have voted. +#[storage_alias(dynamic)] +type Tips, I: 'static> = StorageMap< + >::PalletName, + Twox64Concat, + >::Hash, + crate::OpenTip< + >::AccountId, + BalanceOf, + >::BlockNumber, + >::Hash, + >, + OptionQuery, +>; /// A migration that unreserves all tip deposits. /// @@ -34,9 +85,9 @@ use sp_std::vec::Vec; /// The pallet should be made inoperable before or immediately after this migration is run. /// /// (See also the `RemovePallet` migration in `frame/support/src/migrations.rs`) -pub struct UnreserveDeposits, I: 'static>(sp_std::marker::PhantomData<(T, I)>); +pub struct UnreserveDeposits, I: 'static>(sp_std::marker::PhantomData<(T, I)>); -impl, I: 'static> UnreserveDeposits { +impl, I: 'static> UnreserveDeposits { /// Calculates and returns the total amount reserved by each account by this pallet from open /// tips. /// @@ -46,14 +97,14 @@ impl, I: 'static> UnreserveDeposits { /// reserved balance by this pallet /// * `frame_support::weights::Weight`: The weight of this operation. fn get_deposits() -> (BTreeMap>, frame_support::weights::Weight) { - use frame_support::traits::Get; + use sp_core::Get; let mut tips_len = 0; - let account_deposits: BTreeMap> = crate::Tips::::iter() + let account_deposits: BTreeMap> = Tips::::iter() .map(|(_hash, open_tip)| open_tip) .fold(BTreeMap::new(), |mut acc, tip| { // Count the total number of tips - tips_len.saturating_accrue(1); + tips_len.saturating_inc(); // Add the balance to the account's existing deposit in the accumulator acc.entry(tip.finder).or_insert(Zero::zero()).saturating_accrue(tip.deposit); @@ -64,7 +115,7 @@ impl, I: 'static> UnreserveDeposits { } } -impl, I: 'static> OnRuntimeUpgrade for UnreserveDeposits +impl, I: 'static> OnRuntimeUpgrade for UnreserveDeposits where BalanceOf: Sum, { @@ -82,7 +133,7 @@ where /// Fails with a `TryRuntimeError` if somehow the amount reserved by this pallet is greater than /// the actual total reserved amount for any accounts. #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use codec::Encode; use frame_support::ensure; @@ -107,8 +158,8 @@ where // Print some summary stats let total_deposits_to_unreserve = account_deposits.clone().into_values().sum::>(); - log::info!("Total accounts: {}", account_deposits.keys().count()); - log::info!("Total amount to unreserve: {:?}", total_deposits_to_unreserve); + log::info!(target: LOG_TARGET, "Total accounts: {}", account_deposits.keys().count()); + log::info!(target: LOG_TARGET, "Total amount to unreserve: {:?}", total_deposits_to_unreserve); // Return the actual amount reserved before the upgrade to verify integrity of the upgrade // in the post_upgrade hook. @@ -138,7 +189,7 @@ where /// Verifies that the account reserved balances were reduced by the actual expected amounts. #[cfg(feature = "try-runtime")] fn post_upgrade( - account_reserved_before_bytes: Vec, + account_reserved_before_bytes: sp_std::vec::Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { use codec::Decode; @@ -161,6 +212,7 @@ where if actual_reserved_after != expected_reserved_after { log::error!( + target: LOG_TARGET, "Reserved balance for {:?} is incorrect. actual before: {:?}, actual after, {:?}, expected deducted: {:?}", account, actual_reserved_before, @@ -180,9 +232,27 @@ mod test { use super::*; use crate::{ migrations::unreserve_deposits::UnreserveDeposits, - tests::{new_test_ext, RuntimeOrigin, Test, Tips}, + tests::{new_test_ext, Balances, RuntimeOrigin, Test, Tips}, }; - use frame_support::{assert_ok, traits::TypedGet}; + use frame_support::{assert_ok, parameter_types, traits::TypedGet}; + use frame_system::pallet_prelude::BlockNumberFor; + use sp_core::ConstU64; + + parameter_types! { + const PalletName: &'static str = "Tips"; + } + + struct UnlockConfigImpl; + impl super::UnlockConfig<()> for UnlockConfigImpl { + type Currency = Balances; + type TipReportDepositBase = ConstU64<1>; + type DataDepositPerByte = ConstU64<1>; + type Hash = sp_core::H256; + type AccountId = u128; + type BlockNumber = BlockNumberFor; + type DbWeight = (); + type PalletName = PalletName; + } #[test] fn unreserve_all_funds_works() { @@ -233,12 +303,12 @@ mod test { ); // Execute the migration - let bytes = match UnreserveDeposits::::pre_upgrade() { + let bytes = match UnreserveDeposits::::pre_upgrade() { Ok(bytes) => bytes, Err(e) => panic!("pre_upgrade failed: {:?}", e), }; - UnreserveDeposits::::on_runtime_upgrade(); - assert_ok!(UnreserveDeposits::::post_upgrade(bytes)); + UnreserveDeposits::::on_runtime_upgrade(); + assert_ok!(UnreserveDeposits::::post_upgrade(bytes)); // Check the deposits were were unreserved assert_eq!( diff --git a/primitives/api/proc-macro/src/impl_runtime_apis.rs b/primitives/api/proc-macro/src/impl_runtime_apis.rs index cb683b664495c..66bc5b0e9e5e3 100644 --- a/primitives/api/proc-macro/src/impl_runtime_apis.rs +++ b/primitives/api/proc-macro/src/impl_runtime_apis.rs @@ -229,10 +229,7 @@ fn generate_runtime_api_base_structures() -> Result { pub struct RuntimeApiImpl + 'static> { call: &'static C, transaction_depth: std::cell::RefCell, - changes: std::cell::RefCell<#crate_::OverlayedChanges>, - storage_transaction_cache: std::cell::RefCell< - #crate_::StorageTransactionCache - >, + changes: std::cell::RefCell<#crate_::OverlayedChanges<#crate_::HashingFor>>, recorder: std::option::Option<#crate_::ProofRecorder>, call_context: #crate_::CallContext, extensions: std::cell::RefCell<#crate_::Extensions>, @@ -242,8 +239,6 @@ fn generate_runtime_api_base_structures() -> Result { impl> #crate_::ApiExt for RuntimeApiImpl { - type StateBackend = C::StateBackend; - fn execute_in_transaction #crate_::TransactionOutcome, R>( &self, call: F, @@ -305,22 +300,21 @@ fn generate_runtime_api_base_structures() -> Result { }) } - fn into_storage_changes( + fn into_storage_changes>>( &self, - backend: &Self::StateBackend, + backend: &B, parent_hash: Block::Hash, ) -> core::result::Result< - #crate_::StorageChanges, + #crate_::StorageChanges, String > where Self: Sized { let state_version = #crate_::CallApiAt::::runtime_version_at(self.call, std::clone::Clone::clone(&parent_hash)) .map(|v| #crate_::RuntimeVersion::state_version(&v)) .map_err(|e| format!("Failed to get state version: {}", e))?; - #crate_::OverlayedChanges::into_storage_changes( - std::cell::RefCell::take(&self.changes), + #crate_::OverlayedChanges::drain_storage_changes( + &mut std::cell::RefCell::borrow_mut(&self.changes), backend, - core::cell::RefCell::take(&self.storage_transaction_cache), state_version, ) } @@ -349,7 +343,6 @@ fn generate_runtime_api_base_structures() -> Result { transaction_depth: 0.into(), changes: std::default::Default::default(), recorder: std::default::Default::default(), - storage_transaction_cache: std::default::Default::default(), call_context: #crate_::CallContext::Offchain, extensions: std::default::Default::default(), extensions_generated_for: std::default::Default::default(), @@ -535,7 +528,6 @@ impl<'a> ApiRuntimeImplToApiRuntimeApiImpl<'a> { function: (*fn_name)(version), arguments: params, overlayed_changes: &self.changes, - storage_transaction_cache: &self.storage_transaction_cache, call_context: self.call_context, recorder: &self.recorder, extensions: &self.extensions, diff --git a/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs b/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs index 0a1a89c6dacb5..c1339ff6621b3 100644 --- a/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs +++ b/primitives/api/proc-macro/src/mock_impl_runtime_apis.rs @@ -66,8 +66,6 @@ fn implement_common_api_traits(block_type: TypePath, self_ty: Type) -> Result for #self_ty { - type StateBackend = #crate_::InMemoryBackend<#crate_::HashingFor<#block_type>>; - fn execute_in_transaction #crate_::TransactionOutcome, R>( &self, call: F, @@ -111,12 +109,12 @@ fn implement_common_api_traits(block_type: TypePath, self_ty: Type) -> Result>>( &self, - _: &Self::StateBackend, + _: &B, _: <#block_type as #crate_::BlockT>::Hash, ) -> std::result::Result< - #crate_::StorageChanges, + #crate_::StorageChanges<#block_type>, String > where Self: Sized { unimplemented!("`into_storage_changes` not implemented for runtime api mocks") diff --git a/primitives/api/src/lib.rs b/primitives/api/src/lib.rs index 2cc20dcb356a8..e575f6b9bbff5 100644 --- a/primitives/api/src/lib.rs +++ b/primitives/api/src/lib.rs @@ -456,28 +456,8 @@ pub use sp_api_proc_macro::mock_impl_runtime_apis; #[cfg(feature = "std")] pub type ProofRecorder = sp_trie::recorder::Recorder>; -/// A type that is used as cache for the storage transactions. #[cfg(feature = "std")] -pub type StorageTransactionCache = sp_state_machine::StorageTransactionCache< - >>::Transaction, - HashingFor, ->; - -#[cfg(feature = "std")] -pub type StorageChanges = sp_state_machine::StorageChanges< - >>::Transaction, - HashingFor, ->; - -/// Extract the state backend type for a type that implements `ProvideRuntimeApi`. -#[cfg(feature = "std")] -pub type StateBackendFor = - <

>::Api as ApiExt>::StateBackend; - -/// Extract the state backend transaction type for a type that implements `ProvideRuntimeApi`. -#[cfg(feature = "std")] -pub type TransactionFor = - as StateBackend>>::Transaction; +pub type StorageChanges = sp_state_machine::StorageChanges>; /// Something that can be constructed to a runtime api. #[cfg(feature = "std")] @@ -531,9 +511,6 @@ pub enum ApiError { /// Extends the runtime api implementation with some common functionality. #[cfg(feature = "std")] pub trait ApiExt { - /// The state backend that is used to store the block states. - type StateBackend: StateBackend>; - /// Execute the given closure inside a new transaction. /// /// Depending on the outcome of the closure, the transaction is committed or rolled-back. @@ -582,11 +559,11 @@ pub trait ApiExt { /// api functions. /// /// After executing this function, all collected changes are reset. - fn into_storage_changes( + fn into_storage_changes>>( &self, - backend: &Self::StateBackend, + backend: &B, parent_hash: Block::Hash, - ) -> Result, String> + ) -> Result, String> where Self: Sized; @@ -599,7 +576,7 @@ pub trait ApiExt { /// Parameters for [`CallApiAt::call_api_at`]. #[cfg(feature = "std")] -pub struct CallApiAtParams<'a, Block: BlockT, Backend: StateBackend>> { +pub struct CallApiAtParams<'a, Block: BlockT> { /// The block id that determines the state that should be setup when calling the function. pub at: Block::Hash, /// The name of the function that should be called. @@ -607,9 +584,7 @@ pub struct CallApiAtParams<'a, Block: BlockT, Backend: StateBackend, /// The overlayed changes that are on top of the state. - pub overlayed_changes: &'a RefCell, - /// The cache for storage transactions. - pub storage_transaction_cache: &'a RefCell>, + pub overlayed_changes: &'a RefCell>>, /// The call context of this call. pub call_context: CallContext, /// The optional proof recorder for recording storage accesses. @@ -626,10 +601,7 @@ pub trait CallApiAt { /// Calls the given api function with the given encoded arguments at the given block and returns /// the encoded result. - fn call_api_at( - &self, - params: CallApiAtParams, - ) -> Result, ApiError>; + fn call_api_at(&self, params: CallApiAtParams) -> Result, ApiError>; /// Returns the runtime version at the given block. fn runtime_version_at(&self, at_hash: Block::Hash) -> Result; diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index 2203110437c82..6505d005deb8d 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -91,13 +91,13 @@ pub trait Environment { } /// A proposal that is created by a [`Proposer`]. -pub struct Proposal { +pub struct Proposal { /// The block that was build. pub block: Block, /// Proof that was recorded while building the block. pub proof: Proof, /// The storage changes while building this block. - pub storage_changes: sp_state_machine::StorageChanges>, + pub storage_changes: sp_state_machine::StorageChanges>, } /// Error that is returned when [`ProofRecording`] requested to record a proof, @@ -177,10 +177,8 @@ mod private { pub trait Proposer { /// Error type which can occur when proposing or evaluating. type Error: From + std::error::Error + 'static; - /// The transaction type used by the backend. - type Transaction: Default + Send + 'static; /// Future that resolves to a committed proposal with an optional proof. - type Proposal: Future, Self::Error>> + type Proposal: Future, Self::Error>> + Send + Unpin + 'static; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 1ff27123810b5..17dc7ce50ea8b 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -2299,11 +2299,27 @@ pub trait BlockNumberProvider { mod tests { use super::*; use crate::codec::{Decode, Encode, Input}; + #[cfg(feature = "bls-experimental")] + use sp_core::{bls377, bls381}; use sp_core::{ crypto::{Pair, UncheckedFrom}, - ecdsa, + ecdsa, ed25519, sr25519, }; + macro_rules! signature_verify_test { + ($algorithm:ident) => { + let msg = &b"test-message"[..]; + let wrong_msg = &b"test-msg"[..]; + let (pair, _) = $algorithm::Pair::generate(); + + let signature = pair.sign(&msg); + assert!($algorithm::Pair::verify(&signature, msg, &pair.public())); + + assert!(signature.verify(msg, &pair.public())); + assert!(!signature.verify(wrong_msg, &pair.public())); + }; + } + mod t { use sp_application_crypto::{app_crypto, sr25519}; use sp_core::crypto::KeyTypeId; @@ -2413,15 +2429,28 @@ mod tests { assert_eq!(buffer, [0, 0]); } + #[test] + fn ed25519_verify_works() { + signature_verify_test!(ed25519); + } + + #[test] + fn sr25519_verify_works() { + signature_verify_test!(sr25519); + } + #[test] fn ecdsa_verify_works() { - let msg = &b"test-message"[..]; - let (pair, _) = ecdsa::Pair::generate(); + signature_verify_test!(ecdsa); + } - let signature = pair.sign(&msg); - assert!(ecdsa::Pair::verify(&signature, msg, &pair.public())); + #[cfg(feature = "bls-experimental")] + fn bls377_verify_works() { + signature_verify_test!(bls377) + } - assert!(signature.verify(msg, &pair.public())); - assert!(signature.verify(msg, &pair.public())); + #[cfg(feature = "bls-experimental")] + fn bls381_verify_works() { + signature_verify_test!(bls381) } } diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index f3244308a54cf..2a25bdc54d949 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -30,6 +30,7 @@ use sp_core::storage::{ChildInfo, StateVersion, TrackedStorageKey}; #[cfg(feature = "std")] use sp_core::traits::RuntimeCode; use sp_std::vec::Vec; +use sp_trie::PrefixedMemoryDB; /// A struct containing arguments for iterating over the storage. #[derive(Default)] @@ -168,6 +169,12 @@ where } } +/// The transaction type used by [`Backend`]. +/// +/// This transaction contains all the changes that need to be applied to the backend to create the +/// state for a new block. +pub type BackendTransaction = PrefixedMemoryDB; + /// A state backend is used to read state data and can have changes committed /// to it. /// @@ -176,11 +183,8 @@ pub trait Backend: sp_std::fmt::Debug { /// An error type when fetching data is not possible. type Error: super::Error; - /// Storage changes to be applied if committing - type Transaction: Consolidate + Default + Send; - /// Type of trie backend storage. - type TrieBackendStorage: TrieBackendStorage; + type TrieBackendStorage: TrieBackendStorage; /// Type of the raw storage iterator. type RawIter: StorageIterator; @@ -236,7 +240,7 @@ pub trait Backend: sp_std::fmt::Debug { &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, Self::Transaction) + ) -> (H::Out, BackendTransaction) where H::Out: Ord; @@ -248,7 +252,7 @@ pub trait Backend: sp_std::fmt::Debug { child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, bool, Self::Transaction) + ) -> (H::Out, bool, BackendTransaction) where H::Out: Ord; @@ -283,11 +287,11 @@ pub trait Backend: sp_std::fmt::Debug { Item = (&'a ChildInfo, impl Iterator)>), >, state_version: StateVersion, - ) -> (H::Out, Self::Transaction) + ) -> (H::Out, BackendTransaction) where H::Out: Ord + Encode, { - let mut txs: Self::Transaction = Default::default(); + let mut txs = BackendTransaction::default(); let mut child_roots: Vec<_> = Default::default(); // child first for (child_info, child_delta) in child_deltas { @@ -308,6 +312,7 @@ pub trait Backend: sp_std::fmt::Debug { state_version, ); txs.consolidate(parent_txs); + (root, txs) } @@ -331,7 +336,7 @@ pub trait Backend: sp_std::fmt::Debug { fn commit( &self, _: H::Out, - _: Self::Transaction, + _: BackendTransaction, _: StorageCollection, _: ChildStorageCollection, ) -> Result<(), Self::Error> { @@ -377,34 +382,6 @@ pub trait AsTrieBackend> { fn as_trie_backend(&self) -> &TrieBackend; } -/// Trait that allows consolidate two transactions together. -pub trait Consolidate { - /// Consolidate two transactions into one. - fn consolidate(&mut self, other: Self); -} - -impl Consolidate for () { - fn consolidate(&mut self, _: Self) { - () - } -} - -impl Consolidate for Vec<(Option, StorageCollection)> { - fn consolidate(&mut self, mut other: Self) { - self.append(&mut other); - } -} - -impl Consolidate for sp_trie::GenericMemoryDB -where - H: Hasher, - KF: sp_trie::KeyFunction, -{ - fn consolidate(&mut self, other: Self) { - sp_trie::GenericMemoryDB::consolidate(self, other) - } -} - /// Wrapper to create a [`RuntimeCode`] from a type that implements [`Backend`]. #[cfg(feature = "std")] pub struct BackendRuntimeCode<'a, B, H> { diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index a7adbc8a0daee..ace88aee2628f 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -29,7 +29,7 @@ use sp_core::{ Blake2Hasher, }; use sp_externalities::{Extension, Extensions, MultiRemovalResults}; -use sp_trie::{empty_child_trie_root, HashKey, LayoutV0, LayoutV1, TrieConfiguration}; +use sp_trie::{empty_child_trie_root, LayoutV0, LayoutV1, TrieConfiguration}; use std::{ any::{Any, TypeId}, collections::BTreeMap, @@ -39,7 +39,7 @@ use std::{ /// Simple Map-based Externalities impl. #[derive(Debug)] pub struct BasicExternalities { - overlay: OverlayedChanges, + overlay: OverlayedChanges, extensions: Extensions, } @@ -282,7 +282,7 @@ impl Externalities for BasicExternalities { if let Some((data, child_info)) = self.overlay.child_changes(child_info.storage_key()) { let delta = data.into_iter().map(|(k, v)| (k.as_ref(), v.value().map(|v| v.as_slice()))); - crate::in_memory_backend::new_in_mem::>() + crate::in_memory_backend::new_in_mem::() .child_storage_root(&child_info, delta, state_version) .0 } else { diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 3c088a2176582..11df46f2a4a3a 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -22,7 +22,7 @@ use crate::overlayed_changes::OverlayedExtensions; use crate::{ backend::Backend, IndexOperation, IterArgs, OverlayedChanges, StorageKey, StorageValue, }; -use codec::{Decode, Encode, EncodeAppend}; +use codec::{Encode, EncodeAppend}; use hash_db::Hasher; #[cfg(feature = "std")] use sp_core::hexdisplay::HexDisplay; @@ -30,9 +30,8 @@ use sp_core::storage::{ well_known_keys::is_child_storage_key, ChildInfo, StateVersion, TrackedStorageKey, }; use sp_externalities::{Extension, ExtensionStore, Externalities, MultiRemovalResults}; -use sp_trie::{empty_child_trie_root, LayoutV1}; -use crate::{log_error, trace, warn, StorageTransactionCache}; +use crate::{log_error, trace, warn}; use sp_std::{ any::{Any, TypeId}, boxed::Box, @@ -98,11 +97,9 @@ where B: 'a + Backend, { /// The overlayed changes to write to. - overlay: &'a mut OverlayedChanges, + overlay: &'a mut OverlayedChanges, /// The storage backend to read from. backend: &'a B, - /// The cache for the storage transactions. - storage_transaction_cache: &'a mut StorageTransactionCache, /// Pseudo-unique id used for tracing. pub id: u16, /// Extensions registered with this instance. @@ -117,37 +114,24 @@ where { /// Create a new `Ext`. #[cfg(not(feature = "std"))] - pub fn new( - overlay: &'a mut OverlayedChanges, - storage_transaction_cache: &'a mut StorageTransactionCache, - backend: &'a B, - ) -> Self { - Ext { overlay, backend, id: 0, storage_transaction_cache } + pub fn new(overlay: &'a mut OverlayedChanges, backend: &'a B) -> Self { + Ext { overlay, backend, id: 0 } } /// Create a new `Ext` from overlayed changes and read-only backend #[cfg(feature = "std")] pub fn new( - overlay: &'a mut OverlayedChanges, - storage_transaction_cache: &'a mut StorageTransactionCache, + overlay: &'a mut OverlayedChanges, backend: &'a B, extensions: Option<&'a mut sp_externalities::Extensions>, ) -> Self { Self { overlay, backend, - storage_transaction_cache, id: rand::random(), extensions: extensions.map(OverlayedExtensions::new), } } - - /// Invalidates the currently cached storage root and the db transaction. - /// - /// Called when there are changes that likely will invalidate the storage root. - fn mark_dirty(&mut self) { - self.storage_transaction_cache.reset(); - } } #[cfg(test)] @@ -412,7 +396,6 @@ where ), ); - self.mark_dirty(); self.overlay.set_storage(key, value); } @@ -432,7 +415,6 @@ where ); let _guard = guard(); - self.mark_dirty(); self.overlay.set_child_storage(child_info, key, value); } @@ -449,7 +431,6 @@ where child_info = %HexDisplay::from(&child_info.storage_key()), ); let _guard = guard(); - self.mark_dirty(); let overlay = self.overlay.clear_child_storage(child_info); let (maybe_cursor, backend, loops) = self.limit_remove_from_backend(Some(child_info), None, maybe_limit, maybe_cursor); @@ -478,7 +459,6 @@ where return MultiRemovalResults { maybe_cursor: None, backend: 0, unique: 0, loops: 0 } } - self.mark_dirty(); let overlay = self.overlay.clear_prefix(prefix); let (maybe_cursor, backend, loops) = self.limit_remove_from_backend(None, Some(prefix), maybe_limit, maybe_cursor); @@ -501,7 +481,6 @@ where ); let _guard = guard(); - self.mark_dirty(); let overlay = self.overlay.clear_child_prefix(child_info, prefix); let (maybe_cursor, backend, loops) = self.limit_remove_from_backend( Some(child_info), @@ -522,7 +501,6 @@ where ); let _guard = guard(); - self.mark_dirty(); let backend = &mut self.backend; let current_value = self.overlay.value_mut_or_insert_with(&key, || { @@ -533,27 +511,17 @@ where fn storage_root(&mut self, state_version: StateVersion) -> Vec { let _guard = guard(); - if let Some(ref root) = self.storage_transaction_cache.transaction_storage_root { - trace!( - target: "state", - method = "StorageRoot", - ext_id = %HexDisplay::from(&self.id.to_le_bytes()), - storage_root = %HexDisplay::from(&root.as_ref()), - cached = true, - ); - return root.encode() - } - let root = - self.overlay - .storage_root(self.backend, self.storage_transaction_cache, state_version); + let (root, _cached) = self.overlay.storage_root(self.backend, state_version); + trace!( target: "state", method = "StorageRoot", ext_id = %HexDisplay::from(&self.id.to_le_bytes()), storage_root = %HexDisplay::from(&root.as_ref()), - cached = false, + cached = %_cached, ); + root.encode() } @@ -563,74 +531,22 @@ where state_version: StateVersion, ) -> Vec { let _guard = guard(); - let storage_key = child_info.storage_key(); - let prefixed_storage_key = child_info.prefixed_storage_key(); - if self.storage_transaction_cache.transaction_storage_root.is_some() { - let root = self - .storage(prefixed_storage_key.as_slice()) - .and_then(|k| Decode::decode(&mut &k[..]).ok()) - // V1 is equivalent to V0 on empty root. - .unwrap_or_else(empty_child_trie_root::>); - trace!( - target: "state", - method = "ChildStorageRoot", - ext_id = %HexDisplay::from(&self.id.to_le_bytes()), - child_info = %HexDisplay::from(&storage_key), - storage_root = %HexDisplay::from(&root.as_ref()), - cached = true, - ); - root.encode() - } else { - let root = if let Some((changes, info)) = self.overlay.child_changes(storage_key) { - let delta = changes.map(|(k, v)| (k.as_ref(), v.value().map(AsRef::as_ref))); - Some(self.backend.child_storage_root(info, delta, state_version)) - } else { - None - }; - - if let Some((root, is_empty, _)) = root { - let root = root.encode(); - // We store update in the overlay in order to be able to use - // 'self.storage_transaction' cache. This is brittle as it rely on Ext only querying - // the trie backend for storage root. - // A better design would be to manage 'child_storage_transaction' in a - // similar way as 'storage_transaction' but for each child trie. - if is_empty { - self.overlay.set_storage(prefixed_storage_key.into_inner(), None); - } else { - self.overlay.set_storage(prefixed_storage_key.into_inner(), Some(root.clone())); - } - trace!( - target: "state", - method = "ChildStorageRoot", - ext_id = %HexDisplay::from(&self.id.to_le_bytes()), - child_info = %HexDisplay::from(&storage_key), - storage_root = %HexDisplay::from(&root.as_ref()), - cached = false, - ); + let (root, _cached) = self + .overlay + .child_storage_root(child_info, self.backend, state_version) + .expect(EXT_NOT_ALLOWED_TO_FAIL); - root - } else { - // empty overlay - let root = self - .storage(prefixed_storage_key.as_slice()) - .and_then(|k| Decode::decode(&mut &k[..]).ok()) - // V1 is equivalent to V0 on empty root. - .unwrap_or_else(empty_child_trie_root::>); - - trace!( - target: "state", - method = "ChildStorageRoot", - ext_id = %HexDisplay::from(&self.id.to_le_bytes()), - child_info = %HexDisplay::from(&storage_key), - storage_root = %HexDisplay::from(&root.as_ref()), - cached = false, - ); + trace!( + target: "state", + method = "ChildStorageRoot", + ext_id = %HexDisplay::from(&self.id.to_le_bytes()), + child_info = %HexDisplay::from(&child_info.storage_key()), + storage_root = %HexDisplay::from(&root.as_ref()), + cached = %_cached, + ); - root.encode() - } - } + root.encode() } fn storage_index_transaction(&mut self, index: u32, hash: &[u8], size: u32) { @@ -669,7 +585,6 @@ where } fn storage_rollback_transaction(&mut self) -> Result<(), ()> { - self.mark_dirty(); self.overlay.rollback_transaction().map_err(|_| ()) } @@ -682,14 +597,9 @@ where self.overlay.rollback_transaction().expect(BENCHMARKING_FN); } self.overlay - .drain_storage_changes( - self.backend, - self.storage_transaction_cache, - Default::default(), // using any state - ) + .drain_storage_changes(self.backend, Default::default()) .expect(EXT_NOT_ALLOWED_TO_FAIL); self.backend.wipe().expect(EXT_NOT_ALLOWED_TO_FAIL); - self.mark_dirty(); self.overlay .enter_runtime() .expect("We have reset the overlay above, so we can not be in the runtime; qed"); @@ -703,7 +613,7 @@ where } let changes = self .overlay - .drain_storage_changes(self.backend, self.storage_transaction_cache, state_version) + .drain_storage_changes(self.backend, state_version) .expect(EXT_NOT_ALLOWED_TO_FAIL); self.backend .commit( @@ -713,7 +623,6 @@ where changes.child_storage_changes, ) .expect(EXT_NOT_ALLOWED_TO_FAIL); - self.mark_dirty(); self.overlay .enter_runtime() .expect("We have reset the overlay above, so we can not be in the runtime; qed"); @@ -914,7 +823,7 @@ where mod tests { use super::*; use crate::InMemoryBackend; - use codec::Encode; + use codec::{Decode, Encode}; use sp_core::{ map, storage::{Storage, StorageChild}, @@ -926,7 +835,6 @@ mod tests { #[test] fn next_storage_key_works() { - let mut cache = StorageTransactionCache::default(); let mut overlay = OverlayedChanges::default(); overlay.set_storage(vec![20], None); overlay.set_storage(vec![30], Some(vec![31])); @@ -943,7 +851,7 @@ mod tests { ) .into(); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); // next_backend < next_overlay assert_eq!(ext.next_storage_key(&[5]), Some(vec![10])); @@ -959,7 +867,7 @@ mod tests { drop(ext); overlay.set_storage(vec![50], Some(vec![50])); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); // next_overlay exist but next_backend doesn't exist assert_eq!(ext.next_storage_key(&[40]), Some(vec![50])); @@ -967,7 +875,6 @@ mod tests { #[test] fn next_storage_key_works_with_a_lot_empty_values_in_overlay() { - let mut cache = StorageTransactionCache::default(); let mut overlay = OverlayedChanges::default(); overlay.set_storage(vec![20], None); overlay.set_storage(vec![21], None); @@ -990,7 +897,7 @@ mod tests { ) .into(); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); assert_eq!(ext.next_storage_key(&[5]), Some(vec![30])); @@ -1002,7 +909,6 @@ mod tests { let child_info = ChildInfo::new_default(b"Child1"); let child_info = &child_info; - let mut cache = StorageTransactionCache::default(); let mut overlay = OverlayedChanges::default(); overlay.set_child_storage(child_info, vec![20], None); overlay.set_child_storage(child_info, vec![30], Some(vec![31])); @@ -1024,7 +930,7 @@ mod tests { ) .into(); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); // next_backend < next_overlay assert_eq!(ext.next_child_storage_key(child_info, &[5]), Some(vec![10])); @@ -1040,7 +946,7 @@ mod tests { drop(ext); overlay.set_child_storage(child_info, vec![50], Some(vec![50])); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); // next_overlay exist but next_backend doesn't exist assert_eq!(ext.next_child_storage_key(child_info, &[40]), Some(vec![50])); @@ -1050,7 +956,6 @@ mod tests { fn child_storage_works() { let child_info = ChildInfo::new_default(b"Child1"); let child_info = &child_info; - let mut cache = StorageTransactionCache::default(); let mut overlay = OverlayedChanges::default(); overlay.set_child_storage(child_info, vec![20], None); overlay.set_child_storage(child_info, vec![30], Some(vec![31])); @@ -1072,7 +977,7 @@ mod tests { ) .into(); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); assert_eq!(ext.child_storage(child_info, &[10]), Some(vec![10])); assert_eq!( @@ -1094,7 +999,6 @@ mod tests { fn clear_prefix_cannot_delete_a_child_root() { let child_info = ChildInfo::new_default(b"Child1"); let child_info = &child_info; - let mut cache = StorageTransactionCache::default(); let mut overlay = OverlayedChanges::default(); let backend = ( Storage { @@ -1112,7 +1016,7 @@ mod tests { ) .into(); - let ext = TestExt::new(&mut overlay, &mut cache, &backend, None); + let ext = TestExt::new(&mut overlay, &backend, None); use sp_core::storage::well_known_keys; let mut ext = ext; diff --git a/primitives/state-machine/src/in_memory_backend.rs b/primitives/state-machine/src/in_memory_backend.rs index 2c3ed7441501c..ce551cec2a473 100644 --- a/primitives/state-machine/src/in_memory_backend.rs +++ b/primitives/state-machine/src/in_memory_backend.rs @@ -24,36 +24,22 @@ use crate::{ use codec::Codec; use hash_db::Hasher; use sp_core::storage::{ChildInfo, StateVersion, Storage}; -use sp_trie::{empty_trie_root, GenericMemoryDB, HashKey, KeyFunction, LayoutV1, MemoryDB}; +use sp_trie::{empty_trie_root, LayoutV1, PrefixedMemoryDB}; use std::collections::{BTreeMap, HashMap}; /// Create a new empty instance of in-memory backend. -/// -/// It will use [`HashKey`] to store the keys internally. -pub fn new_in_mem_hash_key() -> TrieBackend, H> +pub fn new_in_mem() -> TrieBackend, H> where H: Hasher, H::Out: Codec + Ord, { - new_in_mem::>() -} - -/// Create a new empty instance of in-memory backend. -pub fn new_in_mem() -> TrieBackend, H> -where - H: Hasher, - H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, -{ - let db = GenericMemoryDB::default(); // V1 is same as V0 for an empty trie. - TrieBackendBuilder::new(db, empty_trie_root::>()).build() + TrieBackendBuilder::new(Default::default(), empty_trie_root::>()).build() } -impl TrieBackend, H> +impl TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { /// Copy the state, with applied updates pub fn update, StorageCollection)>>( @@ -85,15 +71,16 @@ where } /// Merge trie nodes into this backend. - pub fn update_backend(&self, root: H::Out, changes: GenericMemoryDB) -> Self { + pub fn update_backend(&self, root: H::Out, changes: PrefixedMemoryDB) -> Self { let mut clone = self.backend_storage().clone(); clone.consolidate(changes); TrieBackendBuilder::new(clone, root).build() } /// Apply the given transaction to this backend and set the root to the given value. - pub fn apply_transaction(&mut self, root: H::Out, transaction: GenericMemoryDB) { + pub fn apply_transaction(&mut self, root: H::Out, transaction: PrefixedMemoryDB) { let mut storage = sp_std::mem::take(self).into_storage(); + storage.consolidate(transaction); *self = TrieBackendBuilder::new(storage, root).build(); } @@ -104,33 +91,29 @@ where } } -impl Clone for TrieBackend, H> +impl Clone for TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn clone(&self) -> Self { TrieBackendBuilder::new(self.backend_storage().clone(), *self.root()).build() } } -impl Default for TrieBackend, H> +impl Default for TrieBackend, H> where H: Hasher, H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn default() -> Self { new_in_mem() } } -impl - From<(HashMap, BTreeMap>, StateVersion)> - for TrieBackend, H> +impl From<(HashMap, BTreeMap>, StateVersion)> + for TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn from( (inner, state_version): ( @@ -149,10 +132,9 @@ where } } -impl From<(Storage, StateVersion)> for TrieBackend, H> +impl From<(Storage, StateVersion)> for TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn from((inners, state_version): (Storage, StateVersion)) -> Self { let mut inner: HashMap, BTreeMap> = inners @@ -165,11 +147,10 @@ where } } -impl From<(BTreeMap, StateVersion)> - for TrieBackend, H> +impl From<(BTreeMap, StateVersion)> + for TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn from((inner, state_version): (BTreeMap, StateVersion)) -> Self { let mut expanded = HashMap::new(); @@ -178,11 +159,10 @@ where } } -impl From<(Vec<(Option, StorageCollection)>, StateVersion)> - for TrieBackend, H> +impl From<(Vec<(Option, StorageCollection)>, StateVersion)> + for TrieBackend, H> where H::Out: Codec + Ord, - KF: KeyFunction + Send + Sync, { fn from( (inner, state_version): (Vec<(Option, StorageCollection)>, StateVersion), @@ -212,7 +192,7 @@ mod tests { #[test] fn in_memory_with_child_trie_only() { let state_version = StateVersion::default(); - let storage = new_in_mem_hash_key::(); + let storage = new_in_mem::(); let child_info = ChildInfo::new_default(b"1"); let child_info = &child_info; let storage = storage.update( @@ -228,7 +208,7 @@ mod tests { #[test] fn insert_multiple_times_child_data_works() { let state_version = StateVersion::default(); - let mut storage = new_in_mem_hash_key::(); + let mut storage = new_in_mem::(); let child_info = ChildInfo::new_default(b"1"); storage.insert( diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index 3ef923851ffd8..0e2b9bfdfffcf 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -125,13 +125,13 @@ impl sp_std::fmt::Display for DefaultError { } pub use crate::{ - backend::{Backend, IterArgs, KeysIter, PairsIter, StorageIterator}, + backend::{Backend, BackendTransaction, IterArgs, KeysIter, PairsIter, StorageIterator}, error::{Error, ExecutionError}, ext::Ext, overlayed_changes::{ ChildStorageCollection, IndexOperation, OffchainChangesCollection, OffchainOverlayedChanges, OverlayedChanges, StorageChanges, StorageCollection, StorageKey, - StorageTransactionCache, StorageValue, + StorageValue, }, stats::{StateMachineStats, UsageInfo, UsageUnit}, trie_backend::{TrieBackend, TrieBackendBuilder}, @@ -143,7 +143,7 @@ mod std_reexport { pub use crate::{ basic::BasicExternalities, error::{Error, ExecutionError}, - in_memory_backend::{new_in_mem, new_in_mem_hash_key}, + in_memory_backend::new_in_mem, read_only::{InspectState, ReadOnlyExternalities}, testing::TestExternalities, trie_backend::create_proof_check_backend, @@ -168,6 +168,7 @@ mod execution { traits::{CallContext, CodeExecutor, RuntimeCode}, }; use sp_externalities::Extensions; + use sp_trie::PrefixedMemoryDB; use std::collections::{HashMap, HashSet}; pub(crate) type CallResult = Result, E>; @@ -176,7 +177,7 @@ mod execution { pub type DefaultHandler = fn(CallResult, CallResult) -> CallResult; /// Trie backend with in-memory storage. - pub type InMemoryBackend = TrieBackend, H>; + pub type InMemoryBackend = TrieBackend, H>; /// Storage backend trust level. #[derive(Debug, Clone)] @@ -199,9 +200,8 @@ mod execution { exec: &'a Exec, method: &'a str, call_data: &'a [u8], - overlay: &'a mut OverlayedChanges, + overlay: &'a mut OverlayedChanges, extensions: &'a mut Extensions, - storage_transaction_cache: Option<&'a mut StorageTransactionCache>, runtime_code: &'a RuntimeCode<'a>, stats: StateMachineStats, /// The hash of the block the state machine will be executed on. @@ -231,7 +231,7 @@ mod execution { /// Creates new substrate state machine. pub fn new( backend: &'a B, - overlay: &'a mut OverlayedChanges, + overlay: &'a mut OverlayedChanges, exec: &'a Exec, method: &'a str, call_data: &'a [u8], @@ -246,7 +246,6 @@ mod execution { call_data, extensions, overlay, - storage_transaction_cache: None, runtime_code, stats: StateMachineStats::default(), parent_hash: None, @@ -254,19 +253,6 @@ mod execution { } } - /// Use given `cache` as storage transaction cache. - /// - /// The cache will be used to cache storage transactions that can be build while executing a - /// function in the runtime. For example, when calculating the storage root a transaction is - /// build that will be cached. - pub fn with_storage_transaction_cache( - mut self, - cache: Option<&'a mut StorageTransactionCache>, - ) -> Self { - self.storage_transaction_cache = cache; - self - } - /// Set the given `parent_hash` as the hash of the parent block. /// /// This will be used for improved logging. @@ -284,18 +270,11 @@ mod execution { /// /// Returns the SCALE encoded result of the executed function. pub fn execute(&mut self) -> Result, Box> { - let mut cache = StorageTransactionCache::default(); - - let cache = match self.storage_transaction_cache.as_mut() { - Some(cache) => cache, - None => &mut cache, - }; - self.overlay .enter_runtime() .expect("StateMachine is never called from the runtime; qed"); - let mut ext = Ext::new(self.overlay, cache, self.backend, Some(self.extensions)); + let mut ext = Ext::new(self.overlay, self.backend, Some(self.extensions)); let ext_id = ext.id; @@ -331,7 +310,7 @@ mod execution { /// Prove execution using the given state backend, overlayed changes, and call executor. pub fn prove_execution( backend: &mut B, - overlay: &mut OverlayedChanges, + overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], @@ -366,7 +345,7 @@ mod execution { /// blocks (e.g. a transaction at a time), ensure a different method is used. pub fn prove_execution_on_trie_backend( trie_backend: &TrieBackend, - overlay: &mut OverlayedChanges, + overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], @@ -405,7 +384,7 @@ mod execution { pub fn execution_proof_check( root: H::Out, proof: StorageProof, - overlay: &mut OverlayedChanges, + overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], @@ -430,7 +409,7 @@ mod execution { /// Check execution proof on proving backend, generated by `prove_execution` call. pub fn execution_proof_check_on_trie_backend( trie_backend: &TrieBackend, H>, - overlay: &mut OverlayedChanges, + overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], @@ -1109,7 +1088,7 @@ mod execution { #[cfg(test)] mod tests { use super::{backend::AsTrieBackend, ext::Ext, *}; - use crate::{execution::CallResult, in_memory_backend::new_in_mem_hash_key}; + use crate::{execution::CallResult, in_memory_backend::new_in_mem}; use assert_matches::assert_matches; use codec::Encode; use sp_core::{ @@ -1287,8 +1266,7 @@ mod tests { let overlay_limit = overlay.clone(); { - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); let _ = ext.clear_prefix(b"ab", None, None); } overlay.commit_transaction().unwrap(); @@ -1311,8 +1289,7 @@ mod tests { let mut overlay = overlay_limit; { - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); assert_matches!( ext.clear_prefix(b"ab", Some(1), None).deconstruct(), (Some(_), 1, 3, 1) @@ -1356,8 +1333,7 @@ mod tests { overlay.set_child_storage(&child_info, b"4".to_vec(), Some(b"1312".to_vec())); { - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, &backend, None); + let mut ext = Ext::new(&mut overlay, &backend, None); let r = ext.kill_child_storage(&child_info, Some(2), None); assert_matches!(r.deconstruct(), (Some(_), 2, 6, 2)); } @@ -1392,8 +1368,7 @@ mod tests { ]; let backend = InMemoryBackend::::from((initial, StateVersion::default())); let mut overlay = OverlayedChanges::default(); - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, &backend, None); + let mut ext = Ext::new(&mut overlay, &backend, None); let r = ext.kill_child_storage(&child_info, Some(0), None).deconstruct(); assert_matches!(r, (Some(_), 0, 0, 0)); let r = ext @@ -1422,8 +1397,7 @@ mod tests { ]; let backend = InMemoryBackend::::from((initial, StateVersion::default())); let mut overlay = OverlayedChanges::default(); - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, &backend, None); + let mut ext = Ext::new(&mut overlay, &backend, None); assert_eq!(ext.kill_child_storage(&child_info, None, None).deconstruct(), (None, 4, 4, 4)); } @@ -1431,11 +1405,10 @@ mod tests { fn set_child_storage_works() { let child_info = ChildInfo::new_default(b"sub1"); let child_info = &child_info; - let state = new_in_mem_hash_key::(); + let state = new_in_mem::(); let backend = state.as_trie_backend(); let mut overlay = OverlayedChanges::default(); - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); ext.set_child_storage(child_info, b"abc".to_vec(), b"def".to_vec()); assert_eq!(ext.child_storage(child_info, b"abc"), Some(b"def".to_vec())); @@ -1447,19 +1420,18 @@ mod tests { fn append_storage_works() { let reference_data = vec![b"data1".to_vec(), b"2".to_vec(), b"D3".to_vec(), b"d4".to_vec()]; let key = b"key".to_vec(); - let state = new_in_mem_hash_key::(); + let state = new_in_mem::(); let backend = state.as_trie_backend(); let mut overlay = OverlayedChanges::default(); - let mut cache = StorageTransactionCache::default(); { - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); ext.storage_append(key.clone(), reference_data[0].encode()); assert_eq!(ext.storage(key.as_slice()), Some(vec![reference_data[0].clone()].encode())); } overlay.start_transaction(); { - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); for i in reference_data.iter().skip(1) { ext.storage_append(key.clone(), i.encode()); @@ -1468,7 +1440,7 @@ mod tests { } overlay.rollback_transaction().unwrap(); { - let ext = Ext::new(&mut overlay, &mut cache, backend, None); + let ext = Ext::new(&mut overlay, backend, None); assert_eq!(ext.storage(key.as_slice()), Some(vec![reference_data[0].clone()].encode())); } } @@ -1483,14 +1455,13 @@ mod tests { } let key = b"events".to_vec(); - let mut cache = StorageTransactionCache::default(); - let state = new_in_mem_hash_key::(); + let state = new_in_mem::(); let backend = state.as_trie_backend(); let mut overlay = OverlayedChanges::default(); // For example, block initialization with event. { - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); ext.clear_storage(key.as_slice()); ext.storage_append(key.clone(), Item::InitializationItem.encode()); } @@ -1498,7 +1469,7 @@ mod tests { // For example, first transaction resulted in panic during block building { - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); assert_eq!(ext.storage(key.as_slice()), Some(vec![Item::InitializationItem].encode())); @@ -1513,7 +1484,7 @@ mod tests { // Then we apply next transaction which is valid this time. { - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); assert_eq!(ext.storage(key.as_slice()), Some(vec![Item::InitializationItem].encode())); @@ -1528,7 +1499,7 @@ mod tests { // Then only initlaization item and second (committed) item should persist. { - let ext = Ext::new(&mut overlay, &mut cache, backend, None); + let ext = Ext::new(&mut overlay, backend, None); assert_eq!( ext.storage(key.as_slice()), Some(vec![Item::InitializationItem, Item::CommitedItem].encode()), @@ -1945,12 +1916,11 @@ mod tests { let mut transaction = { let backend = test_trie(state_version, None, None); - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, &backend, None); + let mut ext = Ext::new(&mut overlay, &backend, None); ext.set_child_storage(&child_info_1, b"abc".to_vec(), b"def".to_vec()); ext.set_child_storage(&child_info_2, b"abc".to_vec(), b"def".to_vec()); ext.storage_root(state_version); - cache.transaction.unwrap() + overlay.drain_storage_changes(&backend, state_version).unwrap().transaction }; let mut duplicate = false; for (k, (value, rc)) in transaction.drain().iter() { @@ -1982,8 +1952,7 @@ mod tests { assert_eq!(overlay.storage(b"bbb"), None); { - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, backend, None); + let mut ext = Ext::new(&mut overlay, backend, None); assert_eq!(ext.storage(b"bbb"), Some(vec![])); assert_eq!(ext.storage(b"ccc"), Some(vec![])); ext.clear_storage(b"ccc"); diff --git a/primitives/state-machine/src/overlayed_changes/mod.rs b/primitives/state-machine/src/overlayed_changes/mod.rs index b32df635b177c..28cfecf1dbd62 100644 --- a/primitives/state-machine/src/overlayed_changes/mod.rs +++ b/primitives/state-machine/src/overlayed_changes/mod.rs @@ -21,7 +21,7 @@ mod changeset; mod offchain; use self::changeset::OverlayedChangeSet; -use crate::{backend::Backend, stats::StateMachineStats, DefaultError}; +use crate::{backend::Backend, stats::StateMachineStats, BackendTransaction, DefaultError}; use codec::{Decode, Encode}; use hash_db::Hasher; pub use offchain::OffchainOverlayedChanges; @@ -34,6 +34,7 @@ use sp_externalities::{Extension, Extensions}; #[cfg(not(feature = "std"))] use sp_std::collections::btree_map::BTreeMap as Map; use sp_std::{collections::btree_set::BTreeSet, vec::Vec}; +use sp_trie::{empty_child_trie_root, LayoutV1}; #[cfg(feature = "std")] use std::collections::{hash_map::Entry as MapEntry, HashMap as Map}; #[cfg(feature = "std")] @@ -88,8 +89,7 @@ impl Extrinsics { /// The set of changes that are overlaid onto the backend. /// /// It allows changes to be modified using nestable transactions. -#[derive(Debug, Default, Clone)] -pub struct OverlayedChanges { +pub struct OverlayedChanges { /// Top level storage changes. top: OverlayedChangeSet, /// Child storage changes. The map key is the child storage key without the common prefix. @@ -102,6 +102,52 @@ pub struct OverlayedChanges { collect_extrinsics: bool, /// Collect statistic on this execution. stats: StateMachineStats, + /// Caches the "storage transaction" that is created while calling `storage_root`. + /// + /// This transaction can be applied to the backend to persist the state changes. + storage_transaction_cache: Option>, +} + +impl Default for OverlayedChanges { + fn default() -> Self { + Self { + top: Default::default(), + children: Default::default(), + offchain: Default::default(), + transaction_index_ops: Default::default(), + collect_extrinsics: Default::default(), + stats: Default::default(), + storage_transaction_cache: None, + } + } +} + +impl Clone for OverlayedChanges { + fn clone(&self) -> Self { + Self { + top: self.top.clone(), + children: self.children.clone(), + offchain: self.offchain.clone(), + transaction_index_ops: self.transaction_index_ops.clone(), + collect_extrinsics: self.collect_extrinsics, + stats: self.stats.clone(), + storage_transaction_cache: self.storage_transaction_cache.clone(), + } + } +} + +impl sp_std::fmt::Debug for OverlayedChanges { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("OverlayedChanges") + .field("top", &self.top) + .field("children", &self.children) + .field("offchain", &self.offchain) + .field("transaction_index_ops", &self.transaction_index_ops) + .field("collect_extrinsics", &self.collect_extrinsics) + .field("stats", &self.stats) + .field("storage_transaction_cache", &self.storage_transaction_cache) + .finish() + } } /// Transaction index operation. @@ -129,7 +175,7 @@ pub enum IndexOperation { /// /// This contains all the changes to the storage and transactions to apply theses changes to the /// backend. -pub struct StorageChanges { +pub struct StorageChanges { /// All changes to the main storage. /// /// A value of `None` means that it was deleted. @@ -142,7 +188,7 @@ pub struct StorageChanges { /// [`main_storage_changes`](StorageChanges::main_storage_changes) and from /// [`child_storage_changes`](StorageChanges::child_storage_changes). /// [`offchain_storage_changes`](StorageChanges::offchain_storage_changes). - pub transaction: Transaction, + pub transaction: BackendTransaction, /// The storage root after applying the transaction. pub transaction_storage_root: H::Out, /// Changes to the transaction index, @@ -151,7 +197,7 @@ pub struct StorageChanges { } #[cfg(feature = "std")] -impl StorageChanges { +impl StorageChanges { /// Deconstruct into the inner values pub fn into_inner( self, @@ -159,7 +205,7 @@ impl StorageChanges { StorageCollection, ChildStorageCollection, OffchainChangesCollection, - Transaction, + BackendTransaction, H::Out, Vec, ) { @@ -174,44 +220,60 @@ impl StorageChanges { } } +impl Default for StorageChanges { + fn default() -> Self { + Self { + main_storage_changes: Default::default(), + child_storage_changes: Default::default(), + offchain_storage_changes: Default::default(), + transaction: Default::default(), + transaction_storage_root: Default::default(), + #[cfg(feature = "std")] + transaction_index_changes: Default::default(), + } + } +} + /// Storage transactions are calculated as part of the `storage_root`. /// These transactions can be reused for importing the block into the /// storage. So, we cache them to not require a recomputation of those transactions. -pub struct StorageTransactionCache { +struct StorageTransactionCache { /// Contains the changes for the main and the child storages as one transaction. - pub(crate) transaction: Option, + transaction: BackendTransaction, /// The storage root after applying the transaction. - pub(crate) transaction_storage_root: Option, + transaction_storage_root: H::Out, } -impl StorageTransactionCache { - /// Reset the cached transactions. - pub fn reset(&mut self) { - *self = Self::default(); +impl StorageTransactionCache { + fn into_inner(self) -> (BackendTransaction, H::Out) { + (self.transaction, self.transaction_storage_root) } } -impl Default for StorageTransactionCache { - fn default() -> Self { - Self { transaction: None, transaction_storage_root: None } +impl Clone for StorageTransactionCache { + fn clone(&self) -> Self { + Self { + transaction: self.transaction.clone(), + transaction_storage_root: self.transaction_storage_root, + } } } -impl Default for StorageChanges { - fn default() -> Self { - Self { - main_storage_changes: Default::default(), - child_storage_changes: Default::default(), - offchain_storage_changes: Default::default(), - transaction: Default::default(), - transaction_storage_root: Default::default(), - #[cfg(feature = "std")] - transaction_index_changes: Default::default(), - } +impl sp_std::fmt::Debug for StorageTransactionCache { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut debug = f.debug_struct("StorageTransactionCache"); + + #[cfg(feature = "std")] + debug.field("transaction_storage_root", &self.transaction_storage_root); + + #[cfg(not(feature = "std"))] + debug.field("transaction_storage_root", &self.transaction_storage_root.as_ref()); + + debug.finish() } } -impl OverlayedChanges { +impl OverlayedChanges { /// Whether no changes are contained in the top nor in any of the child changes. pub fn is_empty(&self) -> bool { self.top.is_empty() && self.children.is_empty() @@ -234,6 +296,12 @@ impl OverlayedChanges { }) } + /// Should be called when there are changes that require to reset the + /// `storage_transaction_cache`. + fn mark_dirty(&mut self) { + self.storage_transaction_cache = None; + } + /// Returns mutable reference to current value. /// If there is no value in the overlay, the given callback is used to initiate the value. /// Warning this function registers a change, so the mutable reference MUST be modified. @@ -245,6 +313,8 @@ impl OverlayedChanges { key: &[u8], init: impl Fn() -> StorageValue, ) -> &mut StorageValue { + self.mark_dirty(); + let value = self.top.modify(key.to_vec(), init, self.extrinsic_index()); // if the value was deleted initialise it back with an empty vec @@ -266,6 +336,8 @@ impl OverlayedChanges { /// /// Can be rolled back or committed when called inside a transaction. pub fn set_storage(&mut self, key: StorageKey, val: Option) { + self.mark_dirty(); + let size_write = val.as_ref().map(|x| x.len() as u64).unwrap_or(0); self.stats.tally_write_overlay(size_write); self.top.set(key, val, self.extrinsic_index()); @@ -282,6 +354,8 @@ impl OverlayedChanges { key: StorageKey, val: Option, ) { + self.mark_dirty(); + let extrinsic_index = self.extrinsic_index(); let size_write = val.as_ref().map(|x| x.len() as u64).unwrap_or(0); self.stats.tally_write_overlay(size_write); @@ -300,6 +374,8 @@ impl OverlayedChanges { /// /// Can be rolled back or committed when called inside a transaction. pub(crate) fn clear_child_storage(&mut self, child_info: &ChildInfo) -> u32 { + self.mark_dirty(); + let extrinsic_index = self.extrinsic_index(); let storage_key = child_info.storage_key().to_vec(); let top = &self.top; @@ -316,6 +392,8 @@ impl OverlayedChanges { /// /// Can be rolled back or committed when called inside a transaction. pub(crate) fn clear_prefix(&mut self, prefix: &[u8]) -> u32 { + self.mark_dirty(); + self.top.clear_where(|key, _| key.starts_with(prefix), self.extrinsic_index()) } @@ -323,6 +401,8 @@ impl OverlayedChanges { /// /// Can be rolled back or committed when called inside a transaction pub(crate) fn clear_child_prefix(&mut self, child_info: &ChildInfo, prefix: &[u8]) -> u32 { + self.mark_dirty(); + let extrinsic_index = self.extrinsic_index(); let storage_key = child_info.storage_key().to_vec(); let top = &self.top; @@ -364,6 +444,8 @@ impl OverlayedChanges { /// Any changes made during that transaction are discarded. Returns an error if /// there is no open transaction that can be rolled back. pub fn rollback_transaction(&mut self) -> Result<(), NoOpenTransaction> { + self.mark_dirty(); + self.top.rollback_transaction()?; retain_map(&mut self.children, |_, (changeset, _)| { changeset @@ -432,32 +514,6 @@ impl OverlayedChanges { Ok(()) } - /// Consume all changes (top + children) and return them. - /// - /// After calling this function no more changes are contained in this changeset. - /// - /// Panics: - /// Panics if `transaction_depth() > 0` - fn drain_committed( - &mut self, - ) -> ( - impl Iterator)>, - impl Iterator< - Item = ( - StorageKey, - (impl Iterator)>, ChildInfo), - ), - >, - ) { - use sp_std::mem::take; - ( - take(&mut self.top).drain_commited(), - take(&mut self.children) - .into_iter() - .map(|(key, (val, info))| (key, (val.drain_commited(), info))), - ) - } - /// Consume all changes (top + children) and return them. /// /// After calling this function no more changes are contained in this changeset. @@ -495,42 +551,33 @@ impl OverlayedChanges { &self.transaction_index_ops } - /// Convert this instance with all changes into a [`StorageChanges`] instance. - #[cfg(feature = "std")] - pub fn into_storage_changes, H: Hasher>( - mut self, - backend: &B, - mut cache: StorageTransactionCache, - state_version: StateVersion, - ) -> Result, DefaultError> - where - H::Out: Ord + Encode + 'static, - { - self.drain_storage_changes(backend, &mut cache, state_version) - } - /// Drain all changes into a [`StorageChanges`] instance. Leave empty overlay in place. - pub fn drain_storage_changes, H: Hasher>( + pub fn drain_storage_changes>( &mut self, backend: &B, - cache: &mut StorageTransactionCache, state_version: StateVersion, - ) -> Result, DefaultError> + ) -> Result, DefaultError> where H::Out: Ord + Encode + 'static, { - // If the transaction does not exist, we generate it. - if cache.transaction.is_none() { - self.storage_root(backend, cache, state_version); - } + let (transaction, transaction_storage_root) = match self.storage_transaction_cache.take() { + Some(cache) => cache.into_inner(), + // If the transaction does not exist, we generate it. + None => { + self.storage_root(backend, state_version); + self.storage_transaction_cache + .take() + .expect("`storage_transaction_cache` was just initialized; qed") + .into_inner() + }, + }; - let (transaction, transaction_storage_root) = cache - .transaction - .take() - .and_then(|t| cache.transaction_storage_root.take().map(|tr| (t, tr))) - .expect("Transaction was be generated as part of `storage_root`; qed"); + use sp_std::mem::take; + let main_storage_changes = take(&mut self.top).drain_commited(); + let child_storage_changes = take(&mut self.children) + .into_iter() + .map(|(key, (val, info))| (key, (val.drain_commited(), info))); - let (main_storage_changes, child_storage_changes) = self.drain_committed(); let offchain_storage_changes = self.offchain_drain_committed().collect(); #[cfg(feature = "std")] @@ -562,29 +609,29 @@ impl OverlayedChanges { /// Changes that are made outside of extrinsics, are marked with /// `NO_EXTRINSIC_INDEX` index. fn extrinsic_index(&self) -> Option { - match self.collect_extrinsics { - true => Some( - self.storage(EXTRINSIC_INDEX) - .and_then(|idx| idx.and_then(|idx| Decode::decode(&mut &*idx).ok())) - .unwrap_or(NO_EXTRINSIC_INDEX), - ), - false => None, - } + self.collect_extrinsics.then(|| { + self.storage(EXTRINSIC_INDEX) + .and_then(|idx| idx.and_then(|idx| Decode::decode(&mut &*idx).ok())) + .unwrap_or(NO_EXTRINSIC_INDEX) + }) } /// Generate the storage root using `backend` and all changes /// as seen by the current transaction. /// - /// Returns the storage root and caches storage transaction in the given `cache`. - pub fn storage_root>( - &self, + /// Returns the storage root and whether it was already cached. + pub fn storage_root>( + &mut self, backend: &B, - cache: &mut StorageTransactionCache, state_version: StateVersion, - ) -> H::Out + ) -> (H::Out, bool) where H::Out: Ord + Encode, { + if let Some(cache) = &self.storage_transaction_cache { + return (cache.transaction_storage_root, true) + } + let delta = self.changes().map(|(k, v)| (&k[..], v.value().map(|v| &v[..]))); let child_delta = self.children().map(|(changes, info)| { (info, changes.map(|(k, v)| (&k[..], v.value().map(|v| &v[..])))) @@ -592,10 +639,72 @@ impl OverlayedChanges { let (root, transaction) = backend.full_storage_root(delta, child_delta, state_version); - cache.transaction = Some(transaction); - cache.transaction_storage_root = Some(root); + self.storage_transaction_cache = + Some(StorageTransactionCache { transaction, transaction_storage_root: root }); + + (root, false) + } + + /// Generate the child storage root using `backend` and all child changes + /// as seen by the current transaction. + /// + /// Returns the child storage root and whether it was already cached. + pub fn child_storage_root>( + &mut self, + child_info: &ChildInfo, + backend: &B, + state_version: StateVersion, + ) -> Result<(H::Out, bool), B::Error> + where + H::Out: Ord + Encode + Decode, + { + let storage_key = child_info.storage_key(); + let prefixed_storage_key = child_info.prefixed_storage_key(); + + if self.storage_transaction_cache.is_some() { + let root = self + .storage(prefixed_storage_key.as_slice()) + .map(|v| Ok(v.map(|v| v.to_vec()))) + .or_else(|| backend.storage(prefixed_storage_key.as_slice()).map(Some).transpose()) + .transpose()? + .flatten() + .and_then(|k| Decode::decode(&mut &k[..]).ok()) + // V1 is equivalent to V0 on empty root. + .unwrap_or_else(empty_child_trie_root::>); + + return Ok((root, true)) + } - root + let root = if let Some((changes, info)) = self.child_changes(storage_key) { + let delta = changes.map(|(k, v)| (k.as_ref(), v.value().map(AsRef::as_ref))); + Some(backend.child_storage_root(info, delta, state_version)) + } else { + None + }; + + let root = if let Some((root, is_empty, _)) = root { + // We store update in the overlay in order to be able to use + // 'self.storage_transaction' cache. This is brittle as it rely on Ext only querying + // the trie backend for storage root. + // A better design would be to manage 'child_storage_transaction' in a + // similar way as 'storage_transaction' but for each child trie. + self.set_storage(prefixed_storage_key.into_inner(), (!is_empty).then(|| root.encode())); + + self.mark_dirty(); + + root + } else { + // empty overlay + let root = backend + .storage(prefixed_storage_key.as_slice())? + .and_then(|k| Decode::decode(&mut &k[..]).ok()) + // V1 is equivalent to V0 on empty root. + .unwrap_or_else(empty_child_trie_root::>); + + root + }; + + Ok((root, false)) } /// Returns an iterator over the keys (in lexicographic order) following `key` (excluding `key`) @@ -639,7 +748,7 @@ impl OverlayedChanges { } #[cfg(feature = "std")] -impl From for OverlayedChanges { +impl From for OverlayedChanges { fn from(storage: sp_core::storage::Storage) -> Self { Self { top: storage.top.into(), @@ -742,7 +851,8 @@ impl<'a> OverlayedExtensions<'a> { #[cfg(test)] mod tests { use super::*; - use crate::{ext::Ext, InMemoryBackend}; + use crate::{ext::Ext, new_in_mem, InMemoryBackend}; + use array_bytes::bytes2hex; use sp_core::{traits::Externalities, Blake2Hasher}; use std::collections::BTreeMap; @@ -755,7 +865,7 @@ mod tests { #[test] fn overlayed_storage_works() { - let mut overlayed = OverlayedChanges::default(); + let mut overlayed = OverlayedChanges::::default(); let key = vec![42, 69, 169, 142]; @@ -790,7 +900,7 @@ mod tests { fn offchain_overlayed_storage_transactions_works() { use sp_core::offchain::STORAGE_PREFIX; fn check_offchain_content( - state: &OverlayedChanges, + state: &OverlayedChanges, nb_commit: usize, expected: Vec<(Vec, Option>)>, ) { @@ -867,18 +977,61 @@ mod tests { overlay.set_storage(b"dogglesworth".to_vec(), Some(b"cat".to_vec())); overlay.set_storage(b"doug".to_vec(), None); - let mut cache = StorageTransactionCache::default(); - let mut ext = Ext::new(&mut overlay, &mut cache, &backend, None); - let root = array_bytes::hex2bytes_unchecked( - "39245109cef3758c2eed2ccba8d9b370a917850af3824bc8348d505df2c298fa", - ); + { + let mut ext = Ext::new(&mut overlay, &backend, None); + let root = "39245109cef3758c2eed2ccba8d9b370a917850af3824bc8348d505df2c298fa"; + + assert_eq!(bytes2hex("", &ext.storage_root(state_version)), root); + // Calling a second time should use it from the cache + assert_eq!(bytes2hex("", &ext.storage_root(state_version)), root); + } + + // Check that the storage root is recalculated + overlay.set_storage(b"doug2".to_vec(), Some(b"yes".to_vec())); - assert_eq!(&ext.storage_root(state_version)[..], &root); + let mut ext = Ext::new(&mut overlay, &backend, None); + let root = "5c0a4e35cb967de785e1cb8743e6f24b6ff6d45155317f2078f6eb3fc4ff3e3d"; + assert_eq!(bytes2hex("", &ext.storage_root(state_version)), root); + } + + #[test] + fn overlayed_child_storage_root_works() { + let state_version = StateVersion::default(); + let child_info = ChildInfo::new_default(b"Child1"); + let child_info = &child_info; + let backend = new_in_mem::(); + let mut overlay = OverlayedChanges::::default(); + overlay.start_transaction(); + overlay.set_child_storage(child_info, vec![20], Some(vec![20])); + overlay.set_child_storage(child_info, vec![30], Some(vec![30])); + overlay.set_child_storage(child_info, vec![40], Some(vec![40])); + overlay.commit_transaction().unwrap(); + overlay.set_child_storage(child_info, vec![10], Some(vec![10])); + overlay.set_child_storage(child_info, vec![30], None); + + { + let mut ext = Ext::new(&mut overlay, &backend, None); + let child_root = "c02965e1df4dc5baf6977390ce67dab1d7a9b27a87c1afe27b50d29cc990e0f5"; + let root = "eafb765909c3ed5afd92a0c564acf4620d0234b31702e8e8e9b48da72a748838"; + + assert_eq!( + bytes2hex("", &ext.child_storage_root(child_info, state_version)), + child_root, + ); + + assert_eq!(bytes2hex("", &ext.storage_root(state_version)), root); + + // Calling a second time should use it from the cache + assert_eq!( + bytes2hex("", &ext.child_storage_root(child_info, state_version)), + child_root, + ); + } } #[test] fn extrinsic_changes_are_collected() { - let mut overlay = OverlayedChanges::default(); + let mut overlay = OverlayedChanges::::default(); overlay.set_collect_extrinsics(true); overlay.start_transaction(); @@ -919,7 +1072,7 @@ mod tests { #[test] fn next_storage_key_change_works() { - let mut overlay = OverlayedChanges::default(); + let mut overlay = OverlayedChanges::::default(); overlay.start_transaction(); overlay.set_storage(vec![20], Some(vec![20])); overlay.set_storage(vec![30], Some(vec![30])); @@ -960,7 +1113,7 @@ mod tests { let child_info = ChildInfo::new_default(b"Child1"); let child_info = &child_info; let child = child_info.storage_key(); - let mut overlay = OverlayedChanges::default(); + let mut overlay = OverlayedChanges::::default(); overlay.start_transaction(); overlay.set_child_storage(child_info, vec![20], Some(vec![20])); overlay.set_child_storage(child_info, vec![30], Some(vec![30])); diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index 78e956952f723..0eb7b6d1118f9 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -23,8 +23,8 @@ use std::{ }; use crate::{ - backend::Backend, ext::Ext, InMemoryBackend, OverlayedChanges, StorageKey, - StorageTransactionCache, StorageValue, TrieBackendBuilder, + backend::Backend, ext::Ext, InMemoryBackend, OverlayedChanges, StorageKey, StorageValue, + TrieBackendBuilder, }; use hash_db::{HashDB, Hasher}; @@ -36,7 +36,7 @@ use sp_core::{ }, }; use sp_externalities::{Extension, ExtensionStore, Extensions}; -use sp_trie::StorageProof; +use sp_trie::{PrefixedMemoryDB, StorageProof}; /// Simple HashMap-based Externalities impl. pub struct TestExternalities @@ -45,10 +45,8 @@ where H::Out: codec::Codec + Ord, { /// The overlay changed storage. - overlay: OverlayedChanges, + overlay: OverlayedChanges, offchain_db: TestPersistentOffchainDB, - storage_transaction_cache: - StorageTransactionCache< as Backend>::Transaction, H>, /// Storage backend. pub backend: InMemoryBackend, /// Extensions. @@ -64,12 +62,7 @@ where { /// Get externalities implementation. pub fn ext(&mut self) -> Ext> { - Ext::new( - &mut self.overlay, - &mut self.storage_transaction_cache, - &self.backend, - Some(&mut self.extensions), - ) + Ext::new(&mut self.overlay, &self.backend, Some(&mut self.extensions)) } /// Create a new instance of `TestExternalities` with storage. @@ -112,13 +105,12 @@ where offchain_db, extensions: Default::default(), backend, - storage_transaction_cache: Default::default(), state_version, } } /// Returns the overlayed changes. - pub fn overlayed_changes(&self) -> &OverlayedChanges { + pub fn overlayed_changes(&self) -> &OverlayedChanges { &self.overlay } @@ -165,32 +157,50 @@ where /// This can be used as a fast way to restore the storage state from a backup because the trie /// does not need to be computed. pub fn from_raw_snapshot( - &mut self, - raw_storage: Vec<(H::Out, (Vec, i32))>, + raw_storage: Vec<(Vec, (Vec, i32))>, storage_root: H::Out, - ) { - for (k, (v, ref_count)) in raw_storage { + state_version: StateVersion, + ) -> Self { + let mut backend = PrefixedMemoryDB::default(); + + for (key, (v, ref_count)) in raw_storage { + let mut hash = H::Out::default(); + let hash_len = hash.as_ref().len(); + + if key.len() < hash_len { + log::warn!("Invalid key in `from_raw_snapshot`: {key:?}"); + continue + } + + hash.as_mut().copy_from_slice(&key[(key.len() - hash_len)..]); + // Each time .emplace is called the internal MemoryDb ref count increments. // Repeatedly call emplace to initialise the ref count to the correct value. for _ in 0..ref_count { - self.backend.backend_storage_mut().emplace(k, hash_db::EMPTY_PREFIX, v.clone()); + backend.emplace(hash, (&key[..(key.len() - hash_len)], None), v.clone()); } } - self.backend.set_root(storage_root); + + Self { + backend: TrieBackendBuilder::new(backend, storage_root).build(), + overlay: Default::default(), + offchain_db: Default::default(), + extensions: Default::default(), + state_version, + } } /// Drains the underlying raw storage key/values and returns the root hash. /// /// Useful for backing up the storage in a format that can be quickly re-loaded. - /// - /// Note: This DB will be inoperable after this call. - pub fn into_raw_snapshot(mut self) -> (Vec<(H::Out, (Vec, i32))>, H::Out) { + pub fn into_raw_snapshot(mut self) -> (Vec<(Vec, (Vec, i32))>, H::Out) { let raw_key_values = self .backend .backend_storage_mut() .drain() .into_iter() - .collect::, i32))>>(); + .filter(|(_, (_, r))| *r > 0) + .collect::, (Vec, i32))>>(); (raw_key_values, *self.backend.root()) } @@ -220,11 +230,7 @@ where /// /// This will panic if there are still open transactions. pub fn commit_all(&mut self) -> Result<(), String> { - let changes = self.overlay.drain_storage_changes::<_, _>( - &self.backend, - &mut Default::default(), - self.state_version, - )?; + let changes = self.overlay.drain_storage_changes(&self.backend, self.state_version)?; self.backend .apply_transaction(changes.transaction_storage_root, changes.transaction); @@ -248,12 +254,8 @@ where let proving_backend = TrieBackendBuilder::wrap(&self.backend) .with_recorder(Default::default()) .build(); - let mut proving_ext = Ext::new( - &mut self.overlay, - &mut self.storage_transaction_cache, - &proving_backend, - Some(&mut self.extensions), - ); + let mut proving_ext = + Ext::new(&mut self.overlay, &proving_backend, Some(&mut self.extensions)); let outcome = sp_externalities::set_and_run_with_externalities(&mut proving_ext, execute); let proof = proving_backend.extract_proof().expect("Failed to extract storage proof"); @@ -409,36 +411,25 @@ mod tests { original_ext.insert_child(child_info.clone(), b"cattytown".to_vec(), b"is_dark".to_vec()); original_ext.insert_child(child_info.clone(), b"doggytown".to_vec(), b"is_sunny".to_vec()); - // Call emplace on one of the keys to increment the MemoryDb refcount, so we can check - // that it is intact in the recovered_ext. - let keys = original_ext.backend.backend_storage_mut().keys(); - let expected_ref_count = 5; - let ref_count_key = keys.into_iter().next().unwrap().0; - for _ in 0..expected_ref_count - 1 { - original_ext.backend.backend_storage_mut().emplace( - ref_count_key, - hash_db::EMPTY_PREFIX, - // We can use anything for the 'value' because it does not affect behavior when - // emplacing an existing key. - (&[0u8; 32]).to_vec(), - ); - } - let refcount = original_ext - .backend - .backend_storage() - .raw(&ref_count_key, hash_db::EMPTY_PREFIX) - .unwrap() - .1; - assert_eq!(refcount, expected_ref_count); + // Apply the backend to itself again to increase the ref count of all nodes. + original_ext.backend.apply_transaction( + *original_ext.backend.root(), + original_ext.backend.clone().into_storage(), + ); + + // Ensure all have the correct ref counrt + assert!(original_ext.backend.backend_storage().keys().values().all(|r| *r == 2)); // Drain the raw storage and root. let root = *original_ext.backend.root(); let (raw_storage, storage_root) = original_ext.into_raw_snapshot(); // Load the raw storage and root into a new TestExternalities. - let mut recovered_ext = - TestExternalities::::from((Default::default(), Default::default())); - recovered_ext.from_raw_snapshot(raw_storage, storage_root); + let recovered_ext = TestExternalities::::from_raw_snapshot( + raw_storage, + storage_root, + Default::default(), + ); // Check the storage root is the same as the original assert_eq!(root, *recovered_ext.backend.root()); @@ -458,14 +449,8 @@ mod tests { Some(b"is_sunny".to_vec()) ); - // Check the refcount of the key with > 1 refcount is correct. - let refcount = recovered_ext - .backend - .backend_storage() - .raw(&ref_count_key, hash_db::EMPTY_PREFIX) - .unwrap() - .1; - assert_eq!(refcount, expected_ref_count); + // Ensure all have the correct ref count after importing + assert!(recovered_ext.backend.backend_storage().keys().values().all(|r| *r == 2)); } #[test] diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index b7940fa8c39df..cc7132181f90a 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/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_trie::PrefixedMemoryDB; #[cfg(feature = "std")] use sp_trie::{ cache::{LocalTrieCache, TrieCache}, @@ -377,7 +378,6 @@ where H::Out: Ord + Codec, { type Error = crate::DefaultError; - type Transaction = S::Overlay; type TrieBackendStorage = S; type RawIter = crate::trie_backend_essence::RawIter; @@ -458,7 +458,7 @@ where &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, Self::Transaction) + ) -> (H::Out, PrefixedMemoryDB) where H::Out: Ord, { @@ -470,7 +470,7 @@ where child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, bool, Self::Transaction) + ) -> (H::Out, bool, PrefixedMemoryDB) where H::Out: Ord, { @@ -529,7 +529,7 @@ pub mod tests { use sp_trie::{ cache::{CacheSize, SharedTrieCache}, trie_types::{TrieDBBuilder, TrieDBMutBuilderV0, TrieDBMutBuilderV1}, - KeySpacedDBMut, PrefixedKey, PrefixedMemoryDB, Trie, TrieCache, TrieMut, + KeySpacedDBMut, PrefixedMemoryDB, Trie, TrieCache, TrieMut, }; use std::iter; use trie_db::NodeCodec; @@ -1187,7 +1187,7 @@ pub mod tests { (Some(child_info_1.clone()), (28..65).map(|i| (vec![i], Some(vec![i]))).collect()), (Some(child_info_2.clone()), (10..15).map(|i| (vec![i], Some(vec![i]))).collect()), ]; - let in_memory = new_in_mem::>(); + let in_memory = new_in_mem::(); let in_memory = in_memory.update(contents, state_version); let child_storage_keys = vec![child_info_1.to_owned(), child_info_2.to_owned()]; let in_memory_root = in_memory @@ -1292,7 +1292,7 @@ pub mod tests { .collect(), ), ]; - let in_memory = new_in_mem::>(); + let in_memory = new_in_mem::(); let in_memory = in_memory.update(contents, state_version); let child_storage_keys = vec![child_info_1.to_owned()]; let in_memory_root = in_memory @@ -1480,7 +1480,7 @@ pub mod tests { (Some(child_info_1.clone()), vec![(key.clone(), Some(child_trie_1_val.clone()))]), (Some(child_info_2.clone()), vec![(key.clone(), Some(child_trie_2_val.clone()))]), ]; - let in_memory = new_in_mem::>(); + let in_memory = new_in_mem::(); let in_memory = in_memory.update(contents, state_version); let child_storage_keys = vec![child_info_1.to_owned(), child_info_2.to_owned()]; let in_memory_root = in_memory diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index 22c76b56deb05..4bb51f4a13437 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -19,7 +19,7 @@ //! from storage. use crate::{ - backend::{Consolidate, IterArgs, StorageIterator}, + backend::{IterArgs, StorageIterator}, trie_backend::TrieCacheProvider, warn, StorageKey, StorageValue, }; @@ -35,7 +35,8 @@ use sp_trie::{ child_delta_trie_root, delta_trie_root, empty_child_trie_root, read_child_trie_hash, read_child_trie_value, read_trie_value, trie_types::{TrieDBBuilder, TrieError}, - DBValue, KeySpacedDB, NodeCodec, Trie, TrieCache, TrieDBRawIterator, TrieRecorder, + DBValue, KeySpacedDB, NodeCodec, PrefixedMemoryDB, Trie, TrieCache, TrieDBRawIterator, + TrieRecorder, }; #[cfg(feature = "std")] use std::{collections::HashMap, sync::Arc}; @@ -621,8 +622,8 @@ where &self, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, S::Overlay) { - let mut write_overlay = S::Overlay::default(); + ) -> (H::Out, PrefixedMemoryDB) { + let mut write_overlay = PrefixedMemoryDB::default(); let root = self.with_recorder_and_cache_for_storage_root(None, |recorder, cache| { let mut eph = Ephemeral::new(self.backend_storage(), &mut write_overlay); @@ -654,11 +655,11 @@ where child_info: &ChildInfo, delta: impl Iterator)>, state_version: StateVersion, - ) -> (H::Out, bool, S::Overlay) { + ) -> (H::Out, bool, PrefixedMemoryDB) { let default_root = match child_info.child_type() { ChildType::ParentKeyId => empty_child_trie_root::>(), }; - let mut write_overlay = S::Overlay::default(); + let mut write_overlay = PrefixedMemoryDB::default(); let child_root = match self.child_root(child_info) { Ok(Some(hash)) => hash, Ok(None) => default_root, @@ -707,7 +708,7 @@ where pub(crate) struct Ephemeral<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> { storage: &'a S, - overlay: &'a mut S::Overlay, + overlay: &'a mut PrefixedMemoryDB, } impl<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> AsHashDB @@ -722,7 +723,7 @@ impl<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> AsHashDB } impl<'a, S: TrieBackendStorage, H: Hasher> Ephemeral<'a, S, H> { - pub fn new(storage: &'a S, overlay: &'a mut S::Overlay) -> Self { + pub fn new(storage: &'a S, overlay: &'a mut PrefixedMemoryDB) -> Self { Ephemeral { storage, overlay } } } @@ -768,16 +769,11 @@ impl<'a, S: 'a + TrieBackendStorage, H: Hasher> HashDBRef for Eph /// Key-value pairs storage that is used by trie backend essence. pub trait TrieBackendStorage: Send + Sync { - /// Type of in-memory overlay. - type Overlay: HashDB + Default + Consolidate; - /// Get the value stored at key. fn get(&self, key: &H::Out, prefix: Prefix) -> Result>; } impl, H: Hasher> TrieBackendStorage for &T { - type Overlay = T::Overlay; - fn get(&self, key: &H::Out, prefix: Prefix) -> Result> { (*self).get(key, prefix) } @@ -786,8 +782,6 @@ impl, H: Hasher> TrieBackendStorage for &T { // This implementation is used by normal storage trie clients. #[cfg(feature = "std")] impl TrieBackendStorage for Arc> { - type Overlay = sp_trie::PrefixedMemoryDB; - fn get(&self, key: &H::Out, prefix: Prefix) -> Result> { Storage::::get(std::ops::Deref::deref(self), key, prefix) } @@ -798,8 +792,6 @@ where H: Hasher, KF: sp_trie::KeyFunction + Send + Sync, { - type Overlay = Self; - fn get(&self, key: &H::Out, prefix: Prefix) -> Result> { Ok(hash_db::HashDB::get(self, key, prefix)) } diff --git a/scripts/ci/gitlab/pipeline/build.yml b/scripts/ci/gitlab/pipeline/build.yml index e6ee155466361..8f63f6ecc3911 100644 --- a/scripts/ci/gitlab/pipeline/build.yml +++ b/scripts/ci/gitlab/pipeline/build.yml @@ -15,6 +15,7 @@ variables: RUSTFLAGS: "-D warnings" script: + - cargo install --locked --git https://github.com/paritytech/try-runtime-cli --rev a93c9b5abe5d31a4cf1936204f7e5c489184b521 - git clone --depth=1 --branch="$PIPELINE_SCRIPTS_TAG" @@ -36,10 +37,9 @@ substrate: polkadot-v* polkadot: release-v* COMPANION_CHECK_COMMAND: > - time cargo build --release -p "$NETWORK"-runtime && - time cargo run --release --features try-runtime try-runtime \ + time cargo build --release -p "$NETWORK"-runtime --features try-runtime && + time try-runtime \ --runtime ./target/release/wbuild/"$NETWORK"-runtime/target/wasm32-unknown-unknown/release/"$NETWORK"_runtime.wasm \ - --chain=${NETWORK}-dev \ on-runtime-upgrade --checks=pre-and-post live --uri wss://${NETWORK}-try-runtime-node.parity-chains.parity.io:443 # Individual jobs are set up for each dependent project so that they can be ran in parallel. diff --git a/test-utils/client/src/client_ext.rs b/test-utils/client/src/client_ext.rs index a258faa5e03e3..8efa7b5f07f8d 100644 --- a/test-utils/client/src/client_ext.rs +++ b/test-utils/client/src/client_ext.rs @@ -87,10 +87,9 @@ where /// This implementation is required, because of the weird api requirements around `BlockImport`. #[async_trait::async_trait] -impl ClientBlockImportExt for std::sync::Arc +impl ClientBlockImportExt for std::sync::Arc where - for<'r> &'r T: BlockImport, - Transaction: Send + 'static, + for<'r> &'r T: BlockImport, T: Send + Sync, { async fn import(&mut self, origin: BlockOrigin, block: Block) -> Result<(), ConsensusError> { @@ -153,7 +152,6 @@ where RA: Send, B: Send + Sync, E: Send, - >::Transaction: Send, { async fn import(&mut self, origin: BlockOrigin, block: Block) -> Result<(), ConsensusError> { let (header, extrinsics) = block.deconstruct(); diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index 320d0e07deceb..43ab0da98bd6a 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -83,7 +83,6 @@ std = [ "log/std", "sp-offchain/std", "sp-core/std", - "sp-core/std", "sp-std/std", "sp-io/std", "frame-support/std", diff --git a/test-utils/runtime/client/src/block_builder_ext.rs b/test-utils/runtime/client/src/block_builder_ext.rs index a9b0d49f3543e..78863209e33e9 100644 --- a/test-utils/runtime/client/src/block_builder_ext.rs +++ b/test-utils/runtime/client/src/block_builder_ext.rs @@ -49,11 +49,7 @@ impl<'a, A, B> BlockBuilderExt for sc_block_builder::BlockBuilder<'a, substrate_test_runtime::Block, A, B> where A: ProvideRuntimeApi + 'a, - A::Api: BlockBuilderApi - + ApiExt< - substrate_test_runtime::Block, - StateBackend = backend::StateBackendFor, - >, + A::Api: BlockBuilderApi + ApiExt, B: backend::Backend, { fn push_transfer( diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 0cc32e50956c8..b116c8556815f 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -816,10 +816,8 @@ fn test_witness(proof: StorageProof, root: crate::Hash) { let db: sp_trie::MemoryDB = proof.into_memory_db(); let backend = sp_state_machine::TrieBackendBuilder::<_, crate::Hashing>::new(db, root).build(); let mut overlay = sp_state_machine::OverlayedChanges::default(); - let mut cache = sp_state_machine::StorageTransactionCache::<_, _>::default(); let mut ext = sp_state_machine::Ext::new( &mut overlay, - &mut cache, &backend, #[cfg(feature = "std")] None, diff --git a/utils/frame/benchmarking-cli/src/block/bench.rs b/utils/frame/benchmarking-cli/src/block/bench.rs index 960056991a190..c9a7fb1ad33df 100644 --- a/utils/frame/benchmarking-cli/src/block/bench.rs +++ b/utils/frame/benchmarking-cli/src/block/bench.rs @@ -77,7 +77,7 @@ where + UsageProvider + BlockBackend + HeaderBackend, - C::Api: ApiExt + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { /// Returns a new [`Self`] from the arguments. pub fn new(client: Arc, params: BenchmarkParams) -> Self { diff --git a/utils/frame/benchmarking-cli/src/block/cmd.rs b/utils/frame/benchmarking-cli/src/block/cmd.rs index 90b71cd78c2a4..ee12c1c5dac33 100644 --- a/utils/frame/benchmarking-cli/src/block/cmd.rs +++ b/utils/frame/benchmarking-cli/src/block/cmd.rs @@ -90,7 +90,7 @@ impl BlockCmd { + StorageProvider + UsageProvider + HeaderBackend, - C::Api: ApiExt + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { // Put everything in the benchmark type to have the generic types handy. Benchmark::new(client, self.params.clone()).run() diff --git a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs index facde14adab59..693b9f99f08e8 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/bench.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/bench.rs @@ -76,7 +76,7 @@ where C: BlockBuilderProvider + ProvideRuntimeApi + sp_blockchain::HeaderBackend, - C::Api: ApiExt + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { /// Create a new [`Self`] from the arguments. pub fn new( diff --git a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs index 1001958fe0d28..4c3a6ed1bcd78 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs @@ -97,7 +97,7 @@ impl ExtrinsicCmd { C: BlockBuilderProvider + ProvideRuntimeApi + sp_blockchain::HeaderBackend, - C::Api: ApiExt + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { // Short circuit if --list was specified. if self.params.list { diff --git a/utils/frame/benchmarking-cli/src/overhead/cmd.rs b/utils/frame/benchmarking-cli/src/overhead/cmd.rs index 70e64cc2b66ad..5a4c37b1f6f07 100644 --- a/utils/frame/benchmarking-cli/src/overhead/cmd.rs +++ b/utils/frame/benchmarking-cli/src/overhead/cmd.rs @@ -111,7 +111,7 @@ impl OverheadCmd { C: BlockBuilderProvider + ProvideRuntimeApi + sp_blockchain::HeaderBackend, - C::Api: ApiExt + BlockBuilderApi, + C::Api: ApiExt + BlockBuilderApi, { if ext_builder.pallet() != "system" || ext_builder.extrinsic() != "remark" { return Err(format!("The extrinsic builder is required to build `System::Remark` extrinsics but builds `{}` extrinsics instead", ext_builder.name()).into()); diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 82a258e0ec39b..75f25bf322f90 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -16,8 +16,8 @@ jsonrpsee = { version = "0.16.2", features = ["http-client"] } codec = { package = "parity-scale-codec", version = "3.6.1" } log = "0.4.17" serde = "1.0.163" -frame-support = { version = "4.0.0-dev", optional = true, path = "../../../frame/support" } sp-core = { version = "21.0.0", path = "../../../primitives/core" } +sp-state-machine = { version = "0.28.0", path = "../../../primitives/state-machine" } sp-io = { version = "23.0.0", path = "../../../primitives/io" } sp-runtime = { version = "24.0.0", path = "../../../primitives/runtime" } tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] } @@ -29,9 +29,7 @@ spinners = "4.1.0" tokio-retry = "0.3.0" [dev-dependencies] -frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } -pallet-elections-phragmen = { version = "5.0.0-dev", path = "../../../frame/elections-phragmen" } -tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } +sp-tracing = { version = "10.0.0", path = "../../../primitives/tracing" } [features] -remote-test = ["frame-support"] +remote-test = [] diff --git a/utils/frame/remote-externalities/src/lib.rs b/utils/frame/remote-externalities/src/lib.rs index 761f3c8859046..072ea6ef5e597 100644 --- a/utils/frame/remote-externalities/src/lib.rs +++ b/utils/frame/remote-externalities/src/lib.rs @@ -36,10 +36,12 @@ use sp_core::{ well_known_keys::{is_default_child_storage_key, DEFAULT_CHILD_STORAGE_KEY_PREFIX}, ChildInfo, ChildType, PrefixedStorageKey, StorageData, StorageKey, }, - H256, }; -pub use sp_io::TestExternalities; -use sp_runtime::{traits::Block as BlockT, StateVersion}; +use sp_runtime::{ + traits::{Block as BlockT, HashingFor}, + StateVersion, +}; +use sp_state_machine::TestExternalities; use spinners::{Spinner, Spinners}; use std::{ cmp::max, @@ -58,7 +60,7 @@ type SnapshotVersion = Compact; const LOG_TARGET: &str = "remote-ext"; const DEFAULT_HTTP_ENDPOINT: &str = "https://rpc.polkadot.io:443"; -const SNAPSHOT_VERSION: SnapshotVersion = Compact(2); +const SNAPSHOT_VERSION: SnapshotVersion = Compact(3); /// The snapshot that we store on disk. #[derive(Decode, Encode)] @@ -67,16 +69,16 @@ struct Snapshot { state_version: StateVersion, block_hash: B::Hash, // > - raw_storage: Vec<(H256, (Vec, i32))>, - storage_root: H256, + raw_storage: Vec<(Vec, (Vec, i32))>, + storage_root: B::Hash, } impl Snapshot { pub fn new( state_version: StateVersion, block_hash: B::Hash, - raw_storage: Vec<(H256, (Vec, i32))>, - storage_root: H256, + raw_storage: Vec<(Vec, (Vec, i32))>, + storage_root: B::Hash, ) -> Self { Self { snapshot_version: SNAPSHOT_VERSION, @@ -91,21 +93,14 @@ impl Snapshot { let bytes = fs::read(path).map_err(|_| "fs::read failed.")?; // The first item in the SCALE encoded struct bytes is the snapshot version. We decode and // check that first, before proceeding to decode the rest of the snapshot. - let maybe_version: Result = Decode::decode(&mut &*bytes); - match maybe_version { - Ok(snapshot_version) => { - if snapshot_version != SNAPSHOT_VERSION { - return Err( - "Unsupported snapshot version detected. Please create a new snapshot.", - ) - } - match Decode::decode(&mut &*bytes) { - Ok(snapshot) => return Ok(snapshot), - Err(_) => Err("Decode failed"), - } - }, - Err(_) => Err("Decode failed"), + let snapshot_version = SnapshotVersion::decode(&mut &*bytes) + .map_err(|_| "Failed to decode snapshot version")?; + + if snapshot_version != SNAPSHOT_VERSION { + return Err("Unsupported snapshot version detected. Please create a new snapshot.") } + + Decode::decode(&mut &*bytes).map_err(|_| "Decode failed") } } @@ -113,13 +108,13 @@ impl Snapshot { /// bits and pieces to it, and can be loaded remotely. pub struct RemoteExternalities { /// The inner externalities. - pub inner_ext: TestExternalities, + pub inner_ext: TestExternalities>, /// The block hash it which we created this externality env. pub block_hash: B::Hash, } impl Deref for RemoteExternalities { - type Target = TestExternalities; + type Target = TestExternalities>; fn deref(&self) -> &Self::Target { &self.inner_ext } @@ -319,8 +314,6 @@ pub struct Builder { overwrite_state_version: Option, } -// NOTE: ideally we would use `DefaultNoBound` here, but not worth bringing in frame-support for -// that. impl Default for Builder { fn default() -> Self { Self { @@ -576,7 +569,7 @@ where &self, prefix: StorageKey, at: B::Hash, - pending_ext: &mut TestExternalities, + pending_ext: &mut TestExternalities>, ) -> Result, &'static str> { let start = Instant::now(); let mut sp = Spinner::with_timer(Spinners::Dots, "Scraping keys...".into()); @@ -768,7 +761,7 @@ where async fn load_child_remote( &self, top_kv: &[KeyValue], - pending_ext: &mut TestExternalities, + pending_ext: &mut TestExternalities>, ) -> Result { let child_roots = top_kv .into_iter() @@ -826,7 +819,7 @@ where /// cache, we can also optimize further. async fn load_top_remote( &self, - pending_ext: &mut TestExternalities, + pending_ext: &mut TestExternalities>, ) -> Result { let config = self.as_online(); let at = self @@ -926,7 +919,9 @@ where /// `load_child_remote`. /// /// Must be called after `init_remote_client`. - async fn load_remote_and_maybe_save(&mut self) -> Result { + async fn load_remote_and_maybe_save( + &mut self, + ) -> Result>, &'static str> { let state_version = StateApi::::runtime_version(self.as_online().rpc_client(), None) .await @@ -966,13 +961,11 @@ where std::fs::write(path, encoded).map_err(|_| "fs::write failed")?; // pending_ext was consumed when creating the snapshot, need to reinitailize it - let mut pending_ext = TestExternalities::new_with_code_and_state( - Default::default(), - Default::default(), + return Ok(TestExternalities::from_raw_snapshot( + raw_storage, + storage_root, self.overwrite_state_version.unwrap_or(state_version), - ); - pending_ext.from_raw_snapshot(raw_storage, storage_root); - return Ok(pending_ext) + )) } Ok(pending_ext) @@ -995,12 +988,11 @@ where let Snapshot { snapshot_version: _, block_hash, state_version, raw_storage, storage_root } = Snapshot::::load(&config.state_snapshot.path)?; - let mut inner_ext = TestExternalities::new_with_code_and_state( - Default::default(), - Default::default(), + let inner_ext = TestExternalities::from_raw_snapshot( + raw_storage, + storage_root, self.overwrite_state_version.unwrap_or(state_version), ); - inner_ext.from_raw_snapshot(raw_storage, storage_root); sp.stop_with_message(format!("✅ Loaded snapshot ({:.2}s)", start.elapsed().as_secs_f32())); Ok(RemoteExternalities { inner_ext, block_hash }) @@ -1099,17 +1091,12 @@ where #[cfg(test)] mod test_prelude { - use tracing_subscriber::EnvFilter; - pub(crate) use super::*; pub(crate) use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper, H256 as Hash}; pub(crate) type Block = RawBlock>; pub(crate) fn init_logger() { - let _ = tracing_subscriber::fmt() - .with_env_filter(EnvFilter::from_default_env()) - .with_level(true) - .try_init(); + let _ = sp_tracing::try_init_simple(); } } @@ -1369,9 +1356,6 @@ mod remote_tests { .filter(|p| p.path().file_name().unwrap_or_default() == CACHE) .collect::>(); - let snap: Snapshot = Builder::::new().load_snapshot(CACHE.into()).unwrap(); - assert!(matches!(snap, Snapshot { raw_storage, .. } if raw_storage.len() > 0)); - assert!(to_delete.len() == 1); let to_delete = to_delete.first().unwrap(); assert!(std::fs::metadata(to_delete.path()).unwrap().size() > 1); @@ -1401,9 +1385,6 @@ mod remote_tests { .filter(|p| p.path().file_name().unwrap_or_default() == CACHE) .collect::>(); - let snap: Snapshot = Builder::::new().load_snapshot(CACHE.into()).unwrap(); - assert!(matches!(snap, Snapshot { raw_storage, .. } if raw_storage.len() > 0)); - assert!(to_delete.len() == 1); let to_delete = to_delete.first().unwrap(); assert!(std::fs::metadata(to_delete.path()).unwrap().size() > 1); diff --git a/utils/frame/remote-externalities/test_data/proxy_test b/utils/frame/remote-externalities/test_data/proxy_test index de8105ee152df..f0b1b4f5af40b 100644 Binary files a/utils/frame/remote-externalities/test_data/proxy_test and b/utils/frame/remote-externalities/test_data/proxy_test differ diff --git a/utils/frame/try-runtime/cli/src/commands/fast_forward.rs b/utils/frame/try-runtime/cli/src/commands/fast_forward.rs index ea3ae532ca74d..f1dee16debe73 100644 --- a/utils/frame/try-runtime/cli/src/commands/fast_forward.rs +++ b/utils/frame/try-runtime/cli/src/commands/fast_forward.rs @@ -25,11 +25,11 @@ use sc_executor::{sp_wasm_interface::HostFunctions, WasmExecutor}; use serde::de::DeserializeOwned; use sp_core::H256; use sp_inherents::{InherentData, InherentDataProvider}; -use sp_io::TestExternalities; use sp_runtime::{ - traits::{Header, NumberFor, One}, + traits::{HashingFor, Header, NumberFor, One}, Digest, }; +use sp_state_machine::TestExternalities; use std::{fmt::Debug, str::FromStr}; use substrate_rpc_client::{ws_client, ChainApi}; @@ -92,8 +92,8 @@ where } /// Call `method` with `data` and return the result. `externalities` will not change. -async fn dry_run( - externalities: &TestExternalities, +fn dry_run( + externalities: &TestExternalities>, executor: &WasmExecutor, method: &'static str, data: &[u8], @@ -111,7 +111,7 @@ async fn dry_run( /// Call `method` with `data` and actually save storage changes to `externalities`. async fn run( - externalities: &mut TestExternalities, + externalities: &mut TestExternalities>, executor: &WasmExecutor, method: &'static str, data: &[u8], @@ -124,11 +124,8 @@ async fn run( full_extensions(executor.clone()), )?; - let storage_changes = changes.drain_storage_changes( - &externalities.backend, - &mut Default::default(), - externalities.state_version, - )?; + let storage_changes = + changes.drain_storage_changes(&externalities.backend, externalities.state_version)?; externalities .backend @@ -143,7 +140,7 @@ async fn next_empty_block< HostFns: HostFunctions, BBIP: BlockBuildingInfoProvider>, >( - externalities: &mut TestExternalities, + externalities: &mut TestExternalities>, executor: &WasmExecutor, parent_height: NumberFor, parent_hash: Block::Hash, @@ -182,8 +179,7 @@ async fn next_empty_block< executor, "BlockBuilder_inherent_extrinsics", &inherent_data.encode(), - ) - .await?; + )?; } for xt in &extrinsics { @@ -196,8 +192,7 @@ async fn next_empty_block< executor, "BlockBuilder_finalize_block", &[0u8; 0], - ) - .await?; + )?; run::(externalities, executor, "BlockBuilder_finalize_block", &[0u8; 0]).await?; diff --git a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs index cfcdb4654c8c5..53db5e6434632 100644 --- a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs +++ b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs @@ -177,7 +177,6 @@ where let storage_changes = changes .drain_storage_changes( &state_ext.backend, - &mut Default::default(), // Note that in case a block contains a runtime upgrade, state version could // potentially be incorrect here, this is very niche and would only result in // unaligned roots, so this use case is ignored for now. diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index fbc55ad1dce6f..73952ce816af4 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -17,338 +17,10 @@ //! # Try-runtime //! -//! Substrate's ultimate testing framework for the power users. +//! Substrate's `try-runtime` subcommand has been migrated to a [standalone +//! CLI](https://github.com/paritytech/try-runtime-cli). //! -//! > As the name suggests, `try-runtime` is a detailed testing framework that gives you a lot of -//! control over what is being executed in which environment. It is recommended that user's first -//! familiarize themselves with substrate in depth, particularly the execution model. It is critical -//! to deeply understand how the wasm/client/runtime interactions, and the runtime apis work in the -//! substrate runtime, before commencing to working with `try-runtime`. -//! -//! #### Resources -//! -//! Some resources about the above: -//! -//! 1. -//! 2. -//! 3. -//! -//! --- -//! -//! ## Background Knowledge -//! -//! The basis of all try-runtime commands is the same: connect to a live node, scrape its *state* -//! and put it inside a `TestExternalities`, then call into a *specific runtime-api* using the given -//! state and some *runtime*. -//! -//! Alternatively, the state could come from a snapshot file. -//! -//! All of the variables in the above statement are made *italic*. Let's look at each of them: -//! -//! 1. **State** is the key-value pairs of data that comprise the canonical information that any -//! blockchain is keeping. A state can be full (all key-value pairs), or be partial (only pairs -//! related to some pallets/prefixes). Moreover, some keys are especial and are not related to -//! specific pallets, known as [`well_known_keys`] in substrate. The most important of these is -//! the `:CODE:` key, which contains the code used for execution, when wasm execution is chosen. -//! -//! 2. *A runtime-api* call is a call into a function defined in the runtime, *on top of a given -//! state*. Each subcommand of `try-runtime` utilizes a specific *runtime-api*. -//! -//! 3. Finally, the **runtime** is the actual code that is used to execute the aforementioned -//! runtime-api. Everything in this crate assumes wasm execution, which means the runtime that -//! you use is the one stored onchain, namely under the `:CODE:` key. -//! -//! To recap, a typical try-runtime command does the following: -//! -//! 1. Download the state of a live chain, and write to an `externalities`. -//! 2. Overwrite the `:CODE:` with a given wasm blob -//! 3. Test some functionality via calling a runtime-api. -//! -//! ## Usage -//! -//! To use any of the provided commands, [`SharedParams`] must be provided. The most important of -//! which being [`SharedParams::runtime`], which specifies which runtime to use. Furthermore, -//! [`SharedParams::overwrite_state_version`] can be used to alter the state-version (see -//! for more info). -//! -//! Then, the specific command has to be specified. See [`Command`] for more information about each -//! command's specific customization flags, and assumptions regarding the runtime being used. -//! -//! Said briefly, this CLI is capable of executing: -//! -//! * [`Command::OnRuntimeUpgrade`]: execute all the `on_runtime_upgrade` hooks. -//! * [`Command::ExecuteBlock`]: re-execute the given block. -//! * [`Command::OffchainWorker`]: re-execute the given block's offchain worker code path. -//! * [`Command::FollowChain`]: continuously execute the blocks of a remote chain on top of a given -//! runtime. -//! * [`Command::CreateSnapshot`]: Create a snapshot file from a remote node. -//! -//! Finally, To make sure there are no errors regarding this, always run any `try-runtime` command -//! with `executor=trace` logging targets, which will specify which runtime is being used per api -//! call. Moreover, `remote-ext`, `try-runtime` and `runtime` logs targets will also be useful. -//! -//! ## Spec name check -//! -//! A common pitfall is that you might be running some test on top of the state of chain `x`, with -//! the runtime of chain `y`. To avoid this all commands do a spec-name check before executing -//! anything by default. This will check the, if any alterations are being made to the `:CODE:`, -//! then the spec names match. The spec versions are warned, but are not mandated to match. -//! -//! > If anything, in most cases, we expect spec-versions to NOT match, because try-runtime is all -//! > about testing unreleased runtimes. -//! -//! ## Note on signature and state-root checks -//! -//! All of the commands calling into `TryRuntime_execute_block` ([`Command::ExecuteBlock`] and -//! [`Command::FollowChain`]) disable both state root and signature checks. This is because in 99% -//! of the cases, the runtime that is being tested is different from the one that is stored in the -//! canonical chain state. This implies: -//! -//! 1. the state root will NEVER match, because `:CODE:` is different between the two. -//! 2. replaying all transactions will fail, because the spec-version is part of the transaction -//! signature. -//! -//! ## Best Practices -//! -//! Try-runtime is all about battle-testing unreleased runtime. The following list of suggestions -//! help developers maximize the testing coverage and make base use of `try-runtime`. -//! -//! #### Adding pre/post hooks -//! -//! One of the gems that come only in the `try-runtime` feature flag is the `pre_upgrade` and -//! `post_upgrade` hooks for `OnRuntimeUpgrade`. This trait is implemented either inside the pallet, -//! or manually in a runtime, to define a migration. In both cases, these functions can be added, -//! given the right flag: -//! -//! ```ignore -//! #[cfg(feature = "try-runtime")] -//! fn pre_upgrade() -> Result, TryRuntimeError> {} -//! -//! #[cfg(feature = "try-runtime")] -//! fn post_upgrade(state: Vec) -> Result<(), TryRuntimeError> {} -//! ``` -//! -//! (The pallet macro syntax will support this simply as a part of `#[pallet::hooks]`). -//! -//! These hooks allow you to execute some code, only within the `on-runtime-upgrade` command, before -//! and after the migration. Moreover, `pre_upgrade` can return a `Vec` that contains arbitrary -//! encoded data (usually some pre-upgrade state) which will be passed to `post_upgrade` after -//! upgrading and used for post checking. -//! -//! ## State Consistency -//! -//! Similarly, each pallet can expose a function in `#[pallet::hooks]` section as follows: -//! -//! ```ignore -//! #[cfg(feature = "try-runtime")] -//! fn try_state(_: BlockNumber) -> Result<(), TryRuntimeError> {} -//! ``` -//! -//! which is called on numerous code paths in the try-runtime tool. These checks should ensure that -//! the state of the pallet is consistent and correct. See `frame_support::try_runtime::TryState` -//! for more info. -//! -//! #### Logging -//! -//! It is super helpful to make sure your migration code uses logging (always with a `runtime` log -//! target prefix, e.g. `runtime::balance`) and state exactly at which stage it is, and what it is -//! doing. -//! -//! #### Guarding migrations -//! -//! Always make sure that any migration code is guarded either by `StorageVersion`, or by some -//! custom storage item, so that it is NEVER executed twice, even if the code lives in two -//! consecutive runtimes. -//! -//! ## Examples -//! -//! For the following examples, we assume the existence of the following: -//! -//! 1. a substrate node compiled without `--feature try-runtime`, called `substrate`. This will be -//! the running node that you connect to. then, after some changes to this node, you compile it with -//! `--features try-runtime`. This gives you: -//! 2. a substrate binary that has the try-runtime sub-command enabled. -//! 3. a wasm blob that has try-runtime functionality. -//! -//! ```bash -//! # this is like your running deployed node. -//! cargo build --release && cp target/release/substrate . -//! -//! # this is like your WIP branch. -//! cargo build --release --features try-runtime -//! cp target/release/substrate substrate-try-runtime -//! cp ./target/release/wbuild/kitchensink-runtime/kitchensink_runtime.wasm runtime-try-runtime.wasm -//! ``` -//! -//! > The above example is with `substrate`'s `kitchensink-runtime`, but is applicable to any -//! > substrate-based chain that has implemented `try-runtime-cli`. -//! -//! * If you run `try-runtime` subcommand against `substrate` binary listed above, you get the -//! following error. -//! -//! ```bash -//! [substrate] ./substrate try-runtime -//! Error: Input("TryRuntime wasn't enabled when building the node. You can enable it with `--features try-runtime`.") -//! ``` -//! -//! * If you run the same against `substrate-try-runtime`, it will work. -//! -//! ```bash -//! [substrate] ./substrate-try-runtime try-runtime -//! Try some command against runtime state -//! -//! Usage: substrate-try-runtime try-runtime [OPTIONS] --runtime -//! -//! Commands: -//! on-runtime-upgrade Execute the migrations of the "local runtime" -//! execute-block Executes the given block against some state -//! offchain-worker Executes *the offchain worker hooks* of a given block against some state -//! follow-chain Follow the given chain's finalized blocks and apply all of its extrinsics -//! create-snapshot Create a new snapshot file -//! help Print this message or the help of the given subcommand(s) -//! -//! Options: -//! --chain -//! Specify the chain specification -//! --dev -//! Specify the development chain -//! -d, --base-path -//! Specify custom base path -//! -l, --log ... -//! Sets a custom logging filter. Syntax is `=`, e.g. -lsync=debug -//! --detailed-log-output -//! Enable detailed log output -//! --disable-log-color -//! Disable log color output -//! --enable-log-reloading -//! Enable feature to dynamically update and reload the log filter -//! --tracing-targets -//! Sets a custom profiling filter. Syntax is the same as for logging: `=` -//! --tracing-receiver -//! Receiver to process tracing messages [default: log] [possible values: log] -//! --runtime -//! The runtime to use -//! --wasm-execution -//! Type of wasm execution used [default: compiled] [possible values: interpreted-i-know-what-i-do, compiled] -//! --wasm-instantiation-strategy -//! The WASM instantiation method to use [default: pooling-copy-on-write] [possible values: pooling-copy-on-write, recreate-instance-copy-on-write, pooling, recreate-instance, legacy-instance-reuse] -//! --heap-pages -//! The number of 64KB pages to allocate for Wasm execution. Defaults to [`sc_service::Configuration.default_heap_pages`] -//! --overwrite-state-version -//! Overwrite the `state_version` -//! -h, --help -//! Print help information (use `--help` for more detail) -//! -V, --version -//! Print version information -//! ``` -//! -//! * Run the migrations of a given runtime on top of a live state. -//! -//! ```bash -//! # assuming there's `./substrate --dev --tmp --ws-port 9999` or similar running. -//! ./substrate-try-runtime \ -//! try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! on-runtime-upgrade \ -//! live --uri ws://localhost:9999 -//! ``` -//! -//! * Same as the previous one, but run it at specific block number's state. This means that this -//! block hash's state shall not yet have been pruned in `rpc.polkadot.io`. -//! -//! ```bash -//! ./substrate-try-runtime \ -//! try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! on-runtime-upgrade \ -//! live --uri ws://localhost:9999 \ -//! # replace with your desired block hash! -//! --at 0xa1b16c1efd889a9f17375ec4dd5c1b4351a2be17fa069564fced10d23b9b3836 -//! ``` -//! -//! * Executing the same command with the [`Runtime::Existing`] will fail because the existing -//! runtime, stored onchain in `substrate` binary that we compiled earlier does not have -//! `try-runtime` feature! -//! -//! ```bash -//! ./substrate-try-runtime try-runtime --runtime existing -lruntime=debug on-runtime-upgrade live --uri ws://localhost:9999 -//! ... -//! Error: Input("given runtime is NOT compiled with try-runtime feature!") -//! ``` -//! -//! * Now, let's use a snapshot file. First, we create the snapshot: -//! -//! ```bash -//! ./substrate-try-runtime try-runtime --runtime existing -lruntime=debug create-snapshot --uri ws://localhost:9999 -//! 2022-12-13 10:28:17.516 INFO main try-runtime::cli: snapshot path not provided (-s), using 'node-268@latest.snap' -//! 2022-12-13 10:28:17.516 INFO main remote-ext: since no at is provided, setting it to latest finalized head, 0xe7d0b614dfe89af65b33577aae46a6f958c974bf52f8a5e865a0f4faeb578d22 -//! 2022-12-13 10:28:17.516 INFO main remote-ext: since no prefix is filtered, the data for all pallets will be downloaded -//! 2022-12-13 10:28:17.550 INFO main remote-ext: writing snapshot of 1611464 bytes to "node-268@latest.snap" -//! 2022-12-13 10:28:17.551 INFO main remote-ext: initialized state externalities with storage root 0x925e4e95de4c08474fb7f976c4472fa9b8a1091619cd7820a793bf796ee6d932 and state_version V1 -//! ``` -//! -//! > Note that the snapshot contains the `existing` runtime, which does not have the correct -//! > `try-runtime` feature. In the following commands, we still need to overwrite the runtime. -//! -//! Then, we can use it to have the same command as before, `on-runtime-upgrade` -//! -//! ```bash -//! ./substrate-try-runtime try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! on-runtime-upgrade \ -//! snap -s node-268@latest.snap -//! ``` -//! -//! * Execute the latest finalized block with the given runtime. -//! -//! ```bash -//! ./substrate-try-runtime try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! execute-block live \ -//! --uri ws://localhost:9999 -//! ``` -//! -//! This can still be customized at a given block with `--at`. If you want to use a snapshot, you -//! can still use `--block-ws-uri` to provide a node form which the block data can be fetched. -//! -//! Moreover, this runs the `frame_support::try_runtime::TryState` hooks as well. The hooks to run -//! can be customized with the `--try-state`. For example: -//! -//! ```bash -//! ./substrate-try-runtime try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! execute-block \ -//! --try-state System,Staking \ -//! live \ -//! --uri ws://localhost:9999 \ -//! --pallet System Staking -//! ``` -//! -//! Will only run the `try-state` of the two given pallets. When running `try-state` against -//! some real chain data it can take a long time for the command to execute since it has to -//! query all the key-value pairs. In scenarios like above where we only want to run the -//! `try-state` for some specific pallets, we can use the `--pallet` option to specify from -//! which pallets we want to query the state. This will greatly decrease the execution time. -//! -//! See [`frame_try_runtime::TryStateSelect`] for more information. -//! -//! * Follow our live chain's blocks using `follow-chain`, whilst running the try-state of 3 pallets -//! in a round robin fashion -//! -//! ```bash -//! ./substrate-try-runtime \ -//! try-runtime \ -//! --runtime runtime-try-runtime.wasm \ -//! -lruntime=debug \ -//! follow-chain \ -//! --uri ws://localhost:9999 \ -//! --try-state rr-3 -//! ``` +//! It is no longer maintained here and will be removed in the future. #![cfg(feature = "try-runtime")] @@ -356,7 +28,6 @@ use crate::block_building_info::BlockBuildingInfoProvider; use parity_scale_codec::Decode; use remote_externalities::{ Builder, Mode, OfflineConfig, OnlineConfig, RemoteExternalities, SnapshotConfig, - TestExternalities, }; use sc_cli::{ execution_method_from_cli, CliConfiguration, RuntimeVersion, WasmExecutionMethod, @@ -366,7 +37,6 @@ use sc_cli::{ use sc_executor::{ sp_wasm_interface::HostFunctions, HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY, }; -use sp_api::HashT; use sp_core::{ hexdisplay::HexDisplay, offchain::{ @@ -381,10 +51,12 @@ use sp_externalities::Extensions; use sp_inherents::InherentData; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - traits::{BlakeTwo256, Block as BlockT, NumberFor}, + traits::{BlakeTwo256, Block as BlockT, Hash as HashT, HashingFor, NumberFor}, DeserializeOwned, Digest, }; -use sp_state_machine::{CompactProof, OverlayedChanges, StateMachine, TrieBackendBuilder}; +use sp_state_machine::{ + CompactProof, OverlayedChanges, StateMachine, TestExternalities, TrieBackendBuilder, +}; use sp_version::StateVersion; use std::{fmt::Debug, path::PathBuf, str::FromStr}; @@ -722,7 +394,13 @@ impl State { } } +pub const DEPRECATION_NOTICE: &str = "Substrate's `try-runtime` subcommand has been migrated to a standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer being maintained here and will be removed entirely some time after January 2024. Please remove this subcommand from your runtime and use the standalone CLI."; + impl TryRuntimeCmd { + // Can't reuse DEPRECATION_NOTICE in the deprecated macro + #[deprecated( + note = "Substrate's `try-runtime` subcommand has been migrated to a standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer being maintained here and will be removed entirely some time after January 2024. Please remove this subcommand from your runtime and use the standalone CLI." + )] pub async fn run( &self, block_building_info_provider: Option, @@ -836,7 +514,7 @@ pub(crate) fn build_executor(shared: &SharedParams) -> WasmExe /// Ensure that the given `ext` is compiled with `try-runtime` fn ensure_try_runtime( executor: &WasmExecutor, - ext: &mut TestExternalities, + ext: &mut TestExternalities>, ) -> bool { use sp_api::RuntimeApiInfo; let final_code = ext @@ -854,12 +532,12 @@ fn ensure_try_runtime( /// Execute the given `method` and `data` on top of `ext`, returning the results (encoded) and the /// state `changes`. pub(crate) fn state_machine_call( - ext: &TestExternalities, + ext: &TestExternalities>, executor: &WasmExecutor, method: &'static str, data: &[u8], mut extensions: Extensions, -) -> sc_cli::Result<(OverlayedChanges, Vec)> { +) -> sc_cli::Result<(OverlayedChanges>, Vec)> { let mut changes = Default::default(); let encoded_results = StateMachine::new( &ext.backend, @@ -883,13 +561,13 @@ pub(crate) fn state_machine_call( /// /// Make sure [`LOG_TARGET`] is enabled in logging. pub(crate) fn state_machine_call_with_proof( - ext: &TestExternalities, + ext: &TestExternalities>, executor: &WasmExecutor, method: &'static str, data: &[u8], mut extensions: Extensions, maybe_export_proof: Option, -) -> sc_cli::Result<(OverlayedChanges, Vec)> { +) -> sc_cli::Result<(OverlayedChanges>, Vec)> { use parity_scale_codec::Encode; let mut changes = Default::default(); @@ -946,7 +624,7 @@ pub(crate) fn state_machine_call_with_proof(pre_root) + .into_compact_proof::>(pre_root) .map_err(|e| { log::error!(target: LOG_TARGET, "failed to generate compact proof {}: {:?}", method, e); e diff --git a/utils/frame/try-runtime/cli/tests/create_snapshot.rs b/utils/frame/try-runtime/cli/tests/create_snapshot.rs deleted file mode 100644 index c524e5af48ad3..0000000000000 --- a/utils/frame/try-runtime/cli/tests/create_snapshot.rs +++ /dev/null @@ -1,95 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#![cfg(unix)] -#![cfg(feature = "try-runtime")] - -use assert_cmd::cargo::cargo_bin; -use node_primitives::Hash; -use regex::Regex; -use remote_externalities::{Builder, Mode, OfflineConfig, SnapshotConfig}; -use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper}; -use std::{ - path::{Path, PathBuf}, - process, - time::Duration, -}; -use substrate_cli_test_utils as common; -use tokio::process::{Child, Command}; - -type Block = RawBlock>; - -#[tokio::test] -async fn create_snapshot_works() { - // Build substrate so binaries used in the test use the latest code. - common::build_substrate(&["--features=try-runtime"]); - - let temp_dir = tempfile::Builder::new() - .prefix("try-runtime-cli-test-dir") - .tempdir() - .expect("Failed to create a tempdir"); - let snap_file_path = temp_dir.path().join("snapshot.snap"); - - common::run_with_timeout(Duration::from_secs(60), async move { - fn create_snapshot(ws_url: &str, snap_file: &PathBuf, at: Hash) -> Child { - Command::new(cargo_bin("substrate-node")) - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .args(&["try-runtime", "--runtime=existing"]) - .args(&["create-snapshot", format!("--uri={}", ws_url).as_str()]) - .arg(snap_file) - .args(&["--at", format!("{:?}", at).as_str()]) - .kill_on_drop(true) - .spawn() - .unwrap() - } - - // Start a node and wait for it to begin finalizing blocks - let mut node = common::KillChildOnDrop(common::start_node()); - let ws_url = common::extract_info_from_output(node.stderr.take().unwrap()).0.ws_url; - common::wait_n_finalized_blocks(3, &ws_url).await; - - let block_number = 2; - let block_hash = common::block_hash(block_number, &ws_url).await.unwrap(); - - // Try to create a snapshot. - let mut snapshot_creation = create_snapshot(&ws_url, &snap_file_path, block_hash); - - let re = Regex::new(r#".*writing snapshot of (\d+) bytes to .*"#).unwrap(); - let matched = - common::wait_for_stream_pattern_match(snapshot_creation.stderr.take().unwrap(), re) - .await; - - // Assert that the snapshot creation succeded. - assert!(matched.is_ok(), "Failed to create snapshot"); - - let snapshot_is_on_disk = Path::new(&snap_file_path).exists(); - assert!(snapshot_is_on_disk, "Snapshot was not written to disk"); - - // Try and load the snapshot we have created by running `create-snapshot`. - let snapshot_loading_result = Builder::::new() - .mode(Mode::Offline(OfflineConfig { - state_snapshot: SnapshotConfig { path: snap_file_path }, - })) - .build() - .await; - - assert!(snapshot_loading_result.is_ok(), "Snapshot couldn't be loaded"); - }) - .await; -} diff --git a/utils/frame/try-runtime/cli/tests/execute_block.rs b/utils/frame/try-runtime/cli/tests/execute_block.rs deleted file mode 100644 index 9ad49e0ceaf9a..0000000000000 --- a/utils/frame/try-runtime/cli/tests/execute_block.rs +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#![cfg(unix)] -#![cfg(feature = "try-runtime")] - -use assert_cmd::cargo::cargo_bin; -use node_primitives::Hash; -use regex::Regex; -use std::{process, time::Duration}; -use substrate_cli_test_utils as common; -use tokio::process::{Child, Command}; - -#[tokio::test] -async fn block_execution_works() { - // Build substrate so binaries used in the test use the latest code. - common::build_substrate(&["--features=try-runtime"]); - - common::run_with_timeout(Duration::from_secs(60), async move { - fn execute_block(ws_url: &str, at: Hash) -> Child { - Command::new(cargo_bin("substrate-node")) - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .args(&["try-runtime", "--runtime=existing"]) - .args(&["execute-block"]) - .args(&["live", format!("--uri={}", ws_url).as_str()]) - .args(&["--at", format!("{:?}", at).as_str()]) - .kill_on_drop(true) - .spawn() - .unwrap() - } - - // Start a node and wait for it to begin finalizing blocks - let mut node = common::KillChildOnDrop(common::start_node()); - let ws_url = common::extract_info_from_output(node.stderr.take().unwrap()).0.ws_url; - common::wait_n_finalized_blocks(3, &ws_url).await; - - let block_number = 1; - let block_hash = common::block_hash(block_number, &ws_url).await.unwrap(); - - // Try to execute the block. - let mut block_execution = execute_block(&ws_url, block_hash); - - // The execute-block command is actually executing the next block. - let expected_output = - format!(r#".*Block #{} successfully executed"#, block_number.saturating_add(1)); - let re = Regex::new(expected_output.as_str()).unwrap(); - let matched = - common::wait_for_stream_pattern_match(block_execution.stderr.take().unwrap(), re).await; - - // Assert that the block-execution process has executed a block. - assert!(matched.is_ok()); - }) - .await; -} diff --git a/utils/frame/try-runtime/cli/tests/follow_chain.rs b/utils/frame/try-runtime/cli/tests/follow_chain.rs deleted file mode 100644 index d7ff7b09cbb72..0000000000000 --- a/utils/frame/try-runtime/cli/tests/follow_chain.rs +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#![cfg(unix)] -#![cfg(feature = "try-runtime")] - -use assert_cmd::cargo::cargo_bin; -use regex::Regex; -use std::{ - process::{self}, - time::Duration, -}; -use substrate_cli_test_utils as common; -use tokio::process::{Child, Command}; - -#[tokio::test] -async fn follow_chain_works() { - // Build substrate so binaries used in the test use the latest code. - common::build_substrate(&["--features=try-runtime"]); - - common::run_with_timeout(Duration::from_secs(60), async move { - fn start_follow(ws_url: &str) -> Child { - Command::new(cargo_bin("substrate-node")) - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .args(&["try-runtime", "--runtime=existing"]) - .args(&["follow-chain", format!("--uri={}", ws_url).as_str()]) - .kill_on_drop(true) - .spawn() - .unwrap() - } - - // Start a node and wait for it to begin finalizing blocks - let mut node = common::KillChildOnDrop(common::start_node()); - let ws_url = common::extract_info_from_output(node.stderr.take().unwrap()).0.ws_url; - common::wait_n_finalized_blocks(1, &ws_url).await; - - // Kick off the follow-chain process and wait for it to process at least 3 blocks. - let mut follow = start_follow(&ws_url); - let re = Regex::new(r#".*executed block ([3-9]|[1-9]\d+).*"#).unwrap(); - let matched = - common::wait_for_stream_pattern_match(follow.stderr.take().unwrap(), re).await; - - // Assert that the follow-chain process has followed at least 3 blocks. - assert!(matched.is_ok()); - }) - .await; -}