diff --git a/crates/pallet-domains/Cargo.toml b/crates/pallet-domains/Cargo.toml index 0115dc6312..d48d83b05b 100644 --- a/crates/pallet-domains/Cargo.toml +++ b/crates/pallet-domains/Cargo.toml @@ -71,5 +71,6 @@ runtime-benchmarks = [ "frame-benchmarking", "frame-benchmarking/runtime-benchmarks", "sp-domains/runtime-benchmarks", + "sp-domains-fraud-proof/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] diff --git a/crates/pallet-domains/res/README.md b/crates/pallet-domains/res/README.md index 69c581fdf0..781f961040 100644 --- a/crates/pallet-domains/res/README.md +++ b/crates/pallet-domains/res/README.md @@ -2,4 +2,6 @@ This runtime is used for benchmarking the `register_domain_runtime` and `upgrade **Don't use them in production environments!** -To update the just copy the new runtime from `target/release/wbuild/evm-domain-test-runtime/evm_domain_test_runtime.compact.compressed.wasm` to here. +To update: +1. Build the `subspace-node` binary +2. Run `subspace-node domain build-genesis-storage --chain dev > evm-domain-genesis-storage` diff --git a/crates/pallet-domains/res/evm-domain-genesis-storage b/crates/pallet-domains/res/evm-domain-genesis-storage new file mode 100644 index 0000000000..9f7b86e8e9 Binary files /dev/null and b/crates/pallet-domains/res/evm-domain-genesis-storage differ diff --git a/crates/pallet-domains/src/benchmarking.rs b/crates/pallet-domains/src/benchmarking.rs index dd78afa450..7b19c6e78f 100644 --- a/crates/pallet-domains/src/benchmarking.rs +++ b/crates/pallet-domains/src/benchmarking.rs @@ -3,12 +3,22 @@ extern crate alloc; use super::*; +use crate::block_tree::{prune_receipt, BlockTreeNode}; +use crate::bundle_storage_fund::refund_storage_fee; use crate::domain_registry::DomainConfig; -use crate::staking::{do_reward_operators, OperatorConfig, OperatorStatus}; -use crate::staking_epoch::{do_finalize_domain_current_epoch, do_finalize_domain_epoch_staking}; +use crate::staking::{ + do_convert_previous_epoch_deposits, do_reward_operators, do_slash_operators, OperatorConfig, + OperatorStatus, +}; +use crate::staking_epoch::{ + do_finalize_domain_current_epoch, do_finalize_domain_epoch_staking, + do_finalize_slashed_operators, operator_take_reward_tax_and_stake, +}; use crate::{DomainBlockNumberFor, Pallet as Domains}; #[cfg(not(feature = "std"))] use alloc::borrow::ToOwned; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_support::traits::fungible::Mutate; @@ -17,10 +27,12 @@ use frame_support::weights::Weight; use frame_system::{Pallet as System, RawOrigin}; use sp_core::crypto::UncheckedFrom; use sp_domains::{ - dummy_opaque_bundle, DomainId, ExecutionReceipt, OperatorAllowList, OperatorId, - OperatorPublicKey, RuntimeType, + dummy_opaque_bundle, ConfirmedDomainBlock, DomainId, ExecutionReceipt, OperatorAllowList, + OperatorId, OperatorPublicKey, RuntimeType, }; +use sp_domains_fraud_proof::fraud_proof::FraudProof; use sp_runtime::traits::{CheckedAdd, One, Zero}; +use sp_std::collections::btree_set::BTreeSet; const SEED: u32 = 0; @@ -37,14 +49,14 @@ mod benchmarks { let block_tree_pruning_depth = T::BlockTreePruningDepth::get().saturated_into::(); let domain_id = register_domain::(); let (_, operator_id) = - register_helper_operator::(domain_id, T::Currency::minimum_balance()); + register_helper_operator::(domain_id, T::MinNominatorStake::get()); let mut receipt = BlockTree::::get::<_, DomainBlockNumberFor>(domain_id, Zero::zero()) .and_then(BlockTreeNodes::::get) .expect("genesis receipt must exist") .execution_receipt; - for i in 1..=(block_tree_pruning_depth + 1) { + for i in [1, 2, 3, block_tree_pruning_depth] { let consensus_block_number = i.into(); let domain_block_number = i.into(); @@ -54,9 +66,32 @@ mod benchmarks { frame_system::Pallet::::block_hash(consensus_block_number - One::one()), ); - // Submit a bundle with the receipt of the last block - let bundle = dummy_opaque_bundle(domain_id, operator_id, receipt); - assert_ok!(Domains::::submit_bundle(RawOrigin::None.into(), bundle)); + if i != block_tree_pruning_depth { + // Submit a bundle with the receipt of the last block + let bundle = dummy_opaque_bundle(domain_id, operator_id, receipt); + assert_ok!(Domains::::submit_bundle(RawOrigin::None.into(), bundle)); + } else { + // Since the challenge period is set to 1 day we don't want to fill up all the ERs + // (i.e. 14_400 number of ERs) which seems take forever to finish, thus we instead + // manually insert the last ER into the state. + let receipt_block_number = domain_block_number - One::one(); + let receipt = ExecutionReceipt::dummy::>( + consensus_block_number - One::one(), + frame_system::Pallet::::block_hash(consensus_block_number - One::one()), + receipt_block_number, + Default::default(), + ); + let receipt_hash = receipt.hash::>(); + HeadReceiptNumber::::set(domain_id, receipt_block_number); + BlockTree::::insert(domain_id, receipt_block_number, receipt_hash); + BlockTreeNodes::::insert( + receipt_hash, + BlockTreeNode { + execution_receipt: receipt, + operator_ids: sp_std::vec![operator_id], + }, + ); + } // Create ER for the above bundle let head_receipt_number = HeadReceiptNumber::::get(domain_id); @@ -71,11 +106,11 @@ mod benchmarks { } assert_eq!( Domains::::head_receipt_number(domain_id), - (block_tree_pruning_depth).into() + (block_tree_pruning_depth - 1).into() ); // Construct bundle that will prune the block tree - let block_number = (block_tree_pruning_depth + 2).into(); + let block_number = (block_tree_pruning_depth + 1).into(); run_to_block::( block_number, frame_system::Pallet::::block_hash(block_number - One::one()), @@ -87,7 +122,7 @@ mod benchmarks { assert_eq!( Domains::::head_receipt_number(domain_id), - (block_tree_pruning_depth + 1).into() + block_tree_pruning_depth.into() ); assert_eq!( Domains::::oldest_unconfirmed_receipt_number(domain_id), @@ -95,98 +130,382 @@ mod benchmarks { ); } - /// Benchmark pending staking operation with the worst possible conditions: - /// - There are `MaxPendingStakingOperation` number of pending staking operation - /// - All pending staking operation are withdrawal that withdraw partial stake #[benchmark] - fn pending_staking_operation() { - let max_pending_staking_op = T::MaxPendingStakingOperation::get(); - let minimum_nominator_stake = T::Currency::minimum_balance(); - let withdraw_amount = T::MinOperatorStake::get(); + fn submit_fraud_proof() { + let domain_id = register_domain::(); + let (_, operator_id) = + register_helper_operator::(domain_id, T::MinNominatorStake::get()); + + let mut target_receipt_hash = None; + let mut receipt = + BlockTree::::get::<_, DomainBlockNumberFor>(domain_id, Zero::zero()) + .and_then(BlockTreeNodes::::get) + .expect("genesis receipt must exist") + .execution_receipt; + for i in 1u32..=3u32 { + let consensus_block_number = i.into(); + let domain_block_number = i.into(); + + // Run to `block_number` + run_to_block::( + consensus_block_number, + frame_system::Pallet::::block_hash(consensus_block_number - One::one()), + ); + + // Submit a bundle with the receipt of the last block + let bundle = dummy_opaque_bundle(domain_id, operator_id, receipt); + assert_ok!(Domains::::submit_bundle(RawOrigin::None.into(), bundle)); + + // Create ER for the above bundle + let head_receipt_number = HeadReceiptNumber::::get(domain_id); + let parent_domain_block_receipt = BlockTree::::get(domain_id, head_receipt_number) + .expect("parent receipt must exist"); + receipt = ExecutionReceipt::dummy::>( + consensus_block_number, + frame_system::Pallet::::block_hash(consensus_block_number), + domain_block_number, + parent_domain_block_receipt, + ); + if i == 1 { + target_receipt_hash.replace(receipt.hash::>()); + } + } + assert_eq!(Domains::::head_receipt_number(domain_id), 2u32.into()); + + // Construct fraud proof that target the ER at block #1 + let fraud_proof = FraudProof::dummy_fraud_proof(domain_id, target_receipt_hash.unwrap()); + + #[extrinsic_call] + submit_fraud_proof(RawOrigin::None, Box::new(fraud_proof)); + + assert_eq!(Domains::::head_receipt_number(domain_id), 0u32.into()); + assert_eq!( + Domains::::oldest_unconfirmed_receipt_number(domain_id), + None, + ); + } + + /// Benchmark prune bad ER and slash the submitter based on the number of submitter + #[benchmark] + fn handle_bad_receipt(n: Linear<1, MAX_BUNLDE_PER_BLOCK>) { + let minimum_nominator_stake = T::MinNominatorStake::get(); + let domain_id = register_domain::(); + let mut operator_ids = Vec::new(); + for i in 0..n { + let (_, operator_id) = + register_operator_with_seed::(domain_id, i + 1, minimum_nominator_stake); + operator_ids.push(operator_id); + } + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + // Construct a bad ER ar block #1 and inject it in to the block tree + let receipt_number = 1u32.into(); + let receipt = ExecutionReceipt::dummy::>( + 1u32.into(), + frame_system::Pallet::::block_hash::>(1u32.into()), + receipt_number, + Default::default(), + ); + let receipt_hash = receipt.hash::>(); + HeadReceiptNumber::::set(domain_id, receipt_number); + BlockTree::::insert(domain_id, receipt_number, receipt_hash); + BlockTreeNodes::::insert( + receipt_hash, + BlockTreeNode { + execution_receipt: receipt, + operator_ids, + }, + ); + + #[block] + { + let block_tree_node = prune_receipt::(domain_id, receipt_number) + .expect("prune bad receipt should success") + .expect("block tree node must exist"); + + do_slash_operators::( + block_tree_node.operator_ids.into_iter(), + SlashedReason::BadExecutionReceipt(receipt_hash), + ) + .expect("slash operator should success"); + } + + assert_eq!( + PendingSlashes::::get(domain_id) + .expect("pedning slash must exist") + .len(), + n as usize + ); + assert!(BlockTree::::get(domain_id, receipt_number).is_none()); + } + + /// Benchmark confirm domain block based on the number of valid and invalid bundles have submitted + /// in this block + #[benchmark] + fn confirm_domain_block( + n: Linear<1, MAX_BUNLDE_PER_BLOCK>, + s: Linear<0, MAX_BUNLDE_PER_BLOCK>, + ) { + let minimum_nominator_stake = T::MinNominatorStake::get(); let operator_rewards = - T::Currency::minimum_balance().saturating_mul(BalanceOf::::from(100u32)); + T::Currency::minimum_balance().saturating_mul(BalanceOf::::from(1000u32)); + let total_storage_fee = + T::Currency::minimum_balance().saturating_mul(BalanceOf::::from(1000u32)); + + // Ensure the treasury account is above ED + T::Currency::set_balance( + &T::TreasuryAccount::get(), + T::Currency::minimum_balance() + 1u32.into(), + ); let domain_id = register_domain::(); - let (_, operator_id) = register_helper_operator::(domain_id, minimum_nominator_stake); + let mut operator_ids = Vec::new(); + for i in 0..(n + s) { + let (_, operator_id) = + register_operator_with_seed::(domain_id, i + 1, minimum_nominator_stake); + operator_ids.push(operator_id); + } do_finalize_domain_current_epoch::(domain_id) .expect("finalize domain staking should success"); - for i in 0..max_pending_staking_op { - let nominator = account("nominator", i, SEED); - T::Currency::set_balance( - &nominator, - withdraw_amount * 2u32.into() + T::Currency::minimum_balance(), + #[allow(clippy::unnecessary_to_owned)] + #[block] + { + refund_storage_fee::( + total_storage_fee, + operator_ids + .iter() + .take(n as usize) + .map(|id| (*id, 1u32)) + .collect(), + ) + .expect("refund storage fee should success"); + + do_reward_operators::( + domain_id, + operator_ids[..n as usize].to_vec().into_iter(), + operator_rewards, + ) + .expect("reward operator should success"); + + do_slash_operators::( + operator_ids[n as usize..].to_vec().into_iter(), + SlashedReason::InvalidBundle(1u32.into()), + ) + .expect("slash operator should success"); + } + + let staking_summary = + DomainStakingSummary::::get(domain_id).expect("staking summary must exist"); + assert!(!staking_summary.current_epoch_rewards.is_empty()); + if s != 0 { + assert_eq!( + PendingSlashes::::get(domain_id) + .expect("pedning slash must exist") + .len(), + s as usize ); - assert_ok!(Domains::::nominate_operator( - RawOrigin::Signed(nominator).into(), - operator_id, - withdraw_amount * 2u32.into(), - )); + } + } + + /// Benchmark `operator_take_reward_tax_and_stake` based on the number of operator who has reward + /// in the current epoch + #[benchmark] + fn operator_reward_tax_and_restake(n: Linear<1, MAX_BUNLDE_PER_BLOCK>) { + let minimum_nominator_stake = T::MinNominatorStake::get(); + let operator_rewards = + T::Currency::minimum_balance().saturating_mul(BalanceOf::::from(1000u32)); + + // Ensure the treasury account is above ED + T::Currency::set_balance( + &T::TreasuryAccount::get(), + T::Currency::minimum_balance() + 1u32.into(), + ); + + let domain_id = register_domain::(); + let mut operator_ids = Vec::new(); + for i in 0..n { + let (_, operator_id) = + register_operator_with_seed::(domain_id, i + 1, minimum_nominator_stake); + operator_ids.push(operator_id); } do_finalize_domain_current_epoch::(domain_id) .expect("finalize domain staking should success"); - assert_eq!(PendingStakingOperationCount::::get(domain_id), 0); - for i in 0..max_pending_staking_op { - let nominator = account("nominator", i, SEED); - assert_ok!(Domains::::withdraw_stake( - RawOrigin::Signed(nominator).into(), - operator_id, - withdraw_amount.into(), - )); + do_reward_operators::( + domain_id, + operator_ids.clone().into_iter(), + operator_rewards, + ) + .expect("reward operator should success"); + + let staking_summary = + DomainStakingSummary::::get(domain_id).expect("staking summary must exist"); + assert_eq!(staking_summary.current_epoch_rewards.len(), n as usize); + + #[block] + { + operator_take_reward_tax_and_stake::(domain_id) + .expect("operator take reward tax and restake should success"); } + + let staking_summary = + DomainStakingSummary::::get(domain_id).expect("staking summary must exist"); + assert!(staking_summary.current_epoch_rewards.is_empty()); + } + + /// Benchmark `do_finalize_slashed_operators` based on the number of operator and the number of their + // nominator that has slashed in the current epoch + #[benchmark] + fn finalize_slashed_operators( + n: Linear<1, { MAX_BUNLDE_PER_BLOCK * T::MaxNominators::get() }>, + ) { + let minimum_nominator_stake = T::MinNominatorStake::get(); + let domain_id = register_domain::(); + + let (operator_count, nominator_per_operator) = if n <= MAX_BUNLDE_PER_BLOCK { + (n, 1) + } else { + (MAX_BUNLDE_PER_BLOCK, n.div_ceil(MAX_BUNLDE_PER_BLOCK)) + }; + + let mut operator_ids = Vec::new(); + for i in 0..operator_count { + let (_, operator_id) = + register_operator_with_seed::(domain_id, i + 1, minimum_nominator_stake); + operator_ids.push(operator_id); + } + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + // Ensure the treasury account is above ED + T::Currency::set_balance( + &T::TreasuryAccount::get(), + T::Currency::minimum_balance() + 1u32.into(), + ); + + for (i, operator_id) in operator_ids.iter().enumerate() { + // Minus one since the operator owner is already a nominator + for j in 1..nominator_per_operator { + let nominator = account("nominator", i as u32, j); + T::Currency::set_balance(&nominator, minimum_nominator_stake * 2u32.into()); + assert_ok!(Domains::::nominate_operator( + RawOrigin::Signed(nominator).into(), + *operator_id, + minimum_nominator_stake, + )); + } + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + } + + // Slash operator + do_slash_operators::( + operator_ids.into_iter(), + SlashedReason::InvalidBundle(1u32.into()), + ) + .expect("slash operator should success"); + assert_eq!( - PendingStakingOperationCount::::get(domain_id) as u32, - max_pending_staking_op + PendingSlashes::::get(domain_id) + .expect("pedning slash must exist") + .len(), + operator_count as usize ); #[block] { - do_reward_operators::(domain_id, vec![operator_id].into_iter(), operator_rewards) - .expect("reward operator should success"); + do_finalize_slashed_operators::(domain_id).expect("finalize slash should success"); + } - do_finalize_domain_current_epoch::(domain_id) + assert!(PendingSlashes::::get(domain_id).is_none()); + } + + /// Benchmark `do_finalize_domain_epoch_staking` based on the number of operator who has deposit/withdraw/reward + /// happen in the current epoch + #[benchmark] + fn finalize_domain_epoch_staking(p: Linear<0, { T::MaxPendingStakingOperation::get() }>) { + let minimum_nominator_stake = T::MinNominatorStake::get(); + let operator_rewards = + T::Currency::minimum_balance().saturating_mul(BalanceOf::::from(1000u32)); + + // Ensure the treasury account is above ED + T::Currency::set_balance( + &T::TreasuryAccount::get(), + T::Currency::minimum_balance() + 1u32.into(), + ); + + let domain_id = register_domain::(); + let mut operator_ids = Vec::new(); + for i in 0..T::MaxPendingStakingOperation::get() { + let (_, operator_id) = + register_operator_with_seed::(domain_id, i + 1, minimum_nominator_stake); + operator_ids.push(operator_id); + } + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + for (i, operator_id) in operator_ids.iter().enumerate().take(p as usize) { + let nominator = account("nominator", i as u32, SEED); + T::Currency::set_balance(&nominator, minimum_nominator_stake * 2u32.into()); + assert_ok!(Domains::::nominate_operator( + RawOrigin::Signed(nominator).into(), + *operator_id, + minimum_nominator_stake, + )); + } + assert_eq!(PendingStakingOperationCount::::get(domain_id), p); + + do_reward_operators::(domain_id, operator_ids.into_iter(), operator_rewards) + .expect("reward operator should success"); + + let epoch_index = DomainStakingSummary::::get(domain_id) + .expect("staking summary must exist") + .current_epoch_index; + + #[block] + { + do_finalize_domain_epoch_staking::(domain_id) .expect("finalize domain staking should success"); } - assert_eq!(PendingStakingOperationCount::::get(domain_id), 0); + let staking_summary = + DomainStakingSummary::::get(domain_id).expect("staking summary must exist"); + assert_eq!(staking_summary.current_epoch_index, epoch_index + 1u32); } #[benchmark] fn register_domain_runtime() { - let runtime_blob = - include_bytes!("../res/evm_domain_test_runtime.compact.compressed.wasm").to_vec(); + let genesis_storage = include_bytes!("../res/evm-domain-genesis-storage").to_vec(); let runtime_id = NextRuntimeId::::get(); - let runtime_hash = T::Hashing::hash(&runtime_blob); #[extrinsic_call] _( RawOrigin::Root, "evm-domain".to_owned(), RuntimeType::Evm, - runtime_blob, + genesis_storage, ); let runtime_obj = RuntimeRegistry::::get(runtime_id).expect("runtime object must exist"); assert_eq!(runtime_obj.runtime_name, "evm-domain".to_owned()); assert_eq!(runtime_obj.runtime_type, RuntimeType::Evm); - assert_eq!(runtime_obj.hash, runtime_hash); assert_eq!(NextRuntimeId::::get(), runtime_id + 1); } #[benchmark] fn upgrade_domain_runtime() { - let runtime_blob = - include_bytes!("../res/evm_domain_test_runtime.compact.compressed.wasm").to_vec(); + let genesis_storage = include_bytes!("../res/evm-domain-genesis-storage").to_vec(); let runtime_id = NextRuntimeId::::get(); - // The `runtime_blob` have `spec_version = 1` thus we need to modify the runtime object + // The `genesis_storage` have `spec_version = 1` thus we need to modify the runtime object // version to 0 to bypass the `can_upgrade_code` check when calling `upgrade_domain_runtime` assert_ok!(Domains::::register_domain_runtime( RawOrigin::Root.into(), "evm-domain".to_owned(), RuntimeType::Evm, - runtime_blob.clone() + genesis_storage.clone() )); RuntimeRegistry::::mutate(runtime_id, |maybe_runtime_object| { let runtime_obj = maybe_runtime_object @@ -196,7 +515,7 @@ mod benchmarks { }); #[extrinsic_call] - _(RawOrigin::Root, runtime_id, runtime_blob.clone()); + _(RawOrigin::Root, runtime_id, genesis_storage.clone()); let scheduled_at = frame_system::Pallet::::current_block_number() .checked_add(&T::DomainRuntimeUpgradeDelay::get()) @@ -204,18 +523,14 @@ mod benchmarks { let scheduled_upgrade = ScheduledRuntimeUpgrades::::get(scheduled_at, runtime_id) .expect("scheduled upgrade must exist"); assert_eq!(scheduled_upgrade.version.spec_version, 1); - assert_eq!( - scheduled_upgrade.raw_genesis.get_runtime_code().unwrap(), - runtime_blob - ); } #[benchmark] fn instantiate_domain() { - let creator = account("creator", 1, SEED); + let creator = T::SudoId::get(); T::Currency::set_balance( &creator, - T::DomainInstantiationDeposit::get() + T::Currency::minimum_balance(), + T::DomainInstantiationDeposit::get() + T::MinNominatorStake::get(), ); let runtime_id = register_runtime::(); @@ -232,7 +547,7 @@ mod benchmarks { }; #[extrinsic_call] - _(RawOrigin::Signed(creator.clone()), domain_config.clone()); + _(RawOrigin::Root, domain_config.clone()); let domain_obj = DomainRegistry::::get(domain_id).expect("domain object must exist"); assert_eq!(domain_obj.domain_config, domain_config); @@ -249,14 +564,14 @@ mod benchmarks { let operator_account = account("operator", 1, SEED); T::Currency::set_balance( &operator_account, - T::MinOperatorStake::get() + T::Currency::minimum_balance(), + T::MinOperatorStake::get() + T::MinNominatorStake::get(), ); let domain_id = register_domain::(); let operator_id = NextOperatorId::::get(); let operator_config = OperatorConfig { signing_key: OperatorPublicKey::unchecked_from([1u8; 32]), - minimum_nominator_stake: T::Currency::minimum_balance(), + minimum_nominator_stake: T::MinNominatorStake::get(), nomination_tax: Default::default(), }; @@ -283,14 +598,15 @@ mod benchmarks { } /// Benchmark `nominate_operator` extrinsic with the worst possible conditions: - /// - There is already a pending deposit of the nominator + /// - There is already a pending deposit of the nominator from the previous epoch + /// that need to convert into share #[benchmark] fn nominate_operator() { let nominator = account("nominator", 1, SEED); - let minimum_nominator_stake = T::Currency::minimum_balance(); + let minimum_nominator_stake = T::MinNominatorStake::get(); T::Currency::set_balance( &nominator, - minimum_nominator_stake * 2u32.into() + T::Currency::minimum_balance(), + minimum_nominator_stake * 2u32.into() + T::MinNominatorStake::get(), ); let domain_id = register_domain::(); @@ -302,6 +618,8 @@ mod benchmarks { operator_id, minimum_nominator_stake, )); + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); #[extrinsic_call] _( @@ -309,6 +627,9 @@ mod benchmarks { operator_id, minimum_nominator_stake, ); + + let operator = Operators::::get(operator_id).expect("operator must exist"); + assert!(!operator.deposits_in_epoch.is_zero()); } // TODO: `switch_domain` is not supported currently due to incompatible with lazily slashing @@ -341,7 +662,7 @@ mod benchmarks { let domain_id = register_domain::(); let (operator_owner, operator_id) = - register_helper_operator::(domain_id, T::Currency::minimum_balance()); + register_helper_operator::(domain_id, T::MinNominatorStake::get()); #[extrinsic_call] _(RawOrigin::Signed(operator_owner.clone()), operator_id); @@ -349,22 +670,24 @@ mod benchmarks { let operator = Operators::::get(operator_id).expect("operator must exist"); assert_eq!( *operator.status::(operator_id), - OperatorStatus::Deregistered((domain_id, 0, DomainBlockNumberFor::::zero()).into()) + OperatorStatus::Deregistered( + (domain_id, 1u32, T::StakeWithdrawalLockingPeriod::get()).into() + ), ); } /// Benchmark `withdraw_stake` extrinsic with the worst possible conditions: - /// - There is unmint reward of the nominator - /// - There is already a pending withdrawal of the nominator + /// - There is a pending withdrawal and a pending deposit from the previous epoch that + /// need to convert into balance/share /// - Only withdraw partial of the nominator's stake #[benchmark] fn withdraw_stake() { let nominator = account("nominator", 1, SEED); - let minimum_nominator_stake = T::Currency::minimum_balance(); + let minimum_nominator_stake = T::MinNominatorStake::get(); let withdraw_amount = T::MinOperatorStake::get(); T::Currency::set_balance( &nominator, - withdraw_amount * 3u32.into() + T::Currency::minimum_balance(), + withdraw_amount * 4u32.into() + T::MinNominatorStake::get(), ); let domain_id = register_domain::(); @@ -377,23 +700,19 @@ mod benchmarks { do_finalize_domain_epoch_staking::(domain_id) .expect("finalize domain staking should success"); - // Add reward to the operator - let _ = DomainStakingSummary::::try_mutate(domain_id, |maybe_stake_summary| { - let stake_summary = maybe_stake_summary - .as_mut() - .expect("staking summary must exist"); - stake_summary - .current_epoch_rewards - .insert(operator_id, T::MinOperatorStake::get()); - Ok::<_, ()>(()) - }); - - // Add one more withdraw + // Add one more withdraw and deposit to the previous epoch assert_ok!(Domains::::withdraw_stake( RawOrigin::Signed(nominator.clone()).into(), operator_id, withdraw_amount.into(), )); + assert_ok!(Domains::::nominate_operator( + RawOrigin::Signed(nominator.clone()).into(), + operator_id, + withdraw_amount, + )); + do_finalize_domain_epoch_staking::(domain_id) + .expect("finalize domain staking should success"); #[extrinsic_call] _( @@ -401,33 +720,178 @@ mod benchmarks { operator_id, withdraw_amount.into(), ); + + let operator = Operators::::get(operator_id).expect("operator must exist"); + assert_eq!(operator.withdrawals_in_epoch, withdraw_amount.into()); + } + + /// Benchmark `unlock_funds` extrinsic with the worst possible conditions: + /// - Unlock a full withdrawal which also remove the deposit storage for the nominator + #[benchmark] + fn unlock_funds() { + let nominator = account("nominator", 1, SEED); + let minimum_nominator_stake = T::MinNominatorStake::get(); + let staking_amount = T::MinOperatorStake::get(); + T::Currency::set_balance(&nominator, staking_amount + T::MinNominatorStake::get()); + + let domain_id = register_domain::(); + let (_, operator_id) = register_helper_operator::(domain_id, minimum_nominator_stake); + assert_ok!(Domains::::nominate_operator( + RawOrigin::Signed(nominator.clone()).into(), + operator_id, + staking_amount, + )); + do_finalize_domain_epoch_staking::(domain_id) + .expect("finalize domain staking should success"); + + // Withdraw all deposit + let withdraw_amount = { + let mut deposit = + Deposits::::get(operator_id, nominator.clone()).expect("deposit must exist"); + do_convert_previous_epoch_deposits::(operator_id, &mut deposit) + .expect("convert must success"); + deposit.known.shares + }; + assert_ok!(Domains::::withdraw_stake( + RawOrigin::Signed(nominator.clone()).into(), + operator_id, + withdraw_amount, + )); + do_finalize_domain_epoch_staking::(domain_id) + .expect("finalize domain staking should success"); + + // Update the `LatestConfirmedDomainBlock` so unlock can success + let confirmed_domain_block_number = + Pallet::::latest_confirmed_domain_block_number(domain_id) + + T::StakeWithdrawalLockingPeriod::get() + + One::one(); + LatestConfirmedDomainBlock::::insert( + domain_id, + ConfirmedDomainBlock { + block_number: confirmed_domain_block_number, + block_hash: Default::default(), + parent_block_receipt_hash: Default::default(), + state_root: Default::default(), + extrinsics_root: Default::default(), + }, + ); + + #[extrinsic_call] + _(RawOrigin::Signed(nominator.clone()), operator_id); + + assert!(Withdrawals::::get(operator_id, nominator.clone()).is_none()); + assert!(Deposits::::get(operator_id, nominator).is_none()); + } + + /// Benchmark `unlock_operator` extrinsic based on the number of nominator of the unlocked operator + #[benchmark] + fn unlock_operator(n: Linear<0, { T::MaxNominators::get() }>) { + let domain_id = register_domain::(); + let (operator_owner, operator_id) = + register_helper_operator::(domain_id, T::MinNominatorStake::get()); + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + // Ensure the treasury account is above ED + T::Currency::set_balance( + &T::TreasuryAccount::get(), + T::Currency::minimum_balance() + 1u32.into(), + ); + + for i in 0..n { + let nominator = account("nominator", i, SEED); + T::Currency::set_balance( + &nominator, + T::MinNominatorStake::get() + T::Currency::minimum_balance(), + ); + assert_ok!(Domains::::nominate_operator( + RawOrigin::Signed(nominator).into(), + operator_id, + T::MinNominatorStake::get(), + )); + } + if n != 0 { + assert_eq!(PendingStakingOperationCount::::get(domain_id), 1); + } + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + // Deregister operator + assert_ok!(Domains::::deregister_operator( + RawOrigin::Signed(operator_owner.clone()).into(), + operator_id, + )); + + // Update the `LatestConfirmedDomainBlock` so unlock can success + let confirmed_domain_block_number = + Pallet::::latest_confirmed_domain_block_number(domain_id) + + T::StakeWithdrawalLockingPeriod::get() + + One::one(); + LatestConfirmedDomainBlock::::insert( + domain_id, + ConfirmedDomainBlock { + block_number: confirmed_domain_block_number, + block_hash: Default::default(), + parent_block_receipt_hash: Default::default(), + state_root: Default::default(), + extrinsics_root: Default::default(), + }, + ); + + #[extrinsic_call] + _(RawOrigin::Signed(operator_owner), operator_id); + + assert!(OperatorIdOwner::::get(operator_id).is_none()); + } + + #[benchmark] + fn update_domain_operator_allow_list() { + let domain_id = register_domain::(); + let _ = register_helper_operator::(domain_id, T::MinNominatorStake::get()); + do_finalize_domain_current_epoch::(domain_id) + .expect("finalize domain staking should success"); + + let domain_owner = DomainRegistry::::get(domain_id) + .expect("domain object must exist") + .owner_account_id; + let new_allow_list = OperatorAllowList::Operators(BTreeSet::from_iter(vec![account( + "allowed-account", + 0, + SEED, + )])); + + #[extrinsic_call] + _( + RawOrigin::Signed(domain_owner), + domain_id, + new_allow_list.clone(), + ); + + let domain_obj = DomainRegistry::::get(domain_id).expect("domain object must exist"); + assert_eq!(domain_obj.domain_config.operator_allow_list, new_allow_list); } fn register_runtime() -> RuntimeId { - let runtime_blob = - include_bytes!("../res/evm_domain_test_runtime.compact.compressed.wasm").to_vec(); + let genesis_storage = include_bytes!("../res/evm-domain-genesis-storage").to_vec(); let runtime_id = NextRuntimeId::::get(); - let runtime_hash = T::Hashing::hash(&runtime_blob); assert_ok!(Domains::::register_domain_runtime( RawOrigin::Root.into(), "evm-domain".to_owned(), RuntimeType::Evm, - runtime_blob, + genesis_storage, )); - let runtime_obj = RuntimeRegistry::::get(runtime_id).expect("runtime object must exist"); - assert_eq!(runtime_obj.hash, runtime_hash); assert_eq!(NextRuntimeId::::get(), runtime_id + 1); runtime_id } fn register_domain() -> DomainId { - let creator = account("creator", 1, SEED); + let creator = T::SudoId::get(); T::Currency::set_balance( &creator, - T::DomainInstantiationDeposit::get() + T::Currency::minimum_balance(), + T::DomainInstantiationDeposit::get() + T::MinNominatorStake::get(), ); let runtime_id = register_runtime::(); @@ -444,7 +908,7 @@ mod benchmarks { }; assert_ok!(Domains::::instantiate_domain( - RawOrigin::Signed(creator.clone()).into(), + RawOrigin::Root.into(), domain_config.clone(), )); @@ -459,15 +923,28 @@ mod benchmarks { domain_id: DomainId, minimum_nominator_stake: BalanceOf, ) -> (T::AccountId, OperatorId) { - let operator_account = account("operator", 1, SEED); + register_operator_with_seed::(domain_id, 1u32, minimum_nominator_stake) + } + + fn register_operator_with_seed( + domain_id: DomainId, + operator_seed: u32, + minimum_nominator_stake: BalanceOf, + ) -> (T::AccountId, OperatorId) { + let operator_account = account("operator", operator_seed, SEED); T::Currency::set_balance( &operator_account, - T::MinOperatorStake::get() + T::Currency::minimum_balance(), + T::MinOperatorStake::get() + T::MinNominatorStake::get(), ); + let key = { + let mut k = [0u8; 32]; + (k[..4]).copy_from_slice(&operator_seed.to_be_bytes()[..]); + k + }; let operator_id = NextOperatorId::::get(); let operator_config = OperatorConfig { - signing_key: OperatorPublicKey::unchecked_from([1u8; 32]), + signing_key: OperatorPublicKey::unchecked_from(key), minimum_nominator_stake, nomination_tax: Default::default(), }; diff --git a/crates/pallet-domains/src/lib.rs b/crates/pallet-domains/src/lib.rs index abdcd40b91..e675227ee4 100644 --- a/crates/pallet-domains/src/lib.rs +++ b/crates/pallet-domains/src/lib.rs @@ -37,6 +37,8 @@ extern crate alloc; use crate::block_tree::verify_execution_receipt; use crate::domain_registry::Error as DomainRegistryError; use crate::staking::OperatorStatus; +use crate::staking_epoch::EpochTransitionResult; +use crate::weights::WeightInfo; #[cfg(not(feature = "std"))] use alloc::boxed::Box; use alloc::collections::btree_map::BTreeMap; @@ -47,6 +49,7 @@ use frame_support::ensure; use frame_support::pallet_prelude::StorageVersion; use frame_support::traits::fungible::{Inspect, InspectHold}; use frame_support::traits::{Get, Randomness as RandomnessT}; +use frame_support::weights::Weight; use frame_system::offchain::SubmitTransaction; use frame_system::pallet_prelude::*; pub use pallet::*; @@ -134,15 +137,22 @@ pub type BlockTreeNodeFor = crate::block_tree::BlockTreeNode< /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); +/// The number of bundle of a particular domain to be included in the block is probabilistic +/// and based on the consensus chain slot probability and domain bundle slot probability, usually +/// the value is 6 on average, smaller/bigger value with less probability, we hypocritically use +/// 100 as the maximum number of bundle per block for benchmarking. +const MAX_BUNLDE_PER_BLOCK: u32 = 100; + #[frame_support::pallet] mod pallet { #![allow(clippy::large_enum_variant)] use crate::block_tree::{ - execution_receipt_type, process_execution_receipt, prune_receipt, AcceptedReceiptType, - Error as BlockTreeError, ReceiptType, + execution_receipt_type, process_execution_receipt, Error as BlockTreeError, ReceiptType, }; #[cfg(not(feature = "runtime-benchmarks"))] + use crate::block_tree::{prune_receipt, AcceptedReceiptType}; + #[cfg(not(feature = "runtime-benchmarks"))] use crate::bundle_storage_fund::refund_storage_fee; use crate::bundle_storage_fund::{charge_bundle_storage_fee, Error as BundleStorageFundError}; use crate::domain_registry::{ @@ -163,9 +173,11 @@ mod pallet { }; use crate::staking_epoch::{do_finalize_domain_current_epoch, Error as StakingEpochError}; use crate::weights::WeightInfo; + #[cfg(not(feature = "runtime-benchmarks"))] + use crate::DomainHashingFor; use crate::{ - BalanceOf, BlockSlot, BlockTreeNodeFor, DomainBlockNumberFor, DomainHashingFor, - ElectionVerificationParams, HoldIdentifier, NominatorId, OpaqueBundleOf, ReceiptHashFor, + BalanceOf, BlockSlot, BlockTreeNodeFor, DomainBlockNumberFor, ElectionVerificationParams, + HoldIdentifier, NominatorId, OpaqueBundleOf, ReceiptHashFor, MAX_BUNLDE_PER_BLOCK, STORAGE_VERSION, }; #[cfg(not(feature = "std"))] @@ -879,7 +891,7 @@ mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::submit_bundle().saturating_add(T::WeightInfo::pending_staking_operation()))] + #[pallet::weight(Pallet::::max_submit_bundle_weight())] pub fn submit_bundle( origin: OriginFor, opaque_bundle: OpaqueBundleOf, @@ -895,12 +907,13 @@ mod pallet { let operator_id = opaque_bundle.operator_id(); let bundle_size = opaque_bundle.size(); let receipt = opaque_bundle.into_receipt(); + #[cfg_attr(feature = "runtime-benchmarks", allow(unused_variables))] let receipt_block_number = receipt.domain_block_number; #[cfg(not(feature = "runtime-benchmarks"))] - let mut epoch_transitted = false; + let mut actual_weight = T::WeightInfo::submit_bundle(); #[cfg(feature = "runtime-benchmarks")] - let epoch_transitted = false; + let actual_weight = T::WeightInfo::submit_bundle(); match execution_receipt_type::(domain_id, &receipt) { ReceiptType::Rejected(rejected_receipt_type) => { @@ -910,11 +923,20 @@ mod pallet { ReceiptType::Accepted(accepted_receipt_type) => { // Before adding the new head receipt to the block tree, try to prune any previous // bad ER at the same domain block and slash the submitter. + // + // NOTE: Skip the following staking related operations when benchmarking the + // `submit_bundle` call, these operations will be benchmarked separately. + #[cfg(not(feature = "runtime-benchmarks"))] if accepted_receipt_type == AcceptedReceiptType::NewHead { if let Some(block_tree_node) = prune_receipt::(domain_id, receipt_block_number) .map_err(Error::::from)? { + actual_weight = + actual_weight.saturating_add(T::WeightInfo::handle_bad_receipt( + block_tree_node.operator_ids.len() as u32, + )); + let bad_receipt_hash = block_tree_node .execution_receipt .hash::>(); @@ -940,11 +962,14 @@ mod pallet { // // NOTE: Skip the following staking related operations when benchmarking the // `submit_bundle` call, these operations will be benchmarked separately. - // TODO: in order to get a more accurate actual weight, separately benchmark: - // - `do_reward_operators`,`do_slash_operators`,`do_unlock_pending_withdrawals` - // - `do_finalize_domain_current_epoch` #[cfg(not(feature = "runtime-benchmarks"))] if let Some(confirmed_block_info) = maybe_confirmed_domain_block_info { + actual_weight = + actual_weight.saturating_add(T::WeightInfo::confirm_domain_block( + confirmed_block_info.operator_ids.len() as u32, + confirmed_block_info.invalid_bundle_authors.len() as u32, + )); + refund_storage_fee::( confirmed_block_info.total_storage_fee, confirmed_block_info.paid_bundle_storage_fees, @@ -967,15 +992,18 @@ mod pallet { if confirmed_block_info.domain_block_number % T::StakeEpochDuration::get() == Zero::zero() { - let completed_epoch_index = + let epoch_transition_res = do_finalize_domain_current_epoch::(domain_id) .map_err(Error::::from)?; Self::deposit_event(Event::DomainEpochCompleted { domain_id, - completed_epoch_index, + completed_epoch_index: epoch_transition_res.completed_epoch_index, }); - epoch_transitted = true; + + actual_weight = actual_weight.saturating_add( + Self::actual_epoch_transition_weight(epoch_transition_res), + ); } } } @@ -1013,28 +1041,27 @@ mod pallet { bundle_author: operator_id, }); - let actual_weight = if !epoch_transitted { - Some(T::WeightInfo::submit_bundle()) - } else { - Some( - T::WeightInfo::submit_bundle() - .saturating_add(T::WeightInfo::pending_staking_operation()), - ) - }; - Ok(actual_weight.into()) + // Ensure the returned weight not exceed the maximum weight in the `pallet::weight` + Ok(Some(actual_weight.min(Self::max_submit_bundle_weight())).into()) } #[pallet::call_index(1)] - // TODO: proper weight - #[pallet::weight((Weight::from_all(10_000), DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + T::WeightInfo::submit_fraud_proof().saturating_add( + T::WeightInfo::handle_bad_receipt(MAX_BUNLDE_PER_BLOCK) + ), + DispatchClass::Operational, + Pays::No + ))] pub fn submit_fraud_proof( origin: OriginFor, fraud_proof: Box, T::Hash, T::DomainHeader>>, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { ensure_none(origin)?; log::trace!(target: "runtime::domains", "Processing fraud proof: {fraud_proof:?}"); let domain_id = fraud_proof.domain_id(); + let mut actual_weight = T::WeightInfo::submit_fraud_proof(); if let Some(bad_receipt_hash) = fraud_proof.targeted_bad_receipt_hash() { let head_receipt_number = HeadReceiptNumber::::get(domain_id); @@ -1053,14 +1080,26 @@ mod pallet { // Prune the bad ER and slash the submitter, the descendants of the bad ER (i.e. all ERs in // `[bad_receipt_number + 1..head_receipt_number]` ) and the corresponding submitter will be // pruned/slashed lazily as the domain progressed. - let block_tree_node = prune_receipt::(domain_id, bad_receipt_number) - .map_err(Error::::from)? - .ok_or::>(FraudProofError::BadReceiptNotFound.into())?; - do_slash_operators::( - block_tree_node.operator_ids.into_iter(), - SlashedReason::BadExecutionReceipt(bad_receipt_hash), - ) - .map_err(Error::::from)?; + // + // NOTE: Skip the following staking related operations when benchmarking the + // `submit_fraud_proof` call, these operations will be benchmarked separately. + #[cfg(not(feature = "runtime-benchmarks"))] + { + let block_tree_node = prune_receipt::(domain_id, bad_receipt_number) + .map_err(Error::::from)? + .ok_or::>(FraudProofError::BadReceiptNotFound.into())?; + + actual_weight = + actual_weight.saturating_add(T::WeightInfo::handle_bad_receipt( + (block_tree_node.operator_ids.len() as u32).min(MAX_BUNLDE_PER_BLOCK), + )); + + do_slash_operators::( + block_tree_node.operator_ids.into_iter(), + SlashedReason::BadExecutionReceipt(bad_receipt_hash), + ) + .map_err(Error::::from)?; + } // Update the head receipt number to `bad_receipt_number - 1` let new_head_receipt_number = bad_receipt_number.saturating_sub(One::one()); @@ -1083,11 +1122,13 @@ mod pallet { SlashedReason::BundleEquivocation(slot), ) .map_err(Error::::from)?; + + actual_weight = actual_weight.saturating_add(T::WeightInfo::handle_bad_receipt(1)); } SuccessfulFraudProofs::::append(domain_id, fraud_proof.hash()); - Ok(()) + Ok(Some(actual_weight).into()) } #[pallet::call_index(2)] @@ -1248,7 +1289,7 @@ mod pallet { /// Even if rest of the withdrawals are out of unlocking period, nominator /// should call this extrinsic to unlock each withdrawal #[pallet::call_index(10)] - #[pallet::weight(Weight::from_all(10_000))] + #[pallet::weight(T::WeightInfo::unlock_funds())] pub fn unlock_funds(origin: OriginFor, operator_id: OperatorId) -> DispatchResult { let nominator_id = ensure_signed(origin)?; let unlocked_funds = do_unlock_funds::(operator_id, nominator_id.clone()) @@ -1264,12 +1305,22 @@ mod pallet { /// Unlocks the operator given the unlocking period is complete. /// Anyone can initiate the operator unlock. #[pallet::call_index(11)] - #[pallet::weight(Weight::from_all(10_000))] - pub fn unlock_operator(origin: OriginFor, operator_id: OperatorId) -> DispatchResult { + #[pallet::weight(T::WeightInfo::unlock_operator(T::MaxNominators::get()))] + pub fn unlock_operator( + origin: OriginFor, + operator_id: OperatorId, + ) -> DispatchResultWithPostInfo { ensure_signed(origin)?; - do_unlock_operator::(operator_id).map_err(crate::pallet::Error::::from)?; + + let nominator_count = + do_unlock_operator::(operator_id).map_err(crate::pallet::Error::::from)?; + Self::deposit_event(Event::OperatorUnlocked { operator_id }); - Ok(()) + + Ok(Some(T::WeightInfo::unlock_operator( + (nominator_count as u32).min(T::MaxNominators::get()), + )) + .into()) } /// Extrinsic to update domain's operator allow list. @@ -1280,7 +1331,7 @@ mod pallet { /// allow list is set to specific operators, then all the registered not allowed operators /// will continue to operate until they de-register themselves. #[pallet::call_index(12)] - #[pallet::weight(Weight::from_all(10_000))] + #[pallet::weight(T::WeightInfo::update_domain_operator_allow_list())] pub fn update_domain_operator_allow_list( origin: OriginFor, domain_id: DomainId, @@ -1295,21 +1346,26 @@ mod pallet { /// Force staking epoch transition for a given domain #[pallet::call_index(13)] - #[pallet::weight(T::WeightInfo::pending_staking_operation())] + #[pallet::weight(Pallet::::max_staking_epoch_transition())] pub fn force_staking_epoch_transition( origin: OriginFor, domain_id: DomainId, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - let completed_epoch_index = + let epoch_transition_res = do_finalize_domain_current_epoch::(domain_id).map_err(Error::::from)?; Self::deposit_event(Event::ForceDomainEpochTransition { domain_id, - completed_epoch_index, + completed_epoch_index: epoch_transition_res.completed_epoch_index, }); - Ok(()) + + // Ensure the returned weight not exceed the maximum weight in the `pallet::weight` + let actual_weight = Self::actual_epoch_transition_weight(epoch_transition_res) + .min(Self::max_staking_epoch_transition()); + + Ok(Some(actual_weight).into()) } } @@ -2168,6 +2224,49 @@ impl Pallet { // a fraud proof head_receipt_number < latest_submitted_er } + + pub fn max_submit_bundle_weight() -> Weight { + T::WeightInfo::submit_bundle() + .saturating_add( + // NOTE: within `submit_bundle`, only one of (or none) `handle_bad_receipt` and + // `confirm_domain_block` can happen, thus we use the `max` of them + T::WeightInfo::handle_bad_receipt(T::MaxNominators::get()).max( + T::WeightInfo::confirm_domain_block(MAX_BUNLDE_PER_BLOCK, MAX_BUNLDE_PER_BLOCK), + ), + ) + .saturating_add(Self::max_staking_epoch_transition()) + } + + pub fn max_staking_epoch_transition() -> Weight { + T::WeightInfo::operator_reward_tax_and_restake(MAX_BUNLDE_PER_BLOCK) + .saturating_add(T::WeightInfo::finalize_slashed_operators( + // FIXME: the actual value should be `N * T::MaxNominators` where `N` is the number of + // submitter of the bad ER, which is probabilistically bounded by `bundle_slot_probability` + // we use `N = 1` here because `finalize_slashed_operators` is expensive and can consume + // more weight than the max block weight + T::MaxNominators::get(), + )) + .saturating_add(T::WeightInfo::finalize_domain_epoch_staking( + T::MaxPendingStakingOperation::get(), + )) + } + + fn actual_epoch_transition_weight(epoch_transition_res: EpochTransitionResult) -> Weight { + let EpochTransitionResult { + rewarded_operator_count, + slashed_nominator_count, + finalized_operator_count, + .. + } = epoch_transition_res; + + T::WeightInfo::operator_reward_tax_and_restake(rewarded_operator_count) + .saturating_add(T::WeightInfo::finalize_slashed_operators( + slashed_nominator_count, + )) + .saturating_add(T::WeightInfo::finalize_domain_epoch_staking( + finalized_operator_count, + )) + } } impl sp_domains::DomainOwner for Pallet { diff --git a/crates/pallet-domains/src/staking.rs b/crates/pallet-domains/src/staking.rs index 23308ae6ee..12f84663d3 100644 --- a/crates/pallet-domains/src/staking.rs +++ b/crates/pallet-domains/src/staking.rs @@ -561,6 +561,11 @@ pub(crate) fn do_nominate_operator( Error::OperatorNotRegistered ); + // If the this is the first staking request of this operator `note_pending_staking_operation` for it + if operator.deposits_in_epoch.is_zero() && operator.withdrawals_in_epoch.is_zero() { + note_pending_staking_operation::(operator.current_domain_id)?; + } + let domain_stake_summary = DomainStakingSummary::::get(operator.current_domain_id) .ok_or(Error::DomainNotInitialized)?; @@ -727,8 +732,6 @@ pub(crate) fn do_deregister_operator( Operators::::try_mutate(operator_id, |maybe_operator| { let operator = maybe_operator.as_mut().ok_or(Error::UnknownOperator)?; - note_pending_staking_operation::(operator.current_domain_id)?; - ensure!( *operator.status::(operator_id) == OperatorStatus::Registered, Error::OperatorNotRegistered @@ -776,6 +779,11 @@ pub(crate) fn do_withdraw_stake( ensure!(!shares_withdrew.is_zero(), Error::ZeroWithdrawShares); + // If the this is the first staking request of this operator `note_pending_staking_operation` for it + if operator.deposits_in_epoch.is_zero() && operator.withdrawals_in_epoch.is_zero() { + note_pending_staking_operation::(operator.current_domain_id)?; + } + // calculate shares for any previous epoch let domain_stake_summary = DomainStakingSummary::::get(operator.current_domain_id) .ok_or(Error::DomainNotInitialized)?; @@ -1046,7 +1054,9 @@ pub(crate) fn do_unlock_funds( } /// Unlocks an already de-registered operator given unlock wait period is complete. -pub(crate) fn do_unlock_operator(operator_id: OperatorId) -> Result<(), Error> { +/// +/// Return the number of nominator processed +pub(crate) fn do_unlock_operator(operator_id: OperatorId) -> Result { Operators::::try_mutate_exists(operator_id, |maybe_operator| { // take the operator so this operator info is removed once we unlock the operator. let operator = maybe_operator.take().ok_or(Error::UnknownOperator)?; @@ -1081,6 +1091,7 @@ pub(crate) fn do_unlock_operator(operator_id: OperatorId) -> Result<( operator.total_storage_fee_deposit, ); let storage_fund_hold_id = T::HoldIdentifier::storage_fund_withdrawal(operator_id); + let mut nominator_count = 0; Deposits::::drain_prefix(operator_id).try_for_each(|(nominator_id, mut deposit)| { // convert any deposits from the previous epoch to shares do_convert_previous_epoch_deposits::(operator_id, &mut deposit)?; @@ -1160,6 +1171,8 @@ pub(crate) fn do_unlock_operator(operator_id: OperatorId) -> Result<( T::Currency::release_all(&storage_fund_hold_id, &nominator_id, Precision::Exact) .map_err(|_| Error::RemoveLock)?; + nominator_count += 1; + Ok(()) })?; @@ -1182,7 +1195,7 @@ pub(crate) fn do_unlock_operator(operator_id: OperatorId) -> Result<( // remove nominator count for this operator. NominatorCount::::remove(operator_id); - Ok(()) + Ok(nominator_count) }) } diff --git a/crates/pallet-domains/src/staking_epoch.rs b/crates/pallet-domains/src/staking_epoch.rs index c1700dc346..07fc90b328 100644 --- a/crates/pallet-domains/src/staking_epoch.rs +++ b/crates/pallet-domains/src/staking_epoch.rs @@ -32,31 +32,48 @@ pub enum Error { SlashOperator(TransitionError), } +pub(crate) struct EpochTransitionResult { + pub rewarded_operator_count: u32, + pub slashed_nominator_count: u32, + pub finalized_operator_count: u32, + pub completed_epoch_index: EpochIndex, +} + /// Finalizes the domain's current epoch and begins the next epoch. -/// Returns true of the epoch indeed was finished. +/// Returns true of the epoch indeed was finished and the number of operator processed. pub(crate) fn do_finalize_domain_current_epoch( domain_id: DomainId, -) -> Result { +) -> Result { // Reset pending staking operation count to 0 PendingStakingOperationCount::::set(domain_id, 0); // re stake operator's tax from the rewards - operator_take_reward_tax_and_stake::(domain_id)?; + let rewarded_operator_count = operator_take_reward_tax_and_stake::(domain_id)?; // slash the operators - do_finalize_slashed_operators::(domain_id).map_err(Error::SlashOperator)?; + let slashed_nominator_count = + do_finalize_slashed_operators::(domain_id).map_err(Error::SlashOperator)?; // finalize any operator switches do_finalize_switch_operator_domain::(domain_id)?; // finalize any withdrawals and then deposits - do_finalize_domain_epoch_staking::(domain_id) + let (completed_epoch_index, finalized_operator_count) = + do_finalize_domain_epoch_staking::(domain_id)?; + + Ok(EpochTransitionResult { + rewarded_operator_count, + slashed_nominator_count, + finalized_operator_count, + completed_epoch_index, + }) } /// Operator takes `NominationTax` of the current epoch rewards and stake them. pub(crate) fn operator_take_reward_tax_and_stake( domain_id: DomainId, -) -> Result<(), Error> { +) -> Result { + let mut rewarded_operator_count = 0; DomainStakingSummary::::try_mutate(domain_id, |maybe_domain_stake_summary| { let stake_summary = maybe_domain_stake_summary .as_mut() @@ -126,13 +143,17 @@ pub(crate) fn operator_take_reward_tax_and_stake( .checked_add(&rewards) .ok_or(TransitionError::BalanceOverflow)?; + rewarded_operator_count += 1; + Ok(()) })?; } Ok(()) }) - .map_err(Error::OperatorRewardStaking) + .map_err(Error::OperatorRewardStaking)?; + + Ok(rewarded_operator_count) } /// Add all the switched operators to new domain as next operators. @@ -188,7 +209,8 @@ fn switch_operator( pub(crate) fn do_finalize_domain_epoch_staking( domain_id: DomainId, -) -> Result { +) -> Result<(EpochIndex, u32), Error> { + let mut finalized_operator_count = 0; DomainStakingSummary::::try_mutate(domain_id, |maybe_stake_summary| { let stake_summary = maybe_stake_summary .as_mut() @@ -210,7 +232,7 @@ pub(crate) fn do_finalize_domain_epoch_staking( continue; } - let operator_stake = do_finalize_operator_epoch_staking::( + let (operator_stake, stake_changed) = do_finalize_operator_epoch_staking::( domain_id, *next_operator_id, previous_epoch, @@ -221,6 +243,10 @@ pub(crate) fn do_finalize_domain_epoch_staking( .ok_or(TransitionError::BalanceOverflow)?; current_operators.insert(*next_operator_id, operator_stake); next_operators.insert(*next_operator_id); + + if stake_changed { + finalized_operator_count += 1; + } } let election_verification_params = ElectionVerificationParams { @@ -236,90 +262,95 @@ pub(crate) fn do_finalize_domain_epoch_staking( stake_summary.current_operators = current_operators; stake_summary.next_operators = next_operators; - Ok(previous_epoch) + Ok((previous_epoch, finalized_operator_count)) }) .map_err(Error::FinalizeDomainEpochStaking) } +/// Finalize the epoch for the operator +/// +/// Return the new total stake of the operator and a bool indicate if its total stake +/// is changed due to deposit/withdraw/reward happened in the previous epoch pub(crate) fn do_finalize_operator_epoch_staking( domain_id: DomainId, operator_id: OperatorId, previous_epoch: EpochIndex, -) -> Result, TransitionError> { - Operators::::try_mutate(operator_id, |maybe_operator| { - let operator = maybe_operator - .as_mut() - .ok_or(TransitionError::UnknownOperator)?; - - if *operator.status::(operator_id) != OperatorStatus::Registered { - return Err(TransitionError::OperatorNotRegistered); - } - - // if there are no deposits, withdrawls, and epoch rewards for this operator - // then short-circuit and return early. - if operator.deposits_in_epoch.is_zero() - && operator.withdrawals_in_epoch.is_zero() - && operator.current_epoch_rewards.is_zero() - { - return Ok(operator.current_total_stake); - } - - let total_stake = operator - .current_total_stake - .checked_add(&operator.current_epoch_rewards) - .ok_or(TransitionError::BalanceOverflow)?; +) -> Result<(BalanceOf, bool), TransitionError> { + let mut operator = match Operators::::get(operator_id) { + Some(op) => op, + None => return Err(TransitionError::UnknownOperator), + }; - let total_shares = operator.current_total_shares; + if *operator.status::(operator_id) != OperatorStatus::Registered { + return Err(TransitionError::OperatorNotRegistered); + } - let share_price = SharePrice::new::(total_shares, total_stake); + // if there are no deposits, withdrawls, and epoch rewards for this operator + // then short-circuit and return early. + if operator.deposits_in_epoch.is_zero() + && operator.withdrawals_in_epoch.is_zero() + && operator.current_epoch_rewards.is_zero() + { + return Ok((operator.current_total_stake, false)); + } - // calculate and subtract total withdrew shares from previous epoch - let (total_stake, total_shares) = if !operator.withdrawals_in_epoch.is_zero() { - let withdraw_stake = share_price.shares_to_stake::(operator.withdrawals_in_epoch); - let total_stake = total_stake - .checked_sub(&withdraw_stake) - .ok_or(TransitionError::BalanceUnderflow)?; - let total_shares = total_shares - .checked_sub(&operator.withdrawals_in_epoch) - .ok_or(TransitionError::ShareUnderflow)?; + let total_stake = operator + .current_total_stake + .checked_add(&operator.current_epoch_rewards) + .ok_or(TransitionError::BalanceOverflow)?; + + let total_shares = operator.current_total_shares; + + let share_price = SharePrice::new::(total_shares, total_stake); + + // calculate and subtract total withdrew shares from previous epoch + let (total_stake, total_shares) = if !operator.withdrawals_in_epoch.is_zero() { + let withdraw_stake = share_price.shares_to_stake::(operator.withdrawals_in_epoch); + let total_stake = total_stake + .checked_sub(&withdraw_stake) + .ok_or(TransitionError::BalanceUnderflow)?; + let total_shares = total_shares + .checked_sub(&operator.withdrawals_in_epoch) + .ok_or(TransitionError::ShareUnderflow)?; + + operator.withdrawals_in_epoch = Zero::zero(); + (total_stake, total_shares) + } else { + (total_stake, total_shares) + }; - operator.withdrawals_in_epoch = Zero::zero(); - (total_stake, total_shares) - } else { - (total_stake, total_shares) - }; + // calculate and add total deposits from the previous epoch + let (total_stake, total_shares) = if !operator.deposits_in_epoch.is_zero() { + let deposited_shares = share_price.stake_to_shares::(operator.deposits_in_epoch); + let total_stake = total_stake + .checked_add(&operator.deposits_in_epoch) + .ok_or(TransitionError::BalanceOverflow)?; + let total_shares = total_shares + .checked_add(&deposited_shares) + .ok_or(TransitionError::ShareOverflow)?; + operator.deposits_in_epoch = Zero::zero(); + (total_stake, total_shares) + } else { + (total_stake, total_shares) + }; - // calculate and add total deposits from the previous epoch - let (total_stake, total_shares) = if !operator.deposits_in_epoch.is_zero() { - let deposited_shares = share_price.stake_to_shares::(operator.deposits_in_epoch); - let total_stake = total_stake - .checked_add(&operator.deposits_in_epoch) - .ok_or(TransitionError::BalanceOverflow)?; - let total_shares = total_shares - .checked_add(&deposited_shares) - .ok_or(TransitionError::ShareOverflow)?; - operator.deposits_in_epoch = Zero::zero(); - (total_stake, total_shares) - } else { - (total_stake, total_shares) - }; + // update operator pool epoch share price + // TODO: once we have reference counting, we do not need to + // store this for every epoch for every operator but instead + // store only those share prices of operators which has either a deposit or withdraw + OperatorEpochSharePrice::::insert( + operator_id, + DomainEpoch::from((domain_id, previous_epoch)), + share_price, + ); - // update operator pool epoch share price - // TODO: once we have reference counting, we do not need to - // store this for every epoch for every operator but instead - // store only those share prices of operators which has either a deposit or withdraw - OperatorEpochSharePrice::::insert( - operator_id, - DomainEpoch::from((domain_id, previous_epoch)), - share_price, - ); + // update operator state + operator.current_total_shares = total_shares; + operator.current_total_stake = total_stake; + operator.current_epoch_rewards = Zero::zero(); + Operators::::set(operator_id, Some(operator)); - // update operator state - operator.current_total_shares = total_shares; - operator.current_total_stake = total_stake; - operator.current_epoch_rewards = Zero::zero(); - Ok(total_stake) - }) + Ok((total_stake, true)) } pub(crate) fn mint_funds( @@ -336,7 +367,8 @@ pub(crate) fn mint_funds( pub(crate) fn do_finalize_slashed_operators( domain_id: DomainId, -) -> Result<(), TransitionError> { +) -> Result { + let mut slashed_nominator_count = 0; for operator_id in PendingSlashes::::take(domain_id).unwrap_or_default() { Operators::::try_mutate_exists(operator_id, |maybe_operator| { // take the operator so this operator info is removed once we slash the operator. @@ -468,6 +500,8 @@ pub(crate) fn do_finalize_slashed_operators( ) .map_err(|_| TransitionError::RemoveLock)?; + slashed_nominator_count += 1; + Ok(()) }, )?; @@ -483,7 +517,7 @@ pub(crate) fn do_finalize_slashed_operators( })?; } - Ok(()) + Ok(slashed_nominator_count) } #[cfg(test)] diff --git a/crates/pallet-domains/src/tests.rs b/crates/pallet-domains/src/tests.rs index 5b0caef56c..83356c1e6f 100644 --- a/crates/pallet-domains/src/tests.rs +++ b/crates/pallet-domains/src/tests.rs @@ -181,7 +181,7 @@ parameter_types! { pub const StakeEpochDuration: DomainBlockNumber = 5; pub TreasuryAccount: u128 = PalletId(*b"treasury").into_account_truncating(); pub const BlockReward: Balance = 10 * SSC; - pub const MaxPendingStakingOperation: u32 = 100; + pub const MaxPendingStakingOperation: u32 = 512; pub const MaxNominators: u32 = 5; pub const DomainsPalletId: PalletId = PalletId(*b"domains_"); pub const DomainChainByteFee: Balance = 1; diff --git a/crates/pallet-domains/src/weights.rs b/crates/pallet-domains/src/weights.rs index bcb8288a40..fb1ada99af 100644 --- a/crates/pallet-domains/src/weights.rs +++ b/crates/pallet-domains/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for pallet_domains //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-03-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -32,509 +32,887 @@ use core::marker::PhantomData; /// Weight functions needed for pallet_domains. pub trait WeightInfo { fn submit_bundle() -> Weight; - fn pending_staking_operation() -> Weight; + fn submit_fraud_proof() -> Weight; + fn handle_bad_receipt(n: u32, ) -> Weight; + fn confirm_domain_block(n: u32, s: u32, ) -> Weight; + fn operator_reward_tax_and_restake(n: u32, ) -> Weight; + fn finalize_slashed_operators(n: u32, ) -> Weight; + fn finalize_domain_epoch_staking(p: u32, ) -> Weight; fn register_domain_runtime() -> Weight; fn upgrade_domain_runtime() -> Weight; fn instantiate_domain() -> Weight; fn register_operator() -> Weight; fn nominate_operator() -> Weight; - fn switch_domain() -> Weight; fn deregister_operator() -> Weight; fn withdraw_stake() -> Weight; - fn auto_stake_block_rewards() -> Weight; + fn unlock_funds() -> Weight; + fn unlock_operator(n: u32, ) -> Weight; + fn update_domain_operator_allow_list() -> Weight; } /// Weights for pallet_domains using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Domains HeadReceiptNumber (r:1 w:1) - /// Proof Skipped: Domains HeadReceiptNumber (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains BlockTree (r:2 w:2) - /// Proof Skipped: Domains BlockTree (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainBlocks (r:1 w:2) - /// Proof Skipped: Domains DomainBlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains ExecutionInbox (r:3 w:2) - /// Proof Skipped: Domains ExecutionInbox (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains SuccessfulBundles (r:1 w:1) - /// Proof Skipped: Domains SuccessfulBundles (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains HeadDomainNumber (r:1 w:1) - /// Proof Skipped: Domains HeadDomainNumber (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainTxRangeState (r:1 w:1) - /// Proof Skipped: Domains DomainTxRangeState (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains InboxedBundle (r:0 w:2) - /// Proof Skipped: Domains InboxedBundle (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::HeadReceiptNumber` (r:1 w:1) + /// Proof: `Domains::HeadReceiptNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:1) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTree` (r:2 w:2) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:2) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ExecutionInbox` (r:2 w:1) + /// Proof: `Domains::ExecutionInbox` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Transporter::DomainBalances` (r:1 w:1) + /// Proof: `Transporter::DomainBalances` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::SuccessfulBundles` (r:1 w:1) + /// Proof: `Domains::SuccessfulBundles` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::HeadDomainNumber` (r:1 w:1) + /// Proof: `Domains::HeadDomainNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::InboxedBundleAuthor` (r:0 w:1) + /// Proof: `Domains::InboxedBundleAuthor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::HeadReceiptExtended` (r:0 w:1) + /// Proof: `Domains::HeadReceiptExtended` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ConsensusBlockHash` (r:0 w:1) + /// Proof: `Domains::ConsensusBlockHash` (`max_values`: None, `max_size`: None, mode: `Measured`) fn submit_bundle() -> Weight { // Proof Size summary in bytes: - // Measured: `3952` - // Estimated: `12367` - // Minimum execution time: 102_000_000 picoseconds. - Weight::from_parts(118_000_000, 12367) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(12_u64)) + // Measured: `1609` + // Estimated: `7549` + // Minimum execution time: 82_000_000 picoseconds. + Weight::from_parts(86_000_000, 7549) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) + } + /// Storage: `Domains::HeadReceiptNumber` (r:1 w:1) + /// Proof: `Domains::HeadReceiptNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:0) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::SuccessfulFraudProofs` (r:1 w:1) + /// Proof: `Domains::SuccessfulFraudProofs` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn submit_fraud_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `1000` + // Estimated: `4465` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(29_000_000, 4465) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `Domains::BlockTree` (r:1 w:1) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:1) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:100 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:1) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + fn handle_bad_receipt(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1062 + n * (208 ±0)` + // Estimated: `4527 + n * (2683 ±0)` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4527) + // Standard Error: 69_114 + .saturating_add(Weight::from_parts(18_092_085, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2683).saturating_mul(n.into())) } - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingSlashes (r:1 w:0) - /// Proof Skipped: Domains PendingSlashes (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorSwitches (r:1 w:0) - /// Proof Skipped: Domains PendingOperatorSwitches (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorDeregistrations (r:1 w:0) - /// Proof Skipped: Domains PendingOperatorDeregistrations (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:101 w:100) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:100 w:100) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:100 w:100) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: System Account (r:100 w:100) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Domains PendingNominatorUnlocks (r:1 w:1) - /// Proof Skipped: Domains PendingNominatorUnlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingUnlocks (r:1 w:1) - /// Proof Skipped: Domains PendingUnlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:1 w:0) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains LastEpochStakingDistribution (r:0 w:1) - /// Proof Skipped: Domains LastEpochStakingDistribution (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:0 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - fn pending_staking_operation() -> Weight { - // Proof Size summary in bytes: - // Measured: `32723` - // Estimated: `523490` - // Minimum execution time: 12_571_000_000 picoseconds. - Weight::from_parts(12_688_000_000, 523490) - .saturating_add(T::DbWeight::get().reads(409_u64)) - .saturating_add(T::DbWeight::get().writes(406_u64)) - } - /// Storage: Domains NextRuntimeId (r:1 w:1) - /// Proof Skipped: Domains NextRuntimeId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Domains RuntimeRegistry (r:0 w:1) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::Operators` (r:200 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:100 w:100) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:1) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + fn confirm_domain_block(n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + n * (377 ±0) + s * (238 ±0)` + // Estimated: `272098 + n * (2588 ±30) + s * (978 ±30)` + // Minimum execution time: 1_769_000_000 picoseconds. + Weight::from_parts(1_800_000_000, 272098) + // Standard Error: 355_370 + .saturating_add(Weight::from_parts(9_600_004, 0).saturating_mul(n.into())) + // Standard Error: 355_697 + .saturating_add(Weight::from_parts(13_568_927, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_parts(0, 2588).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 978).saturating_mul(s.into())) + } + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + fn operator_reward_tax_and_restake(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `417 + n * (224 ±0)` + // Estimated: `3882 + n * (2699 ±0)` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(22_123_780, 3882) + // Standard Error: 11_945 + .saturating_add(Weight::from_parts(2_897_925, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2699).saturating_mul(n.into())) + } + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:25701 w:25701) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:25700 w:25600) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:25600 w:25600) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:200 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:25600 w:0) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:100) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 25600]`. + fn finalize_slashed_operators(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `60223 + n * (329 ±0)` + // Estimated: `513821 + n * (5223 ±0)` + // Minimum execution time: 141_000_000 picoseconds. + Weight::from_parts(144_000_000, 513821) + // Standard Error: 120_663 + .saturating_add(Weight::from_parts(81_434_735, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(670_u64)) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(434_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5223).saturating_mul(n.into())) + } + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1000 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:1000 w:1000) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LastEpochStakingDistribution` (r:0 w:1) + /// Proof: `Domains::LastEpochStakingDistribution` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:0 w:1000) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn finalize_domain_epoch_staking(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `225040` + // Estimated: `2701030` + // Minimum execution time: 5_201_000_000 picoseconds. + Weight::from_parts(5_387_893_148, 2701030) + // Standard Error: 22_716 + .saturating_add(Weight::from_parts(2_502_115, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2001_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(p.into()))) + } + /// Storage: `Domains::NextRuntimeId` (r:1 w:1) + /// Proof: `Domains::NextRuntimeId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::RuntimeRegistry` (r:0 w:1) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_domain_runtime() -> Weight { // Proof Size summary in bytes: - // Measured: `43` - // Estimated: `1528` - // Minimum execution time: 14_372_000_000 picoseconds. - Weight::from_parts(14_986_000_000, 1528) + // Measured: `297` + // Estimated: `1782` + // Minimum execution time: 19_240_000_000 picoseconds. + Weight::from_parts(20_604_000_000, 1782) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Domains RuntimeRegistry (r:1 w:0) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains ScheduledRuntimeUpgrades (r:0 w:1) - /// Proof Skipped: Domains ScheduledRuntimeUpgrades (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::RuntimeRegistry` (r:1 w:0) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ScheduledRuntimeUpgrades` (r:0 w:1) + /// Proof: `Domains::ScheduledRuntimeUpgrades` (`max_values`: None, `max_size`: None, mode: `Measured`) fn upgrade_domain_runtime() -> Weight { // Proof Size summary in bytes: - // Measured: `438682` - // Estimated: `442147` - // Minimum execution time: 25_485_000_000 picoseconds. - Weight::from_parts(26_355_000_000, 442147) + // Measured: `2481404` + // Estimated: `2484869` + // Minimum execution time: 19_355_000_000 picoseconds. + Weight::from_parts(19_883_000_000, 2484869) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Domains RuntimeRegistry (r:1 w:0) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Domains NextDomainId (r:1 w:1) - /// Proof Skipped: Domains NextDomainId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System BlockHash (r:1 w:0) - /// Proof: System BlockHash (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: Domains BlockTree (r:1 w:1) - /// Proof Skipped: Domains BlockTree (max_values: None, max_size: None, mode: Measured) - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Domains DomainBlocks (r:0 w:1) - /// Proof Skipped: Domains DomainBlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainRegistry (r:0 w:1) - /// Proof Skipped: Domains DomainRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:0 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Sudo::Key` (r:1 w:0) + /// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Domains::RuntimeRegistry` (r:1 w:0) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::NextDomainId` (r:1 w:1) + /// Proof: `Domains::NextDomainId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NextEVMChainId` (r:1 w:1) + /// Proof: `Domains::NextEVMChainId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Transporter::DomainBalances` (r:1 w:1) + /// Proof: `Transporter::DomainBalances` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainRegistry` (r:0 w:1) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:0 w:1) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:0 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:0 w:1) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTree` (r:0 w:1) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) fn instantiate_domain() -> Weight { // Proof Size summary in bytes: - // Measured: `438839` - // Estimated: `442304` - // Minimum execution time: 228_000_000 picoseconds. - Weight::from_parts(247_000_000, 442304) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains NextOperatorId (r:1 w:1) - /// Proof Skipped: Domains NextOperatorId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: Domains Operators (r:0 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:0 w:1) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains OperatorIdOwner (r:0 w:1) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) + // Measured: `2481830` + // Estimated: `2485295` + // Minimum execution time: 4_861_000_000 picoseconds. + Weight::from_parts(5_260_000_000, 2485295) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(11_u64)) + } + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorSigningKey` (r:1 w:1) + /// Proof: `Domains::OperatorSigningKey` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainRegistry` (r:1 w:0) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NextOperatorId` (r:1 w:1) + /// Proof: `Domains::NextOperatorId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:0) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:0) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:0 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LastEpochStakingDistribution` (r:0 w:1) + /// Proof: `Domains::LastEpochStakingDistribution` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:1) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:0 w:1) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `880` // Estimated: `6215` - // Minimum execution time: 66_000_000 picoseconds. - Weight::from_parts(70_000_000, 6215) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: Domains Operators (r:1 w:0) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:1 w:0) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:1 w:1) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) + // Minimum execution time: 129_000_000 picoseconds. + Weight::from_parts(144_000_000, 6215) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) + } + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:0) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) fn nominate_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `789` + // Measured: `1291` // Estimated: `6215` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(69_000_000, 6215) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:2 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorSwitches (r:1 w:1) - /// Proof Skipped: Domains PendingOperatorSwitches (max_values: None, max_size: None, mode: Measured) - fn switch_domain() -> Weight { - // Proof Size summary in bytes: - // Measured: `577` - // Estimated: `6517` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(38_000_000, 6517) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Minimum execution time: 111_000_000 picoseconds. + Weight::from_parts(131_000_000, 6215) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorDeregistrations (r:1 w:1) - /// Proof Skipped: Domains PendingOperatorDeregistrations (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::OperatorIdOwner` (r:1 w:0) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn deregister_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `543` - // Estimated: `4008` - // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(33_000_000, 4008) + // Measured: `949` + // Estimated: `4414` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(34_000_000, 4414) .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Domains PendingDeposits (r:1 w:0) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:1 w:1) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:0) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:0) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:1 w:1) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:1 w:0) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn withdraw_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `788` - // Estimated: `4253` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(38_000_000, 4253) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `1785` + // Estimated: `6215` + // Minimum execution time: 103_000_000 picoseconds. + Weight::from_parts(106_000_000, 6215) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:0) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PreferredOperator (r:0 w:1) - /// Proof Skipped: Domains PreferredOperator (max_values: None, max_size: None, mode: Measured) - fn auto_stake_block_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `514` - // Estimated: `3979` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(26_000_000, 3979) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + /// Storage: `Domains::Operators` (r:1 w:0) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:1 w:1) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn unlock_funds() -> Weight { + // Proof Size summary in bytes: + // Measured: `1390` + // Estimated: `6215` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(93_000_000, 6215) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:259 w:258) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:258 w:257) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:2 w:2) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:257 w:257) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Withdrawals` (r:257 w:0) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorSigningKey` (r:0 w:1) + /// Proof: `Domains::OperatorSigningKey` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:1) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NominatorCount` (r:0 w:1) + /// Proof: `Domains::NominatorCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[0, 256]`. + fn unlock_operator(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1160 + n * (330 ±0)` + // Estimated: `8799 + n * (5225 ±0)` + // Minimum execution time: 168_000_000 picoseconds. + Weight::from_parts(56_673_368, 8799) + // Standard Error: 401_978 + .saturating_add(Weight::from_parts(91_340_500, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(10_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5225).saturating_mul(n.into())) + } + /// Storage: `Domains::DomainRegistry` (r:1 w:1) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn update_domain_operator_allow_list() -> Weight { + // Proof Size summary in bytes: + // Measured: `432` + // Estimated: `3897` + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(16_000_000, 3897) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Domains HeadReceiptNumber (r:1 w:1) - /// Proof Skipped: Domains HeadReceiptNumber (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains BlockTree (r:2 w:2) - /// Proof Skipped: Domains BlockTree (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainBlocks (r:1 w:2) - /// Proof Skipped: Domains DomainBlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains ExecutionInbox (r:3 w:2) - /// Proof Skipped: Domains ExecutionInbox (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains SuccessfulBundles (r:1 w:1) - /// Proof Skipped: Domains SuccessfulBundles (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains HeadDomainNumber (r:1 w:1) - /// Proof Skipped: Domains HeadDomainNumber (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainTxRangeState (r:1 w:1) - /// Proof Skipped: Domains DomainTxRangeState (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains InboxedBundle (r:0 w:2) - /// Proof Skipped: Domains InboxedBundle (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::HeadReceiptNumber` (r:1 w:1) + /// Proof: `Domains::HeadReceiptNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:1) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTree` (r:2 w:2) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:2) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ExecutionInbox` (r:2 w:1) + /// Proof: `Domains::ExecutionInbox` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Transporter::DomainBalances` (r:1 w:1) + /// Proof: `Transporter::DomainBalances` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::SuccessfulBundles` (r:1 w:1) + /// Proof: `Domains::SuccessfulBundles` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::HeadDomainNumber` (r:1 w:1) + /// Proof: `Domains::HeadDomainNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::InboxedBundleAuthor` (r:0 w:1) + /// Proof: `Domains::InboxedBundleAuthor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::HeadReceiptExtended` (r:0 w:1) + /// Proof: `Domains::HeadReceiptExtended` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ConsensusBlockHash` (r:0 w:1) + /// Proof: `Domains::ConsensusBlockHash` (`max_values`: None, `max_size`: None, mode: `Measured`) fn submit_bundle() -> Weight { // Proof Size summary in bytes: - // Measured: `3952` - // Estimated: `12367` - // Minimum execution time: 102_000_000 picoseconds. - Weight::from_parts(118_000_000, 12367) - .saturating_add(ParityDbWeight::get().reads(10_u64)) - .saturating_add(ParityDbWeight::get().writes(12_u64)) + // Measured: `1609` + // Estimated: `7549` + // Minimum execution time: 82_000_000 picoseconds. + Weight::from_parts(86_000_000, 7549) + .saturating_add(ParityDbWeight::get().reads(11_u64)) + .saturating_add(ParityDbWeight::get().writes(13_u64)) + } + /// Storage: `Domains::HeadReceiptNumber` (r:1 w:1) + /// Proof: `Domains::HeadReceiptNumber` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:0) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::SuccessfulFraudProofs` (r:1 w:1) + /// Proof: `Domains::SuccessfulFraudProofs` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn submit_fraud_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `1000` + // Estimated: `4465` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(29_000_000, 4465) + .saturating_add(ParityDbWeight::get().reads(3_u64)) + .saturating_add(ParityDbWeight::get().writes(2_u64)) + } + /// Storage: `Domains::BlockTree` (r:1 w:1) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:1 w:1) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:100 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:1) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + fn handle_bad_receipt(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1062 + n * (208 ±0)` + // Estimated: `4527 + n * (2683 ±0)` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4527) + // Standard Error: 69_114 + .saturating_add(Weight::from_parts(18_092_085, 0).saturating_mul(n.into())) + .saturating_add(ParityDbWeight::get().reads(5_u64)) + .saturating_add(ParityDbWeight::get().reads((2_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().writes(5_u64)) + .saturating_add(ParityDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2683).saturating_mul(n.into())) } - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingSlashes (r:1 w:0) - /// Proof Skipped: Domains PendingSlashes (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorSwitches (r:1 w:0) - /// Proof Skipped: Domains PendingOperatorSwitches (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorDeregistrations (r:1 w:0) - /// Proof Skipped: Domains PendingOperatorDeregistrations (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:101 w:100) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:100 w:100) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:100 w:100) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: System Account (r:100 w:100) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Domains PendingNominatorUnlocks (r:1 w:1) - /// Proof Skipped: Domains PendingNominatorUnlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingUnlocks (r:1 w:1) - /// Proof Skipped: Domains PendingUnlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:1 w:0) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains LastEpochStakingDistribution (r:0 w:1) - /// Proof Skipped: Domains LastEpochStakingDistribution (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:0 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - fn pending_staking_operation() -> Weight { - // Proof Size summary in bytes: - // Measured: `32723` - // Estimated: `523490` - // Minimum execution time: 12_571_000_000 picoseconds. - Weight::from_parts(12_688_000_000, 523490) - .saturating_add(ParityDbWeight::get().reads(409_u64)) - .saturating_add(ParityDbWeight::get().writes(406_u64)) - } - /// Storage: Domains NextRuntimeId (r:1 w:1) - /// Proof Skipped: Domains NextRuntimeId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Domains RuntimeRegistry (r:0 w:1) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::Operators` (r:200 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:100 w:100) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:1) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + fn confirm_domain_block(n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + n * (377 ±0) + s * (238 ±0)` + // Estimated: `272098 + n * (2588 ±30) + s * (978 ±30)` + // Minimum execution time: 1_769_000_000 picoseconds. + Weight::from_parts(1_800_000_000, 272098) + // Standard Error: 355_370 + .saturating_add(Weight::from_parts(9_600_004, 0).saturating_mul(n.into())) + // Standard Error: 355_697 + .saturating_add(Weight::from_parts(13_568_927, 0).saturating_mul(s.into())) + .saturating_add(ParityDbWeight::get().reads(3_u64)) + .saturating_add(ParityDbWeight::get().reads((2_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(ParityDbWeight::get().writes(3_u64)) + .saturating_add(ParityDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_parts(0, 2588).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 978).saturating_mul(s.into())) + } + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 100]`. + fn operator_reward_tax_and_restake(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `417 + n * (224 ±0)` + // Estimated: `3882 + n * (2699 ±0)` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(22_123_780, 3882) + // Standard Error: 11_945 + .saturating_add(Weight::from_parts(2_897_925, 0).saturating_mul(n.into())) + .saturating_add(ParityDbWeight::get().reads(1_u64)) + .saturating_add(ParityDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().writes(1_u64)) + .saturating_add(ParityDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2699).saturating_mul(n.into())) + } + /// Storage: `Domains::PendingSlashes` (r:1 w:1) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:100 w:100) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:25701 w:25701) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:25700 w:25600) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:25600 w:25600) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:200 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:25600 w:0) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:100) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[1, 25600]`. + fn finalize_slashed_operators(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `60223 + n * (329 ±0)` + // Estimated: `513821 + n * (5223 ±0)` + // Minimum execution time: 141_000_000 picoseconds. + Weight::from_parts(144_000_000, 513821) + // Standard Error: 120_663 + .saturating_add(Weight::from_parts(81_434_735, 0).saturating_mul(n.into())) + .saturating_add(ParityDbWeight::get().reads(670_u64)) + .saturating_add(ParityDbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().writes(434_u64)) + .saturating_add(ParityDbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5223).saturating_mul(n.into())) + } + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1000 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:1000 w:1000) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LastEpochStakingDistribution` (r:0 w:1) + /// Proof: `Domains::LastEpochStakingDistribution` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:0 w:1000) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn finalize_domain_epoch_staking(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `225040` + // Estimated: `2701030` + // Minimum execution time: 5_201_000_000 picoseconds. + Weight::from_parts(5_387_893_148, 2701030) + // Standard Error: 22_716 + .saturating_add(Weight::from_parts(2_502_115, 0).saturating_mul(p.into())) + .saturating_add(ParityDbWeight::get().reads(2001_u64)) + .saturating_add(ParityDbWeight::get().writes(2_u64)) + .saturating_add(ParityDbWeight::get().writes((2_u64).saturating_mul(p.into()))) + } + /// Storage: `Domains::NextRuntimeId` (r:1 w:1) + /// Proof: `Domains::NextRuntimeId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::RuntimeRegistry` (r:0 w:1) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_domain_runtime() -> Weight { // Proof Size summary in bytes: - // Measured: `43` - // Estimated: `1528` - // Minimum execution time: 14_372_000_000 picoseconds. - Weight::from_parts(14_986_000_000, 1528) + // Measured: `297` + // Estimated: `1782` + // Minimum execution time: 19_240_000_000 picoseconds. + Weight::from_parts(20_604_000_000, 1782) .saturating_add(ParityDbWeight::get().reads(1_u64)) .saturating_add(ParityDbWeight::get().writes(2_u64)) } - /// Storage: Domains RuntimeRegistry (r:1 w:0) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains ScheduledRuntimeUpgrades (r:0 w:1) - /// Proof Skipped: Domains ScheduledRuntimeUpgrades (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::RuntimeRegistry` (r:1 w:0) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::ScheduledRuntimeUpgrades` (r:0 w:1) + /// Proof: `Domains::ScheduledRuntimeUpgrades` (`max_values`: None, `max_size`: None, mode: `Measured`) fn upgrade_domain_runtime() -> Weight { // Proof Size summary in bytes: - // Measured: `438682` - // Estimated: `442147` - // Minimum execution time: 25_485_000_000 picoseconds. - Weight::from_parts(26_355_000_000, 442147) + // Measured: `2481404` + // Estimated: `2484869` + // Minimum execution time: 19_355_000_000 picoseconds. + Weight::from_parts(19_883_000_000, 2484869) .saturating_add(ParityDbWeight::get().reads(1_u64)) .saturating_add(ParityDbWeight::get().writes(1_u64)) } - /// Storage: Domains RuntimeRegistry (r:1 w:0) - /// Proof Skipped: Domains RuntimeRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Domains NextDomainId (r:1 w:1) - /// Proof Skipped: Domains NextDomainId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System BlockHash (r:1 w:0) - /// Proof: System BlockHash (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: Domains BlockTree (r:1 w:1) - /// Proof Skipped: Domains BlockTree (max_values: None, max_size: None, mode: Measured) - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Domains DomainBlocks (r:0 w:1) - /// Proof Skipped: Domains DomainBlocks (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainRegistry (r:0 w:1) - /// Proof Skipped: Domains DomainRegistry (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:0 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Sudo::Key` (r:1 w:0) + /// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `Domains::RuntimeRegistry` (r:1 w:0) + /// Proof: `Domains::RuntimeRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::NextDomainId` (r:1 w:1) + /// Proof: `Domains::NextDomainId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NextEVMChainId` (r:1 w:1) + /// Proof: `Domains::NextEVMChainId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Transporter::DomainBalances` (r:1 w:1) + /// Proof: `Transporter::DomainBalances` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainRegistry` (r:0 w:1) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTreeNodes` (r:0 w:1) + /// Proof: `Domains::BlockTreeNodes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:0 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:0 w:1) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::BlockTree` (r:0 w:1) + /// Proof: `Domains::BlockTree` (`max_values`: None, `max_size`: None, mode: `Measured`) fn instantiate_domain() -> Weight { // Proof Size summary in bytes: - // Measured: `438839` - // Estimated: `442304` - // Minimum execution time: 228_000_000 picoseconds. - Weight::from_parts(247_000_000, 442304) - .saturating_add(ParityDbWeight::get().reads(7_u64)) - .saturating_add(ParityDbWeight::get().writes(8_u64)) - } - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains NextOperatorId (r:1 w:1) - /// Proof Skipped: Domains NextOperatorId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) - /// Storage: Domains Operators (r:0 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:0 w:1) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains OperatorIdOwner (r:0 w:1) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) + // Measured: `2481830` + // Estimated: `2485295` + // Minimum execution time: 4_861_000_000 picoseconds. + Weight::from_parts(5_260_000_000, 2485295) + .saturating_add(ParityDbWeight::get().reads(8_u64)) + .saturating_add(ParityDbWeight::get().writes(11_u64)) + } + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorSigningKey` (r:1 w:1) + /// Proof: `Domains::OperatorSigningKey` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainRegistry` (r:1 w:0) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NextOperatorId` (r:1 w:1) + /// Proof: `Domains::NextOperatorId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingSlashes` (r:1 w:0) + /// Proof: `Domains::PendingSlashes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingOperatorSwitches` (r:1 w:0) + /// Proof: `Domains::PendingOperatorSwitches` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:0 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LastEpochStakingDistribution` (r:0 w:1) + /// Proof: `Domains::LastEpochStakingDistribution` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:1) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:0 w:1) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `880` // Estimated: `6215` - // Minimum execution time: 66_000_000 picoseconds. - Weight::from_parts(70_000_000, 6215) - .saturating_add(ParityDbWeight::get().reads(5_u64)) - .saturating_add(ParityDbWeight::get().writes(8_u64)) - } - /// Storage: Domains Operators (r:1 w:0) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:1 w:0) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingDeposits (r:1 w:1) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(2750), added: 5225, mode: MaxEncodedLen) + // Minimum execution time: 129_000_000 picoseconds. + Weight::from_parts(144_000_000, 6215) + .saturating_add(ParityDbWeight::get().reads(12_u64)) + .saturating_add(ParityDbWeight::get().writes(12_u64)) + } + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:0) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) fn nominate_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `789` + // Measured: `1291` // Estimated: `6215` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(69_000_000, 6215) - .saturating_add(ParityDbWeight::get().reads(7_u64)) - .saturating_add(ParityDbWeight::get().writes(4_u64)) - } - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:2 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorSwitches (r:1 w:1) - /// Proof Skipped: Domains PendingOperatorSwitches (max_values: None, max_size: None, mode: Measured) - fn switch_domain() -> Weight { - // Proof Size summary in bytes: - // Measured: `577` - // Estimated: `6517` - // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(38_000_000, 6517) - .saturating_add(ParityDbWeight::get().reads(6_u64)) - .saturating_add(ParityDbWeight::get().writes(4_u64)) + // Minimum execution time: 111_000_000 picoseconds. + Weight::from_parts(131_000_000, 6215) + .saturating_add(ParityDbWeight::get().reads(9_u64)) + .saturating_add(ParityDbWeight::get().writes(6_u64)) } - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingOperatorDeregistrations (r:1 w:1) - /// Proof Skipped: Domains PendingOperatorDeregistrations (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:1) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::OperatorIdOwner` (r:1 w:0) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:1) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn deregister_operator() -> Weight { // Proof Size summary in bytes: - // Measured: `543` - // Estimated: `4008` - // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(33_000_000, 4008) + // Measured: `949` + // Estimated: `4414` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(34_000_000, 4414) .saturating_add(ParityDbWeight::get().reads(5_u64)) - .saturating_add(ParityDbWeight::get().writes(4_u64)) + .saturating_add(ParityDbWeight::get().writes(2_u64)) } - /// Storage: Domains PendingDeposits (r:1 w:0) - /// Proof Skipped: Domains PendingDeposits (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:1) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains OperatorIdOwner (r:1 w:0) - /// Proof Skipped: Domains OperatorIdOwner (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingWithdrawals (r:1 w:1) - /// Proof Skipped: Domains PendingWithdrawals (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains DomainStakingSummary (r:1 w:0) - /// Proof Skipped: Domains DomainStakingSummary (max_values: None, max_size: None, mode: Measured) + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::PendingStakingOperationCount` (r:1 w:1) + /// Proof: `Domains::PendingStakingOperationCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::DomainStakingSummary` (r:1 w:0) + /// Proof: `Domains::DomainStakingSummary` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:1 w:1) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:1 w:0) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn withdraw_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `788` - // Estimated: `4253` - // Minimum execution time: 36_000_000 picoseconds. - Weight::from_parts(38_000_000, 4253) - .saturating_add(ParityDbWeight::get().reads(7_u64)) - .saturating_add(ParityDbWeight::get().writes(3_u64)) + // Measured: `1785` + // Estimated: `6215` + // Minimum execution time: 103_000_000 picoseconds. + Weight::from_parts(106_000_000, 6215) + .saturating_add(ParityDbWeight::get().reads(12_u64)) + .saturating_add(ParityDbWeight::get().writes(7_u64)) } - /// Storage: Domains Nominators (r:1 w:0) - /// Proof Skipped: Domains Nominators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains Operators (r:1 w:0) - /// Proof Skipped: Domains Operators (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PendingStakingOperationCount (r:1 w:1) - /// Proof Skipped: Domains PendingStakingOperationCount (max_values: None, max_size: None, mode: Measured) - /// Storage: Domains PreferredOperator (r:0 w:1) - /// Proof Skipped: Domains PreferredOperator (max_values: None, max_size: None, mode: Measured) - fn auto_stake_block_rewards() -> Weight { - // Proof Size summary in bytes: - // Measured: `514` - // Estimated: `3979` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(26_000_000, 3979) - .saturating_add(ParityDbWeight::get().reads(3_u64)) - .saturating_add(ParityDbWeight::get().writes(2_u64)) + /// Storage: `Domains::Operators` (r:1 w:0) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::Withdrawals` (r:1 w:1) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:1 w:0) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:1 w:1) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn unlock_funds() -> Weight { + // Proof Size summary in bytes: + // Measured: `1390` + // Estimated: `6215` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(93_000_000, 6215) + .saturating_add(ParityDbWeight::get().reads(8_u64)) + .saturating_add(ParityDbWeight::get().writes(4_u64)) + } + /// Storage: `Domains::Operators` (r:1 w:1) + /// Proof: `Domains::Operators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestSubmittedER` (r:1 w:0) + /// Proof: `Domains::LatestSubmittedER` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::LatestConfirmedDomainBlock` (r:1 w:0) + /// Proof: `Domains::LatestConfirmedDomainBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:259 w:258) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Domains::Deposits` (r:258 w:257) + /// Proof: `Domains::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorEpochSharePrice` (r:2 w:2) + /// Proof: `Domains::OperatorEpochSharePrice` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:257 w:257) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(2750), added: 5225, mode: `MaxEncodedLen`) + /// Storage: `Domains::Withdrawals` (r:257 w:0) + /// Proof: `Domains::Withdrawals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorSigningKey` (r:0 w:1) + /// Proof: `Domains::OperatorSigningKey` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::OperatorIdOwner` (r:0 w:1) + /// Proof: `Domains::OperatorIdOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Domains::NominatorCount` (r:0 w:1) + /// Proof: `Domains::NominatorCount` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `n` is `[0, 256]`. + fn unlock_operator(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1160 + n * (330 ±0)` + // Estimated: `8799 + n * (5225 ±0)` + // Minimum execution time: 168_000_000 picoseconds. + Weight::from_parts(56_673_368, 8799) + // Standard Error: 401_978 + .saturating_add(Weight::from_parts(91_340_500, 0).saturating_mul(n.into())) + .saturating_add(ParityDbWeight::get().reads(12_u64)) + .saturating_add(ParityDbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(ParityDbWeight::get().writes(10_u64)) + .saturating_add(ParityDbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5225).saturating_mul(n.into())) + } + /// Storage: `Domains::DomainRegistry` (r:1 w:1) + /// Proof: `Domains::DomainRegistry` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn update_domain_operator_allow_list() -> Weight { + // Proof Size summary in bytes: + // Measured: `432` + // Estimated: `3897` + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(16_000_000, 3897) + .saturating_add(ParityDbWeight::get().reads(1_u64)) + .saturating_add(ParityDbWeight::get().writes(1_u64)) } } diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 5a101c7b9a..9f8f045ffc 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -608,7 +608,7 @@ parameter_types! { // operations allowed within each epoch. pub const StakeEpochDuration: DomainNumber = 100; pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating(); - pub const MaxPendingStakingOperation: u32 = 100; + pub const MaxPendingStakingOperation: u32 = 512; pub const MaxNominators: u32 = 256; pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist"); pub const DomainsPalletId: PalletId = PalletId(*b"domains_"); diff --git a/domains/pallets/executive/res/README.md b/domains/pallets/executive/res/README.md new file mode 100644 index 0000000000..982e1f5141 --- /dev/null +++ b/domains/pallets/executive/res/README.md @@ -0,0 +1,5 @@ +This runtime is used for benchmarking the `set_code` extrinsic. + +**Don't use them in production environments!** + +To update the just copy the new runtime from `target/release/wbuild/evm-domain-test-runtime/evm_domain_test_runtime.compact.compressed.wasm` to here. diff --git a/crates/pallet-domains/res/evm_domain_test_runtime.compact.compressed.wasm b/domains/pallets/executive/res/evm_domain_test_runtime.compact.compressed.wasm similarity index 100% rename from crates/pallet-domains/res/evm_domain_test_runtime.compact.compressed.wasm rename to domains/pallets/executive/res/evm_domain_test_runtime.compact.compressed.wasm diff --git a/domains/pallets/executive/src/benchmarking.rs b/domains/pallets/executive/src/benchmarking.rs index 7b56015d00..38365f28d7 100644 --- a/domains/pallets/executive/src/benchmarking.rs +++ b/domains/pallets/executive/src/benchmarking.rs @@ -8,10 +8,7 @@ use frame_system::RawOrigin; use crate::Pallet as Executive; fn get_runtime_code() -> Vec { - include_bytes!( - "../../../../crates/pallet-domains/res/evm_domain_test_runtime.compact.compressed.wasm" - ) - .to_vec() + include_bytes!("../res/evm_domain_test_runtime.compact.compressed.wasm").to_vec() } #[benchmarks] diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 1b8d46b6e2..8ef8299d26 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -646,7 +646,7 @@ parameter_types! { pub const StakeWithdrawalLockingPeriod: BlockNumber = 20; pub const StakeEpochDuration: DomainNumber = 5; pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating(); - pub const MaxPendingStakingOperation: u32 = 100; + pub const MaxPendingStakingOperation: u32 = 512; pub const MaxNominators: u32 = 100; pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist"); pub const DomainsPalletId: PalletId = PalletId(*b"domains_");