diff --git a/pallets/slow-clap/Cargo.toml b/pallets/slow-clap/Cargo.toml index f41da26..3cc1748 100644 --- a/pallets/slow-clap/Cargo.toml +++ b/pallets/slow-clap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghost-slow-clap" -version = "0.4.0" +version = "0.4.1" description = "Applause protocol for the EVM bridge" license.workspace = true authors.workspace = true diff --git a/pallets/slow-clap/src/bitmap.rs b/pallets/slow-clap/src/bitmap.rs index 9e17c80..843df57 100644 --- a/pallets/slow-clap/src/bitmap.rs +++ b/pallets/slow-clap/src/bitmap.rs @@ -24,7 +24,11 @@ impl BitMap { buckets.insert(bucket_id, 0); } - BitMap { buckets, max_length, max_value } + BitMap { + buckets, + max_length, + max_value, + } } pub fn size_of_bucket() -> u32 { @@ -66,7 +70,8 @@ impl BitMap { } pub fn count_ones(&self) -> u32 { - let zeros: u32 = self.iter_buckets() + let zeros: u32 = self + .iter_buckets() .map(|(_, bucket)| bucket.count_zeros()) .sum(); let total_bits = self.total_bits(); @@ -85,7 +90,7 @@ impl BitMap { .entry(key) .and_modify(|lhs_value| *lhs_value |= rhs_value) .or_insert(rhs_value); - } + } base } diff --git a/pallets/slow-clap/src/lib.rs b/pallets/slow-clap/src/lib.rs index 0196b4c..d550004 100644 --- a/pallets/slow-clap/src/lib.rs +++ b/pallets/slow-clap/src/lib.rs @@ -39,11 +39,11 @@ use sp_staking::{ }; use sp_std::{collections::btree_map::BTreeMap, prelude::*, vec::Vec}; -use ghost_traits::exposure::ExposureListener; use ghost_networks::{ NetworkData, NetworkDataBasicHandler, NetworkDataInspectHandler, NetworkDataMutateHandler, NetworkType, }; +use ghost_traits::exposure::ExposureListener; pub mod weights; pub use crate::weights::WeightInfo; @@ -51,12 +51,12 @@ mod benchmarking; mod mock; mod tests; +mod bitmap; mod deserialisations; mod evm_types; -mod bitmap; +use bitmap::{BitMap, Bucket}; use evm_types::{EvmResponse, EvmResponseType}; -use bitmap::{Bucket, BitMap}; pub mod sr25519 { mod app_sr25519 { @@ -76,12 +76,12 @@ pub mod sr25519 { const LOG_TARGET: &str = "runtime::ghost-slow-clap"; const DB_PREFIX: &[u8] = b"slow_clap::"; -const MIN_LOCK_GUARD_PERIOD: u64 = 15_000; -const FETCH_TIMEOUT_PERIOD: u64 = 3_000; -const LOCK_BLOCK_EXPIRATION: u64 = 20; +const MIN_LOCK_GUARD_PERIOD: u64 = 15_000; +const FETCH_TIMEOUT_PERIOD: u64 = 3_000; +const LOCK_BLOCK_EXPIRATION: u64 = 20; const COMMITMENT_DELAY_MILLIS: u64 = 600_000; -const ONE_HOUR_MILLIS: u64 = 3_600_000; +const ONE_HOUR_MILLIS: u64 = 3_600_000; pub type AuthIndex = u32; @@ -355,13 +355,8 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn latest_executed_block)] - pub(super) type LatestExecutedBlock = StorageMap< - _, - Twox64Concat, - NetworkIdOf, - u64, - ValueQuery, - >; + pub(super) type LatestExecutedBlock = + StorageMap<_, Twox64Concat, NetworkIdOf, u64, ValueQuery>; #[pallet::storage] #[pallet::getter(fn block_commitments)] @@ -382,18 +377,13 @@ pub mod pallet { Twox64Concat, H256, ApplauseDetail, BalanceOf>, - OptionQuery + OptionQuery, >; #[pallet::storage] #[pallet::getter(fn disabled_authority_indexes)] - pub(super) type DisabledAuthorityIndexes = StorageMap< - _, - Twox64Concat, - SessionIndex, - BitMap, - OptionQuery, - >; + pub(super) type DisabledAuthorityIndexes = + StorageMap<_, Twox64Concat, SessionIndex, BitMap, OptionQuery>; #[pallet::storage] #[pallet::getter(fn authorities)] @@ -480,16 +470,21 @@ pub mod pallet { type Call = Call; fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { match call { - Call::commit_block { block_commitment, signature } => { + Call::commit_block { + block_commitment, + signature, + } => { let session_index = block_commitment.session_index; let authority_index = block_commitment.authority_index; match Authorities::::get(&session_index).get(authority_index as usize) { Some(authority) => { - if !block_commitment.using_encoded(|encoded| authority.verify(&encoded, signature)) { + if !block_commitment + .using_encoded(|encoded| authority.verify(&encoded, signature)) + { return InvalidTransaction::BadProof.into(); } - }, + } None => return InvalidTransaction::BadSigner.into(), } @@ -505,10 +500,11 @@ pub mod pallet { match Authorities::::get(&session_index).get(clap.authority_index as usize) { Some(authority) => { - if !clap.using_encoded(|encoded| authority.verify(&encoded, signature)) { + if !clap.using_encoded(|encoded| authority.verify(&encoded, signature)) + { return InvalidTransaction::BadProof.into(); } - }, + } None => return InvalidTransaction::BadSigner.into(), } @@ -583,18 +579,22 @@ impl Pallet { let prev_session_index = clap.session_index.saturating_sub(1); let clap_unique_hash = Self::generate_unique_hash(&clap); - let session_index = if ApplauseDetails::::get(&prev_session_index, &clap_unique_hash).is_some() { - prev_session_index - } else { - clap.session_index - }; + let session_index = + if ApplauseDetails::::get(&prev_session_index, &clap_unique_hash).is_some() { + prev_session_index + } else { + clap.session_index + }; (session_index, clap_unique_hash) } fn try_slow_clap(clap: &Clap, BalanceOf>) -> DispatchResult { let network_id = clap.network_id; - ensure!(T::NetworkDataHandler::get(&network_id).is_some(), Error::::UnregistedNetwork); + ensure!( + T::NetworkDataHandler::get(&network_id).is_some(), + Error::::UnregistedNetwork + ); let (session_index, clap_unique_hash) = Self::mended_session_index(&clap); let authorities_length = Authorities::::get(&session_index).len(); @@ -607,20 +607,19 @@ impl Pallet { let applause_threshold = Perbill::from_parts(T::ApplauseThreshold::get()); let threshold_amount = applause_threshold.mul_floor(TotalExposure::::get()); - let new_clapped_amount = T::ExposureListener::get_validator_exposure( - clap.authority_index, - ); + let new_clapped_amount = T::ExposureListener::get_validator_exposure(clap.authority_index); - let mut applause_details = match ApplauseDetails::::take(&session_index, &clap_unique_hash) { - Some(applause_details) => applause_details, - None => { - ensure!( - LatestExecutedBlock::::get(&network_id) <= clap.block_number, - Error::::ExecutedBlockIsHigher, - ); - ApplauseDetail::new(network_id, clap.block_number, authorities_length) - } - }; + let mut applause_details = + match ApplauseDetails::::take(&session_index, &clap_unique_hash) { + Some(applause_details) => applause_details, + None => { + ensure!( + LatestExecutedBlock::::get(&network_id) <= clap.block_number, + Error::::ExecutedBlockIsHigher, + ); + ApplauseDetail::new(network_id, clap.block_number, authorities_length) + } + }; let total_clapped = if clap.removed { ensure!( @@ -628,14 +627,18 @@ impl Pallet { Error::::UnregisteredClapRemove, ); applause_details.authorities.unset(clap.authority_index); - applause_details.clapped_amount.saturating_sub(new_clapped_amount) + applause_details + .clapped_amount + .saturating_sub(new_clapped_amount) } else { ensure!( !applause_details.authorities.exists(&clap.authority_index), Error::::AlreadyClapped, ); applause_details.authorities.set(clap.authority_index); - applause_details.clapped_amount.saturating_add(new_clapped_amount) + applause_details + .clapped_amount + .saturating_add(new_clapped_amount) }; applause_details.clapped_amount = total_clapped; @@ -649,7 +652,8 @@ impl Pallet { removed: clap.removed, }); - let is_enough = applause_details.authorities + let is_enough = applause_details + .authorities .count_ones() .gt(&(authorities_length as u32 / 2)); @@ -690,7 +694,7 @@ impl Pallet { network_id: clap.network_id, receiver: clap.receiver.clone(), received_amount: final_amount, - block_number: clap.block_number + block_number: clap.block_number, }); Ok(()) @@ -699,30 +703,36 @@ impl Pallet { fn try_commit_block(new_commitment: &BlockCommitment>) -> DispatchResult { let authority_index = new_commitment.authority_index; let network_id = new_commitment.network_id; - ensure!(T::NetworkDataHandler::get(&network_id).is_some(), Error::::UnregistedNetwork); + ensure!( + T::NetworkDataHandler::get(&network_id).is_some(), + Error::::UnregistedNetwork + ); - let current_commits = BlockCommitments::::try_mutate(&network_id, |current_commitments| -> Result { - let mut new_commitment_details = new_commitment.commitment; + let current_commits = BlockCommitments::::try_mutate( + &network_id, + |current_commitments| -> Result { + let mut new_commitment_details = new_commitment.commitment; - let (current_commits, current_last_updated) = current_commitments - .get(&authority_index) - .map(|details| (details.commits + 1, details.last_updated)) - .unwrap_or((1, 0)); + let (current_commits, current_last_updated) = current_commitments + .get(&authority_index) + .map(|details| (details.commits + 1, details.last_updated)) + .unwrap_or((1, 0)); - ensure!( - new_commitment_details.last_updated > current_last_updated, - Error::::TimeWentBackwards - ); + ensure!( + new_commitment_details.last_updated > current_last_updated, + Error::::TimeWentBackwards + ); - new_commitment_details.commits = current_commits; - current_commitments.insert(authority_index, new_commitment_details); + new_commitment_details.commits = current_commits; + current_commitments.insert(authority_index, new_commitment_details); - Ok(current_commits) - })?; + Ok(current_commits) + }, + )?; Self::deposit_event(Event::::BlockCommited { network_id, - authority_id: authority_index + authority_id: authority_index, }); let session_index = T::ValidatorSet::session_index(); @@ -733,10 +743,11 @@ impl Pallet { .unwrap_or(BitMap::new(validators.len() as u32)); let max_block_deviation = T::NetworkDataHandler::get(&network_id) - .map(|network| ONE_HOUR_MILLIS - .saturating_mul(6) - .saturating_div(network.avg_block_speed) - ) + .map(|network| { + ONE_HOUR_MILLIS + .saturating_mul(6) + .saturating_div(network.avg_block_speed) + }) .unwrap_or_default(); if current_commits > 1 { @@ -1016,7 +1027,7 @@ impl Pallet { Authorities::::get(&session_index).is_empty(), "Authorities are already initilized!" ); - + let authorities_len = authorities.len(); let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities) .expect("more than the maximum number of authorities"); @@ -1086,7 +1097,10 @@ impl Pallet { let mut time_updates: Vec<(AuthIndex, u64)> = Vec::new(); for authority_index in 0..validators_len { - let data = block_commitments.get(&authority_index).copied().unwrap_or_default(); + let data = block_commitments + .get(&authority_index) + .copied() + .unwrap_or_default(); stored_blocks.push((authority_index, data.last_stored_block)); time_updates.push((authority_index, data.last_updated)); } @@ -1094,8 +1108,20 @@ impl Pallet { let stored_block_median = Self::calculate_weighted_median(&mut stored_blocks); let time_update_median = Self::calculate_weighted_median(&mut time_updates); - Self::apply_median_deviation(&mut delayed, disabled_bitmap, &stored_blocks, stored_block_median, max_block_deviation); - Self::apply_median_deviation(&mut delayed, disabled_bitmap, &time_updates, time_update_median, ONE_HOUR_MILLIS); + Self::apply_median_deviation( + &mut delayed, + disabled_bitmap, + &stored_blocks, + stored_block_median, + max_block_deviation, + ); + Self::apply_median_deviation( + &mut delayed, + disabled_bitmap, + &time_updates, + time_update_median, + ONE_HOUR_MILLIS, + ); delayed } @@ -1134,11 +1160,10 @@ impl Pallet { } missed_validators.set(position.into()); - missed_percent = missed_percent - .saturating_add(Perbill::from_rational( - total_exposure.saturating_sub(clapped_amount), - total_exposure, - )); + missed_percent = missed_percent.saturating_add(Perbill::from_rational( + total_exposure.saturating_sub(clapped_amount), + total_exposure, + )); } } } @@ -1169,10 +1194,8 @@ impl Pallet { .collect::>>(); let not_enough_validators_left = validator_set_count - .saturating_sub(disabled_bitmap - .bitor(offence_bitmap) - .count_ones() - ).lt(&T::MinAuthoritiesNumber::get()); + .saturating_sub(disabled_bitmap.bitor(offence_bitmap).count_ones()) + .lt(&T::MinAuthoritiesNumber::get()); if not_enough_validators_left && offenders.len() > 0 { Self::deposit_event(Event::::BlackSwan); @@ -1189,10 +1212,12 @@ impl Pallet { } let offence_event = match offence_type { - OffenceType::CommitmentOffence => - Event::::SomeAuthoritiesDelayed { delayed: offenders.clone() }, - OffenceType::ThrottlingOffence(_) => - Event::::SomeAuthoritiesTrottling { throttling: offenders.clone() }, + OffenceType::CommitmentOffence => Event::::SomeAuthoritiesDelayed { + delayed: offenders.clone(), + }, + OffenceType::ThrottlingOffence(_) => Event::::SomeAuthoritiesTrottling { + throttling: offenders.clone(), + }, }; Self::deposit_event(offence_event); @@ -1201,7 +1226,7 @@ impl Pallet { validator_set_count, session_index: *session_index, offenders, - offence_type, + offence_type, }; if let Err(e) = T::ReportUnresponsiveness::report_offence(vec![], offence) { @@ -1328,13 +1353,15 @@ impl Offence for SlowClapOffence { fn slash_fraction(&self, offenders_count: u32) -> Perbill { match self.offence_type { - OffenceType::ThrottlingOffence(missed_percent) => missed_percent - .saturating_mul(Perbill::from_rational(1, offenders_count)), + OffenceType::ThrottlingOffence(missed_percent) => { + missed_percent.saturating_mul(Perbill::from_rational(1, offenders_count)) + } OffenceType::CommitmentOffence => offenders_count .checked_sub(self.validator_set_count / 10 + 1) - .map(|threshold| Perbill::from_rational(3 * threshold, self.validator_set_count) - .saturating_mul(Perbill::from_percent(7)) - ) + .map(|threshold| { + Perbill::from_rational(3 * threshold, self.validator_set_count) + .saturating_mul(Perbill::from_percent(7)) + }) .unwrap_or_default(), } } diff --git a/pallets/slow-clap/src/mock.rs b/pallets/slow-clap/src/mock.rs index 0eeab0c..cc7df50 100644 --- a/pallets/slow-clap/src/mock.rs +++ b/pallets/slow-clap/src/mock.rs @@ -20,7 +20,7 @@ use sp_staking::{ use sp_runtime::BuildStorage; use crate::{self as slow_clap, AuthIndex}; -use crate::{ExposureListener, Config, EraIndex}; +use crate::{Config, EraIndex, ExposureListener}; type Block = frame_system::mocking::MockBlock; diff --git a/pallets/slow-clap/src/tests.rs b/pallets/slow-clap/src/tests.rs index b697e63..5a56dac 100644 --- a/pallets/slow-clap/src/tests.rs +++ b/pallets/slow-clap/src/tests.rs @@ -38,8 +38,14 @@ fn should_calculate_throttling_slash_function_correctly() { assert_eq!(dummy_offence.slash_fraction(1), Perbill::zero()); assert_eq!(dummy_offence.slash_fraction(5), Perbill::zero()); - assert_eq!(dummy_offence.slash_fraction(7), Perbill::from_parts(4_200_000)); - assert_eq!(dummy_offence.slash_fraction(17), Perbill::from_parts(46_200_000)); + assert_eq!( + dummy_offence.slash_fraction(7), + Perbill::from_parts(4_200_000) + ); + assert_eq!( + dummy_offence.slash_fraction(17), + Perbill::from_parts(46_200_000) + ); } #[test] @@ -307,8 +313,8 @@ fn should_emit_offence_on_missed_clap() { System::assert_has_event(RuntimeEvent::SlowClap( crate::Event::SomeAuthoritiesTrottling { - throttling: vec![(0, 0)] - } + throttling: vec![(0, 0)], + }, )); }); } @@ -329,8 +335,8 @@ fn should_emit_offence_on_fake_clap() { System::assert_has_event(RuntimeEvent::SlowClap( crate::Event::SomeAuthoritiesTrottling { - throttling: vec![(0, 0), (1, 1)] - } + throttling: vec![(0, 0), (1, 1)], + }, )); }); } @@ -352,8 +358,8 @@ fn should_not_emit_offence_if_already_disabled() { System::assert_has_event(RuntimeEvent::SlowClap( crate::Event::SomeAuthoritiesTrottling { - throttling: vec![(1, 1)] - } + throttling: vec![(1, 1)], + }, )); }); } @@ -406,7 +412,8 @@ fn should_emit_authorities_equilibrium_if_no_deviation() { advance_session(); let binding = System::events(); - let number_of_events = binding.iter() + let number_of_events = binding + .iter() .filter(|x| { x.event == RuntimeEvent::SlowClap(crate::Event::AuthoritiesApplauseEquilibrium) }) @@ -425,18 +432,27 @@ fn should_clear_sesions_based_on_history_depth() { let session_index = advance_session_and_get_index(); prepare_evm_network(None, None); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); assert_ok!(do_clap_from(session_index, network_id, 0, false)); assert_ok!(do_clap_from(session_index, network_id, 1, false)); assert_ok!(do_clap_from(session_index, network_id, 2, false)); assert_ok!(do_clap_from(session_index, network_id, 3, false)); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash).is_some(), true); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash).is_some(), + true + ); for _ in 0..history_depth { advance_session(); } - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); }); } @@ -515,8 +531,8 @@ fn should_applause_and_take_next_claps() { assert_eq!(Balances::total_balance(&receiver), 0); for i in 0..=3 { assert_ok!(do_clap_from(session_index, network_id, i, false)); - clapped_amount = TestExposureListener::get_validator_exposure(i) - .saturating_add(clapped_amount); + clapped_amount = + TestExposureListener::get_validator_exposure(i).saturating_add(clapped_amount); assert_clapped_amount(&session_index, &unique_hash, clapped_amount); } assert_applaused(&session_index, &unique_hash); @@ -561,13 +577,17 @@ fn should_remove_clap_by_authority() { #[test] fn should_throw_error_if_executed_block_number_is_higher() { - let (network_id, block_number, unique_hash) = generate_unique_hash(None, None, None, None, None); + let (network_id, block_number, unique_hash) = + generate_unique_hash(None, None, None, None, None); new_test_ext().execute_with(|| { let session_index = advance_session_and_get_index(); prepare_evm_network(None, None); - assert_eq!(ApplauseDetails::::get(session_index, unique_hash), None); + assert_eq!( + ApplauseDetails::::get(session_index, unique_hash), + None + ); assert_ok!(do_clap_from(session_index, network_id, 0, false)); assert_ok!(do_clap_from(session_index, network_id, 1, false)); assert_ok!(do_clap_from(session_index, network_id, 2, false)); @@ -591,23 +611,32 @@ fn should_throw_error_if_validator_disabled_and_ignore_later() { let session_index = advance_session_and_get_index(); prepare_evm_network(None, None); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); assert_eq!(Session::disable_index(0), true); assert_err!( do_clap_from(session_index, network_id, 0, false), Error::::DisabledAuthority, ); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); advance_session(); - let session_index = session_index + 1; + let session_index = session_index + 1; assert_eq!(Session::disable_index(0), true); assert_err!( do_clap_from(session_index, network_id, 0, false), Error::::DisabledAuthority, ); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); }); } @@ -777,7 +806,10 @@ fn should_avoid_session_overlap_on_mended_session_index() { assert_ok!(do_clap_from(new_session_index, network_id, 2, false)); assert_eq!(Balances::total_balance(&receiver), amount); - assert_eq!(ApplauseDetails::::get(new_session_index, unique_hash), None); + assert_eq!( + ApplauseDetails::::get(new_session_index, unique_hash), + None + ); assert_applaused(&session_index, &unique_hash); assert_clapped(&session_index, &unique_hash, 0, true); @@ -810,7 +842,10 @@ fn should_emit_event_on_each_clap_and_on_applause() { let _ = prepare_evm_network(None, Some(100_000_000)); let session_index = advance_session_and_get_index(); - assert_eq!(ApplauseDetails::::get(&session_index, &unique_hash), None); + assert_eq!( + ApplauseDetails::::get(&session_index, &unique_hash), + None + ); for index in 0..2 { assert_ok!(do_clap_from(session_index, network_id, index, false)); System::assert_last_event(RuntimeEvent::SlowClap(crate::Event::Clapped { @@ -875,7 +910,10 @@ fn should_not_fail_on_sub_existential_balance() { assert_eq!(Networks::bridged_imbalance().bridged_in, 0); assert_eq!(Networks::bridged_imbalance().bridged_out, 0); assert_eq!(Balances::total_balance(&receiver), 0); - assert_eq!(ApplauseDetails::::get(session_index, unique_hash), None); + assert_eq!( + ApplauseDetails::::get(session_index, unique_hash), + None + ); assert_ok!(do_clap_from(session_index, network_id, 0, false)); assert_ok!(do_clap_from(session_index, network_id, 1, false)); @@ -910,7 +948,12 @@ fn should_register_block_commitments() { last_updated: 1337, }; for i in 0..=3 { - assert_ok!(do_block_commitment(session_index, network_id, i, &block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + i, + &block_commitment + )); } block_commitment.last_updated = 1000; @@ -966,17 +1009,25 @@ fn should_disable_on_commitment_inactivity() { for extra_time in 0..=2 { block_commitment.last_updated += extra_time; for i in 0..3 { - assert_ok!(do_block_commitment(session_index, network_id, i, &block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + i, + &block_commitment + )); } } System::assert_has_event(RuntimeEvent::SlowClap( crate::Event::SomeAuthoritiesDelayed { - delayed: vec![(3, 3)] - } + delayed: vec![(3, 3)], + }, )); - for commitment_details in BlockCommitments::::get(network_id).values().take(2) { + for commitment_details in BlockCommitments::::get(network_id) + .values() + .take(2) + { assert_eq!(commitment_details.commits, 3); } }); @@ -1017,15 +1068,25 @@ fn should_disable_on_commitment_block_deviation() { block_commitment.last_updated += extra_time; bad_block_commitment.last_updated += extra_time; for i in 0..3 { - assert_ok!(do_block_commitment(session_index, network_id, i, &block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + i, + &block_commitment + )); } - assert_ok!(do_block_commitment(session_index, network_id, 3, &bad_block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + 3, + &bad_block_commitment + )); } System::assert_has_event(RuntimeEvent::SlowClap( crate::Event::SomeAuthoritiesDelayed { - delayed: vec![(3, 3)] - } + delayed: vec![(3, 3)], + }, )); }); } @@ -1059,7 +1120,12 @@ fn should_not_offend_disabled_authorities() { for extra_time in 0..=2 { block_commitment.last_updated += extra_time; for i in 0..3 { - assert_ok!(do_block_commitment(session_index, network_id, i, &block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + i, + &block_commitment + )); } } @@ -1099,7 +1165,12 @@ fn should_not_slash_by_applause_if_disabled_by_commitment() { for extra_time in 0..=2 { block_commitment.last_updated += extra_time; for i in 0..3 { - assert_ok!(do_block_commitment(session_index, network_id, i, &block_commitment)); + assert_ok!(do_block_commitment( + session_index, + network_id, + i, + &block_commitment + )); } } @@ -1272,8 +1343,7 @@ fn generate_unique_hash( ) -> (NetworkIdOf, u64, H256) { let network_id = maybe_network_id.unwrap_or(1); - let (transaction_hash, receiver, amount, block_number) = - get_mocked_metadata(); + let (transaction_hash, receiver, amount, block_number) = get_mocked_metadata(); let transaction_hash = maybe_transaction_hash.unwrap_or(transaction_hash); let receiver = maybe_receiver.unwrap_or(receiver);