Skip to content

Commit

Permalink
benches: fix epoch params in gov proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Sep 20, 2023
1 parent 195c56c commit e676e68
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
15 changes: 11 additions & 4 deletions benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ use namada::ledger::masp::{
use namada::ledger::queries::{
Client, EncodedResponseQuery, RequestCtx, RequestQuery, Router, RPC,
};
use namada::ledger::storage_api::StorageRead;
use namada::ledger::wallet::Wallet;
use namada::proof_of_stake;
use namada::proto::{Code, Data, Section, Signature, Tx};
Expand All @@ -82,7 +83,7 @@ use namada::types::chain::ChainId;
use namada::types::masp::{
ExtendedViewingKey, PaymentAddress, TransferSource, TransferTarget,
};
use namada::types::storage::{BlockHeight, KeySeg, TxIndex};
use namada::types::storage::{BlockHeight, Epoch, KeySeg, TxIndex};
use namada::types::time::DateTimeUtc;
use namada::types::token::DenominatedAmount;
use namada::types::transaction::governance::InitProposalData;
Expand Down Expand Up @@ -215,16 +216,17 @@ impl Default for BenchShell {

// Initialize governance proposal
let content_section = Section::ExtraData(Code::new(vec![]));
let voting_start_epoch = Epoch(25);
let signed_tx = generate_tx(
TX_INIT_PROPOSAL_WASM,
InitProposalData {
id: None,
content: content_section.get_hash(),
author: defaults::albert_address(),
r#type: ProposalType::Default(None),
voting_start_epoch: 12.into(),
voting_end_epoch: 15.into(),
grace_epoch: 18.into(),
voting_start_epoch,
voting_end_epoch: 28.into(),
grace_epoch: 34.into(),
},
None,
Some(vec![content_section]),
Expand All @@ -239,6 +241,11 @@ impl Default for BenchShell {
for _ in 0..=(params.pipeline_len + params.unbonding_len) {
bench_shell.advance_epoch();
}
// Must start after current epoch
debug_assert_eq!(
bench_shell.wl_storage.get_block_epoch().unwrap().next(),
voting_start_epoch
);

bench_shell
}
Expand Down
26 changes: 19 additions & 7 deletions benches/native_vps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use namada::ledger::native_vp::{Ctx, NativeVp};
use namada::ledger::storage_api::StorageRead;
use namada::proto::{Code, Section};
use namada::types::address::InternalAddress;
use namada::types::storage::TxIndex;
use namada::types::storage::{Epoch, TxIndex};
use namada::types::transaction::governance::{
InitProposalData, VoteProposalData,
};
Expand Down Expand Up @@ -123,16 +123,22 @@ fn governance(c: &mut Criterion) {
),
"minimal_proposal" => {
let content_section = Section::ExtraData(Code::new(vec![]));
let voting_start_epoch = Epoch(25);
// Must start after current epoch
debug_assert_eq!(
shell.wl_storage.get_block_epoch().unwrap().next(),
voting_start_epoch
);
generate_tx(
TX_INIT_PROPOSAL_WASM,
InitProposalData {
id: None,
content: content_section.get_hash(),
author: defaults::albert_address(),
r#type: ProposalType::Default(None),
voting_start_epoch: 12.into(),
voting_end_epoch: 15.into(),
grace_epoch: 18.into(),
voting_start_epoch,
voting_end_epoch: 28.into(),
grace_epoch: 34.into(),
},
None,
Some(vec![content_section]),
Expand Down Expand Up @@ -164,6 +170,12 @@ fn governance(c: &mut Criterion) {
let wasm_code_section =
Section::ExtraData(Code::new(vec![0; max_code_size as _]));

let voting_start_epoch = Epoch(25);
// Must start after current epoch
debug_assert_eq!(
shell.wl_storage.get_block_epoch().unwrap().next(),
voting_start_epoch
);
generate_tx(
TX_INIT_PROPOSAL_WASM,
InitProposalData {
Expand All @@ -173,9 +185,9 @@ fn governance(c: &mut Criterion) {
r#type: ProposalType::Default(Some(
wasm_code_section.get_hash(),
)),
voting_start_epoch: 12.into(),
voting_end_epoch: 15.into(),
grace_epoch: 18.into(),
voting_start_epoch,
voting_end_epoch: 28.into(),
grace_epoch: 34.into(),
},
None,
Some(vec![content_section, wasm_code_section]),
Expand Down

0 comments on commit e676e68

Please sign in to comment.