diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ff3d7bb4..72ef94fb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,11 @@ At the moment this project **does not** adhere to structure, and the `NodeInfoChanged` event were removed from the Staking Extension pallet. The `AttestationHandler` config type was added to the Staking Extension pallet. The `KeyProvider` and `AttestationQueue` config types were removed from the Attestation pallet. - +- In [#1134](https://github.com/entropyxyz/entropy-core/pull/1134/) the ```no-sync``` option was removed ### Changed - Use correct key rotation endpoint in OCW ([#1104](https://github.com/entropyxyz/entropy-core/pull/1104)) - Change attestation flow to be pull based ([#1109](https://github.com/entropyxyz/entropy-core/pull/1109/)) +- Remove declare synced ([#1134](https://github.com/entropyxyz/entropy-core/pull/1134/)) ## [0.3.0-rc.1](https://github.com/entropyxyz/entropy-core/compare/release/v0.2.0...release/v0.3.0-rc.1) - 2024-10-04 diff --git a/crates/client/entropy_metadata.scale b/crates/client/entropy_metadata.scale index a49f28a02..c2927b48e 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/helpers/launch.rs b/crates/threshold-signature-server/src/helpers/launch.rs index 8f5a98042..444d98f62 100644 --- a/crates/threshold-signature-server/src/helpers/launch.rs +++ b/crates/threshold-signature-server/src/helpers/launch.rs @@ -153,16 +153,6 @@ pub async fn load_kv_store( #[derive(Parser, Debug, Clone)] #[command(about, version)] pub struct StartupArgs { - /// Indicates that a Threshold server **should not** ask its peers for key-share data. - /// - /// This is useful to avoid in cases where: - /// - /// - The network is being bootstrapped and peers don't have any useful data yet. - /// - /// - There is outdated information about peers (e.g, outdated IP addresses coming from the - /// on-chain registry) and we don't want to sync outdated key-shares. - #[arg(short = 's', long = "no-sync")] - pub no_sync: bool, /// Use the developer key Bob. #[arg(short = 'b', long = "bob")] pub bob: bool, diff --git a/docker-compose.yaml b/docker-compose.yaml index 7656c0988..c5c1c8a71 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -27,7 +27,6 @@ services: - "0.0.0.0:3001" - "--chain-endpoint" - "ws://alice-chain-node:9944" - - "--no-sync" # In a local devnet setup, for now, this is "Alice's chain." alice-chain-node: @@ -64,7 +63,6 @@ services: - "0.0.0.0:3002" - "--chain-endpoint" - "ws://bob-chain-node:9944" - - "--no-sync" # "Bob's chain node." bob-chain-node: @@ -102,7 +100,6 @@ services: - "0.0.0.0:3003" - "--chain-endpoint" - "ws://charlie-chain-node:9944" - - "--no-sync" # "Charlie's chain node." charlie-chain-node: @@ -140,7 +137,6 @@ services: - "0.0.0.0:3004" - "--chain-endpoint" - "ws://dave-chain-node:9944" - - "--no-sync" # "Dave's chain node." dave-chain-node: diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index 79e2c7710..dee1c07f2 100644 --- a/pallets/registry/src/benchmarking.rs +++ b/pallets/registry/src/benchmarking.rs @@ -25,8 +25,8 @@ use frame_system::{EventRecord, RawOrigin}; use pallet_programs::{ProgramInfo, Programs}; use pallet_session::Validators; use pallet_staking_extension::{ - benchmarking::create_validators, IsValidatorSynced, JumpStartDetails, JumpStartProgress, - JumpStartStatus, ServerInfo, ThresholdServers, ThresholdToStash, + benchmarking::create_validators, JumpStartDetails, JumpStartProgress, JumpStartStatus, + ServerInfo, ThresholdServers, ThresholdToStash, }; use sp_runtime::traits::Hash; use sp_std::{vec, vec::Vec}; @@ -46,9 +46,8 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { assert_eq!(event, &system_event); } -pub fn add_non_syncing_validators( +pub fn add_validators( validator_amount: u32, - syncing_validators: u32, ) -> Vec<::ValidatorId> { let validators = create_validators::(validator_amount, SEED); let account = account::("ts_account", 1, SEED); @@ -58,14 +57,8 @@ pub fn add_non_syncing_validators( endpoint: vec![20], provisioning_certification_key: BoundedVec::with_max_capacity(), }; - for (c, validator) in validators.iter().enumerate() { + for validator in &validators { >::insert(validator, server_info.clone()); - if c >= syncing_validators.try_into().unwrap() { - >::insert(validator, true); - } - } - if syncing_validators == validator_amount { - >::insert(&validators[0], true); } validators } @@ -93,7 +86,7 @@ benchmarks! { accounts.push(account::("ts_account", i as u32, SEED)); } - let validators = add_non_syncing_validators::(MAX_SIGNERS as u32, 0); + let validators = add_validators::(MAX_SIGNERS as u32); >::set(validators.clone()); for i in 0..MAX_SIGNERS { @@ -132,7 +125,7 @@ benchmarks! { // add validators for i in 0..MAX_SIGNERS { - let validators = add_non_syncing_validators::(MAX_SIGNERS as u32, 0); + let validators = add_validators::(MAX_SIGNERS as u32); >::set(validators.clone()); >::insert(&threshold_account, &validators[i as usize]); } diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index f7bddaac9..ab093c334 100644 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -336,16 +336,6 @@ benchmarks! { ); } - declare_synced { - let caller: T::AccountId = whitelisted_caller(); - let validator_id_res = ::ValidatorId::try_from(caller.clone()).or(Err(Error::::InvalidValidatorId)).unwrap(); - ThresholdToStash::::insert(caller.clone(), validator_id_res.clone()); - - }: _(RawOrigin::Signed(caller.clone()), true) - verify { - assert_last_event::(Event::::ValidatorSyncStatus(validator_id_res, true).into()); - } - confirm_key_reshare_confirmed { let c in 0 .. MAX_SIGNERS as u32; // leave a space for two as not to rotate and only confirm rotation diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index fab92e76e..0ee229299 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -172,17 +172,6 @@ pub mod pallet { pub type ThresholdToStash = StorageMap<_, Blake2_128Concat, T::AccountId, T::ValidatorId, OptionQuery>; - /// Tracks wether the validator's kvdb is synced using a stash key as an identifier - #[pallet::storage] - #[pallet::getter(fn is_validator_synced)] - pub type IsValidatorSynced = StorageMap< - _, - Blake2_128Concat, - ::ValidatorId, - bool, - ValueQuery, - >; - #[derive( Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen, Default, )] @@ -278,7 +267,6 @@ pub mod pallet { ThresholdServers::::insert(validator_stash, server_info.clone()); ThresholdToStash::::insert(&server_info.tss_account, validator_stash); - IsValidatorSynced::::insert(validator_stash, true); } let refresh_info = RefreshInfo { @@ -485,7 +473,6 @@ pub mod pallet { let server_info = ThresholdServers::::take(&validator_id).ok_or(Error::::NoThresholdKey)?; ThresholdToStash::::remove(&server_info.tss_account); - IsValidatorSynced::::remove(&validator_id); Self::deposit_event(Event::NodeInfoRemoved(controller)); } Ok(Some(::WeightInfo::withdraw_unbonded( @@ -559,19 +546,7 @@ pub mod pallet { Ok(()) } - /// Let a validator declare if their kvdb is synced or not synced - /// `synced`: State of validator's kvdb #[pallet::call_index(6)] - #[pallet::weight(::WeightInfo::declare_synced())] - pub fn declare_synced(origin: OriginFor, synced: bool) -> DispatchResult { - let who = ensure_signed(origin.clone())?; - let stash = Self::threshold_to_stash(who).ok_or(Error::::NoThresholdKey)?; - IsValidatorSynced::::insert(&stash, synced); - Self::deposit_event(Event::ValidatorSyncStatus(stash, synced)); - Ok(()) - } - - #[pallet::call_index(7)] #[pallet::weight(({ ::WeightInfo::confirm_key_reshare_confirmed(MAX_SIGNERS as u32) .max(::WeightInfo::confirm_key_reshare_completed()) diff --git a/pallets/staking/src/mock.rs b/pallets/staking/src/mock.rs index 6c593d622..58898d137 100644 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -385,7 +385,7 @@ impl pallet_parameters::Config for Test { } parameter_types! { - pub const MaxEndpointLength: u32 = 3; + pub const MaxEndpointLength: u32 = 25; } pub(crate) const VALID_QUOTE: [u8; 32] = [0; 32]; diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index c753ffc59..a1acf8ddc 100644 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -14,8 +14,7 @@ // along with this program. If not, see . use crate::{ - mock::*, tests::RuntimeEvent, Error, IsValidatorSynced, NextSignerInfo, NextSigners, - ServerInfo, Signers, ThresholdToStash, + mock::*, tests::RuntimeEvent, Error, NextSignerInfo, NextSigners, ServerInfo, Signers, }; use codec::Encode; use frame_support::{assert_noop, assert_ok}; @@ -49,8 +48,6 @@ fn basic_setup_works() { ); assert_eq!(Staking::threshold_to_stash(7).unwrap(), 5); assert_eq!(Staking::threshold_to_stash(8).unwrap(), 6); - assert!(Staking::is_validator_synced(5)); - assert!(Staking::is_validator_synced(6)); }); } @@ -84,7 +81,7 @@ fn it_takes_in_an_endpoint() { let server_info = ServerInfo { tss_account: 3, x25519_public_key: NULL_ARR, - endpoint: vec![20, 20, 20, 20], + endpoint: vec![20; 26], provisioning_certification_key: BoundedVec::with_max_capacity(), }; assert_noop!( @@ -325,8 +322,6 @@ fn it_deletes_when_no_bond_left() { VALID_QUOTE.to_vec(), )); - IsValidatorSynced::::insert(2, true); - let ServerInfo { tss_account, endpoint, .. } = Staking::threshold_server(2).unwrap(); assert_eq!(endpoint, vec![20]); assert_eq!(tss_account, 3); @@ -359,8 +354,6 @@ fn it_deletes_when_no_bond_left() { lock = Balances::locks(2); assert_eq!(lock[0].amount, 50); assert_eq!(lock.len(), 1); - // validator still synced - assert_eq!(Staking::is_validator_synced(2), true); let ServerInfo { tss_account, endpoint, .. } = Staking::threshold_server(2).unwrap(); assert_eq!(endpoint, vec![20]); @@ -377,8 +370,6 @@ fn it_deletes_when_no_bond_left() { assert_eq!(lock.len(), 0); assert_eq!(Staking::threshold_server(2), None); assert_eq!(Staking::threshold_to_stash(3), None); - // validator no longer synced - assert_eq!(Staking::is_validator_synced(2), false); assert_ok!(FrameStaking::bond( RuntimeOrigin::signed(7), @@ -425,21 +416,6 @@ fn it_deletes_when_no_bond_left() { }); } -#[test] -fn it_declares_synced() { - new_test_ext().execute_with(|| { - assert_noop!( - Staking::declare_synced(RuntimeOrigin::signed(5), true), - Error::::NoThresholdKey - ); - - ThresholdToStash::::insert(5, 5); - - assert_ok!(Staking::declare_synced(RuntimeOrigin::signed(5), true)); - assert!(Staking::is_validator_synced(5)); - }); -} - #[test] fn it_tests_new_session_handler() { new_test_ext().execute_with(|| { diff --git a/pallets/staking/src/weights.rs b/pallets/staking/src/weights.rs index 5faf7880e..f04bfbe25 100644 --- a/pallets/staking/src/weights.rs +++ b/pallets/staking/src/weights.rs @@ -58,7 +58,6 @@ pub trait WeightInfo { fn unbond(c: u32, n: u32) -> Weight; fn withdraw_unbonded(c: u32, n: u32) -> Weight; fn validate() -> Weight; - fn declare_synced() -> Weight; fn confirm_key_reshare_confirmed(c: u32) -> Weight; fn confirm_key_reshare_completed() -> Weight; fn new_session_base_weight(s: u32) -> Weight; @@ -254,19 +253,6 @@ impl WeightInfo for SubstrateWeight { } /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::IsValidatorSynced` (r:0 w:1) - /// Proof: `StakingExtension::IsValidatorSynced` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn declare_synced() -> Weight { - // Proof Size summary in bytes: - // Measured: `285` - // Estimated: `3750` - // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3750) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// 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]`. @@ -529,19 +515,6 @@ impl WeightInfo for () { } /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::IsValidatorSynced` (r:0 w:1) - /// Proof: `StakingExtension::IsValidatorSynced` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn declare_synced() -> Weight { - // Proof Size summary in bytes: - // Measured: `285` - // Estimated: `3750` - // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3750) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// 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]`. diff --git a/runtime/src/weights/pallet_staking_extension.rs b/runtime/src/weights/pallet_staking_extension.rs index d64f3336d..2bc199b58 100644 --- a/runtime/src/weights/pallet_staking_extension.rs +++ b/runtime/src/weights/pallet_staking_extension.rs @@ -240,20 +240,6 @@ impl pallet_staking_extension::WeightInfo for WeightInf } /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::IsValidatorSynced` (r:0 w:1) - /// Proof: `StakingExtension::IsValidatorSynced` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn declare_synced() -> Weight { - // Proof Size summary in bytes: - // Measured: `353` - // Estimated: `3818` - // Minimum execution time: 16_110_000 picoseconds. - Weight::from_parts(16_488_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::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, 15]`.