bump slow clap version inside lock file

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-11-06 17:06:11 +03:00
commit fc2e4e6bff
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
9 changed files with 232 additions and 140 deletions

4
Cargo.lock generated
View File

@ -1186,7 +1186,7 @@ dependencies = [
[[package]] [[package]]
name = "casper-runtime" name = "casper-runtime"
version = "3.5.31" version = "3.5.33"
dependencies = [ dependencies = [
"casper-runtime-constants", "casper-runtime-constants",
"frame-benchmarking", "frame-benchmarking",
@ -3836,7 +3836,7 @@ dependencies = [
[[package]] [[package]]
name = "ghost-slow-clap" name = "ghost-slow-clap"
version = "0.3.40" version = "0.3.47"
dependencies = [ dependencies = [
"frame-benchmarking", "frame-benchmarking",
"frame-support", "frame-support",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-slow-clap" name = "ghost-slow-clap"
version = "0.3.40" version = "0.3.47"
description = "Applause protocol for the EVM bridge" description = "Applause protocol for the EVM bridge"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -50,10 +50,15 @@ benchmarks! {
self_applause { self_applause {
let session_index = T::ValidatorSet::session_index(); let session_index = T::ValidatorSet::session_index();
let authorities = vec![T::AuthorityId::generate_pair(None)]; let next_session_index = session_index.saturating_add(1);
let authorities = vec![
T::AuthorityId::generate_pair(None),
T::AuthorityId::generate_pair(None),
];
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone()) let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone())
.map_err(|()| "more than the maximum number of keys provided")?; .map_err(|()| "more than the maximum number of keys provided")?;
Authorities::<T>::set(&session_index, bounded_authorities); Authorities::<T>::set(&session_index, bounded_authorities.clone());
Authorities::<T>::set(&next_session_index, bounded_authorities);
let minimum_balance = <<T as pallet::Config>::Currency>::minimum_balance(); let minimum_balance = <<T as pallet::Config>::Currency>::minimum_balance();
let receiver = create_account::<T>(); let receiver = create_account::<T>();
@ -68,6 +73,7 @@ benchmarks! {
&network_id, &network_id,
); );
let storage_key = (session_index, &transaction_hash, &unique_transaction_hash); let storage_key = (session_index, &transaction_hash, &unique_transaction_hash);
let next_storage_key = (next_session_index, &transaction_hash, &unique_transaction_hash);
<Pallet::<T>>::trigger_nullification_for_benchmark(); <Pallet::<T>>::trigger_nullification_for_benchmark();
let clap = Clap { let clap = Clap {
@ -86,11 +92,18 @@ benchmarks! {
.expect("first authority should exist"); .expect("first authority should exist");
let encoded_clap = clap.encode(); let encoded_clap = clap.encode();
let signature = authority_id.sign(&encoded_clap).unwrap(); let signature = authority_id.sign(&encoded_clap).unwrap();
<Pallet<T>>::slow_clap(RawOrigin::None.into(), clap, signature)?; Pallet::<T>::slow_clap(RawOrigin::None.into(), clap, signature)?;
<Pallet::<T>>::trigger_nullification_for_benchmark(); Pallet::<T>::trigger_nullification_for_benchmark();
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), Default::default()); assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), Default::default());
assert_eq!(ApplausesForTransaction::<T>::get(&storage_key), false); assert_eq!(ApplausesForTransaction::<T>::get(&storage_key), false);
frame_system::Pallet::<T>::on_initialize(1u32.into());
let mut fake_received_clap =
BoundedBTreeSet::<AuthIndex, T::MaxAuthorities>::new();
assert_eq!(fake_received_clap.try_insert(1).unwrap(), true);
pallet::ReceivedClaps::<T>::insert(&next_storage_key, fake_received_clap);
}: _(RawOrigin::Signed(receiver_clone), network_id, session_index, transaction_hash, receiver_clone.clone(), amount) }: _(RawOrigin::Signed(receiver_clone), network_id, session_index, transaction_hash, receiver_clone.clone(), amount)
verify { verify {
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), amount); assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), amount);

View File

@ -35,7 +35,11 @@ use sp_staking::{
offence::{Kind, Offence, ReportOffence}, offence::{Kind, Offence, ReportOffence},
SessionIndex, SessionIndex,
}; };
use sp_std::{collections::btree_map::BTreeMap, prelude::*, vec::Vec}; use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
vec::Vec,
};
use ghost_networks::{ use ghost_networks::{
NetworkData, NetworkDataBasicHandler, NetworkDataInspectHandler, NetworkDataMutateHandler, NetworkData, NetworkDataBasicHandler, NetworkDataInspectHandler, NetworkDataMutateHandler,
@ -72,7 +76,7 @@ const LOG_TARGET: &str = "runtime::ghost-slow-clap";
const DB_PREFIX: &[u8] = b"slow_clap::"; const DB_PREFIX: &[u8] = b"slow_clap::";
const FETCH_TIMEOUT_PERIOD: u64 = 3_000; const FETCH_TIMEOUT_PERIOD: u64 = 3_000;
const LOCK_BLOCK_EXPIRATION: u64 = 10; const LOCK_BLOCK_EXPIRATION: u64 = 20;
pub type AuthIndex = u32; pub type AuthIndex = u32;
@ -166,7 +170,7 @@ type OffchainResult<T, A> = Result<A, OffchainErr<NetworkIdOf<T>>>;
pub mod pallet { pub mod pallet {
use super::*; use super::*;
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
#[pallet::pallet] #[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)] #[pallet::storage_version(STORAGE_VERSION)]
@ -238,7 +242,6 @@ pub mod pallet {
#[pallet::error] #[pallet::error]
pub enum Error<T> { pub enum Error<T> {
NotEnoughClaps, NotEnoughClaps,
NotAnAuthority,
CurrentValidatorIsDisabled, CurrentValidatorIsDisabled,
AlreadyClapped, AlreadyClapped,
UnregisteredClapRemove, UnregisteredClapRemove,
@ -294,6 +297,16 @@ pub mod pallet {
ValueQuery, ValueQuery,
>; >;
#[pallet::storage]
#[pallet::getter(fn validators)]
pub(super) type Validators<T: Config> = StorageMap<
_,
Twox64Concat,
SessionIndex,
WeakBoundedVec<ValidatorId<T>, T::MaxAuthorities>,
OptionQuery,
>;
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)] #[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
@ -330,7 +343,7 @@ pub mod pallet {
pub fn self_applause( pub fn self_applause(
origin: OriginFor<T>, origin: OriginFor<T>,
network_id: NetworkIdOf<T>, network_id: NetworkIdOf<T>,
session_index: SessionIndex, prev_session_index: SessionIndex,
transaction_hash: H256, transaction_hash: H256,
receiver: T::AccountId, receiver: T::AccountId,
amount: BalanceOf<T>, amount: BalanceOf<T>,
@ -338,7 +351,7 @@ pub mod pallet {
let _ = ensure_signed(origin)?; let _ = ensure_signed(origin)?;
Self::applause_if_posible( Self::applause_if_posible(
network_id, network_id,
session_index, prev_session_index,
transaction_hash, transaction_hash,
receiver, receiver,
amount, amount,
@ -378,7 +391,8 @@ pub mod pallet {
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
if let Call::slow_clap { clap, signature } = call { if let Call::slow_clap { clap, signature } = call {
let authorities = Authorities::<T>::get(&clap.session_index); let (session_index, _) = Self::mended_session_index(&clap);
let authorities = Authorities::<T>::get(&session_index);
let authority = match authorities.get(clap.authority_index as usize) { let authority = match authorities.get(clap.authority_index as usize) {
Some(authority) => authority, Some(authority) => authority,
None => return InvalidTransaction::BadSigner.into(), None => return InvalidTransaction::BadSigner.into(),
@ -459,27 +473,49 @@ impl<T: Config> Pallet<T> {
hex_str hex_str
} }
fn try_slow_clap(clap: &Clap<T::AccountId, NetworkIdOf<T>, BalanceOf<T>>) -> DispatchResult { fn mended_session_index(
let authorities = Authorities::<T>::get(&clap.session_index); clap: &Clap<T::AccountId, NetworkIdOf<T>, BalanceOf<T>>,
ensure!( ) -> (SessionIndex, H256) {
authorities.get(clap.authority_index as usize).is_some(), let prev_session_index = clap.session_index.saturating_sub(1);
Error::<T>::NotAnAuthority let clap_unique_hash =
Self::generate_unique_hash(&clap.receiver, &clap.amount, &clap.network_id);
let received_claps_key = (
prev_session_index,
&clap.transaction_hash,
&clap_unique_hash,
); );
let session_index = ReceivedClaps::<T>::get(&received_claps_key)
.is_empty()
.then(|| clap.session_index)
.unwrap_or(prev_session_index);
(session_index, clap_unique_hash)
}
fn try_slow_clap(clap: &Clap<T::AccountId, NetworkIdOf<T>, BalanceOf<T>>) -> DispatchResult {
let (session_index, clap_unique_hash) = Self::mended_session_index(&clap);
let mut claps_in_session = ClapsInSession::<T>::get(&session_index);
ensure!( ensure!(
ClapsInSession::<T>::get(&clap.session_index) claps_in_session
.get(&clap.authority_index) .get(&clap.authority_index)
.map(|info| !info.disabled) .map(|info| !info.disabled)
.unwrap_or(true), .unwrap_or(true),
Error::<T>::CurrentValidatorIsDisabled Error::<T>::CurrentValidatorIsDisabled
); );
let clap_unique_hash = let disabled_authorites = claps_in_session
Self::generate_unique_hash(&clap.receiver, &clap.amount, &clap.network_id); .values()
let received_claps_key = ( .filter(|info| info.disabled)
clap.session_index, .count();
&clap.transaction_hash,
&clap_unique_hash, let active_authorities = Authorities::<T>::get(&session_index)
); .len()
.saturating_sub(disabled_authorites);
let received_claps_key = (session_index, &clap.transaction_hash, &clap_unique_hash);
let number_of_received_claps = let number_of_received_claps =
ReceivedClaps::<T>::try_mutate(&received_claps_key, |tree_of_claps| { ReceivedClaps::<T>::try_mutate(&received_claps_key, |tree_of_claps| {
@ -498,15 +534,15 @@ impl<T: Config> Pallet<T> {
} }
})?; })?;
ClapsInSession::<T>::mutate(&clap.session_index, |claps_details| { claps_in_session
(*claps_details) .entry(clap.authority_index)
.entry(clap.authority_index) .and_modify(|individual| individual.claps.saturating_inc())
.and_modify(|individual| (*individual).claps.saturating_inc()) .or_insert(SessionAuthorityInfo {
.or_insert(SessionAuthorityInfo { claps: 1u32,
claps: 1u32, disabled: false,
disabled: false, });
});
}); ClapsInSession::<T>::insert(&session_index, claps_in_session);
Self::deposit_event(Event::<T>::Clapped { Self::deposit_event(Event::<T>::Clapped {
authority_id: clap.authority_index, authority_id: clap.authority_index,
@ -517,7 +553,7 @@ impl<T: Config> Pallet<T> {
}); });
let enough_authorities = let enough_authorities =
Perbill::from_rational(number_of_received_claps as u32, authorities.len() as u32) Perbill::from_rational(number_of_received_claps as u32, active_authorities as u32)
> Perbill::from_percent(T::ApplauseThreshold::get()); > Perbill::from_percent(T::ApplauseThreshold::get());
if enough_authorities { if enough_authorities {
@ -574,32 +610,61 @@ impl<T: Config> Pallet<T> {
fn applause_if_posible( fn applause_if_posible(
network_id: NetworkIdOf<T>, network_id: NetworkIdOf<T>,
session_index: SessionIndex, prev_session_index: SessionIndex,
transaction_hash: H256, transaction_hash: H256,
receiver: T::AccountId, receiver: T::AccountId,
amount: BalanceOf<T>, amount: BalanceOf<T>,
) -> DispatchResult { ) -> DispatchResult {
let curr_session_index = prev_session_index.saturating_add(1);
let clap_unique_hash = Self::generate_unique_hash(&receiver, &amount, &network_id); let clap_unique_hash = Self::generate_unique_hash(&receiver, &amount, &network_id);
let received_claps_key = (session_index, &transaction_hash, &clap_unique_hash);
let prev_authorities = Authorities::<T>::get(&prev_session_index);
let curr_authorities = Authorities::<T>::get(&curr_session_index);
let prev_received_claps_key = (prev_session_index, &transaction_hash, &clap_unique_hash);
let curr_received_claps_key = (curr_session_index, &transaction_hash, &clap_unique_hash);
let prev_received_claps = ReceivedClaps::<T>::get(&prev_received_claps_key)
.into_iter()
.filter_map(|auth_index| prev_authorities.get(auth_index as usize))
.cloned()
.collect::<BTreeSet<T::AuthorityId>>();
let curr_received_claps = ReceivedClaps::<T>::get(&curr_received_claps_key)
.into_iter()
.filter_map(|auth_index| curr_authorities.get(auth_index as usize))
.cloned()
.collect::<BTreeSet<T::AuthorityId>>();
let disabled_authorites = ClapsInSession::<T>::get(&prev_session_index)
.values()
.filter(|info| info.disabled)
.count();
let active_authorities = prev_authorities.len().saturating_sub(disabled_authorites);
let summary_authority_claps_length = curr_received_claps
.symmetric_difference(&prev_received_claps)
.count();
let clap = Clap { let clap = Clap {
authority_index: Default::default(), authority_index: Default::default(),
block_number: Default::default(), block_number: Default::default(),
removed: false, removed: Default::default(),
session_index, session_index: Default::default(),
transaction_hash: Default::default(),
network_id, network_id,
receiver, receiver,
amount, amount,
transaction_hash,
}; };
let enough_authorities = Perbill::from_rational( let enough_authorities = Perbill::from_rational(
ReceivedClaps::<T>::get(&received_claps_key).len() as u32, summary_authority_claps_length as u32,
Authorities::<T>::get(session_index).len() as u32, active_authorities as u32,
) > Perbill::from_percent(T::ApplauseThreshold::get()); ) > Perbill::from_percent(T::ApplauseThreshold::get());
ensure!(enough_authorities, Error::<T>::NotEnoughClaps); ensure!(enough_authorities, Error::<T>::NotEnoughClaps);
Self::try_applause(&clap, &received_claps_key)?; Self::try_applause(&clap, &prev_received_claps_key)?;
Ok(()) Ok(())
} }
@ -766,14 +831,17 @@ impl<T: Config> Pallet<T> {
Some(_) if from_block.le(&to_block) => { Some(_) if from_block.le(&to_block) => {
let adjusted_to_block = estimated_block let adjusted_to_block = estimated_block
.checked_sub(from_block) .checked_sub(from_block)
.map(|current_distance| current_distance .map(|current_distance| {
.le(&max_block_distance) current_distance
.then(|| estimated_block) .le(&max_block_distance)
) .then(|| estimated_block)
})
.flatten() .flatten()
.unwrap_or(from_block .unwrap_or(
.saturating_add(max_block_distance) from_block
.min(estimated_block)); .saturating_add(max_block_distance)
.min(estimated_block),
);
(from_block, adjusted_to_block) (from_block, adjusted_to_block)
} }
_ => (to_block, to_block), _ => (to_block, to_block),
@ -1026,16 +1094,23 @@ impl<T: Config> Pallet<T> {
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities) let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities)
.expect("more than the maximum number of authorities"); .expect("more than the maximum number of authorities");
let validators = T::ValidatorSet::validators();
let bounded_validators = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(validators)
.expect("more than the maximum number of validators");
if let Some(target_session_index) = session_index.checked_sub(T::HistoryDepth::get()) { if let Some(target_session_index) = session_index.checked_sub(T::HistoryDepth::get()) {
Self::clear_history(&target_session_index); Self::clear_history(&target_session_index);
} }
Validators::<T>::insert(&session_index, bounded_validators);
Authorities::<T>::set(&session_index, bounded_authorities); Authorities::<T>::set(&session_index, bounded_authorities);
ClapsInSession::<T>::set(&session_index, Default::default()); ClapsInSession::<T>::set(&session_index, Default::default());
} }
fn clear_history(target_session_index: &SessionIndex) { fn clear_history(target_session_index: &SessionIndex) {
ClapsInSession::<T>::remove(target_session_index); ClapsInSession::<T>::remove(target_session_index);
Authorities::<T>::remove(target_session_index);
Validators::<T>::remove(target_session_index);
let mut cursor = ReceivedClaps::<T>::clear_prefix((target_session_index,), u32::MAX, None); let mut cursor = ReceivedClaps::<T>::clear_prefix((target_session_index,), u32::MAX, None);
debug_assert!(cursor.maybe_cursor.is_none()); debug_assert!(cursor.maybe_cursor.is_none());
cursor = cursor =
@ -1087,8 +1162,8 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
} }
fn on_before_session_ending() { fn on_before_session_ending() {
let session_index = T::ValidatorSet::session_index(); let session_index = T::ValidatorSet::session_index().saturating_sub(1);
let validators = T::ValidatorSet::validators(); let validators = Validators::<T>::get(&session_index).unwrap_or_default();
let authorities_len = Authorities::<T>::get(&session_index).len(); let authorities_len = Authorities::<T>::get(&session_index).len();
let claps_in_session = ClapsInSession::<T>::get(&session_index); let claps_in_session = ClapsInSession::<T>::get(&session_index);
@ -1097,11 +1172,13 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
let offenders = validators let offenders = validators
.into_iter() .into_iter()
.enumerate() .enumerate()
.filter(|(index, _)| !Self::is_good_actor(*index, median_claps, &claps_in_session)) .filter_map(|(index, id)| {
.filter_map(|(_, id)| { (!Self::is_good_actor(index, median_claps, &claps_in_session)).then(|| {
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert( <T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
id.clone(), id.clone(),
).map(|full_id| (id, full_id)) ).map(|full_id| (id, full_id))
})
.flatten()
}) })
.collect::<Vec<IdentificationTuple<T>>>(); .collect::<Vec<IdentificationTuple<T>>>();

View File

@ -665,15 +665,14 @@ fn should_throw_error_if_session_index_is_not_current() {
network_id, network_id,
authority_prev authority_prev
)); ));
assert_ok!(do_clap_from_first_authority( assert_err!(
session_index_next, do_clap_from_first_authority(session_index_next, network_id, authority_next),
network_id, DispatchError::Other("Transaction has a bad signature")
authority_next );
));
assert_claps_info_correct(&storage_key_curr, &session_index_curr, 1); assert_claps_info_correct(&storage_key_curr, &session_index_curr, 1);
assert_claps_info_correct(&storage_key_prev, &session_index_prev, 1); assert_claps_info_correct(&storage_key_prev, &session_index_prev, 1);
assert_claps_info_correct(&storage_key_next, &session_index_next, 1); assert_claps_info_correct(&storage_key_next, &session_index_next, 0);
} }
}); });
} }
@ -688,22 +687,12 @@ fn should_throw_error_if_signer_has_incorrect_index() {
let storage_key = (session_index, transaction_hash, unique_transaction_hash); let storage_key = (session_index, transaction_hash, unique_transaction_hash);
assert_claps_info_correct(&storage_key, &session_index, 0); assert_claps_info_correct(&storage_key, &session_index, 0);
let clap = Clap { assert_invalid_signing_address(session_index, network_id, 69);
block_number: 420, assert_transaction_has_bad_signature(session_index, network_id, 69);
removed: false, assert_invalid_signing_address(session_index, network_id, 420);
transaction_hash, assert_transaction_has_bad_signature(session_index, network_id, 420);
session_index, assert_invalid_signing_address(session_index, network_id, 1337);
authority_index: 1337, assert_transaction_has_bad_signature(session_index, network_id, 1337);
network_id,
receiver: 69,
amount: 420,
};
let authority = UintAuthorityId::from((1) as u64);
let signature = authority.sign(&clap.encode()).unwrap();
assert_err!(
SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature),
Error::<Runtime>::NotAnAuthority
);
assert_claps_info_correct(&storage_key, &session_index, 0); assert_claps_info_correct(&storage_key, &session_index, 0);
}); });
} }
@ -956,8 +945,8 @@ fn should_avoid_applause_during_nullification_period() {
} }
#[test] #[test]
fn should_self_applause_if_enough_received_claps() { fn should_self_applause_if_enough_claps() {
let zero: u64 = 0u64; let zero = 0u64;
let (network_id, transaction_hash, unique_transaction_hash) = let (network_id, transaction_hash, unique_transaction_hash) =
generate_unique_hash(None, None, None, None); generate_unique_hash(None, None, None, None);
let (_, receiver, amount) = get_mocked_metadata(); let (_, receiver, amount) = get_mocked_metadata();
@ -976,7 +965,7 @@ fn should_self_applause_if_enough_received_claps() {
receiver, receiver,
amount, amount,
), ),
Error::<Runtime>::NotEnoughClaps Error::<Runtime>::NotEnoughClaps,
); );
assert_eq!( assert_eq!(
@ -984,45 +973,56 @@ fn should_self_applause_if_enough_received_claps() {
false false
); );
assert_eq!(Balances::balance(&receiver), zero); assert_eq!(Balances::balance(&receiver), zero);
assert_eq!(
BridgedInflationCurve::<RewardCurve, Runtime>::era_payout(zero, zero, zero),
(zero, zero)
);
assert_ok!(do_clap_from(session_index, network_id, 0, false)); assert_ok!(do_clap_from(session_index, network_id, 0, false));
advance_session();
let mut fake_received_clap =
BoundedBTreeSet::<AuthIndex, <Runtime as pallet::Config>::MaxAuthorities>::new();
assert_eq!(fake_received_clap.try_insert(1).unwrap(), true);
assert_eq!(fake_received_clap.try_insert(2).unwrap(), true);
pallet::ReceivedClaps::<Runtime>::insert(&storage_key, fake_received_clap);
assert_ok!(SlowClap::self_applause(
RuntimeOrigin::signed(receiver),
network_id,
session_index,
transaction_hash,
receiver,
amount,
));
assert_eq!(
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
true
);
assert_eq!(Balances::balance(&receiver), amount);
});
}
#[test]
fn should_avoid_session_overlap_on_mended_session_index() {
let (network_id, transaction_hash, unique_transaction_hash) =
generate_unique_hash(None, None, None, None);
let (_, receiver, amount) = get_mocked_metadata();
new_test_ext().execute_with(|| {
let _ = prepare_evm_network(Some(network_id), Some(0));
let session_index = advance_session_and_get_index();
let storage_key = (session_index, transaction_hash, unique_transaction_hash);
assert_ok!(do_clap_from(session_index, network_id, 0, false));
advance_session();
assert_eq!(
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
false
);
assert_eq!(Balances::balance(&receiver), 0u64);
assert_ok!(do_clap_from(session_index, network_id, 1, 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, 2, false));
assert_eq!(
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
false
);
assert_eq!(Balances::balance(&receiver), 0);
assert_ok!(SlowClap::self_applause(
RuntimeOrigin::signed(receiver),
network_id,
session_index,
transaction_hash,
receiver,
amount,
));
assert_eq!(
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
false
);
assert_eq!(Balances::balance(&receiver), 0);
Networks::on_finalize(System::block_number());
assert_ok!(SlowClap::self_applause(
RuntimeOrigin::signed(receiver),
network_id,
session_index,
transaction_hash,
receiver,
amount,
));
assert_eq!( assert_eq!(
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key), pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
true true

View File

@ -16,7 +16,7 @@
//! Autogenerated weights for `ghost_slow_clap` //! Autogenerated weights for `ghost_slow_clap`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2025-11-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz` //! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024 //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024

View File

@ -1,6 +1,6 @@
[package] [package]
name = "casper-runtime" name = "casper-runtime"
version = "3.5.31" version = "3.5.33"
build = "build.rs" build = "build.rs"
description = "Runtime of the Casper Network" description = "Runtime of the Casper Network"
edition.workspace = true edition.workspace = true

View File

@ -117,11 +117,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("casper"), spec_name: create_runtime_str!("casper"),
impl_name: create_runtime_str!("casper-svengali"), impl_name: create_runtime_str!("casper-svengali"),
authoring_version: 0, authoring_version: 0,
spec_version: 2, spec_version: 3,
impl_version: 0, impl_version: 1,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 1, transaction_version: 1,
state_version: 0, state_version: 1,
}; };
/// The BABE epoch configuration at genesis. /// The BABE epoch configuration at genesis.

View File

@ -16,7 +16,7 @@
//! Autogenerated weights for `ghost_slow_clap` //! Autogenerated weights for `ghost_slow_clap`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2025-11-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz` //! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024 //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024
@ -46,12 +46,12 @@ use core::marker::PhantomData;
/// Weight functions for `ghost_slow_clap`. /// Weight functions for `ghost_slow_clap`.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> ghost_slow_clap::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> ghost_slow_clap::WeightInfo for WeightInfo<T> {
/// Storage: `GhostSlowClaps::Authorities` (r:1 w:0)
/// Proof: `GhostSlowClaps::Authorities` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ReceivedClaps` (r:1 w:1) /// Storage: `GhostSlowClaps::ReceivedClaps` (r:1 w:1)
/// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ClapsInSession` (r:1 w:1) /// Storage: `GhostSlowClaps::ClapsInSession` (r:1 w:1)
/// Proof: `GhostSlowClaps::ClapsInSession` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Proof: `GhostSlowClaps::ClapsInSession` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::Authorities` (r:1 w:0)
/// Proof: `GhostSlowClaps::Authorities` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1) /// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1)
/// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0) /// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0)
@ -68,18 +68,20 @@ impl<T: frame_system::Config> ghost_slow_clap::WeightInfo for WeightInfo<T> {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn slow_clap() -> Weight { fn slow_clap() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `355` // Measured: `387`
// Estimated: `3820` // Estimated: `3852`
// Minimum execution time: 213_817_000 picoseconds. // Minimum execution time: 220_008_000 picoseconds.
Weight::from_parts(216_977_000, 0) Weight::from_parts(223_058_000, 0)
.saturating_add(Weight::from_parts(0, 3820)) .saturating_add(Weight::from_parts(0, 3852))
.saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(7)) .saturating_add(T::DbWeight::get().writes(7))
} }
/// Storage: `GhostSlowClaps::ReceivedClaps` (r:1 w:0) /// Storage: `GhostSlowClaps::Authorities` (r:2 w:0)
/// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::Authorities` (r:1 w:0)
/// Proof: `GhostSlowClaps::Authorities` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Proof: `GhostSlowClaps::Authorities` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ReceivedClaps` (r:2 w:0)
/// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ClapsInSession` (r:1 w:0)
/// Proof: `GhostSlowClaps::ClapsInSession` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1) /// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1)
/// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0) /// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0)
@ -96,12 +98,12 @@ impl<T: frame_system::Config> ghost_slow_clap::WeightInfo for WeightInfo<T> {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn self_applause() -> Weight { fn self_applause() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `655` // Measured: `861`
// Estimated: `4120` // Estimated: `6801`
// Minimum execution time: 210_676_000 picoseconds. // Minimum execution time: 258_510_000 picoseconds.
Weight::from_parts(212_905_000, 0) Weight::from_parts(262_353_000, 0)
.saturating_add(Weight::from_parts(0, 4120)) .saturating_add(Weight::from_parts(0, 6801))
.saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(5)) .saturating_add(T::DbWeight::get().writes(5))
} }
} }