Skip to content

Commit

Permalink
fix for Hermes v1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Jun 7, 2024
1 parent 7abe00c commit 1a13f8c
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 20 deletions.
51 changes: 49 additions & 2 deletions crates/relayer/src/chain/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use core::time::Duration;
use ibc_proto::ibc::applications::fee::v1::{
QueryIncentivizedPacketRequest, QueryIncentivizedPacketResponse,
};
use ibc_proto::ibc::core::channel::v1::{QueryUpgradeErrorRequest, QueryUpgradeRequest};
use ibc_proto::Protobuf;
use ibc_relayer_types::applications::ics31_icq::response::CrossChainQueryResponse;
use ibc_relayer_types::clients::ics07_tendermint::client_state::{
Expand All @@ -20,14 +21,16 @@ use ibc_relayer_types::core::ics03_connection::connection::{
};
use ibc_relayer_types::core::ics04_channel::channel::{ChannelEnd, IdentifiedChannelEnd};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::upgrade::{ErrorReceipt, Upgrade};
use ibc_relayer_types::core::ics23_commitment::commitment::CommitmentPrefix;
use ibc_relayer_types::core::ics23_commitment::merkle::MerkleProof;
use ibc_relayer_types::core::ics24_host::identifier::{
ChainId, ChannelId, ClientId, ConnectionId, PortId,
};
use ibc_relayer_types::core::ics24_host::path::{
AcksPath, ChannelEndsPath, ClientConsensusStatePath, ClientStatePath, CommitmentsPath,
ConnectionsPath, ReceiptsPath, SeqRecvsPath,
AcksPath, ChannelEndsPath, ChannelUpgradeErrorPath, ChannelUpgradePath,
ClientConsensusStatePath, ClientStatePath, CommitmentsPath, ConnectionsPath, ReceiptsPath,
SeqRecvsPath,
};
use ibc_relayer_types::events::IbcEvent;
use ibc_relayer_types::signer::Signer;
Expand Down Expand Up @@ -1220,6 +1223,50 @@ impl ChainEndpoint for NamadaChain {
// not supported
unimplemented!()
}

fn query_upgrade(
&self,
request: QueryUpgradeRequest,
height: ICSHeight,
include_proof: IncludeProof,
) -> Result<(Upgrade, Option<MerkleProof>), Error> {
let port_id = PortId::from_str(&request.port_id)
.map_err(|_| Error::invalid_port_string(request.port_id))?;
let channel_id = ChannelId::from_str(&request.channel_id)
.map_err(|_| Error::invalid_channel_string(request.channel_id))?;
let path = ChannelUpgradePath {
port_id,
channel_id,
};
let key = storage::ibc_key(path.to_string()).expect("the path should be parsable");
let (value, proof) = self.query(key, QueryHeight::Specific(height), include_proof)?;

let upgrade = Upgrade::decode_vec(&value).map_err(Error::decode)?;

Ok((upgrade, proof))
}

fn query_upgrade_error(
&self,
request: QueryUpgradeErrorRequest,
height: ICSHeight,
include_proof: IncludeProof,
) -> Result<(ErrorReceipt, Option<MerkleProof>), Error> {
let port_id = PortId::from_str(&request.port_id)
.map_err(|_| Error::invalid_port_string(request.port_id))?;
let channel_id = ChannelId::from_str(&request.channel_id)
.map_err(|_| Error::invalid_channel_string(request.channel_id))?;
let path = ChannelUpgradeErrorPath {
port_id,
channel_id,
};
let key = storage::ibc_key(path.to_string()).expect("the path should be parsable");
let (value, proof) = self.query(key, QueryHeight::Specific(height), include_proof)?;

let error_receipt = ErrorReceipt::decode_vec(&value).map_err(Error::decode)?;

Ok((error_receipt, proof))
}
}

/// Fetch the node info
Expand Down
5 changes: 4 additions & 1 deletion tools/integration-test/src/tests/channel_upgrade/flushing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeigh
use ibc_relayer_types::core::ics04_channel::channel::State as ChannelState;
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::chain::config::cosmos::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, assert_eventually_channel_upgrade_ack,
Expand Down Expand Up @@ -166,6 +166,7 @@ impl BinaryChannelTest for ChannelUpgradeFlushing {

relayer.with_supervisor(|| {
let denom_b = derive_ibc_denom(
&chains.node_b.chain_driver().value().chain_type,
&channels.port_b.as_ref(),
&channels.channel_id_b.as_ref(),
&denom_a,
Expand Down Expand Up @@ -384,6 +385,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets {
// and move channel ends to `FLUSH_COMPLETE`
relayer.with_supervisor(|| {
let ibc_denom_a = derive_ibc_denom(
&chains.node_a.chain_driver().value().chain_type,
&channels.port_a.as_ref(),
&channels.channel_id_a.as_ref(),
&denom_b,
Expand All @@ -395,6 +397,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeFlushPackets {
)?;

let ibc_denom_b = derive_ibc_denom(
&chains.node_b.chain_driver().value().chain_type,
&channels.port_b.as_ref(),
&channels.channel_id_b.as_ref(),
&denom_a,
Expand Down
8 changes: 4 additions & 4 deletions tools/integration-test/src/tests/channel_upgrade/ica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use ibc_relayer_types::signer::Signer;
use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;

use ibc_test_framework::chain::config::{
use ibc_test_framework::chain::config::cosmos::{
add_allow_message_interchainaccounts, set_max_deposit_period, set_voting_period,
};
use ibc_test_framework::chain::ext::ica::register_ordered_interchain_account;
Expand Down Expand Up @@ -90,7 +90,7 @@ impl BinaryConnectionTest for ChannelUpgradeICACloseChannel {
chains: ConnectedChains<Controller, Host>,
connection: ConnectedConnection<Controller, Host>,
) -> Result<(), Error> {
let stake_denom: MonoTagged<Host, Denom> = MonoTagged::new(Denom::base("stake"));
let stake_denom: MonoTagged<Host, Denom> = MonoTagged::new(Denom::base("stake", "stake"));

// Run the block with supervisor in order to open and then upgrade the ICA channel
let (wallet, ica_address, controller_channel_id, controller_port_id) = relayer
Expand Down Expand Up @@ -312,7 +312,7 @@ impl TestOverrides for ChannelUpgradeICAUnordered {

for chain in &mut config.chains {
match chain {
ChainConfig::CosmosSdk(chain_config) => {
ChainConfig::CosmosSdk(chain_config) | ChainConfig::Namada(chain_config) => {
chain_config.packet_filter = self.packet_filter.clone();
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ impl BinaryConnectionTest for ChannelUpgradeICAUnordered {
chains: ConnectedChains<Controller, Host>,
connection: ConnectedConnection<Controller, Host>,
) -> Result<(), Error> {
let stake_denom: MonoTagged<Host, Denom> = MonoTagged::new(Denom::base("stake"));
let stake_denom: MonoTagged<Host, Denom> = MonoTagged::new(Denom::base("stake", "stake"));

info!("Will register interchain account...");

Expand Down
3 changes: 2 additions & 1 deletion tools/integration-test/src/tests/channel_upgrade/ics29.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::chain::config::cosmos::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, assert_eventually_channel_upgrade_open,
Expand Down Expand Up @@ -202,6 +202,7 @@ impl BinaryChannelTest for ChannelUpgradeICS29 {
)?;

let denom_b = derive_ibc_denom(
&chains.node_b.chain_driver().value().chain_type,
&channels.port_b.as_ref(),
&channels.channel_id_b.as_ref(),
&denom_a,
Expand Down
3 changes: 2 additions & 1 deletion tools/integration-test/src/tests/channel_upgrade/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use ibc_relayer_types::core::ics04_channel::channel::State as ChannelState;
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_relayer_types::events::IbcEventType;
use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::chain::config::cosmos::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, assert_eventually_channel_upgrade_ack,
Expand Down Expand Up @@ -992,6 +992,7 @@ impl BinaryChannelTest for ChannelUpgradeHandshakeTimeoutOnPacketAck {
// and move channel ends to `FLUSH_COMPLETE`
relayer.with_supervisor(|| {
let ibc_denom_b = derive_ibc_denom(
&chains.node_b.chain_driver().value().chain_type,
&channels.port_b.as_ref(),
&channels.channel_id_b.as_ref(),
&denom_a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::thread::sleep;
use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::chain::config::cosmos::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, assert_eventually_channel_upgrade_open,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeigh
use ibc_relayer_types::core::ics04_channel::channel::{State as ChannelState, UpgradeState};
use ibc_relayer_types::core::ics04_channel::packet::Sequence;
use ibc_relayer_types::core::ics04_channel::version::Version;
use ibc_test_framework::chain::config::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::chain::config::cosmos::{set_max_deposit_period, set_voting_period};
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::channel::{
assert_eventually_channel_established, assert_eventually_channel_upgrade_ack,
Expand Down
2 changes: 1 addition & 1 deletion tools/integration-test/src/tests/ica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;

use ibc_test_framework::chain::{
config::add_allow_message_interchainaccounts,
config::cosmos::add_allow_message_interchainaccounts,
ext::ica::{register_interchain_account, register_ordered_interchain_account},
};
use ibc_test_framework::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl TestOverrides for DynamicGasTest {
update_relayer_config_for_consumer_chain(config);

match &mut config.chains[0] {
ChainConfig::CosmosSdk(chain_config_a) => {
ChainConfig::CosmosSdk(chain_config_a) | ChainConfig::Namada(chain_config_a) => {
chain_config_a.gas_price =
GasPrice::new(0.3, chain_config_a.gas_price.denom.clone());

Expand All @@ -89,7 +89,7 @@ impl TestOverrides for DynamicGasTest {
}

match &mut config.chains[1] {
ChainConfig::CosmosSdk(chain_config_b) => {
ChainConfig::CosmosSdk(chain_config_b) | ChainConfig::Namada(chain_config_b) => {
chain_config_b.gas_price =
GasPrice::new(0.3, chain_config_b.gas_price.denom.clone());

Expand Down Expand Up @@ -121,15 +121,14 @@ impl BinaryChannelTest for DynamicGasTest {
let a_to_b_amount = 12345u64;

let denom_a_to_b = derive_ibc_denom(
&chains.node_b.chain_driver().value().chain_type,
&channel.port_b.as_ref(),
&channel.channel_id_b.as_ref(),
&denom_a,
)?;

let gas_denom_a: MonoTagged<ChainA, Denom> =
MonoTagged::new(Denom::Base("stake".to_owned()));
let gas_denom_b: MonoTagged<ChainB, Denom> =
MonoTagged::new(Denom::Base("stake".to_owned()));
let gas_denom_a: MonoTagged<ChainA, Denom> = MonoTagged::new(Denom::base("stake", "stake"));
let gas_denom_b: MonoTagged<ChainB, Denom> = MonoTagged::new(Denom::base("stake", "stake"));

let balance_relayer_b_before = chains.node_b.chain_driver().query_balance(
&chains.node_b.wallets().relayer().address(),
Expand Down Expand Up @@ -185,6 +184,7 @@ impl BinaryChannelTest for DynamicGasTest {
let denom_b = chains.node_b.denom();

let denom_b_to_a = derive_ibc_denom(
&chains.node_a.chain_driver().value().chain_type,
&channel.port_a.as_ref(),
&channel.channel_id_a.as_ref(),
&denom_b,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ibc_relayer_types::bigint::U256;
use ibc_relayer_types::signer::Signer;
use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;
use ibc_test_framework::chain::config::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::config::cosmos::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::ext::ica::register_interchain_account;
use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test;
use ibc_test_framework::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ibc_relayer_types::bigint::U256;
use ibc_relayer_types::signer::Signer;
use ibc_relayer_types::timestamp::Timestamp;
use ibc_relayer_types::tx_msg::Msg;
use ibc_test_framework::chain::config::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::config::cosmos::add_allow_message_interchainaccounts;
use ibc_test_framework::chain::ext::ica::register_interchain_account;
use ibc_test_framework::framework::binary::channel::run_binary_interchain_security_channel_test;
use ibc_test_framework::prelude::*;
Expand Down

0 comments on commit 1a13f8c

Please sign in to comment.