diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de5a8a25..587ea848e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ At the moment this project **does not** adhere to - Jumpstart network ([#918](https://github.com/entropyxyz/entropy-core/pull/918)) - Add Signer groups and rotation ([#938](https://github.com/entropyxyz/entropy-core/pull/938)) - Split jumpstart and register flows ([#952](https://github.com/entropyxyz/entropy-core/pull/952)) +- Reshare confirmation ([#965](https://github.com/entropyxyz/entropy-core/pull/965)) ## [0.2.0](https://github.com/entropyxyz/entropy-core/compare/release/v0.1.0...release/v0.2.0) - 2024-07-11 diff --git a/crates/client/entropy_metadata.scale b/crates/client/entropy_metadata.scale index 9748b94ce..3862a3625 100644 Binary files a/crates/client/entropy_metadata.scale and b/crates/client/entropy_metadata.scale differ diff --git a/crates/threshold-signature-server/src/validator/api.rs b/crates/threshold-signature-server/src/validator/api.rs index e7e6738b5..45211a400 100644 --- a/crates/threshold-signature-server/src/validator/api.rs +++ b/crates/threshold-signature-server/src/validator/api.rs @@ -21,7 +21,7 @@ use crate::{ get_signer_and_x25519_secret, helpers::{ launch::FORBIDDEN_KEYS, - substrate::{get_stash_address, get_validators_info, query_chain}, + substrate::{get_stash_address, get_validators_info, query_chain, submit_transaction}, }, signing_client::{protocol_transport::open_protocol_connections, ProtocolErr}, validator::errors::ValidatorErr, @@ -40,7 +40,10 @@ use parity_scale_codec::{Decode, Encode}; use rand_core::OsRng; use sp_core::Pair; use std::{collections::BTreeSet, str::FromStr, time::Duration}; -use subxt::{backend::legacy::LegacyRpcMethods, utils::AccountId32, OnlineClient}; +use subxt::{ + backend::legacy::LegacyRpcMethods, ext::sp_core::sr25519, tx::PairSigner, utils::AccountId32, + OnlineClient, +}; use synedrion::{ make_key_resharing_session, sessions::SessionId as SynedrionSessionId, KeyResharingInputs, NewHolder, OldHolder, @@ -200,12 +203,45 @@ pub async fn new_reshare( .map_err(|_| ValidatorErr::ProtocolError("Error executing protocol".to_string()))? .0 .ok_or(ValidatorErr::NoOutputFromReshareProtocol)?; - let _serialized_key_share = key_serialize(&new_key_share) + let serialized_key_share = key_serialize(&new_key_share) .map_err(|_| ProtocolErr::KvSerialize("Kv Serialize Error".to_string()))?; - // TODO: do reshare call confirm_reshare (delete key when done) see #941 + let network_parent_key = hex::encode(NETWORK_PARENT_KEY); + // TODO: should this be a two step process? see # https://github.com/entropyxyz/entropy-core/issues/968 + if app_state.kv_store.kv().exists(&network_parent_key).await? { + app_state.kv_store.kv().delete(&network_parent_key).await? + }; + + let reservation = app_state.kv_store.kv().reserve_key(network_parent_key).await?; + app_state.kv_store.kv().put(reservation, serialized_key_share.clone()).await?; + + // TODO: Error handling really complex needs to be thought about. + confirm_key_reshare(&api, &rpc, &signer).await?; Ok(StatusCode::OK) } +/// Confirms that a validator has succefully reshared. +pub async fn confirm_key_reshare( + api: &OnlineClient, + rpc: &LegacyRpcMethods, + signer: &PairSigner, +) -> Result<(), ValidatorErr> { + // TODO error handling + return error + // TODO fire and forget, or wait for in block maybe Ddos error + // TODO: Understand this better, potentially use sign_and_submit_default + // or other method under sign_and_* + let block_hash = rpc + .chain_get_block_hash(None) + .await? + .ok_or_else(|| ValidatorErr::OptionUnwrapError("Error getting block hash".to_string()))?; + + let nonce_call = entropy::apis().account_nonce_api().account_nonce(signer.account_id().clone()); + let nonce = api.runtime_api().at(block_hash).call(nonce_call).await?; + + let confirm_key_reshare_request = entropy::tx().staking_extension().confirm_key_reshare(); + submit_transaction(api, rpc, signer, &confirm_key_reshare_request, Some(nonce)).await?; + Ok(()) +} + /// Validation for if an account can cover tx fees for a tx pub async fn check_balance_for_fees( api: &OnlineClient, diff --git a/crates/threshold-signature-server/src/validator/tests.rs b/crates/threshold-signature-server/src/validator/tests.rs index cc4bb3efd..99a79aef9 100644 --- a/crates/threshold-signature-server/src/validator/tests.rs +++ b/crates/threshold-signature-server/src/validator/tests.rs @@ -21,18 +21,16 @@ use crate::{ helpers::{ launch::{development_mnemonic, ValidatorName, FORBIDDEN_KEYS}, substrate::submit_transaction, - tests::initialize_test_logger, + tests::{initialize_test_logger, spawn_testing_validators, unsafe_get}, validator::get_signer_and_x25519_secret_from_mnemonic, }, validator::errors::ValidatorErr, }; use entropy_kvdb::clean_tests; -use entropy_shared::{OcwMessageReshare, EVE_VERIFYING_KEY, MIN_BALANCE}; +use entropy_shared::{OcwMessageReshare, EVE_VERIFYING_KEY, MIN_BALANCE, NETWORK_PARENT_KEY}; use entropy_testing_utils::{ constants::{ALICE_STASH_ADDRESS, RANDOM_ACCOUNT}, - spawn_testing_validators, - substrate_context::testing_context, - test_context_stationary, + substrate_context::{test_node_process_testing_state, testing_context}, }; use futures::future::join_all; use parity_scale_codec::Encode; @@ -50,20 +48,25 @@ async fn test_reshare() { let alice = AccountKeyring::Alice; - let cxt = test_context_stationary().await; + let cxt = test_node_process_testing_state(true).await; let (_validator_ips, _validator_ids) = spawn_testing_validators(true).await; - let api = get_api(&cxt.node_proc.ws_url).await.unwrap(); - let rpc = get_rpc(&cxt.node_proc.ws_url).await.unwrap(); + let validator_ports = vec![3001, 3002, 3003]; + let api = get_api(&cxt.ws_url).await.unwrap(); + let rpc = get_rpc(&cxt.ws_url).await.unwrap(); let client = reqwest::Client::new(); let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; + let mut key_shares_before = vec![]; + for port in &validator_ports { + key_shares_before.push(unsafe_get(&client, hex::encode(NETWORK_PARENT_KEY), *port).await); + } let onchain_reshare_request = OcwMessageReshare { new_signer: alice.public().encode(), block_number }; setup_for_reshare(&api, &rpc).await; let response_results = join_all( - vec![3001, 3002, 3003] + validator_ports .iter() .map(|port| { client @@ -77,6 +80,13 @@ async fn test_reshare() { for response_result in response_results { assert_eq!(response_result.unwrap().text().await.unwrap(), ""); } + for i in 0..validator_ports.len() { + assert_ne!( + key_shares_before[i], + unsafe_get(&client, hex::encode(NETWORK_PARENT_KEY), validator_ports[i]).await + ); + } + clean_tests(); } diff --git a/node/cli/src/chain_spec/dev.rs b/node/cli/src/chain_spec/dev.rs index 5db913f15..4db7b650a 100644 --- a/node/cli/src/chain_spec/dev.rs +++ b/node/cli/src/chain_spec/dev.rs @@ -276,6 +276,7 @@ pub fn development_genesis_config( }) .collect::>(), proactive_refresh_data: (vec![], vec![]), + mock_signer_rotate: false, inital_signers: initial_authorities.iter().map(|auth| { auth.0.clone() }) diff --git a/node/cli/src/chain_spec/integration_tests.rs b/node/cli/src/chain_spec/integration_tests.rs index 1761bff73..ba80280eb 100644 --- a/node/cli/src/chain_spec/integration_tests.rs +++ b/node/cli/src/chain_spec/integration_tests.rs @@ -208,6 +208,7 @@ pub fn integration_tests_genesis_config( ], vec![EVE_VERIFYING_KEY.to_vec(), DAVE_VERIFYING_KEY.to_vec()], ), + mock_signer_rotate: true, inital_signers: initial_authorities.iter().map(|auth| { auth.0.clone() }) diff --git a/node/cli/src/chain_spec/testnet.rs b/node/cli/src/chain_spec/testnet.rs index c304a555d..cecde11fa 100644 --- a/node/cli/src/chain_spec/testnet.rs +++ b/node/cli/src/chain_spec/testnet.rs @@ -414,6 +414,7 @@ pub fn testnet_genesis_config( }) .collect::>(), proactive_refresh_data: (vec![], vec![]), + mock_signer_rotate: false, inital_signers: initial_authorities.iter().map(|auth| { auth.0.clone() }) diff --git a/pallets/propagation/src/mock.rs b/pallets/propagation/src/mock.rs index 22e52f965..8cbcfa987 100644 --- a/pallets/propagation/src/mock.rs +++ b/pallets/propagation/src/mock.rs @@ -372,6 +372,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (2, (4, NULL_ARR, vec![11])), ], proactive_refresh_data: (vec![], vec![]), + mock_signer_rotate: false, inital_signers: vec![5, 6], }; diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 565c4a238..38522eee7 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -608,7 +608,7 @@ pub mod pallet { ::WeightInfo::confirm_register_registering(pallet_session::Pallet::::validators().len() as u32) .max(::WeightInfo::confirm_register_registered(pallet_session::Pallet::::validators().len() as u32)) .max(::WeightInfo::confirm_register_failed_registering(pallet_session::Pallet::::validators().len() as u32)); - (weight, Pays::No) + (weight, DispatchClass::Operational, Pays::No) })] pub fn confirm_register( origin: OriginFor, diff --git a/pallets/registry/src/mock.rs b/pallets/registry/src/mock.rs index 18a28acae..3f94d8c41 100644 --- a/pallets/registry/src/mock.rs +++ b/pallets/registry/src/mock.rs @@ -365,6 +365,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (7, (4, NULL_ARR, vec![50])), ], proactive_refresh_data: (vec![], vec![]), + mock_signer_rotate: false, inital_signers: vec![5, 6], }; diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index 71fbf0d25..d03baf608 100644 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -15,6 +15,7 @@ //! Benchmarking setup for pallet-propgation #![allow(unused_imports)] +use entropy_shared::SIGNING_PARTY_SIZE; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ assert_ok, ensure, @@ -175,6 +176,56 @@ benchmarks! { verify { assert_last_event::(Event::::ValidatorSyncStatus(validator_id_res, true).into()); } + + confirm_key_reshare_confirmed { + let c in 0 .. SIGNING_PARTY_SIZE as u32; + // leave a space for two as not to rotate and only confirm rotation + let confirmation_num = c.checked_sub(2).unwrap_or(0); + let signer_num = SIGNING_PARTY_SIZE - 1; + let caller: T::AccountId = whitelisted_caller(); + let validator_id_res = ::ValidatorId::try_from(caller.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); + let second_signer: T::AccountId = account("second_signer", 0, SEED); + let second_signer_id = ::ValidatorId::try_from(second_signer.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); + ThresholdToStash::::insert(caller.clone(), validator_id_res.clone()); + + // full signer list leaving room for one extra validator + let mut signers = vec![second_signer_id.clone(); signer_num as usize]; + signers.push(validator_id_res.clone()); + Signers::::put(signers.clone()); + + NextSigners::::put(NextSignerInfo { + next_signers: signers, + confirmations: vec![second_signer_id.clone(); confirmation_num as usize], + }); + + }: confirm_key_reshare(RawOrigin::Signed(caller.clone())) + verify { + assert_last_event::(Event::::SignerConfirmed(validator_id_res).into()); + } + + confirm_key_reshare_completed { + // once less confirmation to always flip to rotate + let confirmation_num = SIGNING_PARTY_SIZE - 1; + + let caller: T::AccountId = whitelisted_caller(); + let validator_id_res = ::ValidatorId::try_from(caller.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); + let second_signer: T::AccountId = account("second_signer", 0, SEED); + let second_signer_id = ::ValidatorId::try_from(second_signer.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); + ThresholdToStash::::insert(caller.clone(), validator_id_res.clone()); + // full signer list leaving room for one extra validator + let mut signers = vec![second_signer_id.clone(); confirmation_num as usize]; + signers.push(validator_id_res.clone()); + + Signers::::put(signers.clone()); + NextSigners::::put(NextSignerInfo { + next_signers: signers.clone(), + confirmations: vec![second_signer_id; confirmation_num as usize], + }); + + }: confirm_key_reshare(RawOrigin::Signed(caller.clone())) + verify { + assert_last_event::(Event::::SignersRotation(signers.clone()).into()); + } } impl_benchmark_test_suite!(Staking, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 8496a3b31..ede1633e8 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -57,9 +57,9 @@ use sp_staking::SessionIndex; #[frame_support::pallet] pub mod pallet { - use entropy_shared::{ValidatorInfo, X25519PublicKey}; + use entropy_shared::{ValidatorInfo, X25519PublicKey, SIGNING_PARTY_SIZE}; use frame_support::{ - dispatch::DispatchResult, + dispatch::{DispatchResult, DispatchResultWithPostInfo}, pallet_prelude::*, traits::{Currency, Randomness}, DefaultNoBound, @@ -71,6 +71,7 @@ pub mod pallet { }; use sp_runtime::traits::TrailingZeroInput; use sp_staking::StakingAccount; + use sp_std::vec; use sp_std::vec::Vec; use super::*; @@ -119,6 +120,12 @@ pub mod pallet { pub new_signer: Vec, pub block_number: BlockNumber, } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] + pub struct NextSignerInfo { + pub next_signers: Vec, + pub confirmations: Vec, + } #[pallet::pallet] #[pallet::without_storage_info] pub struct Pallet(_); @@ -173,7 +180,7 @@ pub mod pallet { /// The next signers ready to take the Signers place when a reshare is done #[pallet::storage] #[pallet::getter(fn next_signers)] - pub type NextSigners = StorageValue<_, Vec, ValueQuery>; + pub type NextSigners = StorageValue<_, NextSignerInfo, OptionQuery>; /// The next time a reshare should happen #[pallet::storage] @@ -193,6 +200,8 @@ pub mod pallet { pub inital_signers: Vec, /// validator info and accounts to take part in proactive refresh pub proactive_refresh_data: (Vec, Vec>), + /// validator info and account to take part in a reshare + pub mock_signer_rotate: bool, } #[pallet::genesis_build] @@ -222,6 +231,13 @@ pub mod pallet { proactive_refresh_keys: self.proactive_refresh_data.1.clone(), }; ProactiveRefresh::::put(refresh_info); + + if self.mock_signer_rotate { + NextSigners::::put(NextSignerInfo { + next_signers: self.inital_signers.clone(), + confirmations: vec![], + }); + } } } // Errors inform users that something went wrong. @@ -234,6 +250,9 @@ pub mod pallet { InvalidValidatorId, SigningGroupError, TssAccountAlreadyExists, + NotNextSigner, + ReshareNotInProgress, + AlreadyConfirmed, } #[pallet::event] @@ -257,6 +276,10 @@ pub mod pallet { Vec::ValidatorId>>, Vec::ValidatorId>>, ), + /// Validators in new signer group [new_signers] + SignerConfirmed(::ValidatorId), + /// Validators subgroups rotated [old, new] + SignersRotation(Vec<::ValidatorId>), } #[pallet::call] @@ -403,6 +426,43 @@ pub mod pallet { Self::deposit_event(Event::ValidatorSyncStatus(stash, synced)); Ok(()) } + + #[pallet::call_index(5)] + #[pallet::weight(({ + ::WeightInfo::confirm_key_reshare_confirmed(SIGNING_PARTY_SIZE as u32) + .max(::WeightInfo::confirm_key_reshare_completed()) + }, DispatchClass::Operational))] + pub fn confirm_key_reshare(origin: OriginFor) -> DispatchResultWithPostInfo { + let ts_server_account = ensure_signed(origin)?; + let validator_stash = + Self::threshold_to_stash(&ts_server_account).ok_or(Error::::NoThresholdKey)?; + + let mut signers_info = + NextSigners::::take().ok_or(Error::::ReshareNotInProgress)?; + ensure!( + signers_info.next_signers.contains(&validator_stash), + Error::::NotNextSigner + ); + + ensure!( + !signers_info.confirmations.contains(&validator_stash), + Error::::AlreadyConfirmed + ); + + // TODO (#927): Add another check, such as a signature or a verifying key comparison, to + // ensure that rotation was indeed successful. + let current_signer_length = signers_info.next_signers.len(); + if signers_info.confirmations.len() == (current_signer_length - 1) { + Signers::::put(signers_info.next_signers.clone()); + Self::deposit_event(Event::SignersRotation(signers_info.next_signers)); + Ok(Pays::No.into()) + } else { + signers_info.confirmations.push(validator_stash.clone()); + NextSigners::::put(signers_info); + Self::deposit_event(Event::SignerConfirmed(validator_stash)); + Ok(Pays::No.into()) + } + } } impl Pallet { @@ -446,7 +506,10 @@ pub mod pallet { // removes first signer and pushes new signer to back current_signers.remove(0); current_signers.push(next_signer_up.clone()); - NextSigners::::put(current_signers); + NextSigners::::put(NextSignerInfo { + next_signers: current_signers, + confirmations: vec![], + }); // trigger reshare at next block let current_block_number = >::block_number(); let reshare_info = ReshareInfo { diff --git a/pallets/staking/src/mock.rs b/pallets/staking/src/mock.rs index ad34160d7..6f1cd56fb 100644 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -396,6 +396,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { threshold_servers: vec![(5, (7, NULL_ARR, vec![20])), (6, (8, NULL_ARR, vec![40]))], inital_signers: vec![5, 6], proactive_refresh_data: (vec![], vec![]), + mock_signer_rotate: false, }; pallet_balances.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index eb517982c..43c98fa4f 100644 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -13,7 +13,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use crate::{mock::*, tests::RuntimeEvent, Error, IsValidatorSynced, ServerInfo, ThresholdToStash}; +use crate::{ + mock::*, tests::RuntimeEvent, Error, IsValidatorSynced, NextSignerInfo, NextSigners, + ServerInfo, ThresholdToStash, +}; use codec::Encode; use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; @@ -330,13 +333,24 @@ fn it_tests_new_session_handler() { // Start with current validators as 5 and 6 based off the Mock `GenesisConfig`. // no next signers at start - assert_eq!(Staking::next_signers().len(), 0); + assert_eq!(Staking::next_signers(), None); assert_eq!(Staking::reshare_data().block_number, 0, "Check reshare block start at zero"); System::set_block_number(100); assert_ok!(Staking::new_session_handler(&[1, 2, 3])); // takes signers original (5,6) pops off first 5, adds (fake randomness in mock so adds 1) - assert_eq!(Staking::next_signers(), vec![6, 1]); + assert_eq!(Staking::next_signers().unwrap().next_signers, vec![6, 1]); + + assert_eq!( + Staking::reshare_data().block_number, + 101, + "Check reshare block start at 100 + 1" + ); + assert_eq!( + Staking::reshare_data().new_signer, + 1u64.encode(), + "Check reshare next signer up is 1" + ); assert_eq!( Staking::reshare_data().block_number, @@ -351,10 +365,56 @@ fn it_tests_new_session_handler() { assert_ok!(Staking::new_session_handler(&[6, 5, 3])); // takes 3 and leaves 5 and 6 since already in signer group - assert_eq!(Staking::next_signers(), vec![6, 3]); + assert_eq!(Staking::next_signers().unwrap().next_signers, vec![6, 3]); assert_ok!(Staking::new_session_handler(&[1])); // does nothing as not enough validators - assert_eq!(Staking::next_signers(), vec![6, 3]); + assert_eq!(Staking::next_signers().unwrap().next_signers, vec![6, 3]); + }); +} + +#[test] +fn it_confirms_keyshare() { + new_test_ext().execute_with(|| { + assert_noop!( + Staking::confirm_key_reshare(RuntimeOrigin::signed(10)), + Error::::NoThresholdKey + ); + + assert_noop!( + Staking::confirm_key_reshare(RuntimeOrigin::signed(7)), + Error::::ReshareNotInProgress + ); + + NextSigners::::put(NextSignerInfo { + next_signers: vec![7, 5], + confirmations: vec![5], + }); + + assert_noop!( + Staking::confirm_key_reshare(RuntimeOrigin::signed(8)), + Error::::NotNextSigner + ); + + assert_noop!( + Staking::confirm_key_reshare(RuntimeOrigin::signed(7)), + Error::::AlreadyConfirmed + ); + + NextSigners::::put(NextSignerInfo { + next_signers: vec![6, 5], + confirmations: vec![], + }); + + let mock_next_signer_info = + NextSignerInfo { next_signers: vec![6, 5], confirmations: vec![5] }; + + assert_ok!(Staking::confirm_key_reshare(RuntimeOrigin::signed(7))); + assert_eq!(Staking::next_signers().unwrap(), mock_next_signer_info, "Confirmation added"); + assert_eq!(Staking::signers(), [5, 6], "check current signers so we can see it changed"); + + assert_ok!(Staking::confirm_key_reshare(RuntimeOrigin::signed(8))); + assert_eq!(Staking::next_signers(), None, "Next Signers cleared"); + assert_eq!(Staking::signers(), [6, 5], "next signers rotated into current signers"); }); } diff --git a/pallets/staking/src/weights.rs b/pallets/staking/src/weights.rs index 356b7c4f8..a78e552f0 100644 --- a/pallets/staking/src/weights.rs +++ b/pallets/staking/src/weights.rs @@ -57,7 +57,8 @@ pub trait WeightInfo { fn withdraw_unbonded() -> Weight; fn validate() -> Weight; fn declare_synced() -> Weight; - fn new_session_handler_helper(c: u32, n: u32, ) -> Weight; + fn confirm_key_reshare_confirmed(c: u32) -> Weight; + fn confirm_key_reshare_completed() -> Weight; } /// Weights for pallet_staking_extension using the Substrate node and recommended hardware. @@ -158,23 +159,36 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `StakingExtension::SigningGroups` (r:2 w:2) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 1000]`. - /// The range of component `n` is `[0, 1000]`. - fn new_session_handler_helper(c: u32, n: u32, ) -> Weight { + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 2]`. + fn confirm_key_reshare_confirmed(_c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + c * (32 ±0)` - // Estimated: `6156 + c * (32 ±0)` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_000_000, 6156) - // Standard Error: 24_941 - .saturating_add(Weight::from_parts(798_680, 0).saturating_mul(c.into())) - // Standard Error: 24_941 - .saturating_add(Weight::from_parts(821_922, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(c.into())) + // Measured: `445` + // Estimated: `3910` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(11_916_666, 0) + .saturating_add(Weight::from_parts(0, 3910)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::Signers` (r:0 w:1) + /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn confirm_key_reshare_completed() -> Weight { + // Proof Size summary in bytes: + // Measured: `477` + // Estimated: `3942` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(13_000_000, 0) + .saturating_add(Weight::from_parts(0, 3942)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } @@ -275,22 +289,35 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `StakingExtension::SigningGroups` (r:2 w:2) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 1000]`. - /// The range of component `n` is `[0, 1000]`. - fn new_session_handler_helper(c: u32, n: u32, ) -> Weight { + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 2]`. + fn confirm_key_reshare_confirmed(_c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + c * (32 ±0)` - // Estimated: `6156 + c * (32 ±0)` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_000_000, 6156) - // Standard Error: 24_941 - .saturating_add(Weight::from_parts(798_680, 0).saturating_mul(c.into())) - // Standard Error: 24_941 - .saturating_add(Weight::from_parts(821_922, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(c.into())) + // Measured: `445` + // Estimated: `3910` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(11_916_666, 0) + .saturating_add(Weight::from_parts(0, 3910)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::Signers` (r:0 w:1) + /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn confirm_key_reshare_completed() -> Weight { + // Proof Size summary in bytes: + // Measured: `477` + // Estimated: `3942` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(13_000_000, 0) + .saturating_add(Weight::from_parts(0, 3942)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } } diff --git a/runtime/src/weights/pallet_staking_extension.rs b/runtime/src/weights/pallet_staking_extension.rs index 279508ea4..87698051d 100644 --- a/runtime/src/weights/pallet_staking_extension.rs +++ b/runtime/src/weights/pallet_staking_extension.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_staking_extension` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 33.0.0 -//! DATE: 2024-06-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-26, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ip-172-31-30-92`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `Jesses-MacBook-Pro.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 // Executed Command: @@ -27,14 +27,11 @@ // pallet // --chain // dev -// --wasm-execution=compiled // --pallet=pallet_staking_extension // --extrinsic=* -// --steps=50 -// --repeat=20 +// --steps=5 +// --repeat=2 // --header=.maintain/AGPL-3.0-header.txt -// --template -// .maintain/frame-weight-template.hbs // --output=./runtime/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] @@ -56,11 +53,11 @@ impl pallet_staking_extension::WeightInfo for WeightInf /// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn change_endpoint() -> Weight { // Proof Size summary in bytes: - // Measured: `1276` - // Estimated: `4741` - // Minimum execution time: 39_814_000 picoseconds. - Weight::from_parts(41_408_000, 0) - .saturating_add(Weight::from_parts(0, 4741)) + // Measured: `1342` + // Estimated: `4807` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(29_000_000, 0) + .saturating_add(Weight::from_parts(0, 4807)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -74,11 +71,11 @@ impl pallet_staking_extension::WeightInfo for WeightInf /// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn change_threshold_accounts() -> Weight { // Proof Size summary in bytes: - // Measured: `1364` - // Estimated: `4829` - // Minimum execution time: 45_234_000 picoseconds. - Weight::from_parts(46_253_000, 0) - .saturating_add(Weight::from_parts(0, 4829)) + // Measured: `1463` + // Estimated: `4928` + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(29_000_000, 0) + .saturating_add(Weight::from_parts(0, 4928)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -96,10 +93,10 @@ impl pallet_staking_extension::WeightInfo for WeightInf /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn withdraw_unbonded() -> Weight { // Proof Size summary in bytes: - // Measured: `1163` + // Measured: `1262` // Estimated: `4764` - // Minimum execution time: 66_668_000 picoseconds. - Weight::from_parts(68_966_000, 0) + // Minimum execution time: 42_000_000 picoseconds. + Weight::from_parts(43_000_000, 0) .saturating_add(Weight::from_parts(0, 4764)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) @@ -132,10 +129,10 @@ impl pallet_staking_extension::WeightInfo for WeightInf /// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn validate() -> Weight { // Proof Size summary in bytes: - // Measured: `1785` + // Measured: `1951` // Estimated: `6248` - // Minimum execution time: 106_974_000 picoseconds. - Weight::from_parts(110_066_000, 0) + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(70_000_000, 0) .saturating_add(Weight::from_parts(0, 6248)) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(8)) @@ -148,33 +145,41 @@ impl pallet_staking_extension::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `353` // Estimated: `3818` - // Minimum execution time: 16_432_000 picoseconds. - Weight::from_parts(17_070_000, 0) + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 0) .saturating_add(Weight::from_parts(0, 3818)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `StakingExtension::SigningGroups` (r:2 w:2) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::ValidatorToSubgroup` (r:0 w:2000) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 1000]`. - /// The range of component `n` is `[0, 1000]`. - fn new_session_handler_helper(c: u32, n: u32, ) -> Weight { + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 2]`. + fn confirm_key_reshare_confirmed(_c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `445` + // Estimated: `3910` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(11_916_666, 0) + .saturating_add(Weight::from_parts(0, 3910)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) + /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::NextSigners` (r:1 w:1) + /// Proof: `StakingExtension::NextSigners` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `StakingExtension::Signers` (r:0 w:1) + /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn confirm_key_reshare_completed() -> Weight { // Proof Size summary in bytes: - // Measured: `252 + c * (32 ±0)` - // Estimated: `6187 + c * (32 ±0)` - // Minimum execution time: 1_310_197_000 picoseconds. - Weight::from_parts(1_315_789_000, 0) - .saturating_add(Weight::from_parts(0, 6187)) - // Standard Error: 45_371 - .saturating_add(Weight::from_parts(1_466_688, 0).saturating_mul(c.into())) - // Standard Error: 45_371 - .saturating_add(Weight::from_parts(1_584_397, 0).saturating_mul(n.into())) + // Measured: `477` + // Estimated: `3942` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(13_000_000, 0) + .saturating_add(Weight::from_parts(0, 3942)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(c.into())) } -} \ No newline at end of file +}