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

feat: broadcast barrier #4207

Merged
merged 38 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d127712
feat: broadcast pause
ramizhasan111 Nov 6, 2023
5af74d7
feat: removed key locking and non-optimistic activation
ramizhasan111 Nov 7, 2023
d777537
fix: tests
ramizhasan111 Nov 8, 2023
078cded
Merge branch 'main' into feat/broadcast-pause
ramizhasan111 Nov 8, 2023
51c49b5
fix: bouncer prettier check
ramizhasan111 Nov 8, 2023
c2a2e20
feat: broadcast pause unit test
ramizhasan111 Nov 9, 2023
fe789b9
chore: comments
ramizhasan111 Nov 14, 2023
b42ef29
chore: test
ramizhasan111 Nov 14, 2023
06b7df2
chore: addressed comments
ramizhasan111 Nov 14, 2023
4d445bb
feat: use same broadcast_id for tx, chain-specific broadcast barriers
ramizhasan111 Nov 17, 2023
56dbec5
chore: reinstate test
ramizhasan111 Nov 20, 2023
2d3cdc5
feat: storage migration
ramizhasan111 Nov 20, 2023
1bd142b
Merge branch 'main' into feat/broadcast-pause
ramizhasan111 Nov 20, 2023
41a7f08
fix: check for all broadcasts before the barrier
ramizhasan111 Nov 21, 2023
24de28d
feat: more tests, test fixes
ramizhasan111 Nov 22, 2023
0852b66
chore: addressed comments
ramizhasan111 Nov 22, 2023
7efd2e5
feat: on_sig_ready call migration
ramizhasan111 Nov 29, 2023
dd513d1
Merge branch 'main' into feat/broadcast-pause
ramizhasan111 Nov 29, 2023
51f014b
fix: vec import for tr-runtime
ramizhasan111 Nov 29, 2023
d9a0be7
fix: use only specific key for signing
ramizhasan111 Nov 29, 2023
ba13b6b
chore: addressed comments
ramizhasan111 Nov 29, 2023
c267707
fix: only add barriers if there are already pending txs before it
ramizhasan111 Nov 30, 2023
c9daf2d
feat: remove aborted broadcasts from pending
ramizhasan111 Dec 1, 2023
20fd42a
chore: remove CurrentKey variant in RequestType
ramizhasan111 Dec 1, 2023
455ebcf
Merge branch 'main' into feat/broadcast-pause
dandanlen Dec 1, 2023
7ddeea6
fix: all tests passing (bouncer tbc)
dandanlen Dec 2, 2023
0c056b5
fix: remove defenisve_proof
dandanlen Dec 4, 2023
dd06205
fix: always remove barrier with pending broadcast
dandanlen Dec 4, 2023
6f3ff2a
chore: readability
dandanlen Dec 4, 2023
5ce1a17
fix: typo
dandanlen Dec 4, 2023
6abf06f
fix: use BTreeSet to avoid duplicates.
dandanlen Dec 4, 2023
8b46d1a
fix: check attempt count >= not ==
dandanlen Dec 4, 2023
7267a8b
test: test that the broadcast is aborted when all broadcasters attempt
kylezs Dec 4, 2023
4cb5d89
Merge branch 'main' into feat/broadcast-pause
dandanlen Dec 4, 2023
558a57a
fix: simplify signature refresh logic
dandanlen Dec 4, 2023
7a0ab45
fix: add PendingBroadcast migration
dandanlen Dec 4, 2023
43d44eb
fix: migrations
kylezs Dec 4, 2023
cd84ee0
fix: use correct spec version
kylezs Dec 5, 2023
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
2 changes: 1 addition & 1 deletion state-chain/pallets/cf-vaults/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod migrations;
mod mock;
mod tests;

pub const PALLET_VERSION: StorageVersion = StorageVersion::new(2);
pub const PALLET_VERSION: StorageVersion = StorageVersion::new(3);

const KEYGEN_CEREMONY_RESPONSE_TIMEOUT_BLOCKS_DEFAULT: u32 = 90;

Expand Down
7 changes: 5 additions & 2 deletions state-chain/pallets/cf-vaults/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pub mod v2;
pub mod v3;

use cf_runtime_upgrade_utilities::VersionedMigration;

pub type PalletMigration<T, I> =
(VersionedMigration<crate::Pallet<T, I>, v2::Migration<T, I>, 1, 2>,);
pub type PalletMigration<T, I> = (
ramizhasan111 marked this conversation as resolved.
Show resolved Hide resolved
VersionedMigration<crate::Pallet<T, I>, v2::Migration<T, I>, 1, 2>,
VersionedMigration<crate::Pallet<T, I>, v2::Migration<T, I>, 2, 3>,
);
63 changes: 63 additions & 0 deletions state-chain/pallets/cf-vaults/src/migrations/v3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::*;

#[cfg(feature = "try-runtime")]
use frame_support::dispatch::DispatchError;
use frame_support::traits::OnRuntimeUpgrade;
use sp_std::marker::PhantomData;

/// v2 migrating storage item KeygenSlashRate -> KeygenSlashAmount
/// Percent -> FlipBalance
pub struct Migration<T: Config<I>, I: 'static>(PhantomData<(T, I)>);

mod old {

use super::*;

#[derive(Debug, TypeInfo, Decode, Encode, Clone, Copy, PartialEq, Eq)]
pub enum KeyState {
Unlocked,
/// Key is only available to sign this request id.
Locked(ThresholdSignatureRequestId),
}
#[derive(Encode, Decode, TypeInfo)]
pub struct VaultEpochAndState {
pub epoch_index: EpochIndex,
pub key_state: KeyState,
}

#[frame_support::storage_alias]
pub type CurrentVaultEpochAndState<T: Config<I>, I: 'static> =
StorageValue<Pallet<T, I>, VaultEpochAndState>;
}

impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
// remove the old storage containing Percent
if let Some(old::VaultEpochAndState { epoch_index, key_state: _ }) =
old::CurrentVaultEpochAndState::<T, I>::take()
{
// set the new storage using the EpochIndex from the old storage item above.
CurrentVaultEpoch::<T, I>::put(epoch_index);
}

Weight::zero()
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
// just check that the old storage item existed
Ok(old::CurrentVaultEpochAndState::<T, I>::exists().encode())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError> {
let old_state = <old::VaultEpochAndState>::decode(&mut &state[..])
.map_err(|_| "Failed to decode pre-upgrade state.")?;

assert!(!old::CurrentVaultEpochAndState::<T, I>::exists());
assert!(CurrentVaultEpoch::<T, I>::exists());
assert_eq!(old_state.epoch_index, CurrentVaultEpoch::<T, I>::get().unwrap());

Ok(())
}
}