diff --git a/CHANGELOG.md b/CHANGELOG.md index 587ea848e..9d27efe12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ At the moment this project **does not** adhere to - 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)) +- Set inital signers ([#971](https://github.com/entropyxyz/entropy-core/pull/971)) ## [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/shared/src/constants.rs b/crates/shared/src/constants.rs index a34a547ac..1fc5ce079 100644 --- a/crates/shared/src/constants.rs +++ b/crates/shared/src/constants.rs @@ -33,8 +33,6 @@ lazy_static! { pub static ref DEVICE_KEY_AUX_DATA_TYPE: Vec = vec![123, 34, 36, 115, 99, 104, 101, 109, 97, 34, 58, 34, 104, 116, 116, 112, 58, 47, 47, 106, 115, 111, 110, 45, 115, 99, 104, 101, 109, 97, 46, 111, 114, 103, 47, 100, 114, 97, 102, 116, 45, 48, 55, 47, 115, 99, 104, 101, 109, 97, 35, 34, 44, 34, 116, 105, 116, 108, 101, 34, 58, 34, 65, 117, 120, 68, 97, 116, 97, 34, 44, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 74, 83, 79, 78, 32, 114, 101, 112, 114, 101, 115, 101, 110, 116, 97, 116, 105, 111, 110, 32, 111, 102, 32, 116, 104, 101, 32, 97, 117, 120, 105, 108, 105, 97, 114, 121, 32, 100, 97, 116, 97, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 111, 98, 106, 101, 99, 116, 34, 44, 34, 114, 101, 113, 117, 105, 114, 101, 100, 34, 58, 91, 34, 99, 111, 110, 116, 101, 120, 116, 34, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 34, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 95, 116, 121, 112, 101, 34, 44, 34, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 93, 44, 34, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 34, 58, 123, 34, 99, 111, 110, 116, 101, 120, 116, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 84, 104, 101, 32, 99, 111, 110, 116, 101, 120, 116, 32, 102, 111, 114, 32, 116, 104, 101, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 32, 111, 110, 108, 121, 32, 110, 101, 101, 100, 101, 100, 32, 105, 110, 32, 115, 114, 50, 53, 53, 49, 57, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 32, 116, 121, 112, 101, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 98, 97, 115, 101, 54, 52, 45, 101, 110, 99, 111, 100, 101, 100, 32, 112, 117, 98, 108, 105, 99, 32, 107, 101, 121, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 95, 116, 121, 112, 101, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 92, 34, 101, 99, 100, 115, 97, 92, 34, 44, 32, 92, 34, 101, 100, 50, 53, 53, 49, 57, 92, 34, 44, 32, 92, 34, 115, 114, 50, 53, 53, 49, 57, 92, 34, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 98, 97, 115, 101, 54, 52, 45, 101, 110, 99, 111, 100, 101, 100, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 125, 125]; } -pub const SIGNING_PARTY_SIZE: usize = 2; - // min balance 10 decimal chain = 1 pub const MIN_BALANCE: u128 = 10_000_000_000; diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index 9655fe0da..6e5b4bda7 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -35,7 +35,7 @@ use entropy_kvdb::kv_manager::{ use entropy_programs_runtime::{Config as ProgramConfig, Runtime, SignatureRequest}; use entropy_protocol::{KeyParams, PartyId, SigningSessionInfo, ValidatorInfo}; use entropy_shared::{ - HashingAlgorithm, OcwMessageDkg, X25519PublicKey, NETWORK_PARENT_KEY, SIGNING_PARTY_SIZE, + HashingAlgorithm, OcwMessageDkg, X25519PublicKey, NETWORK_PARENT_KEY, TOTAL_SIGNERS, }; use futures::{ channel::mpsc, diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index b6d2f80e0..0e4ad7fe4 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -785,7 +785,7 @@ async fn test_jumpstart_network() { // wait for jump start event check that key exists in kvdb let mut got_jumpstart_event = false; - for _ in 0..45 { + for _ in 0..75 { std::thread::sleep(std::time::Duration::from_millis(1000)); let block_hash = rpc.chain_get_block_hash(None).await.unwrap(); let events = EventsClient::new(api.clone()).at(block_hash.unwrap()).await.unwrap(); diff --git a/crates/threshold-signature-server/src/validator/api.rs b/crates/threshold-signature-server/src/validator/api.rs index cfe10c4cb..c6a220ea1 100644 --- a/crates/threshold-signature-server/src/validator/api.rs +++ b/crates/threshold-signature-server/src/validator/api.rs @@ -62,7 +62,6 @@ pub async fn new_reshare( ) -> Result { let data = OcwMessageReshare::decode(&mut encoded_data.as_ref())?; // TODO: validate message came from chain (check reshare block # against current block number) see #941 - let api = get_api(&app_state.configuration.endpoint).await?; let rpc = get_rpc(&app_state.configuration.endpoint).await?; validate_new_reshare(&api, &rpc, &data, &app_state.kv_store).await?; @@ -79,6 +78,7 @@ pub async fn new_reshare( let validators_info = get_validators_info(&api, &rpc, next_signers) .await .map_err(|e| ValidatorErr::UserError(e.to_string()))?; + let (signer, x25519_secret_key) = get_signer_and_x25519_secret(&app_state.kv_store) .await .map_err(|e| ValidatorErr::UserError(e.to_string()))?; diff --git a/crates/threshold-signature-server/src/validator/tests.rs b/crates/threshold-signature-server/src/validator/tests.rs index c419fcfe0..0c9804c55 100644 --- a/crates/threshold-signature-server/src/validator/tests.rs +++ b/crates/threshold-signature-server/src/validator/tests.rs @@ -173,7 +173,7 @@ async fn setup_for_reshare( let jump_start_request = entropy::tx().registry().jump_start_network(); let _result = submit_transaction(api, rpc, &signer, &jump_start_request, None).await.unwrap(); - let validators_names = vec![ValidatorName::Alice, ValidatorName::Bob]; + let validators_names = vec![ValidatorName::Alice, ValidatorName::Bob, ValidatorName::Charlie]; for validator_name in validators_names { let mnemonic = development_mnemonic(&Some(validator_name)); let (tss_signer, _static_secret) = diff --git a/node/cli/src/chain_spec/dev.rs b/node/cli/src/chain_spec/dev.rs index 4db7b650a..3b35079e9 100644 --- a/node/cli/src/chain_spec/dev.rs +++ b/node/cli/src/chain_spec/dev.rs @@ -276,11 +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() - }) - .collect::>(), + mock_signer_rotate: (false, vec![], vec![]), }, "elections": ElectionsConfig { members: endowed_accounts diff --git a/node/cli/src/chain_spec/integration_tests.rs b/node/cli/src/chain_spec/integration_tests.rs index ba80280eb..cad55b3d9 100644 --- a/node/cli/src/chain_spec/integration_tests.rs +++ b/node/cli/src/chain_spec/integration_tests.rs @@ -208,11 +208,9 @@ 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| { + mock_signer_rotate: (true, initial_authorities.iter().map(|auth| { auth.0.clone() - }) - .collect::>(), + }).collect::>(), vec![get_account_id_from_seed::("Alice")],), }, "elections": ElectionsConfig { members: endowed_accounts diff --git a/node/cli/src/chain_spec/testnet.rs b/node/cli/src/chain_spec/testnet.rs index cecde11fa..a3ec871ac 100644 --- a/node/cli/src/chain_spec/testnet.rs +++ b/node/cli/src/chain_spec/testnet.rs @@ -414,11 +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() - }) - .collect::>(), + mock_signer_rotate: (false, vec![], vec![]), }, "elections": ElectionsConfig { members: endowed_accounts diff --git a/pallets/propagation/src/mock.rs b/pallets/propagation/src/mock.rs index 8cbcfa987..f71fa18f4 100644 --- a/pallets/propagation/src/mock.rs +++ b/pallets/propagation/src/mock.rs @@ -372,8 +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], + mock_signer_rotate: (false, vec![], vec![]), }; pallet_staking_extension.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index 12eaf5b36..625c62477 100644 --- a/pallets/registry/src/benchmarking.rs +++ b/pallets/registry/src/benchmarking.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . //! Benchmarking setup for pallet-propgation -use entropy_shared::{SIGNING_PARTY_SIZE, VERIFICATION_KEY_LENGTH}; +use entropy_shared::{TOTAL_SIGNERS, VERIFICATION_KEY_LENGTH}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ traits::{Currency, Get}, @@ -79,26 +79,26 @@ benchmarks! { } confirm_jump_start_done { - let c in 0 .. SIGNING_PARTY_SIZE as u32; + let c in 0 .. TOTAL_SIGNERS as u32; let sig_req_account: T::AccountId = whitelisted_caller(); let validator_account: T::AccountId = whitelisted_caller(); let expected_verifying_key = BoundedVec::default(); let mut accounts = vec![]; - for i in 0..SIGNING_PARTY_SIZE { + for i in 0..TOTAL_SIGNERS { accounts.push(account::("ts_account", i as u32, SEED)); } - let validators = add_non_syncing_validators::(SIGNING_PARTY_SIZE as u32, 0); + let validators = add_non_syncing_validators::(TOTAL_SIGNERS as u32, 0); >::set(validators.clone()); - for i in 0..SIGNING_PARTY_SIZE { - >::insert(accounts[i].clone(), &validators[i]); + for i in 0..TOTAL_SIGNERS { + >::insert(accounts[i as usize].clone(), &validators[i as usize]); } >::put(JumpStartDetails { jump_start_status: JumpStartStatus::InProgress(0), - confirmations: vec![validators[0].clone()], + confirmations: vec![validators[0].clone(), validators[0].clone()], verifying_key: None }); @@ -111,17 +111,17 @@ benchmarks! { } confirm_jump_start_confirm { - let c in 0 .. SIGNING_PARTY_SIZE as u32; + let c in 0 .. TOTAL_SIGNERS as u32; let sig_req_account: T::AccountId = whitelisted_caller(); let validator_account: T::AccountId = whitelisted_caller(); let threshold_account: T::AccountId = whitelisted_caller(); let expected_verifying_key = BoundedVec::default(); // add validators and a registering user - for i in 0..SIGNING_PARTY_SIZE { - let validators = add_non_syncing_validators::(SIGNING_PARTY_SIZE as u32, 0); + for i in 0..TOTAL_SIGNERS { + let validators = add_non_syncing_validators::(TOTAL_SIGNERS as u32, 0); >::set(validators.clone()); - >::insert(&threshold_account, &validators[i]); + >::insert(&threshold_account, &validators[i as usize]); } >::put(JumpStartDetails { jump_start_status: JumpStartStatus::InProgress(0), diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 38522eee7..95a325328 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -53,7 +53,7 @@ pub mod weights; #[frame_support::pallet] pub mod pallet { - use entropy_shared::{NETWORK_PARENT_KEY, SIGNING_PARTY_SIZE, VERIFICATION_KEY_LENGTH}; + use entropy_shared::{NETWORK_PARENT_KEY, TOTAL_SIGNERS, VERIFICATION_KEY_LENGTH}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, pallet_prelude::*, @@ -316,8 +316,8 @@ pub mod pallet { /// Allows validators to signal a successful network jumpstart #[pallet::call_index(1)] #[pallet::weight({ - ::WeightInfo::confirm_jump_start_confirm(SIGNING_PARTY_SIZE as u32) - .max(::WeightInfo::confirm_jump_start_done(SIGNING_PARTY_SIZE as u32)) + ::WeightInfo::confirm_jump_start_confirm(TOTAL_SIGNERS as u32) + .max(::WeightInfo::confirm_jump_start_done(TOTAL_SIGNERS as u32)) })] pub fn confirm_jump_start( origin: OriginFor, @@ -357,7 +357,7 @@ pub mod pallet { // ensure that registration was indeed successful. // // If it fails we'll need to allow another jumpstart. - if jump_start_info.confirmations.len() == (SIGNING_PARTY_SIZE - 1) { + if jump_start_info.confirmations.len() == (TOTAL_SIGNERS as usize - 1) { // registration finished, lock call jump_start_info.confirmations.push(validator_stash); let confirmations = jump_start_info.confirmations.len(); @@ -367,7 +367,8 @@ pub mod pallet { confirmations: vec![], verifying_key: jump_start_info.verifying_key, }); - + // Jumpstart participants become first network signers + pallet_staking_extension::Signers::::put(jump_start_info.confirmations); Self::deposit_event(Event::FinishedNetworkJumpStart()); return Ok(Some(::WeightInfo::confirm_jump_start_done( diff --git a/pallets/registry/src/mock.rs b/pallets/registry/src/mock.rs index 3f94d8c41..e5e5825a2 100644 --- a/pallets/registry/src/mock.rs +++ b/pallets/registry/src/mock.rs @@ -365,13 +365,12 @@ 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], + mock_signer_rotate: (false, vec![], vec![]), }; pallet_staking_extension.assimilate_storage(&mut t).unwrap(); - let stakers = vec![1, 2]; + let stakers = vec![1, 2, 5]; let keys: Vec<_> = stakers.iter().cloned().map(|i| (i, i, UintAuthorityId(i).into())).collect(); pallet_session::GenesisConfig:: { keys }.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index 4a2def60d..d6b3136ad 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -45,8 +45,10 @@ fn it_tests_get_validators_info() { ServerInfo { tss_account: 3, x25519_public_key: NULL_ARR, endpoint: vec![10] }; let server_info_2 = ServerInfo { tss_account: 4, x25519_public_key: NULL_ARR, endpoint: vec![11] }; + let server_info_3 = + ServerInfo { tss_account: 7, x25519_public_key: NULL_ARR, endpoint: vec![20] }; - assert_eq!(result_1, vec![server_info_1, server_info_2]); + assert_eq!(result_1, vec![server_info_1, server_info_2, server_info_3]); }); } @@ -184,10 +186,15 @@ fn it_tests_jump_start_result() { ); pallet_staking_extension::ThresholdToStash::::insert(2, 2); + pallet_staking_extension::ThresholdToStash::::insert(5, 5); assert_ok!(Registry::confirm_jump_start( RuntimeOrigin::signed(2), expected_verifying_key.clone() )); + assert_ok!(Registry::confirm_jump_start( + RuntimeOrigin::signed(5), + expected_verifying_key.clone() + )); assert_eq!( Registry::jump_start_progress(), JumpStartDetails { @@ -197,6 +204,11 @@ fn it_tests_jump_start_result() { }, "Jump start in done status after all confirmations" ); + assert_eq!( + pallet_staking_extension::Signers::::get(), + vec![1, 2, 5], + "Jumpstart sets inital signers" + ); }); } @@ -258,7 +270,7 @@ fn it_confirms_registers_a_user() { ); assert_noop!( - Registry::confirm_register(RuntimeOrigin::signed(7), 1, expected_verifying_key.clone()), + Registry::confirm_register(RuntimeOrigin::signed(8), 1, expected_verifying_key.clone()), Error::::NotValidator ); @@ -278,6 +290,12 @@ fn it_confirms_registers_a_user() { expected_verifying_key.clone() )); + assert_ok!(Registry::confirm_register( + RuntimeOrigin::signed(7), + 1, + expected_verifying_key.clone() + )); + assert_eq!(Registry::registering(1), None); assert_eq!( Registry::registered(expected_verifying_key.clone()).unwrap(), @@ -794,7 +812,7 @@ fn it_provides_free_txs_confirm_done_fails_4() { }); let di = c.get_dispatch_info(); assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&7, &c, &di, 20); + let r = p.validate(&8, &c, &di, 20); assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); }); } diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index d03baf608..5c1926006 100644 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -15,7 +15,7 @@ //! Benchmarking setup for pallet-propgation #![allow(unused_imports)] -use entropy_shared::SIGNING_PARTY_SIZE; +use entropy_shared::TOTAL_SIGNERS; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ assert_ok, ensure, @@ -178,10 +178,10 @@ benchmarks! { } confirm_key_reshare_confirmed { - let c in 0 .. SIGNING_PARTY_SIZE as u32; + let c in 0 .. TOTAL_SIGNERS 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 signer_num = TOTAL_SIGNERS - 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); @@ -205,7 +205,7 @@ benchmarks! { confirm_key_reshare_completed { // once less confirmation to always flip to rotate - let confirmation_num = SIGNING_PARTY_SIZE - 1; + let confirmation_num = TOTAL_SIGNERS as usize - 1; let caller: T::AccountId = whitelisted_caller(); let validator_id_res = ::ValidatorId::try_from(caller.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 33871397f..43dbd78c4 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -58,7 +58,7 @@ use sp_staking::SessionIndex; #[frame_support::pallet] pub mod pallet { use entropy_shared::{ - ValidatorInfo, X25519PublicKey, SIGNING_PARTY_SIZE, TEST_RESHARE_BLOCK_NUMBER, + ValidatorInfo, X25519PublicKey, TEST_RESHARE_BLOCK_NUMBER, TOTAL_SIGNERS, }; use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo}, @@ -199,11 +199,10 @@ pub mod pallet { #[derive(DefaultNoBound)] pub struct GenesisConfig { pub threshold_servers: Vec>, - 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, + /// validator info and account new signer to take part in a reshare + pub mock_signer_rotate: (bool, Vec, Vec), } #[pallet::genesis_build] @@ -225,7 +224,6 @@ pub mod pallet { ThresholdServers::::insert(validator_stash, server_info.clone()); ThresholdToStash::::insert(&server_info.tss_account, validator_stash); IsValidatorSynced::::insert(validator_stash, true); - Signers::::put(&self.inital_signers); } let refresh_info = RefreshInfo { @@ -234,20 +232,20 @@ pub mod pallet { }; ProactiveRefresh::::put(refresh_info); // mocks a signer rotation for tss new_reshare tests - if self.mock_signer_rotate { + if self.mock_signer_rotate.0 { + self.mock_signer_rotate + .clone() + .1 + .push(self.mock_signer_rotate.clone().2[0].clone()); NextSigners::::put(NextSignerInfo { - next_signers: self.inital_signers.clone(), + next_signers: self.mock_signer_rotate.clone().1, confirmations: vec![], }); ReshareData::::put(ReshareInfo { // To give enough time for test_reshare setup block_number: TEST_RESHARE_BLOCK_NUMBER.into(), - // Alice signer public key - new_signer: vec![ - 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, - 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, - ], + new_signer: self.mock_signer_rotate.clone().2[0].encode(), }) } } @@ -441,7 +439,7 @@ pub mod pallet { #[pallet::call_index(5)] #[pallet::weight(({ - ::WeightInfo::confirm_key_reshare_confirmed(SIGNING_PARTY_SIZE as u32) + ::WeightInfo::confirm_key_reshare_confirmed(TOTAL_SIGNERS as u32) .max(::WeightInfo::confirm_key_reshare_completed()) }, DispatchClass::Operational))] pub fn confirm_key_reshare(origin: OriginFor) -> DispatchResultWithPostInfo { diff --git a/pallets/staking/src/mock.rs b/pallets/staking/src/mock.rs index 6f1cd56fb..56f6646f2 100644 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -394,11 +394,9 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let pallet_staking_extension = pallet_staking_extension::GenesisConfig:: { // (ValidatorID, (AccountId, X25519PublicKey, TssServerURL)) 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, + mock_signer_rotate: (false, vec![], vec![]), }; - pallet_balances.assimilate_storage(&mut t).unwrap(); pallet_staking_extension.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index 43c98fa4f..d492b0283 100644 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -15,7 +15,7 @@ use crate::{ mock::*, tests::RuntimeEvent, Error, IsValidatorSynced, NextSignerInfo, NextSigners, - ServerInfo, ThresholdToStash, + ServerInfo, Signers, ThresholdToStash, }; use codec::Encode; use frame_support::{assert_noop, assert_ok}; @@ -241,6 +241,7 @@ fn it_will_not_allow_existing_tss_account_when_changing_threshold_account() { #[test] fn it_deletes_when_no_bond_left() { new_test_ext().execute_with(|| { + Signers::::put(vec![5, 6]); start_active_era(1); assert_ok!(FrameStaking::bond( RuntimeOrigin::signed(2), @@ -331,7 +332,7 @@ fn it_declares_synced() { fn it_tests_new_session_handler() { new_test_ext().execute_with(|| { // Start with current validators as 5 and 6 based off the Mock `GenesisConfig`. - + Signers::::put(vec![5, 6]); // no next signers at start assert_eq!(Staking::next_signers(), None); assert_eq!(Staking::reshare_data().block_number, 0, "Check reshare block start at zero"); @@ -376,6 +377,7 @@ fn it_tests_new_session_handler() { #[test] fn it_confirms_keyshare() { new_test_ext().execute_with(|| { + Signers::::put(vec![5, 6]); assert_noop!( Staking::confirm_key_reshare(RuntimeOrigin::signed(10)), Error::::NoThresholdKey