diff --git a/crates/shared/src/constants.rs b/crates/shared/src/constants.rs index a34a547ac..45067173e 100644 --- a/crates/shared/src/constants.rs +++ b/crates/shared/src/constants.rs @@ -33,7 +33,7 @@ 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; +pub const TOTAL_SIGNERSZE: 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..78e37a446 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_SIGNERSZE, }; use futures::{ channel::mpsc, diff --git a/node/cli/src/chain_spec/dev.rs b/node/cli/src/chain_spec/dev.rs index 4db7b650a..1383ba8db 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![]), }, "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..eb9c81123 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::>()), }, "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..42c6e98b0 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![]), }, "elections": ElectionsConfig { members: endowed_accounts diff --git a/pallets/propagation/src/mock.rs b/pallets/propagation/src/mock.rs index 8cbcfa987..48daa1891 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![]), }; pallet_staking_extension.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index 12eaf5b36..945a70e03 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_SIGNERSZE, VERIFICATION_KEY_LENGTH}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ traits::{Currency, Get}, @@ -79,20 +79,20 @@ benchmarks! { } confirm_jump_start_done { - let c in 0 .. SIGNING_PARTY_SIZE as u32; + let c in 0 .. TOTAL_SIGNERSZE 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_SIGNERSZE { 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_SIGNERSZE as u32, 0); >::set(validators.clone()); - for i in 0..SIGNING_PARTY_SIZE { + for i in 0..TOTAL_SIGNERSZE { >::insert(accounts[i].clone(), &validators[i]); } @@ -111,15 +111,15 @@ benchmarks! { } confirm_jump_start_confirm { - let c in 0 .. SIGNING_PARTY_SIZE as u32; + let c in 0 .. TOTAL_SIGNERSZE 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_SIGNERSZE { + let validators = add_non_syncing_validators::(TOTAL_SIGNERSZE as u32, 0); >::set(validators.clone()); >::insert(&threshold_account, &validators[i]); } diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 38522eee7..75e6d3452 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_SIGNERSZE, 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_SIGNERSZE as u32) + .max(::WeightInfo::confirm_jump_start_done(TOTAL_SIGNERSZE 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_SIGNERSZE - 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..e8247cab9 100644 --- a/pallets/registry/src/mock.rs +++ b/pallets/registry/src/mock.rs @@ -365,8 +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], + mock_signer_rotate: (false, vec![]), }; pallet_staking_extension.assimilate_storage(&mut t).unwrap(); diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index 4a2def60d..63133bd30 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -197,6 +197,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], + "Jumpstart sets inital signers" + ); }); } diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index d03baf608..d8378d225 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_SIGNERSZE; 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_SIGNERSZE 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_SIGNERSZE - 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_SIGNERSZE - 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..eb5719e9a 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, TOTAL_SIGNERSZE, TEST_RESHARE_BLOCK_NUMBER, }; 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, + pub mock_signer_rotate: (bool, 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,9 +232,9 @@ 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 { NextSigners::::put(NextSignerInfo { - next_signers: self.inital_signers.clone(), + next_signers: self.mock_signer_rotate.clone().1, confirmations: vec![], }); @@ -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_SIGNERSZE 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..49529d159 100644 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -394,9 +394,8 @@ 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![]), }; pallet_balances.assimilate_storage(&mut t).unwrap();