From 29e6ca04abe438261d6e5bbb6b5b3897bdb08db4 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:59:50 +0100 Subject: [PATCH] Use `TEST_PRESET` env to run cosmos tests with different chains (#477) * Add dynamic gas config to LegacyCosmosBootstrap and use env variables for legacy cosmos tests * Use Cosmos Nix branch for Osmosis v27 * Apply Github suggestion * Update Nix flake * Remove unnecessary cosmos legacy test * Update cosmos-integration-tests CI job to use test presets * Fix cosmos-integration-tests github action * Remove legacy bootstrap test and unnecessary code * Extract setup creation in different methods --- .github/workflows/integration-tests.yaml | 12 +- .../src/contexts/bootstrap_legacy.rs | 9 +- .../src/impls/bootstrap/build_cosmos_chain.rs | 2 + .../impls/bootstrap/relayer_chain_config.rs | 87 +++---- .../cosmos-integration-tests/src/init.rs | 157 ++++++++++-- .../cosmos-integration-tests/src/lib.rs | 2 + .../tests/bootstrap.rs | 14 +- .../tests/bootstrap_legacy.rs | 45 ---- .../tests/cosmos_integration_tests.rs | 25 +- .../tests/cosmos_integration_tests_legacy.rs | 61 ----- .../cosmos-relayer/src/contexts/build.rs | 2 - .../traits/fields/dynamic_gas_fee.rs | 11 - flake.lock | 236 ++++++++++++++---- 13 files changed, 391 insertions(+), 272 deletions(-) delete mode 100644 crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs delete mode 100644 crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 185cb6049..84f77e633 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -13,6 +13,13 @@ jobs: cosmos-integration-tests: runs-on: ubuntu-20.04 timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + preset: + - GaiaToGaia + - OsmosisToOsmosis + - OsmosisToGaia steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 @@ -32,10 +39,9 @@ jobs: - name: run integration tests env: RUST_BACKTRACE: 1 + TEST_PRESET: ${{ matrix.preset }} run: | - export LEGACY_GAIA_BIN=$(nix build .#gaia14 --print-out-paths --no-link)/bin/gaiad - - nix shell .#cargo-nextest .#protobuf .#gaia .#celestia-app .#ibc-go-v8-simapp -c \ + nix shell .#cargo-nextest .#protobuf .#gaia .#celestia-app .#ibc-go-v8-simapp .#osmosis -c \ cargo nextest run -p hermes-cosmos-integration-tests \ --test-threads=2 diff --git a/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs b/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs index d1c792baa..de9aa6a26 100644 --- a/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs +++ b/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use cgp::core::component::UseContext; use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent}; use cgp::prelude::*; +use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig; use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_cosmos_test_components::bootstrap::components::cosmos_sdk_legacy::*; use hermes_cosmos_test_components::bootstrap::impls::generator::wallet_config::GenerateStandardWalletConfig; @@ -14,9 +15,7 @@ use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::Ac use hermes_cosmos_test_components::bootstrap::traits::fields::chain_command_path::ChainCommandPathGetterComponent; use hermes_cosmos_test_components::bootstrap::traits::fields::chain_store_dir::ChainStoreDirGetterComponent; use hermes_cosmos_test_components::bootstrap::traits::fields::denom::DenomPrefixGetterComponent; -use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::{ - DynamicGasGetterComponent, ReturnNoDynamicGas, -}; +use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::DynamicGasGetterComponent; use hermes_cosmos_test_components::bootstrap::traits::fields::random_id::RandomIdFlagGetterComponent; use hermes_cosmos_test_components::bootstrap::traits::generator::generate_wallet_config::WalletConfigGeneratorComponent; use hermes_cosmos_test_components::bootstrap::traits::modifiers::modify_comet_config::CometConfigModifierComponent; @@ -66,6 +65,7 @@ pub struct LegacyCosmosBootstrapFields { Box Result<(), Error> + Send + Sync + 'static>, pub comet_config_modifier: Box Result<(), Error> + Send + Sync + 'static>, + pub dynamic_gas: Option, } impl CanUseLegacyCosmosSdkChainBootstrapper for LegacyCosmosBootstrap {} @@ -112,6 +112,7 @@ delegate_components! { ChainCommandPathGetterComponent, AccountPrefixGetterComponent, DenomPrefixGetterComponent, + DynamicGasGetterComponent, RandomIdFlagGetterComponent, CompatModeGetterComponent, CosmosBuilderGetterComponent, @@ -119,8 +120,6 @@ delegate_components! { CosmosGenesisConfigModifierComponent, ]: UseContext, - DynamicGasGetterComponent: - ReturnNoDynamicGas, CosmosSdkConfigModifierComponent: NoModifyCosmosSdkConfig, RelayerChainConfigBuilderComponent: diff --git a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/build_cosmos_chain.rs b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/build_cosmos_chain.rs index 5db402311..214c283b5 100644 --- a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/build_cosmos_chain.rs +++ b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/build_cosmos_chain.rs @@ -2,6 +2,7 @@ use core::time::Duration; use cgp::core::error::CanRaiseError; use hermes_cosmos_relayer::contexts::chain::CosmosChain; +use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas; use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType; use hermes_cosmos_test_components::chain::types::wallet::CosmosTestWallet; use hermes_error::types::HermesError; @@ -22,6 +23,7 @@ where + CanBuildRelayerChainConfig + HasCosmosBuilder + HasRuntime + + HasDynamicGas + CanRaiseError, Bootstrap::Runtime: CanSleep, { diff --git a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs index c9c03a62c..6c1a7c3f4 100644 --- a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs +++ b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs @@ -2,7 +2,8 @@ use core::str::FromStr; use core::time::Duration; use cgp::core::error::CanRaiseError; -use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; +use hermes_cosmos_chain_components::impls::types::config::{CosmosChainConfig, EventSourceMode}; +use hermes_cosmos_chain_components::types::config::gas::gas_config::GasConfig; use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::HasAccountPrefix; use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas; use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType; @@ -12,12 +13,10 @@ use hermes_cosmos_test_components::bootstrap::types::genesis_config::CosmosGenes use hermes_cosmos_test_components::chain::types::wallet::CosmosTestWallet; use hermes_test_components::chain::traits::types::wallet::HasWalletType; use hermes_test_components::chain_driver::traits::types::chain::HasChainType; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; -use ibc_relayer::config::dynamic_gas::DynamicGasPrice; -use ibc_relayer::config::gas_multiplier::GasMultiplier; +use ibc_proto::cosmos::base::v1beta1::Coin; +use ibc_proto::cosmos::tx::v1beta1::Fee; use ibc_relayer::config::{self, AddressType}; -use ibc_relayer::keyring::Store; -use tendermint_rpc::{Error as TendermintRpcError, Url, WebSocketClientUrl}; +use tendermint_rpc::{Error as TendermintRpcError, Url}; use crate::traits::bootstrap::compat_mode::HasCompatMode; use crate::traits::bootstrap::relayer_chain_config::RelayerChainConfigBuilder; @@ -41,63 +40,59 @@ where chain_genesis_config: &CosmosGenesisConfig, relayer_wallet: &CosmosTestWallet, ) -> Result { - let dynamic_gas_price = if let Some(dynamic_gas_config) = bootstrap.dynamic_gas() { - DynamicGasPrice::unsafe_new(true, dynamic_gas_config.multiplier, dynamic_gas_config.max) - } else { - DynamicGasPrice::default() + let gas_multiplier = 1.3; + let gas_price = 1.0; + let fee_granter = "".to_owned(); + let max_gas = 900000000; + let max_amount = (max_gas as f64 * gas_multiplier) * gas_price; + let max_gas_fee_in_coin = Coin { + denom: chain_genesis_config.staking_denom.to_string(), + amount: max_amount.to_string(), }; - let relayer_chain_config = CosmosSdkConfig { - id: chain_node_config.chain_id.clone(), + + let max_fee = Fee { + amount: vec![max_gas_fee_in_coin], + gas_limit: max_gas, + payer: "".to_string(), + granter: fee_granter.clone(), + }; + + let gas_config = GasConfig { + default_gas: 400_000, + max_gas, + gas_multiplier, + gas_price: config::GasPrice::new(1.0, chain_genesis_config.staking_denom.to_string()), + max_fee, + fee_granter, + dynamic_gas_config: bootstrap.dynamic_gas().clone(), + }; + + let relayer_chain_config = CosmosChainConfig { + id: chain_node_config.chain_id.to_string(), rpc_addr: Url::from_str(&format!("http://localhost:{}", chain_node_config.rpc_port)) .map_err(Bootstrap::raise_error)?, grpc_addr: Url::from_str(&format!("http://localhost:{}", chain_node_config.grpc_port)) .map_err(Bootstrap::raise_error)?, - event_source: config::EventSourceMode::Push { - url: WebSocketClientUrl::from_str(&format!( - "ws://localhost:{}/websocket", - chain_node_config.rpc_port - )) - .map_err(Bootstrap::raise_error)?, - batch_delay: config::default::batch_delay(), + event_source: EventSourceMode::Push { + url: format!("ws://localhost:{}/websocket", chain_node_config.rpc_port), }, rpc_timeout: config::default::rpc_timeout(), - trusted_node: false, - genesis_restart: None, account_prefix: bootstrap.account_prefix().into(), key_name: relayer_wallet.id.clone(), - key_store_type: Store::Test, key_store_folder: Some(chain_node_config.chain_home_dir.join("hermes_keyring")), store_prefix: "ibc".to_string(), - default_gas: None, - max_gas: Some(900000000), - gas_adjustment: None, - gas_multiplier: Some(GasMultiplier::unsafe_new(1.3)), - dynamic_gas_price, - fee_granter: None, max_msg_num: Default::default(), max_tx_size: Default::default(), - max_grpc_decoding_size: config::default::max_grpc_decoding_size(), - query_packets_chunk_size: config::default::query_packets_chunk_size(), max_block_time: Duration::from_secs(30), clock_drift: Duration::from_secs(5), - trusting_period: Some(Duration::from_secs(14 * 24 * 3600)), - client_refresh_rate: config::default::client_refresh_rate(), - ccv_consumer_chain: false, - trust_threshold: Default::default(), - gas_price: config::GasPrice::new(1.0, chain_genesis_config.staking_denom.to_string()), - packet_filter: Default::default(), - address_type: AddressType::Cosmos, - memo_prefix: Default::default(), - memo_overwrite: None, - proof_specs: Default::default(), + gas_config, + address_type: AddressType::Cosmos.to_string(), extension_options: Default::default(), - sequential_batch_tx: false, - compat_mode: bootstrap.compat_mode().cloned(), - clear_interval: None, - excluded_sequences: Default::default(), - allow_ccq: false, + compat_mode: bootstrap + .compat_mode() + .map(|compat_mode| compat_mode.to_string()), }; - Ok(relayer_chain_config.into()) + Ok(relayer_chain_config) } } diff --git a/crates/cosmos/cosmos-integration-tests/src/init.rs b/crates/cosmos/cosmos-integration-tests/src/init.rs index 8646cac0b..eb7ead302 100644 --- a/crates/cosmos/cosmos-integration-tests/src/init.rs +++ b/crates/cosmos/cosmos-integration-tests/src/init.rs @@ -7,6 +7,8 @@ use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::Dyna use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_error::types::Error; use hermes_runtime::types::runtime::HermesRuntime; +use hermes_test_components::setup::traits::driver::{CanBuildTestDriver, HasTestDriverType}; +use ibc_relayer_types::core::ics24_host::identifier::PortId; use serde_json::Value as JsonValue; use tokio::runtime::Builder; use toml::Value as TomlValue; @@ -16,11 +18,15 @@ use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::{fmt, EnvFilter}; +use crate::contexts::binary_channel::setup::CosmosBinaryChannelSetup; +use crate::contexts::binary_channel::test_driver::CosmosBinaryChannelTestDriver; use crate::contexts::bootstrap::{CosmosBootstrap, CosmosBootstrapFields}; use crate::contexts::bootstrap_legacy::{LegacyCosmosBootstrap, LegacyCosmosBootstrapFields}; pub enum TestPreset { - CosmosToCosmos, + GaiaToGaia, + OsmosisToOsmosis, + OsmosisToGaia, } impl FromStr for TestPreset { @@ -28,7 +34,9 @@ impl FromStr for TestPreset { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { - "cosmostocosmos" => Ok(TestPreset::CosmosToCosmos), + "gaiatogaia" => Ok(TestPreset::GaiaToGaia), + "osmosistoosmosis" => Ok(TestPreset::OsmosisToOsmosis), + "osmosistogaia" => Ok(TestPreset::OsmosisToGaia), _ => Err(Report::msg("unknown test preset: `{s}`")), } } @@ -63,6 +71,8 @@ pub fn build_osmosis_bootstrap( genesis_modifier: impl Fn(&mut JsonValue) -> Result<(), Error> + Send + Sync + 'static, comet_config_modifier: impl Fn(&mut TomlValue) -> Result<(), Error> + Send + Sync + 'static, ) -> LegacyCosmosBootstrap { + let dynamic_gas_config = Some(DynamicGasConfig::new(1.1, 1.6, "osmosis", "stake")); + let cosmos_builder = CosmosBuilder::new_with_default(runtime.clone()); LegacyCosmosBootstrap { @@ -78,6 +88,7 @@ pub fn build_osmosis_bootstrap( transfer_denom_prefix, genesis_config_modifier: Box::new(genesis_modifier), comet_config_modifier: Box::new(comet_config_modifier), + dynamic_gas: dynamic_gas_config, }), } } @@ -90,6 +101,7 @@ pub fn build_gaia_bootstrap( genesis_modifier: impl Fn(&mut JsonValue) -> Result<(), Error> + Send + Sync + 'static, comet_config_modifier: impl Fn(&mut TomlValue) -> Result<(), Error> + Send + Sync + 'static, ) -> CosmosBootstrap { + let dynamic_gas_config = Some(DynamicGasConfig::default()); let cosmos_builder = CosmosBuilder::new_with_default(runtime.clone()); CosmosBootstrap { @@ -104,39 +116,130 @@ pub fn build_gaia_bootstrap( transfer_denom_prefix, genesis_config_modifier: Box::new(genesis_modifier), comet_config_modifier: Box::new(comet_config_modifier), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas: dynamic_gas_config, }), } } -pub fn init_preset_bootstraps( +async fn setup_gaia_to_gaia( + runtime: &HermesRuntime, + builder: CosmosBuilder, +) -> Result { + let bootstrap_chain_0 = build_gaia_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let bootstrap_chain_1 = build_gaia_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let setup = CosmosBinaryChannelSetup { + bootstrap_a: bootstrap_chain_0, + bootstrap_b: bootstrap_chain_1, + builder, + create_client_payload_options: Default::default(), + init_connection_options: Default::default(), + init_channel_options: Default::default(), + port_id: PortId::transfer(), + }; + + setup.build_driver().await +} + +async fn setup_osmosis_to_osmosis( runtime: &HermesRuntime, -) -> Result<(CosmosBootstrap, CosmosBootstrap), Error> { + builder: CosmosBuilder, +) -> Result { + let bootstrap_chain_0 = build_osmosis_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let bootstrap_chain_1 = build_osmosis_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let setup = CosmosBinaryChannelSetup { + bootstrap_a: bootstrap_chain_0, + bootstrap_b: bootstrap_chain_1, + builder, + create_client_payload_options: Default::default(), + init_connection_options: Default::default(), + init_channel_options: Default::default(), + port_id: PortId::transfer(), + }; + + setup.build_driver().await +} + +async fn setup_osmosis_to_gaia( + runtime: &HermesRuntime, + builder: CosmosBuilder, +) -> Result { + let bootstrap_chain_0 = build_osmosis_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let bootstrap_chain_1 = build_gaia_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + ); + + let setup = CosmosBinaryChannelSetup { + bootstrap_a: bootstrap_chain_0, + bootstrap_b: bootstrap_chain_1, + builder, + create_client_payload_options: Default::default(), + init_connection_options: Default::default(), + init_channel_options: Default::default(), + port_id: PortId::transfer(), + }; + + setup.build_driver().await +} + +pub async fn init_preset_bootstraps( + runtime: &HermesRuntime, +) -> Result +where + Setup: HasTestDriverType, +{ let test_preset = env::var("TEST_PRESET") - .unwrap_or_else(|_| "CosmosToCosmos".to_string()) + .unwrap_or_else(|_| "GaiaToGaia".to_string()) .parse::()?; + let builder = CosmosBuilder::new_with_default(runtime.clone()); match test_preset { - TestPreset::CosmosToCosmos => { - let bootstrap_chain_0 = build_gaia_bootstrap( - runtime.clone(), - true, - "./test-data", - "coin".into(), - |_| Ok(()), - |_| Ok(()), - ); - - let bootstrap_chain_1 = build_gaia_bootstrap( - runtime.clone(), - true, - "./test-data", - "coin".into(), - |_| Ok(()), - |_| Ok(()), - ); - - Ok((bootstrap_chain_0, bootstrap_chain_1)) - } + TestPreset::GaiaToGaia => setup_gaia_to_gaia(runtime, builder).await, + TestPreset::OsmosisToOsmosis => setup_osmosis_to_osmosis(runtime, builder).await, + TestPreset::OsmosisToGaia => setup_osmosis_to_gaia(runtime, builder).await, } } diff --git a/crates/cosmos/cosmos-integration-tests/src/lib.rs b/crates/cosmos/cosmos-integration-tests/src/lib.rs index 493bbc13d..8da8e00cc 100644 --- a/crates/cosmos/cosmos-integration-tests/src/lib.rs +++ b/crates/cosmos/cosmos-integration-tests/src/lib.rs @@ -1,4 +1,6 @@ #![allow(clippy::type_complexity)] +#![allow(clippy::too_many_arguments)] +#![recursion_limit = "256"] extern crate alloc; diff --git a/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs b/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs index 97823ae34..aff9ec0ed 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs @@ -1,6 +1,8 @@ use std::sync::Arc; -use hermes_cosmos_integration_tests::init::{build_gaia_bootstrap, init_test_runtime}; +use hermes_cosmos_integration_tests::init::{ + build_gaia_bootstrap, build_osmosis_bootstrap, init_test_runtime, +}; use hermes_error::types::Error; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; @@ -17,8 +19,18 @@ fn test_cosmos_bootstrap() -> Result<(), Error> { |_| Ok(()), )); + let bootstrap_legacy = Arc::new(build_osmosis_bootstrap( + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + )); + runtime.runtime.clone().block_on(async move { let _chain_driver = bootstrap.bootstrap_chain("chain-1").await?; + let _chain_driver = bootstrap_legacy.bootstrap_chain("chain-2").await?; >::Ok(()) })?; diff --git a/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs b/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs deleted file mode 100644 index 12b8a351f..000000000 --- a/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::sync::Arc; - -use hermes_cosmos_integration_tests::contexts::bootstrap_legacy::{ - LegacyCosmosBootstrap, LegacyCosmosBootstrapFields, -}; -use hermes_cosmos_integration_tests::init::init_test_runtime; -use hermes_cosmos_relayer::contexts::build::CosmosBuilder; -use hermes_error::types::Error; -use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; - -#[test] -fn test_cosmos_legacy_bootstrap() -> Result<(), Error> { - let runtime = init_test_runtime(); - - // Note: This test only works with Gaia v14 or older. Hence we get the older version of - // gaiad from the environment variable, if applicable. - let gaia_bin = std::env::var("LEGACY_GAIA_BIN").unwrap_or("gaiad".into()); - - let builder = CosmosBuilder::new_with_default(runtime.clone()); - - // TODO: load parameters from environment variables - let bootstrap = LegacyCosmosBootstrap { - fields: Arc::new(LegacyCosmosBootstrapFields { - runtime: runtime.clone(), - cosmos_builder: builder, - should_randomize_identifiers: true, - chain_store_dir: "./test-data".into(), - chain_command_path: gaia_bin.into(), - account_prefix: "cosmos".into(), - compat_mode: None, - staking_denom_prefix: "stake".into(), - transfer_denom_prefix: "coin".into(), - genesis_config_modifier: Box::new(|_| Ok(())), - comet_config_modifier: Box::new(|_| Ok(())), - }), - }; - - runtime.runtime.clone().block_on(async move { - let _chain_driver = bootstrap.bootstrap_chain("chain-1").await?; - - >::Ok(()) - })?; - - Ok(()) -} diff --git a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs index b846131d9..ba2526368 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs @@ -1,33 +1,24 @@ #![recursion_limit = "256"] use hermes_cosmos_integration_tests::contexts::binary_channel::setup::CosmosBinaryChannelSetup; +use hermes_cosmos_integration_tests::contexts::binary_channel::test_driver::CosmosBinaryChannelTestDriver; +use hermes_cosmos_integration_tests::contexts::bootstrap::CosmosBootstrap; use hermes_cosmos_integration_tests::init::{init_preset_bootstraps, init_test_runtime}; -use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_error::types::Error; use hermes_ibc_test_suite::tests::transfer::TestIbcTransfer; -use hermes_test_components::setup::traits::run_test::CanRunTest; -use ibc_relayer_types::core::ics24_host::identifier::PortId; +use hermes_test_components::test_case::traits::test_case::TestCase; #[test] fn cosmos_integration_tests() -> Result<(), Error> { let runtime = init_test_runtime(); - let builder = CosmosBuilder::new_with_default(runtime.clone()); - - let (bootstrap_chain_0, bootstrap_chain_1) = init_preset_bootstraps(&runtime)?; - - let setup = CosmosBinaryChannelSetup { - bootstrap_a: bootstrap_chain_0, - bootstrap_b: bootstrap_chain_1, - builder, - create_client_payload_options: Default::default(), - init_connection_options: Default::default(), - init_channel_options: Default::default(), - port_id: PortId::transfer(), - }; // TODO: Use a test suite entry point for running multiple tests runtime.runtime.clone().block_on(async move { - setup.run_test(&TestIbcTransfer).await?; + let setup: CosmosBinaryChannelTestDriver = init_preset_bootstraps::< + CosmosBinaryChannelSetup, + >(&runtime) + .await?; + TestIbcTransfer::run_test(&TestIbcTransfer, &setup).await?; >::Ok(()) })?; diff --git a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs deleted file mode 100644 index 0c3cc588b..000000000 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![recursion_limit = "256"] - -use std::sync::Arc; - -use hermes_cosmos_integration_tests::contexts::binary_channel::setup::CosmosBinaryChannelSetup; -use hermes_cosmos_integration_tests::contexts::bootstrap_legacy::{ - LegacyCosmosBootstrap, LegacyCosmosBootstrapFields, -}; -use hermes_cosmos_integration_tests::init::init_test_runtime; -use hermes_cosmos_relayer::contexts::build::CosmosBuilder; -use hermes_error::types::Error; -use hermes_ibc_test_suite::tests::transfer::TestIbcTransfer; -use hermes_test_components::setup::traits::run_test::CanRunTest; -use ibc_relayer_types::core::ics24_host::identifier::PortId; - -#[test] -fn cosmos_integration_tests_legacy() -> Result<(), Error> { - let runtime = init_test_runtime(); - - // Note: This test only works with Gaia v14 or older. Hence we get the older version of - // gaiad from the environment variable, if applicable. - let gaia_bin = std::env::var("LEGACY_GAIA_BIN").unwrap_or("gaiad".into()); - - let builder = CosmosBuilder::new_with_default(runtime.clone()); - - // TODO: load parameters from environment variables - let bootstrap = LegacyCosmosBootstrap { - fields: Arc::new(LegacyCosmosBootstrapFields { - runtime: runtime.clone(), - cosmos_builder: builder.clone(), - should_randomize_identifiers: true, - chain_store_dir: "./test-data".into(), - chain_command_path: gaia_bin.into(), - account_prefix: "cosmos".into(), - compat_mode: None, - staking_denom_prefix: "stake".into(), - transfer_denom_prefix: "coin".into(), - genesis_config_modifier: Box::new(|_| Ok(())), - comet_config_modifier: Box::new(|_| Ok(())), - }), - }; - - let setup = CosmosBinaryChannelSetup { - builder, - bootstrap_a: bootstrap.clone(), - bootstrap_b: bootstrap, - create_client_payload_options: Default::default(), - init_connection_options: Default::default(), - init_channel_options: Default::default(), - port_id: PortId::transfer(), - }; - - // TODO: Use a test suite entry point for running multiple tests - runtime.runtime.clone().block_on(async move { - setup.run_test(&TestIbcTransfer).await?; - - >::Ok(()) - })?; - - Ok(()) -} diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index eb10aabbf..04155d22c 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -189,8 +189,6 @@ impl CosmosBuilder { let event_source_mode = chain_config.event_source.clone(); - //let tx_config = TxConfig::try_from(&chain_config)?; - let mut rpc_client = HttpClient::new(chain_config.rpc_addr.clone())?; let compat_mode = if let Some(compat_mode) = &chain_config.compat_mode { diff --git a/crates/cosmos/cosmos-test-components/src/bootstrap/traits/fields/dynamic_gas_fee.rs b/crates/cosmos/cosmos-test-components/src/bootstrap/traits/fields/dynamic_gas_fee.rs index e410b96de..598676dbf 100644 --- a/crates/cosmos/cosmos-test-components/src/bootstrap/traits/fields/dynamic_gas_fee.rs +++ b/crates/cosmos/cosmos-test-components/src/bootstrap/traits/fields/dynamic_gas_fee.rs @@ -17,14 +17,3 @@ where bootstrap.get_field(PhantomData) } } - -pub struct ReturnNoDynamicGas; - -impl DynamicGasGetter for ReturnNoDynamicGas -where - Bootstrap: Async, -{ - fn dynamic_gas(_bootstrap: &Bootstrap) -> &Option { - &None - } -} diff --git a/flake.lock b/flake.lock index 3d57d4c29..8fa92b9f8 100644 --- a/flake.lock +++ b/flake.lock @@ -135,15 +135,16 @@ "cometbft-src": { "flake": false, "locked": { - "narHash": "sha256-G5gchJMn/BFzwYx8/ikPDL5fS/TuFIBF4DKJbkalp/M=", + "lastModified": 1723450629, + "narHash": "sha256-2QO4KeEUX4HHT1AKhEdPplJHjBhalfM11Dn3/urIVig=", "owner": "cometbft", "repo": "cometbft", - "rev": "66a5a9da9f7a3306f382eb9142ccb9c9f7997d3f", + "rev": "e1b4453baf0af6487ad187c7f17dc50517126673", "type": "github" }, "original": { "owner": "cometbft", - "ref": "v0.38.0", + "ref": "v0.38.11", "repo": "cometbft", "type": "github" } @@ -191,6 +192,8 @@ "gaia15-src": "gaia15-src", "gaia17-src": "gaia17-src", "gaia18-src": "gaia18-src", + "gaia19-src": "gaia19-src", + "gaia20-src": "gaia20-src", "gaia5-src": "gaia5-src", "gaia6-ordered-src": "gaia6-ordered-src", "gaia6-src": "gaia6-src", @@ -250,16 +253,21 @@ "wasmvm_1_3_0-src": "wasmvm_1_3_0-src", "wasmvm_1_5_0-src": "wasmvm_1_5_0-src", "wasmvm_1_5_2-src": "wasmvm_1_5_2-src", + "wasmvm_1_5_4-src": "wasmvm_1_5_4-src", + "wasmvm_1_5_5-src": "wasmvm_1_5_5-src", "wasmvm_1_beta7-src": "wasmvm_1_beta7-src", "wasmvm_2_0_0-src": "wasmvm_2_0_0-src", - "wasmvm_2_1_0-src": "wasmvm_2_1_0-src" + "wasmvm_2_0_3-src": "wasmvm_2_0_3-src", + "wasmvm_2_1_0-src": "wasmvm_2_1_0-src", + "wasmvm_2_1_2-src": "wasmvm_2_1_2-src", + "wasmvm_2_1_3-src": "wasmvm_2_1_3-src" }, "locked": { - "lastModified": 1724685350, - "narHash": "sha256-CssFaW6yHgKLRvzgVZ6ryrkVNk/eazqw+QJyKPdP9P0=", + "lastModified": 1733317488, + "narHash": "sha256-Kr/h0A92hdsnFGAX4ujwLrwlk1voYJkkBp7pHwa4/ag=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "145ce6c6a1cdbca7b32521a8bc9f5434bcbda021", + "rev": "a615496057a069e03674f804e2b089ac67aac925", "type": "github" }, "original": { @@ -287,11 +295,11 @@ "cosmwasm-ibc-src": { "flake": false, "locked": { - "lastModified": 1729198400, - "narHash": "sha256-/5gMBaruutccPvmFuXNTl+8Bi/BzBcC9jnNL42IHDbw=", + "lastModified": 1731691856, + "narHash": "sha256-9bW7TzDundT8uVY1k9qfxrcTBihvb0a0gj7/sQs2ffg=", "owner": "informalsystems", "repo": "cosmwasm-ibc", - "rev": "a376f5df23a6b1a0ef2fe3f65f5be1697972f1da", + "rev": "36e4e0b1db641091aeaf2fc2535c069e50f447b9", "type": "github" }, "original": { @@ -543,11 +551,11 @@ "systems": "systems_6" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -702,6 +710,40 @@ "type": "github" } }, + "gaia19-src": { + "flake": false, + "locked": { + "lastModified": 1724235134, + "narHash": "sha256-iAljnCnviTZ0wpgUYtTj+adH6imx6g6+niLq72yuoTk=", + "owner": "cosmos", + "repo": "gaia", + "rev": "4106e7a673da18b518fd81231a8e8b99bbf0fd0d", + "type": "github" + }, + "original": { + "owner": "cosmos", + "ref": "v19.1.0", + "repo": "gaia", + "type": "github" + } + }, + "gaia20-src": { + "flake": false, + "locked": { + "lastModified": 1726853009, + "narHash": "sha256-N7x3k56AtPbIbbJjqKmlEJIytKElALJwj14lZ2pewZg=", + "owner": "cosmos", + "repo": "gaia", + "rev": "2dba9d471ef73b0a99e844bf55a44ddae700ea06", + "type": "github" + }, + "original": { + "owner": "cosmos", + "ref": "v20.0.0", + "repo": "gaia", + "type": "github" + } + }, "gaia5-src": { "flake": false, "locked": { @@ -993,16 +1035,16 @@ "ibc-go-v6-src": { "flake": false, "locked": { - "lastModified": 1712318519, - "narHash": "sha256-roRXZEOJIFJiXEQ+a71QdMmqoVJKVk2wvPgHJ9r/mQ8=", + "lastModified": 1713970631, + "narHash": "sha256-MpBZ/V8agG3/GFJXEY3kSp+FnUw8rX5C613l5D8HXs4=", "owner": "cosmos", "repo": "ibc-go", - "rev": "8e31269c692d87ac65bfe70cf609925975a57203", + "rev": "8cd96f4169ebee21d50ef69417203b21cf4238ab", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v6.3.0", + "ref": "v6.3.1", "repo": "ibc-go", "type": "github" } @@ -1010,16 +1052,16 @@ "ibc-go-v7-src": { "flake": false, "locked": { - "lastModified": 1712318559, - "narHash": "sha256-uYiUNXLD48v3vRGK6/aQ7z7Ed5hY8VnEBGG/3Uv87Nc=", + "lastModified": 1725009574, + "narHash": "sha256-6Wpxu4mQaSrQKOLSb3kUpzRrr0aIHVMVEHVwpGJw3sM=", "owner": "cosmos", "repo": "ibc-go", - "rev": "802ca265dba74a293747e1ccb8b7999aa985af19", + "rev": "a5dde80a4ba1c4601aa055a311bf46779104627f", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v7.4.0", + "ref": "v7.8.0", "repo": "ibc-go", "type": "github" } @@ -1044,16 +1086,16 @@ "ibc-go-v8-src": { "flake": false, "locked": { - "lastModified": 1716359952, - "narHash": "sha256-KTjyHwmXA/jgppDKRe85XfRmh8O7AHFKhDyyOb9VROU=", + "lastModified": 1726232417, + "narHash": "sha256-oIfVmXIOkRqDF4NGmHsh5BELCIzPydAqiz+7urnZ7A4=", "owner": "cosmos", "repo": "ibc-go", - "rev": "9b6567bf818198ded336490d5f2d89c9d42fd87b", + "rev": "6b2554360c0e3f0bbaa59da5b16b29fc05675c57", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v8.3.1", + "ref": "v8.5.1", "repo": "ibc-go", "type": "github" } @@ -1078,16 +1120,16 @@ "ibc-go-v9-src": { "flake": false, "locked": { - "lastModified": 1723037346, - "narHash": "sha256-ba8gbJ0l4l8ZRT9XVN3hTcnxZSb5Fn20p1xiEG4/54c=", + "lastModified": 1725262239, + "narHash": "sha256-F2p/lIs2/ropKdm0Pebz1kjhRlgwYK0BmDGe/sYec3Y=", "owner": "cosmos", "repo": "ibc-go", - "rev": "66ebf864d7bfe2193a96c972a9e74196b2ddf104", + "rev": "8983f91e519fb1c43d9c9481ba60f11e4ae2b2b0", "type": "github" }, "original": { "owner": "cosmos", - "ref": "v9.0.0-beta.1", + "ref": "v9.0.0-rc.0", "repo": "ibc-go", "type": "github" } @@ -1160,15 +1202,16 @@ "interchain-security-src": { "flake": false, "locked": { - "narHash": "sha256-adBzn51PKoRsCL9gIzC5Tcqmu7u3GjxTcDj2jpZ/da8=", + "lastModified": 1726849313, + "narHash": "sha256-1WEvV3LoXfGvZC9fXOb8mBLKVGCVBiXZcwUewSPit+8=", "owner": "cosmos", "repo": "interchain-security", - "rev": "03aada4af3243dbf739a12adfacc7b37232df694", + "rev": "1e60637f9d8f3505208282416abfbb87fabc4795", "type": "github" }, "original": { "owner": "cosmos", - "ref": "feat/ics-misbehaviour-handling", + "ref": "v6.1.0", "repo": "interchain-security", "type": "github" } @@ -1208,16 +1251,16 @@ "juno-src": { "flake": false, "locked": { - "lastModified": 1720542396, - "narHash": "sha256-niG12wn49bt184zqctrGsT73mgKfZUPTZAzSKX+ZLVs=", + "lastModified": 1727102451, + "narHash": "sha256-UaTCcK+I6Wl4yCpbNckx+lRi55kTSucJxzw5irJOVh4=", "owner": "CosmosContracts", "repo": "juno", - "rev": "bf140aa60045ba92b83d0cb7f3bc47a2661a4e7e", + "rev": "de3c4d145c7a96c31e3fca6fe8850ce4ab559e33", "type": "github" }, "original": { "owner": "CosmosContracts", - "ref": "v23.0.0", + "ref": "v25.0.0", "repo": "juno", "type": "github" } @@ -1273,16 +1316,16 @@ "neutron-src": { "flake": false, "locked": { - "lastModified": 1722341371, - "narHash": "sha256-dhBhWytamqp1hRsQH+xqpq1UJmPi6CRHHDQwveCQ2WQ=", + "lastModified": 1724773633, + "narHash": "sha256-pHubObIv3p6IrzI/U7aeDjdF5kWBpI9qgDoH/Hjk+i8=", "owner": "neutron-org", "repo": "neutron", - "rev": "db33d3302abb45ee3887a97ea3d53923241fc167", + "rev": "1b10cd282d5809ccdd87208918fd175aebec2b0b", "type": "github" }, "original": { "owner": "neutron-org", - "ref": "v4.1.0", + "ref": "v4.2.2", "repo": "neutron", "type": "github" } @@ -1473,11 +1516,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1721782431, - "narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=", + "lastModified": 1733097829, + "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4f02464258baaf54992debfd010a7a3662a25536", + "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a", "type": "github" }, "original": { @@ -1506,16 +1549,16 @@ "osmosis-src": { "flake": false, "locked": { - "lastModified": 1719537675, - "narHash": "sha256-8Lb2SppNfq3+JwP3uanmCxuCek6tXOO/GcG27XGxRrE=", + "lastModified": 1731942173, + "narHash": "sha256-Ie+LKLrWthkGgJGlVpiTDwBvgA+Mo77Isa65vIOr1Ao=", "owner": "osmosis-labs", "repo": "osmosis", - "rev": "b973bffdf127866f45624d7e5a81f31fdc8e8e0b", + "rev": "100ba81036f01a348271ed59917881e2b83d0fbc", "type": "github" }, "original": { "owner": "osmosis-labs", - "ref": "v25.2.0", + "ref": "v27.0.1", "repo": "osmosis", "type": "github" } @@ -1651,11 +1694,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1729477859, - "narHash": "sha256-r0VyeJxy4O4CgTB/PNtfQft9fPfN1VuGvnZiCxDArvg=", + "lastModified": 1733279627, + "narHash": "sha256-NCNDAGPkdFdu+DLErbmNbavmVW9AwkgP7azROFFSB0U=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "ada8266712449c4c0e6ee6fcbc442b3c217c79e1", + "rev": "4da5a80ef76039e80468c902f1e9f5c0eab87d96", "type": "github" }, "original": { @@ -1900,16 +1943,16 @@ "wasmd-src": { "flake": false, "locked": { - "lastModified": 1720696698, - "narHash": "sha256-b2u3PWtjZAgmTdm/b3UcGn9K9qVQj9DR4FMcqg67T1w=", + "lastModified": 1724231006, + "narHash": "sha256-X8Q93gqk+gBJwn4EIxFVeWqRpHcIxNAplfARejHwfbk=", "owner": "CosmWasm", "repo": "wasmd", - "rev": "1ff818801d4aa5dd6f483571ac7a38660c59c671", + "rev": "de7db0dc672e7beb201e06e7eb12b2de356ac7c9", "type": "github" }, "original": { "owner": "CosmWasm", - "ref": "v0.52.0", + "ref": "v0.53.0", "repo": "wasmd", "type": "github" } @@ -2060,6 +2103,40 @@ "type": "github" } }, + "wasmvm_1_5_4-src": { + "flake": false, + "locked": { + "lastModified": 1723135235, + "narHash": "sha256-DGQHC20eMa1CDIx9fWYTTBxdFDCPoS/SsEDJnWJ+7bA=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "9f85c0f44fb8a5573be8e461cad12f784c544c4b", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v1.5.4", + "repo": "wasmvm", + "type": "github" + } + }, + "wasmvm_1_5_5-src": { + "flake": false, + "locked": { + "lastModified": 1727088523, + "narHash": "sha256-ysS2pMMm+s1JsHVv9RhiMHt5g4UGcE5jqOI5YKdC4vU=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "0c5b9ce8446189f07d2bf65fbb902817cf57a563", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v1.5.5", + "repo": "wasmvm", + "type": "github" + } + }, "wasmvm_1_beta7-src": { "flake": false, "locked": { @@ -2093,6 +2170,23 @@ "type": "github" } }, + "wasmvm_2_0_3-src": { + "flake": false, + "locked": { + "lastModified": 1723134607, + "narHash": "sha256-fFFP9sqlfgFbjAPP6VVXEcDQ3is2RHZYNE003Ls8Sfk=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "64b8c846dadb664eeb9da765a98fc370eb594f6d", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v2.0.3", + "repo": "wasmvm", + "type": "github" + } + }, "wasmvm_2_1_0-src": { "flake": false, "locked": { @@ -2109,6 +2203,40 @@ "repo": "wasmvm", "type": "github" } + }, + "wasmvm_2_1_2-src": { + "flake": false, + "locked": { + "lastModified": 1723135029, + "narHash": "sha256-Y3BVRR2T5MLOtXdPK38W8MX8etIuqGcTjvxkaEOyvVM=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "d8f06b73e4d49f8246e1569f032962122427882b", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v2.1.2", + "repo": "wasmvm", + "type": "github" + } + }, + "wasmvm_2_1_3-src": { + "flake": false, + "locked": { + "lastModified": 1727089467, + "narHash": "sha256-gYrK2EHhXnearJgLX38O6NLI6TfoGtpzA9be/7S/0ZU=", + "owner": "CosmWasm", + "repo": "wasmvm", + "rev": "2a104d140a5b2974dab7c15044da652769018cbe", + "type": "github" + }, + "original": { + "owner": "CosmWasm", + "ref": "v2.1.3", + "repo": "wasmvm", + "type": "github" + } } }, "root": "root",