From e676e6882478ddf9fc8e993084b9994e4f6f13f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 20 Sep 2023 12:59:17 +0100 Subject: [PATCH] benches: fix epoch params in gov proposals --- benches/lib.rs | 15 +++++++++++---- benches/native_vps.rs | 26 +++++++++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/benches/lib.rs b/benches/lib.rs index e144e35ea54..2fdd2139496 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -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}; @@ -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; @@ -215,6 +216,7 @@ 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 { @@ -222,9 +224,9 @@ impl Default for BenchShell { 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]), @@ -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 } diff --git a/benches/native_vps.rs b/benches/native_vps.rs index e48f558dd30..1f9f723ffff 100644 --- a/benches/native_vps.rs +++ b/benches/native_vps.rs @@ -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, }; @@ -123,6 +123,12 @@ 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 { @@ -130,9 +136,9 @@ fn governance(c: &mut Criterion) { 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]), @@ -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 { @@ -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]),