diff --git a/Cargo.lock b/Cargo.lock index b999cb586..b858128d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2782,7 +2782,6 @@ dependencies = [ "num", "parity-scale-codec", "project-root", - "rand", "rand_core 0.6.4", "reqwest", "reqwest-eventsource", @@ -14042,7 +14041,7 @@ dependencies = [ [[package]] name = "synedrion" version = "0.1.0" -source = "git+https://github.com/entropyxyz/synedrion/?rev=1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa#1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa" +source = "git+https://github.com/entropyxyz/synedrion?rev=1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa#1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa" dependencies = [ "base64 0.21.7", "bincode 2.0.0-rc.3", diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 3e27b4803..a32b1624a 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -268,8 +268,12 @@ pub mod pallet { origin: OriginFor, verifying_key: VerifyingKey, ) -> DispatchResultWithPostInfo { - // Chack that the confirmation is coming from one of the selected validators let ts_server_account = ensure_signed(origin)?; + let validator_stash = + pallet_staking_extension::Pallet::::threshold_to_stash(&ts_server_account) + .ok_or(Error::::NoThresholdKey)?; + + // Check that the confirmation is coming from one of the selected validators let (_block_number, selected_validators) = JumpstartDkg::::iter().last().ok_or(Error::::JumpStartNotInProgress)?; let selected_validators: Vec<_> = @@ -295,10 +299,6 @@ pub mod pallet { Error::::JumpStartNotInProgress ); - let validator_stash = - pallet_staking_extension::Pallet::::threshold_to_stash(&ts_server_account) - .ok_or(Error::::NoThresholdKey)?; - ensure!( !jump_start_info.confirmations.contains(&validator_stash), Error::::AlreadyConfirmed diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index 77a6517bb..96c00ca75 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -16,8 +16,7 @@ #[allow(unused)] use pallet_registry::Call as RegistryCall; -use codec::Encode; -use entropy_shared::{NETWORK_PARENT_KEY, VERIFICATION_KEY_LENGTH}; +use entropy_shared::{ValidatorInfo, VERIFICATION_KEY_LENGTH}; use frame_support::{assert_noop, assert_ok, BoundedVec}; use pallet_programs::ProgramInfo; use pallet_staking_extension::{JumpStartDetails, JumpStartProgress, JumpStartStatus, ServerInfo}; @@ -300,7 +299,23 @@ fn it_jumps_the_network() { assert_ok!(Registry::jump_start_network(RuntimeOrigin::signed(1))); assert_eq!( Registry::jumpstart_dkg(0), - vec![NETWORK_PARENT_KEY.encode()], + vec![ + ValidatorInfo { + x25519_public_key: [0; 32], + ip_address: vec![20], + tss_account: vec![7, 0, 0, 0, 0, 0, 0, 0] + }, + ValidatorInfo { + x25519_public_key: [0; 32], + ip_address: vec![10], + tss_account: vec![3, 0, 0, 0, 0, 0, 0, 0] + }, + ValidatorInfo { + x25519_public_key: [0; 32], + ip_address: vec![11], + tss_account: vec![4, 0, 0, 0, 0, 0, 0, 0] + }, + ], "ensures a dkg message for the jump start network is prepped" ); assert_eq!( @@ -344,20 +359,20 @@ fn it_tests_jump_start_result() { Registry::confirm_jump_start(RuntimeOrigin::signed(1), expected_verifying_key.clone()), Error::::NoThresholdKey ); - pallet_staking_extension::ThresholdToStash::::insert(1, 1); + pallet_staking_extension::ThresholdToStash::::insert(1, 1); pallet_staking_extension::ThresholdToStash::::insert(7, 7); - assert_noop!( - Registry::confirm_jump_start(RuntimeOrigin::signed(7), expected_verifying_key.clone()), - Error::::NotValidator - ); - assert_noop!( Registry::confirm_jump_start(RuntimeOrigin::signed(1), expected_verifying_key.clone()), Error::::JumpStartNotInProgress ); + // trigger jump start assert_ok!(Registry::jump_start_network(RuntimeOrigin::signed(1))); + assert_noop!( + Registry::confirm_jump_start(RuntimeOrigin::signed(1), expected_verifying_key.clone()), + Error::::NotValidator + ); assert_ok!(Registry::confirm_jump_start( RuntimeOrigin::signed(1),