Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove declare synced #1134

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file modified crates/client/entropy_metadata.scale
Binary file not shown.
10 changes: 0 additions & 10 deletions crates/threshold-signature-server/src/helpers/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 6 additions & 13 deletions pallets/registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -46,9 +46,8 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
assert_eq!(event, &system_event);
}

pub fn add_non_syncing_validators<T: Config>(
pub fn add_validators<T: Config>(
validator_amount: u32,
syncing_validators: u32,
) -> Vec<<T as pallet_session::Config>::ValidatorId> {
let validators = create_validators::<T>(validator_amount, SEED);
let account = account::<T::AccountId>("ts_account", 1, SEED);
Expand All @@ -58,14 +57,8 @@ pub fn add_non_syncing_validators<T: Config>(
endpoint: vec![20],
provisioning_certification_key: BoundedVec::with_max_capacity(),
};
for (c, validator) in validators.iter().enumerate() {
for validator in &validators {
<ThresholdServers<T>>::insert(validator, server_info.clone());
if c >= syncing_validators.try_into().unwrap() {
<IsValidatorSynced<T>>::insert(validator, true);
}
}
if syncing_validators == validator_amount {
<IsValidatorSynced<T>>::insert(&validators[0], true);
}
validators
}
Expand Down Expand Up @@ -93,7 +86,7 @@ benchmarks! {
accounts.push(account::<T::AccountId>("ts_account", i as u32, SEED));
}

let validators = add_non_syncing_validators::<T>(MAX_SIGNERS as u32, 0);
let validators = add_validators::<T>(MAX_SIGNERS as u32);
<Validators<T>>::set(validators.clone());

for i in 0..MAX_SIGNERS {
Expand Down Expand Up @@ -132,7 +125,7 @@ benchmarks! {

// add validators
for i in 0..MAX_SIGNERS {
let validators = add_non_syncing_validators::<T>(MAX_SIGNERS as u32, 0);
let validators = add_validators::<T>(MAX_SIGNERS as u32);
<Validators<T>>::set(validators.clone());
<ThresholdToStash<T>>::insert(&threshold_account, &validators[i as usize]);
}
Expand Down
10 changes: 0 additions & 10 deletions pallets/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,6 @@ benchmarks! {
);
}

declare_synced {
let caller: T::AccountId = whitelisted_caller();
let validator_id_res = <T as pallet_session::Config>::ValidatorId::try_from(caller.clone()).or(Err(Error::<T>::InvalidValidatorId)).unwrap();
ThresholdToStash::<T>::insert(caller.clone(), validator_id_res.clone());

}: _(RawOrigin::Signed(caller.clone()), true)
verify {
assert_last_event::<T>(Event::<T>::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
Expand Down
25 changes: 0 additions & 25 deletions pallets/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,6 @@ pub mod pallet {
pub type ThresholdToStash<T: Config> =
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<T: Config> = StorageMap<
_,
Blake2_128Concat,
<T as pallet_session::Config>::ValidatorId,
bool,
ValueQuery,
>;

#[derive(
Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen, Default,
)]
Expand Down Expand Up @@ -278,7 +267,6 @@ pub mod pallet {

ThresholdServers::<T>::insert(validator_stash, server_info.clone());
ThresholdToStash::<T>::insert(&server_info.tss_account, validator_stash);
IsValidatorSynced::<T>::insert(validator_stash, true);
}

let refresh_info = RefreshInfo {
Expand Down Expand Up @@ -485,7 +473,6 @@ pub mod pallet {
let server_info =
ThresholdServers::<T>::take(&validator_id).ok_or(Error::<T>::NoThresholdKey)?;
ThresholdToStash::<T>::remove(&server_info.tss_account);
IsValidatorSynced::<T>::remove(&validator_id);
Self::deposit_event(Event::NodeInfoRemoved(controller));
}
Ok(Some(<T as Config>::WeightInfo::withdraw_unbonded(
Expand Down Expand Up @@ -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(<T as Config>::WeightInfo::declare_synced())]
pub fn declare_synced(origin: OriginFor<T>, synced: bool) -> DispatchResult {
let who = ensure_signed(origin.clone())?;
let stash = Self::threshold_to_stash(who).ok_or(Error::<T>::NoThresholdKey)?;
IsValidatorSynced::<T>::insert(&stash, synced);
Self::deposit_event(Event::ValidatorSyncStatus(stash, synced));
Ok(())
}

#[pallet::call_index(7)]
#[pallet::weight(({
<T as Config>::WeightInfo::confirm_key_reshare_confirmed(MAX_SIGNERS as u32)
.max(<T as Config>::WeightInfo::confirm_key_reshare_completed())
Expand Down
2 changes: 1 addition & 1 deletion pallets/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
28 changes: 2 additions & 26 deletions pallets/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

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};
Expand Down Expand Up @@ -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));
});
}

Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -325,8 +322,6 @@ fn it_deletes_when_no_bond_left() {
VALID_QUOTE.to_vec(),
));

IsValidatorSynced::<Test>::insert(2, true);

let ServerInfo { tss_account, endpoint, .. } = Staking::threshold_server(2).unwrap();
assert_eq!(endpoint, vec![20]);
assert_eq!(tss_account, 3);
Expand Down Expand Up @@ -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]);
Expand All @@ -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),
Expand Down Expand Up @@ -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::<Test>::NoThresholdKey
);

ThresholdToStash::<Test>::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(|| {
Expand Down
27 changes: 0 additions & 27 deletions pallets/staking/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,19 +253,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
}
/// 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]`.
Expand Down Expand Up @@ -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]`.
Expand Down
14 changes: 0 additions & 14 deletions runtime/src/weights/pallet_staking_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,6 @@ impl<T: frame_system::Config> 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]`.
Expand Down
Loading