Skip to content

Commit

Permalink
Add benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSasaPrsic committed Nov 20, 2024
1 parent 9058edb commit 855cc34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
26 changes: 19 additions & 7 deletions pallets/vector/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const SP1_VERIFICATION_KEY: [u8; 32] =
)]
mod benchmarks {
use super::*;
use crate::{Broadcasters, SyncCommitteeHashes};
use crate::{Broadcasters, SP1VerificationKey, SyncCommitteeHashes};
use sp_runtime::traits::AccountIdConversion;

#[benchmark]
Expand Down Expand Up @@ -496,13 +496,25 @@ mod benchmarks {

#[benchmark]
fn fulfill() -> Result<(), BenchmarkError> {
let sync_committee_hash = H256(hex!(
"f4887c7e675fa7c166c1d17e03d0dd746aa595756b66a8fb8d8fad1215d4caaf"
));
let period = 754;
SyncCommitteeHashes::<T>::set(period, sync_committee_hash);
Updater::<T>::set(H256(ACCOUNT1));
SP1VerificationKey::<T>::set(H256(SP1_VERIFICATION_KEY));

let slots_per_period = 8192;
let finality_threshold = 342u16;
let slot = 6178816u64;
ConfigurationStorage::<T>::set(Configuration {
slots_per_period,
finality_threshold,
});

let period = slot / slots_per_period;
SyncCommitteeHashes::<T>::set(
period,
H256(hex!(
"c00e7928895533bafa24fffba54cc7660664eb0134bffe39932fb28a3ddd4b46"
)),
);

Updater::<T>::set(H256(ACCOUNT1));
let account = T::AccountId::from(ACCOUNT1);
let origin = RawOrigin::Signed(account.clone());

Expand Down
6 changes: 3 additions & 3 deletions pallets/vector/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ fn set_sp1_verification_key_non_root() {
});
}

const PROOF_FILE: &str = "test/proof.bin";
pub const PROOF_FILE: &str = "test/proof.bin";

#[test]
fn test_fulfill_successfully() {
Expand All @@ -1420,7 +1420,7 @@ fn test_fulfill_successfully() {

let proof_outputs: ProofOutputs = SolValue::abi_decode(&public_inputs, true).unwrap();
let slots_per_period = 8192;
let finality_threshold = 342;
let finality_threshold = 342u16;
let slot = 6178816u64;
let current_period = slot / slots_per_period;

Expand All @@ -1430,7 +1430,7 @@ fn test_fulfill_successfully() {

ConfigurationStorage::<Test>::set(Configuration {
slots_per_period,
finality_threshold: finality_threshold as u16,
finality_threshold,
});

Updater::<Test>::set(H256(TEST_SENDER_VEC));
Expand Down

0 comments on commit 855cc34

Please sign in to comment.