mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 03:09:56 +00:00
Compare commits
23 Commits
pallet-net
...
pallet-slo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a2b5a34d2 | ||
|
|
0bb46482b2 | ||
|
|
d76646c191 | ||
|
|
94d28f254f | ||
|
|
55a77cd3d4 | ||
|
|
092679eb0c | ||
|
|
64de0027bf | ||
|
|
a3ed395689 | ||
|
|
7a710ec9cb | ||
|
|
cc141105bb | ||
|
|
0e750c0261 | ||
|
|
cc566ac549 | ||
|
|
18241ea504 | ||
|
|
af14543cc1 | ||
|
|
6acec08fa5 | ||
|
|
d6ecdcd468 | ||
|
|
decf6665df | ||
|
|
ebae9fadbe | ||
|
|
c872eca8ac | ||
|
|
eb181c7f44 | ||
|
|
5307afe352 | ||
|
|
7edc8935b6 | ||
|
|
46aa18aafe |
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -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.39"
|
version = "0.3.47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
|
|||||||
@@ -51,33 +51,6 @@ pub trait WeightInfo {
|
|||||||
fn claim() -> Weight;
|
fn claim() -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weight for ghost_claims using the Substrate node and recommended hardware.
|
|
||||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
|
||||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
|
||||||
/// Storage: `System::Account` (r:2 w:2)
|
|
||||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
|
||||||
/// Storage: `GhostClaims::Total` (r:1 w:1)
|
|
||||||
/// Proof: `GhostClaims::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `CultCollective::Members` (r:2 w:2)
|
|
||||||
/// Proof: `CultCollective::Members` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`)
|
|
||||||
/// Storage: `CultCollective::MemberCount` (r:6 w:6)
|
|
||||||
/// Proof: `CultCollective::MemberCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
|
|
||||||
/// Storage: `CultCollective::IdToIndex` (r:6 w:12)
|
|
||||||
/// Proof: `CultCollective::IdToIndex` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`)
|
|
||||||
/// Storage: `CultCollective::IndexToId` (r:0 w:6)
|
|
||||||
/// Proof: `CultCollective::IndexToId` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`)
|
|
||||||
fn claim() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `896`
|
|
||||||
// Estimated: `16164`
|
|
||||||
// Minimum execution time: 754_086_000 picoseconds.
|
|
||||||
Weight::from_parts(756_147_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 16164))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(17))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(29))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
/// Storage: `System::Account` (r:2 w:2)
|
/// Storage: `System::Account` (r:2 w:2)
|
||||||
/// 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`)
|
||||||
|
|||||||
@@ -63,166 +63,6 @@ pub trait WeightInfo {
|
|||||||
fn remove_network() -> Weight;
|
fn remove_network() -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weight for ghost_networks using the Substrate node and recommended hardware.
|
|
||||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
|
||||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// The range of component `i` is `[1, 20]`.
|
|
||||||
/// The range of component `j` is `[1, 150]`.
|
|
||||||
/// The range of component `k` is `[1, 20]`.
|
|
||||||
fn register_network(_i: u32, _j: u32, k: u32, ) -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `109`
|
|
||||||
// Estimated: `3574`
|
|
||||||
// Minimum execution time: 46_023_000 picoseconds.
|
|
||||||
Weight::from_parts(97_871_287, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3574))
|
|
||||||
// Standard Error: 94_524
|
|
||||||
.saturating_add(Weight::from_parts(940_486, 0).saturating_mul(k.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// The range of component `n` is `[1, 20]`.
|
|
||||||
fn update_network_name(n: u32, ) -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 49_906_000 picoseconds.
|
|
||||||
Weight::from_parts(55_537_587, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
// Standard Error: 87_704
|
|
||||||
.saturating_add(Weight::from_parts(92_366, 0).saturating_mul(n.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// The range of component `n` is `[1, 150]`.
|
|
||||||
fn update_network_endpoint(n: u32, ) -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 50_556_000 picoseconds.
|
|
||||||
Weight::from_parts(57_726_674, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
// Standard Error: 12_261
|
|
||||||
.saturating_add(Weight::from_parts(274, 0).saturating_mul(n.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_finality_delay() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 49_406_000 picoseconds.
|
|
||||||
Weight::from_parts(51_256_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_rate_limit_delay() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 49_572_000 picoseconds.
|
|
||||||
Weight::from_parts(52_584_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_block_distance() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 48_880_000 picoseconds.
|
|
||||||
Weight::from_parts(50_596_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_type() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 48_282_000 picoseconds.
|
|
||||||
Weight::from_parts(49_137_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_gatekeeper() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 50_853_000 picoseconds.
|
|
||||||
Weight::from_parts(51_982_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_network_topic_name() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 50_343_000 picoseconds.
|
|
||||||
Weight::from_parts(52_380_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_incoming_network_fee() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 49_393_000 picoseconds.
|
|
||||||
Weight::from_parts(80_966_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn update_outgoing_network_fee() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 49_579_000 picoseconds.
|
|
||||||
Weight::from_parts(51_126_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
fn remove_network() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `302`
|
|
||||||
// Estimated: `3767`
|
|
||||||
// Minimum execution time: 44_634_000 picoseconds.
|
|
||||||
Weight::from_parts(45_815_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3767))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
/// Storage: `GhostNetworks::Networks` (r:1 w:1)
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.3.40"
|
version = "0.3.56"
|
||||||
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
|
||||||
|
|||||||
@@ -17,62 +17,21 @@ benchmarks! {
|
|||||||
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>();
|
||||||
let amount = minimum_balance + minimum_balance;
|
let amount = minimum_balance + minimum_balance;
|
||||||
|
|
||||||
let network_id = NetworkIdOf::<T>::default();
|
let network_id = NetworkIdOf::<T>::default();
|
||||||
let session_index = T::ValidatorSet::session_index();
|
let session_index = T::ValidatorSet::session_index();
|
||||||
|
|
||||||
let authorities = vec![T::AuthorityId::generate_pair(None)];
|
|
||||||
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone())
|
|
||||||
.map_err(|()| "more than the maximum number of keys provided")?;
|
|
||||||
Authorities::<T>::set(&session_index, bounded_authorities);
|
|
||||||
|
|
||||||
let clap = Clap {
|
|
||||||
session_index: 0,
|
|
||||||
authority_index: 0,
|
|
||||||
transaction_hash: H256::repeat_byte(1u8),
|
|
||||||
block_number: 69,
|
|
||||||
removed: false,
|
|
||||||
network_id,
|
|
||||||
receiver: receiver.clone(),
|
|
||||||
amount,
|
|
||||||
};
|
|
||||||
|
|
||||||
let authority_id = authorities
|
|
||||||
.get(0usize)
|
|
||||||
.expect("first authority should exist");
|
|
||||||
let encoded_clap = clap.encode();
|
|
||||||
let signature = authority_id.sign(&encoded_clap)
|
|
||||||
.ok_or("couldn't make signature")?;
|
|
||||||
|
|
||||||
}: _(RawOrigin::None, clap, signature)
|
|
||||||
verify {
|
|
||||||
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
self_applause {
|
|
||||||
let session_index = T::ValidatorSet::session_index();
|
|
||||||
let authorities = vec![T::AuthorityId::generate_pair(None)];
|
|
||||||
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone())
|
|
||||||
.map_err(|()| "more than the maximum number of keys provided")?;
|
|
||||||
Authorities::<T>::set(&session_index, bounded_authorities);
|
|
||||||
|
|
||||||
let minimum_balance = <<T as pallet::Config>::Currency>::minimum_balance();
|
|
||||||
let receiver = create_account::<T>();
|
|
||||||
let receiver_clone = receiver.clone();
|
|
||||||
let amount = minimum_balance + minimum_balance;
|
|
||||||
let network_id = NetworkIdOf::<T>::default();
|
|
||||||
let transaction_hash = H256::repeat_byte(1u8);
|
let transaction_hash = H256::repeat_byte(1u8);
|
||||||
|
let args_hash = Pallet::<T>::generate_unique_hash(&receiver, &amount, &network_id);
|
||||||
|
|
||||||
let unique_transaction_hash = <Pallet<T>>::generate_unique_hash(
|
let authorities = vec![T::AuthorityId::generate_pair(None)];
|
||||||
&receiver,
|
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone())
|
||||||
&amount,
|
.map_err(|()| "more than the maximum number of keys provided")?;
|
||||||
&network_id,
|
Authorities::<T>::set(&session_index, bounded_authorities);
|
||||||
);
|
let authority_index = 0u32;
|
||||||
let storage_key = (session_index, &transaction_hash, &unique_transaction_hash);
|
|
||||||
|
|
||||||
<Pallet::<T>>::trigger_nullification_for_benchmark();
|
|
||||||
let clap = Clap {
|
let clap = Clap {
|
||||||
session_index,
|
session_index,
|
||||||
authority_index: 0,
|
authority_index,
|
||||||
transaction_hash,
|
transaction_hash,
|
||||||
block_number: 69,
|
block_number: 69,
|
||||||
removed: false,
|
removed: false,
|
||||||
@@ -82,19 +41,54 @@ benchmarks! {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let authority_id = authorities
|
let authority_id = authorities
|
||||||
.get(0usize)
|
.get(authority_index as usize)
|
||||||
.expect("first authority should exist");
|
.expect("first authority should exist");
|
||||||
let encoded_clap = clap.encode();
|
let signature = authority_id.sign(&clap.encode())
|
||||||
let signature = authority_id.sign(&encoded_clap).unwrap();
|
.ok_or("couldn't make signature")?;
|
||||||
<Pallet<T>>::slow_clap(RawOrigin::None.into(), clap, signature)?;
|
|
||||||
<Pallet::<T>>::trigger_nullification_for_benchmark();
|
|
||||||
|
|
||||||
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), Default::default());
|
}: _(RawOrigin::None, clap, signature)
|
||||||
assert_eq!(ApplausesForTransaction::<T>::get(&storage_key), false);
|
|
||||||
}: _(RawOrigin::Signed(receiver_clone), network_id, session_index, transaction_hash, receiver_clone.clone(), amount)
|
|
||||||
verify {
|
verify {
|
||||||
|
let clap_key = (session_index, transaction_hash, args_hash);
|
||||||
|
assert_eq!(ReceivedClaps::<T>::get(&clap_key).get(&authority_index).is_some(), true);
|
||||||
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), amount);
|
assert_eq!(<<T as pallet::Config>::Currency>::total_balance(&receiver), amount);
|
||||||
assert_eq!(ApplausesForTransaction::<T>::get(&storage_key), true);
|
}
|
||||||
|
|
||||||
|
commit_block {
|
||||||
|
let session_index = T::ValidatorSet::session_index();
|
||||||
|
let network_id = NetworkIdOf::<T>::default();
|
||||||
|
|
||||||
|
let authorities = vec![T::AuthorityId::generate_pair(None)];
|
||||||
|
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities.clone())
|
||||||
|
.map_err(|()| "more than the maximum number of keys provided")?;
|
||||||
|
Authorities::<T>::set(&session_index, bounded_authorities);
|
||||||
|
let authority_index = 0u32;
|
||||||
|
|
||||||
|
let block_commitment = BlockCommitment {
|
||||||
|
session_index,
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
commitment: CommitmentDetails {
|
||||||
|
last_registered_block: 69,
|
||||||
|
last_seen_block: 420,
|
||||||
|
last_updated: 1337,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let authority_id = authorities
|
||||||
|
.get(authority_index as usize)
|
||||||
|
.expect("first authority should exist");
|
||||||
|
let signature = authority_id.sign(&block_commitment.encode())
|
||||||
|
.ok_or("couldn't make signature")?;
|
||||||
|
|
||||||
|
}: _(RawOrigin::None, block_commitment, signature)
|
||||||
|
verify {
|
||||||
|
let stored_commitment = BlockCommitments::<T>::get(&network_id)
|
||||||
|
.get(&authority_index)
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_default();
|
||||||
|
assert_eq!(stored_commitment.last_registered_block, 69);
|
||||||
|
assert_eq!(stored_commitment.last_seen_block, 420);
|
||||||
|
assert_eq!(stored_commitment.last_updated, 1337);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_benchmark_test_suite!(
|
impl_benchmark_test_suite!(
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
use sp_runtime::SaturatedConversion;
|
||||||
|
use sp_staking::SessionIndex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
deserialisations::{
|
deserialisations::{
|
||||||
de_string_to_bytes, de_string_to_h256, de_string_to_u64, de_string_to_u64_pure,
|
de_string_to_bytes, de_string_to_h256, de_string_to_u64, de_string_to_u64_pure,
|
||||||
de_string_to_vec_of_bytes,
|
de_string_to_vec_of_bytes,
|
||||||
},
|
},
|
||||||
Decode, Deserialize, Encode, RuntimeDebug, Vec, H256,
|
AuthIndex, BalanceOf, BlockCommitment, BlockCommitments, Call, Clap, CommitmentDetails, Config,
|
||||||
|
Decode, Deserialize, Encode, NetworkIdOf, RuntimeAppPublic, RuntimeDebug, SubmitTransaction,
|
||||||
|
Vec, COMMITMENT_DELAY_MILLIS, H256, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
const NUMBER_OF_TOPICS: usize = 3;
|
const NUMBER_OF_TOPICS: usize = 3;
|
||||||
@@ -40,6 +45,219 @@ pub struct Log {
|
|||||||
pub removed: bool,
|
pub removed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EvmResponseType {
|
||||||
|
fn prepare_block_commitment<T: Config>(
|
||||||
|
&self,
|
||||||
|
from_block: u64,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
) -> BlockCommitment<NetworkIdOf<T>> {
|
||||||
|
let last_updated = sp_io::offchain::timestamp().unix_millis();
|
||||||
|
let current_block = match self {
|
||||||
|
EvmResponseType::BlockNumber(block_number) => *block_number,
|
||||||
|
EvmResponseType::TransactionLogs(_) => Default::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockCommitment {
|
||||||
|
session_index,
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
commitment: CommitmentDetails {
|
||||||
|
last_registered_block: from_block,
|
||||||
|
last_seen_block: current_block,
|
||||||
|
last_updated,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepare_clap<T: Config>(
|
||||||
|
&self,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
log: &Log,
|
||||||
|
) -> Clap<T::AccountId, NetworkIdOf<T>, BalanceOf<T>> {
|
||||||
|
Clap {
|
||||||
|
authority_index,
|
||||||
|
session_index,
|
||||||
|
network_id,
|
||||||
|
removed: log.removed,
|
||||||
|
receiver: T::AccountId::decode(&mut &log.topics[1][0..32])
|
||||||
|
.expect("32 bytes always construct an AccountId32"),
|
||||||
|
amount: u128::from_be_bytes(
|
||||||
|
log.topics[2][16..32]
|
||||||
|
.try_into()
|
||||||
|
.expect("amount is valid hex; qed"),
|
||||||
|
)
|
||||||
|
.saturated_into::<BalanceOf<T>>(),
|
||||||
|
transaction_hash: log.transaction_hash.clone().expect("tx hash exists; qed"),
|
||||||
|
block_number: log.block_number.expect("block number exists; qed"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn iter_claps_from_logs<T: Config>(
|
||||||
|
&self,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
) -> Vec<Clap<T::AccountId, NetworkIdOf<T>, BalanceOf<T>>> {
|
||||||
|
match self {
|
||||||
|
EvmResponseType::TransactionLogs(evm_logs) => evm_logs
|
||||||
|
.iter()
|
||||||
|
.filter_map(move |log| {
|
||||||
|
log.is_sufficient().then(|| {
|
||||||
|
self.prepare_clap::<T>(authority_index, session_index, network_id, log)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
EvmResponseType::BlockNumber(_) => Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sign_and_submit_claps<T: Config>(
|
||||||
|
&self,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
authority_key: T::AuthorityId,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
) {
|
||||||
|
let claps = self.iter_claps_from_logs::<T>(authority_index, session_index, network_id);
|
||||||
|
let claps_len = claps.len();
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 Found {:?} claps for network {:?}",
|
||||||
|
claps_len,
|
||||||
|
network_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (clap_index, clap) in claps.iter().enumerate() {
|
||||||
|
let signature = match authority_key.sign(&clap.encode()) {
|
||||||
|
Some(signature) => signature,
|
||||||
|
None => {
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 Clap #{} signing failed from authority #{:?} for network {:?}",
|
||||||
|
clap_index,
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let call = Call::slow_clap {
|
||||||
|
clap: clap.clone(),
|
||||||
|
signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) =
|
||||||
|
SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into())
|
||||||
|
{
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 Failed to submit clap #{} from authority #{:?} for network {:?}: {:?}",
|
||||||
|
clap_index,
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sign_and_submit_block_commitment<T: Config>(
|
||||||
|
&self,
|
||||||
|
from_block: u64,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
authority_key: T::AuthorityId,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
) {
|
||||||
|
let block_commitment = self.prepare_block_commitment::<T>(
|
||||||
|
from_block,
|
||||||
|
authority_index,
|
||||||
|
session_index,
|
||||||
|
network_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
let stored_last_updated = BlockCommitments::<T>::get(&network_id)
|
||||||
|
.get(&authority_index)
|
||||||
|
.map(|details| details.last_updated)
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let current_last_updated = block_commitment
|
||||||
|
.commitment
|
||||||
|
.last_updated
|
||||||
|
.saturating_sub(COMMITMENT_DELAY_MILLIS);
|
||||||
|
|
||||||
|
if current_last_updated < stored_last_updated {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 New block commitment from authority #{:?} for network {:?}",
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
let signature = match authority_key.sign(&block_commitment.encode()) {
|
||||||
|
Some(signature) => signature,
|
||||||
|
None => {
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 Block commitment signing failed from authority #{:?} for network {:?}",
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let call = Call::commit_block {
|
||||||
|
block_commitment,
|
||||||
|
signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
|
||||||
|
log::info!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"🧐 Failed to submit block commitment from authority #{:?} for network {:?}: {:?}",
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sign_and_submit<T: Config>(
|
||||||
|
&self,
|
||||||
|
from_block: u64,
|
||||||
|
authority_index: AuthIndex,
|
||||||
|
authority_key: T::AuthorityId,
|
||||||
|
session_index: SessionIndex,
|
||||||
|
network_id: NetworkIdOf<T>,
|
||||||
|
) {
|
||||||
|
match self {
|
||||||
|
EvmResponseType::TransactionLogs(_) => self.sign_and_submit_claps::<T>(
|
||||||
|
authority_index,
|
||||||
|
authority_key,
|
||||||
|
session_index,
|
||||||
|
network_id,
|
||||||
|
),
|
||||||
|
EvmResponseType::BlockNumber(_) => self.sign_and_submit_block_commitment::<T>(
|
||||||
|
from_block,
|
||||||
|
authority_index,
|
||||||
|
authority_key,
|
||||||
|
session_index,
|
||||||
|
network_id,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Log {
|
impl Log {
|
||||||
pub fn is_sufficient(&self) -> bool {
|
pub fn is_sufficient(&self) -> bool {
|
||||||
self.transaction_hash.is_some()
|
self.transaction_hash.is_some()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,14 +3,13 @@
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
derive_impl, parameter_types,
|
derive_impl, parameter_types,
|
||||||
traits::{ConstU32, ConstU64},
|
traits::{ConstU32, ConstU64},
|
||||||
weights::Weight,
|
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
use pallet_session::historical as pallet_session_historical;
|
use pallet_session::historical as pallet_session_historical;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
curve::PiecewiseLinear,
|
curve::PiecewiseLinear,
|
||||||
testing::{TestXt, UintAuthorityId},
|
testing::{TestXt, UintAuthorityId},
|
||||||
traits::ConvertInto,
|
traits::{AtLeast32BitUnsigned, ConvertInto},
|
||||||
Permill,
|
Permill,
|
||||||
};
|
};
|
||||||
use sp_staking::{
|
use sp_staking::{
|
||||||
@@ -21,7 +20,7 @@ use sp_staking::{
|
|||||||
use sp_runtime::BuildStorage;
|
use sp_runtime::BuildStorage;
|
||||||
|
|
||||||
use crate as slow_clap;
|
use crate as slow_clap;
|
||||||
use crate::Config;
|
use crate::{ApplauseListener, Config, EraIndex};
|
||||||
|
|
||||||
type Block = frame_system::mocking::MockBlock<Runtime>;
|
type Block = frame_system::mocking::MockBlock<Runtime>;
|
||||||
|
|
||||||
@@ -140,27 +139,6 @@ parameter_types! {
|
|||||||
pub static MockAverageSessionLength: Option<u64> = None;
|
pub static MockAverageSessionLength: Option<u64> = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TestNextSessionRotation;
|
|
||||||
impl frame_support::traits::EstimateNextSessionRotation<u64> for TestNextSessionRotation {
|
|
||||||
fn average_session_length() -> u64 {
|
|
||||||
let mock = MockAverageSessionLength::mutate(|p| p.take());
|
|
||||||
mock.unwrap_or(pallet_session::PeriodicSessions::<Period, Offset>::average_session_length())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn estimate_current_session_progress(now: u64) -> (Option<Permill>, Weight) {
|
|
||||||
let (estimate, weight) =
|
|
||||||
pallet_session::PeriodicSessions::<Period, Offset>::estimate_current_session_progress(
|
|
||||||
now,
|
|
||||||
);
|
|
||||||
let mock = MockCurrentSessionProgress::mutate(|p| p.take());
|
|
||||||
(mock.unwrap_or(estimate), weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn estimate_next_session_rotation(now: u64) -> (Option<u64>, Weight) {
|
|
||||||
pallet_session::PeriodicSessions::<Period, Offset>::estimate_next_session_rotation(now)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ghost_networks::Config for Runtime {
|
impl ghost_networks::Config for Runtime {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
@@ -196,22 +174,50 @@ impl pallet_balances::Config for Runtime {
|
|||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Balance = u64;
|
||||||
|
|
||||||
|
pub struct TestSomeCoolTrait;
|
||||||
|
impl ApplauseListener<Balance> for TestSomeCoolTrait
|
||||||
|
where
|
||||||
|
Balance: AtLeast32BitUnsigned + From<u64>,
|
||||||
|
{
|
||||||
|
fn get_current_era() -> EraIndex {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_threshold_amount(_era: EraIndex) -> Balance {
|
||||||
|
666_666_667u64.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_validator_total_exposure(_era: EraIndex, index: usize) -> Balance {
|
||||||
|
match index {
|
||||||
|
0 => 500_000_000u64,
|
||||||
|
1 => 300_000_000u64,
|
||||||
|
2 => 200_000_000u64,
|
||||||
|
_ => 0,
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Config for Runtime {
|
impl Config for Runtime {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type AuthorityId = UintAuthorityId;
|
type AuthorityId = UintAuthorityId;
|
||||||
|
|
||||||
type NextSessionRotation = TestNextSessionRotation;
|
|
||||||
type ValidatorSet = Historical;
|
type ValidatorSet = Historical;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type NetworkDataHandler = Networks;
|
type NetworkDataHandler = Networks;
|
||||||
type BlockNumberProvider = System;
|
type BlockNumberProvider = System;
|
||||||
type ReportUnresponsiveness = OffenceHandler;
|
type ReportUnresponsiveness = OffenceHandler;
|
||||||
|
type DisabledValidators = Session;
|
||||||
|
type ApplauseListener = TestSomeCoolTrait;
|
||||||
|
|
||||||
type MaxAuthorities = ConstU32<5>;
|
type MaxAuthorities = ConstU32<5>;
|
||||||
type ApplauseThreshold = ConstU32<50>;
|
type ApplauseThreshold = ConstU32<50>;
|
||||||
type OffenceThreshold = ConstU32<75>;
|
type OffenceThreshold = ConstU32<0>;
|
||||||
type UnsignedPriority = ConstU64<{ 1 << 20 }>;
|
type UnsignedPriority = ConstU64<{ 1 << 20 }>;
|
||||||
type HistoryDepth = HistoryDepth;
|
type HistoryDepth = HistoryDepth;
|
||||||
|
type MinAuthoritiesNumber = ConstU32<2>;
|
||||||
|
|
||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,35 @@ fn do_clap_from_first_authority(
|
|||||||
SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature)
|
SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn do_block_commitment(
|
||||||
|
session_index: u32,
|
||||||
|
network_id: u32,
|
||||||
|
authority_index: u32,
|
||||||
|
) -> dispatch::DispatchResult {
|
||||||
|
let last_updated = 1337;
|
||||||
|
|
||||||
|
let block_commitment = BlockCommitment {
|
||||||
|
session_index,
|
||||||
|
authority_index,
|
||||||
|
network_id,
|
||||||
|
commitment: CommitmentDetails {
|
||||||
|
last_registered_block: 69,
|
||||||
|
last_seen_block: 420,
|
||||||
|
last_updated,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let authority = UintAuthorityId::from((authority_index + 1) as u64);
|
||||||
|
let signature = authority.sign(&block_commitment.encode()).unwrap();
|
||||||
|
|
||||||
|
SlowClap::pre_dispatch(&crate::Call::commit_block {
|
||||||
|
block_commitment: block_commitment.clone(),
|
||||||
|
signature: signature.clone(),
|
||||||
|
})
|
||||||
|
.map_err(|e| <&'static str>::from(e))?;
|
||||||
|
|
||||||
|
SlowClap::commit_block(RuntimeOrigin::none(), block_commitment, signature)
|
||||||
|
}
|
||||||
|
|
||||||
fn do_clap_from(
|
fn do_clap_from(
|
||||||
session_index: u32,
|
session_index: u32,
|
||||||
network_id: u32,
|
network_id: u32,
|
||||||
@@ -100,7 +129,7 @@ fn do_clap_from(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_throttling_slash_function() {
|
fn should_calculate_throttling_slash_function_correctly() {
|
||||||
let dummy_offence = ThrottlingOffence {
|
let dummy_offence = ThrottlingOffence {
|
||||||
session_index: 0,
|
session_index: 0,
|
||||||
validator_set_count: 50,
|
validator_set_count: 50,
|
||||||
@@ -120,7 +149,7 @@ fn test_throttling_slash_function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_median_calculations_are_correct() {
|
fn should_calculate_median_correctly() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
let data = BTreeMap::from([
|
let data = BTreeMap::from([
|
||||||
(
|
(
|
||||||
@@ -304,6 +333,16 @@ fn request_body_is_correct_for_get_logs() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_correctly_adjust_to_block() {
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(420, 69, 1337), 420);
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(420, 1337, 69), 420);
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(1337, 420, 69), 489);
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(1337, 69, 420), 489);
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(69, 1337, 420), 69);
|
||||||
|
assert_eq!(SlowClap::adjust_to_block(69, 420, 1337), 69);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_make_http_call_for_block_number() {
|
fn should_make_http_call_for_block_number() {
|
||||||
let (offchain, state) = TestOffchainExt::new();
|
let (offchain, state) = TestOffchainExt::new();
|
||||||
@@ -361,10 +400,14 @@ fn should_make_http_call_and_parse_block_number() {
|
|||||||
|
|
||||||
let request_body = SlowClap::prepare_request_body_for_latest_block(&network_data);
|
let request_body = SlowClap::prepare_request_body_for_latest_block(&network_data);
|
||||||
let raw_response = SlowClap::fetch_from_remote(&rpc_endpoint, &request_body)?;
|
let raw_response = SlowClap::fetch_from_remote(&rpc_endpoint, &request_body)?;
|
||||||
let maybe_evm_block_number =
|
let evm_block_number = SlowClap::parse_evm_response(&raw_response).map(
|
||||||
SlowClap::apply_evm_response(&raw_response, 69, Default::default(), 420, 1)?;
|
|parsed_response| match parsed_response {
|
||||||
|
EvmResponseType::BlockNumber(block_number) => block_number,
|
||||||
|
EvmResponseType::TransactionLogs(_) => 0,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
assert_eq!(maybe_evm_block_number, Some(20335745));
|
assert_eq!(evm_block_number, 20335745);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -382,7 +425,6 @@ fn should_make_http_call_and_parse_logs() {
|
|||||||
evm_logs_response(&mut state.write());
|
evm_logs_response(&mut state.write());
|
||||||
|
|
||||||
let _: Result<(), OffchainErr<u32>> = t.execute_with(|| {
|
let _: Result<(), OffchainErr<u32>> = t.execute_with(|| {
|
||||||
let session_index = advance_session_and_get_index();
|
|
||||||
let rpc_endpoint = get_rpc_endpoint();
|
let rpc_endpoint = get_rpc_endpoint();
|
||||||
|
|
||||||
let from_block: u64 = 20335770;
|
let from_block: u64 = 20335770;
|
||||||
@@ -402,15 +444,6 @@ fn should_make_http_call_and_parse_logs() {
|
|||||||
EvmResponseType::TransactionLogs(evm_logs) => assert_eq!(evm_logs.len(), 2),
|
EvmResponseType::TransactionLogs(evm_logs) => assert_eq!(evm_logs.len(), 2),
|
||||||
}
|
}
|
||||||
|
|
||||||
let maybe_evm_block_number = SlowClap::apply_evm_response(
|
|
||||||
&raw_response,
|
|
||||||
1,
|
|
||||||
UintAuthorityId::from(2),
|
|
||||||
session_index,
|
|
||||||
network_id,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
assert_eq!(maybe_evm_block_number, None);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -529,25 +562,25 @@ fn should_applause_and_take_next_claps() {
|
|||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), 0);
|
assert_eq!(Balances::total_balance(&receiver), 0);
|
||||||
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), 0);
|
assert_eq!(Balances::total_balance(&receiver), 0);
|
||||||
assert_ok!(do_clap_from(session_index, network_id, 1, false));
|
assert_ok!(do_clap_from(session_index, network_id, 1, false));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), amount);
|
assert_eq!(Balances::total_balance(&receiver), amount);
|
||||||
assert_ok!(do_clap_from(session_index, network_id, 2, false));
|
assert_ok!(do_clap_from(session_index, network_id, 2, false));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), amount);
|
assert_eq!(Balances::total_balance(&receiver), amount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,15 +698,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 +720,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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -721,7 +743,7 @@ fn should_throw_error_if_validator_disabled_and_ignore_later() {
|
|||||||
assert_eq!(Session::disable_index(0), true);
|
assert_eq!(Session::disable_index(0), true);
|
||||||
assert_err!(
|
assert_err!(
|
||||||
do_clap_from(session_index, network_id, 0, false),
|
do_clap_from(session_index, network_id, 0, false),
|
||||||
Error::<Runtime>::CurrentValidatorIsDisabled
|
DispatchError::Other("Invalid signing address")
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0);
|
assert_eq!(pallet::ReceivedClaps::<Runtime>::get(&storage_key).len(), 0);
|
||||||
@@ -790,8 +812,8 @@ fn should_clap_without_applause_on_gatekeeper_amount_overflow() {
|
|||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key_first),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key_first),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&first_receiver), big_amount);
|
assert_eq!(Balances::total_balance(&first_receiver), big_amount);
|
||||||
assert_eq!(Balances::balance(&second_receiver), 0);
|
assert_eq!(Balances::total_balance(&second_receiver), 0);
|
||||||
|
|
||||||
for authority_index in 0..=2 {
|
for authority_index in 0..=2 {
|
||||||
let clap = Clap {
|
let clap = Clap {
|
||||||
@@ -809,8 +831,8 @@ fn should_clap_without_applause_on_gatekeeper_amount_overflow() {
|
|||||||
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
|
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(Balances::balance(&first_receiver), big_amount);
|
assert_eq!(Balances::total_balance(&first_receiver), big_amount);
|
||||||
assert_eq!(Balances::balance(&second_receiver), 0);
|
assert_eq!(Balances::total_balance(&second_receiver), 0);
|
||||||
|
|
||||||
assert_eq!(Networks::gatekeeper_amount(network_id), big_amount);
|
assert_eq!(Networks::gatekeeper_amount(network_id), big_amount);
|
||||||
assert_eq!(Networks::bridged_imbalance().bridged_in, big_amount);
|
assert_eq!(Networks::bridged_imbalance().bridged_in, big_amount);
|
||||||
@@ -854,8 +876,8 @@ fn should_clap_without_applause_on_commission_overflow() {
|
|||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key_first),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key_first),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&first_receiver), big_amount);
|
assert_eq!(Balances::total_balance(&first_receiver), big_amount);
|
||||||
assert_eq!(Balances::balance(&second_receiver), 0);
|
assert_eq!(Balances::total_balance(&second_receiver), 0);
|
||||||
|
|
||||||
for authority_index in 0..=2 {
|
for authority_index in 0..=2 {
|
||||||
let clap = Clap {
|
let clap = Clap {
|
||||||
@@ -873,8 +895,8 @@ fn should_clap_without_applause_on_commission_overflow() {
|
|||||||
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
|
assert_ok!(SlowClap::slow_clap(RuntimeOrigin::none(), clap, signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(Balances::balance(&first_receiver), big_amount);
|
assert_eq!(Balances::total_balance(&first_receiver), big_amount);
|
||||||
assert_eq!(Balances::balance(&second_receiver), 0);
|
assert_eq!(Balances::total_balance(&second_receiver), 0);
|
||||||
|
|
||||||
assert_eq!(Networks::gatekeeper_amount(network_id), big_amount);
|
assert_eq!(Networks::gatekeeper_amount(network_id), big_amount);
|
||||||
assert_eq!(Networks::gatekeeper_amount(network_id_other), big_amount);
|
assert_eq!(Networks::gatekeeper_amount(network_id_other), big_amount);
|
||||||
@@ -907,7 +929,7 @@ fn should_nullify_commission_on_finalize() {
|
|||||||
total_issuance,
|
total_issuance,
|
||||||
0u64
|
0u64
|
||||||
),
|
),
|
||||||
(420000000000000u64, 0u64)
|
(amount, 0u64)
|
||||||
); // precomputed values
|
); // precomputed values
|
||||||
assert_eq!(Networks::is_nullification_period(), true);
|
assert_eq!(Networks::is_nullification_period(), true);
|
||||||
Networks::on_finalize(System::block_number());
|
Networks::on_finalize(System::block_number());
|
||||||
@@ -945,19 +967,18 @@ fn should_avoid_applause_during_nullification_period() {
|
|||||||
|
|
||||||
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
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, 1, false));
|
||||||
assert_eq!(Balances::balance(&receiver), 0);
|
assert_eq!(Balances::total_balance(&receiver), 0);
|
||||||
|
|
||||||
Networks::on_finalize(System::block_number());
|
Networks::on_finalize(System::block_number());
|
||||||
assert_eq!(Networks::is_nullification_period(), false);
|
assert_eq!(Networks::is_nullification_period(), 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!(Balances::balance(&receiver), amount);
|
assert_eq!(Balances::total_balance(&receiver), amount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_self_applause_if_enough_received_claps() {
|
fn should_avoid_session_overlap_on_mended_session_index() {
|
||||||
let zero: u64 = 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();
|
||||||
@@ -967,67 +988,23 @@ fn should_self_applause_if_enough_received_claps() {
|
|||||||
let session_index = advance_session_and_get_index();
|
let session_index = advance_session_and_get_index();
|
||||||
let storage_key = (session_index, transaction_hash, unique_transaction_hash);
|
let storage_key = (session_index, transaction_hash, unique_transaction_hash);
|
||||||
|
|
||||||
assert_err!(
|
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
||||||
SlowClap::self_applause(
|
advance_session();
|
||||||
RuntimeOrigin::signed(receiver),
|
|
||||||
network_id,
|
|
||||||
session_index,
|
|
||||||
transaction_hash,
|
|
||||||
receiver,
|
|
||||||
amount,
|
|
||||||
),
|
|
||||||
Error::<Runtime>::NotEnoughClaps
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
pallet::ApplausesForTransaction::<Runtime>::get(&storage_key),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), zero);
|
assert_eq!(Balances::total_balance(&receiver), 0u64);
|
||||||
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, 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
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::balance(&receiver), amount);
|
assert_eq!(Balances::total_balance(&receiver), amount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,7 +1094,7 @@ fn should_not_fail_on_sub_existential_balance() {
|
|||||||
assert_eq!(Networks::gatekeeper_amount(network_id), 0);
|
assert_eq!(Networks::gatekeeper_amount(network_id), 0);
|
||||||
assert_eq!(Networks::bridged_imbalance().bridged_in, 0);
|
assert_eq!(Networks::bridged_imbalance().bridged_in, 0);
|
||||||
assert_eq!(Networks::bridged_imbalance().bridged_out, 0);
|
assert_eq!(Networks::bridged_imbalance().bridged_out, 0);
|
||||||
assert_eq!(Balances::balance(&receiver), 0);
|
assert_eq!(Balances::total_balance(&receiver), 0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
SlowClap::applauses_for_transaction(&received_claps_key),
|
SlowClap::applauses_for_transaction(&received_claps_key),
|
||||||
false
|
false
|
||||||
@@ -1131,7 +1108,7 @@ fn should_not_fail_on_sub_existential_balance() {
|
|||||||
assert_eq!(Networks::gatekeeper_amount(network_id), amount);
|
assert_eq!(Networks::gatekeeper_amount(network_id), amount);
|
||||||
assert_eq!(Networks::bridged_imbalance().bridged_in, 0);
|
assert_eq!(Networks::bridged_imbalance().bridged_in, 0);
|
||||||
assert_eq!(Networks::bridged_imbalance().bridged_out, 0);
|
assert_eq!(Networks::bridged_imbalance().bridged_out, 0);
|
||||||
assert_eq!(Balances::balance(&receiver), 0);
|
assert_eq!(Balances::total_balance(&receiver), 0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
SlowClap::applauses_for_transaction(&received_claps_key),
|
SlowClap::applauses_for_transaction(&received_claps_key),
|
||||||
true
|
true
|
||||||
@@ -1139,6 +1116,99 @@ fn should_not_fail_on_sub_existential_balance() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_emit_black_swan_if_not_enough_authorities_left() {
|
||||||
|
let (network_id, _, _) = generate_unique_hash(None, None, None, None);
|
||||||
|
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let session_index = advance_session_and_get_index();
|
||||||
|
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
||||||
|
Session::disable_index(1);
|
||||||
|
Session::disable_index(2);
|
||||||
|
|
||||||
|
advance_session();
|
||||||
|
advance_session();
|
||||||
|
System::assert_has_event(RuntimeEvent::SlowClap(crate::Event::BlackSwan));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_register_block_commitments() {
|
||||||
|
let (network_id, _, _) = generate_unique_hash(None, None, None, None);
|
||||||
|
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let session_index = advance_session_and_get_index();
|
||||||
|
|
||||||
|
for commitment_details in SlowClap::block_commitments(network_id).values() {
|
||||||
|
assert_eq!(commitment_details.last_registered_block, 0);
|
||||||
|
assert_eq!(commitment_details.last_seen_block, 0);
|
||||||
|
assert_eq!(commitment_details.last_updated, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_ok!(do_block_commitment(session_index, network_id, 0));
|
||||||
|
assert_ok!(do_block_commitment(session_index, network_id, 1));
|
||||||
|
assert_ok!(do_block_commitment(session_index, network_id, 2));
|
||||||
|
|
||||||
|
assert_err!(
|
||||||
|
do_block_commitment(session_index, network_id, 3),
|
||||||
|
DispatchError::Other("Invalid signing address"),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_err!(
|
||||||
|
do_block_commitment(session_index, network_id, 1),
|
||||||
|
Error::<Runtime>::TimeWentBackwards,
|
||||||
|
);
|
||||||
|
|
||||||
|
for commitment_details in SlowClap::block_commitments(network_id).values() {
|
||||||
|
assert_eq!(commitment_details.last_registered_block, 69);
|
||||||
|
assert_eq!(commitment_details.last_seen_block, 420);
|
||||||
|
assert_eq!(commitment_details.last_updated, 1337);
|
||||||
|
}
|
||||||
|
|
||||||
|
advance_session();
|
||||||
|
|
||||||
|
for commitment_details in SlowClap::block_commitments(network_id).values() {
|
||||||
|
assert_eq!(commitment_details.last_registered_block, 0);
|
||||||
|
assert_eq!(commitment_details.last_seen_block, 0);
|
||||||
|
assert_eq!(commitment_details.last_updated, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_accumulate_clapped_amount() {
|
||||||
|
let (network_id, transaction_hash, unique_transaction_hash) =
|
||||||
|
generate_unique_hash(None, None, None, None);
|
||||||
|
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let session_index = advance_session_and_get_index();
|
||||||
|
let storage_key = (session_index, transaction_hash, unique_transaction_hash);
|
||||||
|
|
||||||
|
let era = <Runtime as Config>::ApplauseListener::get_current_era();
|
||||||
|
let threshold_amount = <Runtime as Config>::ApplauseListener::get_threshold_amount(era);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
ClappedAmount::<Runtime>::get(&storage_key) < threshold_amount,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
assert_ok!(do_clap_from(session_index, network_id, 2, false));
|
||||||
|
assert_eq!(
|
||||||
|
ClappedAmount::<Runtime>::get(&storage_key) < threshold_amount,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
assert_ok!(do_clap_from(session_index, network_id, 1, false));
|
||||||
|
assert_eq!(
|
||||||
|
ClappedAmount::<Runtime>::get(&storage_key) < threshold_amount,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
assert_ok!(do_clap_from(session_index, network_id, 0, false));
|
||||||
|
assert_eq!(
|
||||||
|
ClappedAmount::<Runtime>::get(&storage_key) > threshold_amount,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn advance_session_and_get_index() -> u32 {
|
fn advance_session_and_get_index() -> u32 {
|
||||||
advance_session();
|
advance_session();
|
||||||
assert_eq!(Session::validators(), Vec::<u64>::new());
|
assert_eq!(Session::validators(), Vec::<u64>::new());
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -48,70 +48,7 @@ use core::marker::PhantomData;
|
|||||||
|
|
||||||
pub trait WeightInfo {
|
pub trait WeightInfo {
|
||||||
fn slow_clap() -> Weight;
|
fn slow_clap() -> Weight;
|
||||||
fn self_applause()-> Weight;
|
fn commit_block()-> Weight;
|
||||||
}
|
|
||||||
|
|
||||||
/// Weight functions for `ghost_slow_clap`.
|
|
||||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
|
||||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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)
|
|
||||||
/// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostSlowClaps::ClapsInSession` (r:1 w:1)
|
|
||||||
/// Proof: `GhostSlowClaps::ClapsInSession` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1)
|
|
||||||
/// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::NullifyNeeded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::GatekeeperAmount` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::GatekeeperAmount` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::BridgedImbalance` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::BridgedImbalance` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::AccumulatedCommission` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::AccumulatedCommission` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `System::Account` (r:1 w:1)
|
|
||||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
|
||||||
fn slow_clap() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `355`
|
|
||||||
// Estimated: `3820`
|
|
||||||
// Minimum execution time: 213_817_000 picoseconds.
|
|
||||||
Weight::from_parts(216_977_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 3820))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(10))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(7))
|
|
||||||
}
|
|
||||||
/// Storage: `GhostSlowClaps::ReceivedClaps` (r:1 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`)
|
|
||||||
/// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1)
|
|
||||||
/// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::NullifyNeeded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::GatekeeperAmount` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::GatekeeperAmount` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::BridgedImbalance` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::BridgedImbalance` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::AccumulatedCommission` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::AccumulatedCommission` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `System::Account` (r:1 w:1)
|
|
||||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
|
||||||
fn self_applause() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `655`
|
|
||||||
// Estimated: `4120`
|
|
||||||
// Minimum execution time: 210_676_000 picoseconds.
|
|
||||||
Weight::from_parts(212_905_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 4120))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(9))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
@@ -145,32 +82,8 @@ impl WeightInfo for () {
|
|||||||
.saturating_add(RocksDbWeight::get().reads(10))
|
.saturating_add(RocksDbWeight::get().reads(10))
|
||||||
.saturating_add(RocksDbWeight::get().writes(7))
|
.saturating_add(RocksDbWeight::get().writes(7))
|
||||||
}
|
}
|
||||||
/// Storage: `GhostSlowClaps::ReceivedClaps` (r:1 w:0)
|
|
||||||
/// Proof: `GhostSlowClaps::ReceivedClaps` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
fn commit_block()-> Weight {
|
||||||
/// Storage: `GhostSlowClaps::Authorities` (r:1 w:0)
|
Default::default()
|
||||||
/// Proof: `GhostSlowClaps::Authorities` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostSlowClaps::ApplausesForTransaction` (r:1 w:1)
|
|
||||||
/// Proof: `GhostSlowClaps::ApplausesForTransaction` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::NullifyNeeded` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::NullifyNeeded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::Networks` (r:1 w:0)
|
|
||||||
/// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::GatekeeperAmount` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::GatekeeperAmount` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::BridgedImbalance` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::BridgedImbalance` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `GhostNetworks::AccumulatedCommission` (r:1 w:1)
|
|
||||||
/// Proof: `GhostNetworks::AccumulatedCommission` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `System::Account` (r:1 w:1)
|
|
||||||
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
|
|
||||||
fn self_applause() -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `655`
|
|
||||||
// Estimated: `4120`
|
|
||||||
// Minimum execution time: 210_676_000 picoseconds.
|
|
||||||
Weight::from_parts(212_905_000, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 4120))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(9))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(5))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user