Skip to content

Commit

Permalink
fix benches
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Jan 24, 2024
1 parent 27603d2 commit b335442
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 81 deletions.
77 changes: 46 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ flate2 = "1.0.22"
fs_extra = "1.2.0"
futures = "0.3"
git2 = "0.18.1"
ibc = {git = "https://github.com/cosmos/ibc-rs", branch = "feat/ics721-impl", features = ["serde"]}
ibc = {git = "https://github.com/cosmos/ibc-rs", rev = "5053973072f0f955e5d11a048293712c92c4a676", features = ["serde"]}
ibc-derive = "0.5.0"
ibc-testkit = {git = "https://github.com/cosmos/ibc-rs", branch = "feat/ics721-impl", default-features = false}
ibc-testkit = {git = "https://github.com/cosmos/ibc-rs", rev = "5053973072f0f955e5d11a048293712c92c4a676", default-features = false}
ics23 = "0.11.0"
index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", features = ["serialize-borsh", "serialize-serde"] }
itertools = "0.10.0"
Expand Down
21 changes: 12 additions & 9 deletions crates/apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use masp_primitives::zip32::ExtendedFullViewingKey;
use masp_proofs::prover::LocalTxProver;
use namada::governance::storage::proposal::ProposalType;
use namada::governance::InitProposalData;
use namada::ibc::apps::transfer::types::msgs::transfer::MsgTransfer;
use namada::ibc::apps::transfer::types::msgs::transfer::MsgTransfer as IbcMsgTransfer;
use namada::ibc::apps::transfer::types::packet::PacketData;
use namada::ibc::apps::transfer::types::PrefixedCoin;
use namada::ibc::clients::tendermint::client_state::ClientState;
Expand Down Expand Up @@ -47,7 +47,7 @@ use namada::ibc::core::host::types::path::{
ClientConsensusStatePath, ClientStatePath, Path as IbcPath,
};
use namada::ibc::primitives::proto::{Any, Protobuf};
use namada::ibc::primitives::{Timestamp as IbcTimestamp, ToProto};
use namada::ibc::primitives::Timestamp as IbcTimestamp;
use namada::ibc::storage::port_key;
use namada::ledger::dry_run_tx;
use namada::ledger::gas::TxGasMeter;
Expand All @@ -63,6 +63,7 @@ use namada::tx::{Code, Data, Section, Signature, Tx};
use namada::types::address::{self, Address, InternalAddress};
use namada::types::chain::ChainId;
use namada::types::hash::Hash;
use namada::types::ibc::MsgTransfer;
use namada::types::io::StdIo;
use namada::types::key::common::SecretKey;
use namada::types::masp::{
Expand Down Expand Up @@ -325,7 +326,7 @@ impl BenchShell {
tx
}

pub fn generate_ibc_tx(&self, wasm_code_path: &str, msg: Any) -> Tx {
pub fn generate_ibc_tx(&self, wasm_code_path: &str, data: Vec<u8>) -> Tx {
// This function avoid serializaing the tx data with Borsh
let mut tx = Tx::from_type(namada::tx::data::TxType::Decrypted(
namada::tx::data::DecryptedTx::Decrypted,
Expand All @@ -338,10 +339,7 @@ impl BenchShell {
Some(wasm_code_path.to_string()),
));

let mut data = vec![];
prost::Message::encode(&msg, &mut data).unwrap();
tx.set_data(Data::new(data));

// NOTE: the Ibc VP doesn't actually check the signature
tx
}
Expand All @@ -367,7 +365,7 @@ impl BenchShell {
let timeout_timestamp =
(now + std::time::Duration::new(3600, 0)).unwrap();

let msg = MsgTransfer {
let message = IbcMsgTransfer {
port_id_on_a: PortId::transfer(),
chan_id_on_a: ChannelId::new(5),
packet_data: PacketData {
Expand All @@ -380,7 +378,12 @@ impl BenchShell {
timeout_timestamp_on_b: timeout_timestamp,
};

self.generate_ibc_tx(TX_IBC_WASM, msg.to_any())
let msg = MsgTransfer {
message,
shielded_transfer: None,
};

self.generate_ibc_tx(TX_IBC_WASM, msg.serialize_to_vec())
}

pub fn execute_tx(&mut self, tx: &Tx) {
Expand Down Expand Up @@ -421,7 +424,7 @@ impl BenchShell {
.set_header(get_dummy_header())
.unwrap();
// Set client state
let client_id = ClientId::new("01-tendermint", 1).unwrap();
let client_id = ClientId::new("07-tendermint", 1).unwrap();
let client_state_key = addr_key.join(&Key::from(
IbcPath::ClientState(ClientStatePath(client_id.clone()))
.to_string()
Expand Down
1 change: 1 addition & 0 deletions crates/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ masp_primitives.workspace = true
borsh.workspace = true
borsh-ext.workspace = true
criterion = { version = "0.5", features = ["html_reports"] }
prost.workspace = true
rand_core.workspace = true
rand.workspace = true
tempfile.workspace = true
Expand Down
Loading

0 comments on commit b335442

Please sign in to comment.