diff --git a/pallets/slow-clap/Cargo.toml b/pallets/slow-clap/Cargo.toml index dad0a04..6faf2ae 100644 --- a/pallets/slow-clap/Cargo.toml +++ b/pallets/slow-clap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghost-slow-clap" -version = "0.4.16" +version = "0.4.17" description = "Applause protocol for the EVM bridge" license.workspace = true authors.workspace = true diff --git a/pallets/slow-clap/src/benchmarking.rs b/pallets/slow-clap/src/benchmarking.rs index f664c58..10ec813 100644 --- a/pallets/slow-clap/src/benchmarking.rs +++ b/pallets/slow-clap/src/benchmarking.rs @@ -114,6 +114,36 @@ benchmarks! { assert_eq!(stored_commitment.last_updated, 1337); } + try_offend_validators { + let n in 4 .. T::MaxAuthorities::get(); + + let session_index = T::ValidatorSet::session_index(); + let mut validators_vec = Vec::new(); + + for i in 0..T::MaxAuthorities::get() { + let v = account("validator", i, 0); + validators_vec.push(v); + } + + let validators = WeakBoundedVec::, T::MaxAuthorities>::try_from(validators_vec) + .expect("weak bounded vec should be constructed; qed"); + + let offence_type = OffenceType::CommitmentOffence; + let disabled_bitmap = BitMap::new(T::MaxAuthorities::get()); + let mut offence_bitmap = BitMap::new(T::MaxAuthorities::get()); + for i in 0 .. (n / 3) { + offence_bitmap.set(i); + } + }: { + let _ = Pallet::::try_offend_validators( + &session_index, + &validators, + offence_bitmap, + disabled_bitmap, + offence_type + ); + } + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext(), diff --git a/pallets/slow-clap/src/weights.rs b/pallets/slow-clap/src/weights.rs index 8d32173..b78ca31 100644 --- a/pallets/slow-clap/src/weights.rs +++ b/pallets/slow-clap/src/weights.rs @@ -84,11 +84,28 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(7)) } - fn commit_block()-> Weight { - Default::default() + /// Storage: `GhostNetworks::Networks` (r:1 w:0) + /// Proof: `GhostNetworks::Networks` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `GhostSlowClaps::BlockCommitments` (r:1 w:1) + /// Proof: `GhostSlowClaps::BlockCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `GhostSlowClaps::Validators` (r:1 w:0) + /// Proof: `GhostSlowClaps::Validators` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `GhostSlowClaps::DisabledAuthorityIndexes` (r:1 w:0) + /// Proof: `GhostSlowClaps::DisabledAuthorityIndexes` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn commit_block() -> Weight { + // Proof Size summary in bytes: + // Measured: `859` + // Estimated: `4324` + // Minimum execution time: 108_966_000 picoseconds. + Weight::from_parts(110_454_000, 0) + .saturating_add(Weight::from_parts(0, 4324)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(1)) } - fn try_offend_validators(offenders_len: u32) -> Weight { + fn try_offend_validators(_offenders_len: u32) -> Weight { Default::default() } }