From 291512f1f30888ae07153c1b304b6ca4a0d6a966 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 21 Nov 2024 17:32:54 +0100 Subject: [PATCH 1/9] Add dynamic gas config to LegacyCosmosBootstrap and use env variables for legacy cosmos tests --- .../tests/bootstrap.rs | 9 ++- .../tests/celestia_integration_tests.rs | 9 ++- .../cli/cli/src/commands/bootstrap/chain.rs | 6 +- crates/cli/cli/src/impls/build.rs | 1 + .../src/contexts/bootstrap_legacy.rs | 9 ++- .../cosmos-integration-tests/src/init.rs | 62 +++++++++++++++++++ .../cosmos-integration-tests/src/lib.rs | 1 + .../tests/bootstrap.rs | 9 ++- .../tests/bootstrap_legacy.rs | 36 ++++------- .../tests/cosmos_integration_tests.rs | 9 ++- .../tests/cosmos_integration_tests_legacy.rs | 49 ++++++++------- .../cosmos-relayer/src/contexts/build.rs | 11 +++- .../traits/fields/dynamic_gas_fee.rs | 11 ---- .../tests/both_wasm_cosmos.rs | 9 ++- .../tests/cosmos_to_wasm_cosmos.rs | 11 +++- tools/integration-test/src/tests/context.rs | 1 + 16 files changed, 164 insertions(+), 79 deletions(-) diff --git a/crates/celestia/celestia-integration-tests/tests/bootstrap.rs b/crates/celestia/celestia-integration-tests/tests/bootstrap.rs index b12ec7ff6..bbf4decef 100644 --- a/crates/celestia/celestia-integration-tests/tests/bootstrap.rs +++ b/crates/celestia/celestia-integration-tests/tests/bootstrap.rs @@ -20,7 +20,12 @@ fn test_celestia_bootstrap() -> Result<(), Error> { let runtime = HermesRuntime::new(tokio_runtime.clone()); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let dynamic_gas = Some(DynamicGasConfig::default()); + + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); let store_postfix = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis(); @@ -31,7 +36,7 @@ fn test_celestia_bootstrap() -> Result<(), Error> { cosmos_builder: builder.clone(), chain_store_dir: store_dir.join("chains"), bridge_store_dir: store_dir.join("bridges"), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas, }; tokio_runtime.block_on(async move { diff --git a/crates/celestia/celestia-integration-tests/tests/celestia_integration_tests.rs b/crates/celestia/celestia-integration-tests/tests/celestia_integration_tests.rs index f3ddadd8c..6f21db38f 100644 --- a/crates/celestia/celestia-integration-tests/tests/celestia_integration_tests.rs +++ b/crates/celestia/celestia-integration-tests/tests/celestia_integration_tests.rs @@ -23,7 +23,12 @@ use ibc_relayer_types::core::ics24_host::identifier::PortId; fn celestia_integration_tests() -> Result<(), Error> { let runtime = init_test_runtime(); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let dynamic_gas = Some(DynamicGasConfig::default()); + + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); let celestia_bootstrap = Arc::new(CosmosBootstrap { runtime: runtime.clone(), @@ -36,7 +41,7 @@ fn celestia_integration_tests() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), genesis_config_modifier: Box::new(|_| Ok(())), comet_config_modifier: Box::new(|_| Ok(())), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas, }); let cosmos_bootstrap = Arc::new(CosmosBootstrap { diff --git a/crates/cli/cli/src/commands/bootstrap/chain.rs b/crates/cli/cli/src/commands/bootstrap/chain.rs index 648f0cbf1..fc7aad216 100644 --- a/crates/cli/cli/src/commands/bootstrap/chain.rs +++ b/crates/cli/cli/src/commands/bootstrap/chain.rs @@ -44,7 +44,9 @@ where ) -> Result { let runtime = app.runtime(); - let builder = CosmosBuilder::new_with_default(runtime.clone()); + let dynamic_gas = Some(DynamicGasConfig::default()); + + let builder = CosmosBuilder::new_with_default(runtime.clone(), dynamic_gas.clone()); let bootstrap = CosmosBootstrap { runtime: runtime.clone(), @@ -57,7 +59,7 @@ where transfer_denom_prefix: args.transfer_denom.clone(), genesis_config_modifier: Box::new(|_| Ok(())), comet_config_modifier: Box::new(|_| Ok(())), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas, }; Ok(bootstrap) diff --git a/crates/cli/cli/src/impls/build.rs b/crates/cli/cli/src/impls/build.rs index 99a063bc5..12b1c90ad 100644 --- a/crates/cli/cli/src/impls/build.rs +++ b/crates/cli/cli/src/impls/build.rs @@ -35,6 +35,7 @@ where Default::default(), Default::default(), Default::default(), + None, // TODO: Fix CLIs to be able to use dynamic gas ); Ok(builder) 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 1245a3fa9..ea96369d1 100644 --- a/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs +++ b/crates/cosmos/cosmos-integration-tests/src/contexts/bootstrap_legacy.rs @@ -1,9 +1,8 @@ use alloc::sync::Arc; use cgp::core::component::UseContext; +use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig; use hermes_cosmos_test_components::bootstrap::impls::modifiers::no_modify_cosmos_sdk_config::NoModifyCosmosSdkConfig; -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::modifiers::modify_cosmos_sdk_config::CosmosSdkConfigModifierComponent; use std::path::PathBuf; @@ -60,6 +59,7 @@ pub struct LegacyCosmosBootstrap { Box Result<(), Error> + Send + Sync + 'static>, pub comet_config_modifier: Box Result<(), Error> + Send + Sync + 'static>, + pub dynamic_gas: Option, } impl CanUseLegacyCosmosSdkChainBootstrapper for LegacyCosmosBootstrap {} @@ -98,6 +98,7 @@ delegate_components! { ChainCommandPathGetterComponent, AccountPrefixGetterComponent, DenomPrefixGetterComponent, + DynamicGasGetterComponent, RandomIdFlagGetterComponent, CompatModeGetterComponent, CosmosBuilderGetterComponent, @@ -105,8 +106,6 @@ delegate_components! { CosmosGenesisConfigModifierComponent, ]: UseContext, - DynamicGasGetterComponent: - ReturnNoDynamicGas, CosmosSdkConfigModifierComponent: NoModifyCosmosSdkConfig, RelayerChainConfigBuilderComponent: diff --git a/crates/cosmos/cosmos-integration-tests/src/init.rs b/crates/cosmos/cosmos-integration-tests/src/init.rs index a5c247352..eea0c8c84 100644 --- a/crates/cosmos/cosmos-integration-tests/src/init.rs +++ b/crates/cosmos/cosmos-integration-tests/src/init.rs @@ -1,5 +1,11 @@ use alloc::sync::Arc; +use serde_json::Value as JsonValue; +use std::env; +use toml::Value as TomlValue; +use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig; +use hermes_cosmos_relayer::contexts::build::CosmosBuilder; +use hermes_error::types::Error; use hermes_runtime::types::runtime::HermesRuntime; use tokio::runtime::Builder; use tracing::info; @@ -8,6 +14,8 @@ use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::{fmt, EnvFilter}; +use crate::contexts::bootstrap_legacy::LegacyCosmosBootstrap; + pub fn init_test_runtime() -> HermesRuntime { let _ = stable_eyre::install(); @@ -28,3 +36,57 @@ pub fn init_test_runtime() -> HermesRuntime { runtime } + +pub fn init_bootstrap_legacy( + chain_id: usize, + runtime: HermesRuntime, + should_randomize_identifiers: bool, + chain_store_dir: &str, + transfer_denom_prefix: String, + genesis_modifier: impl Fn(&mut JsonValue) -> Result<(), Error> + Send + Sync + 'static, + comet_config_modifier: impl Fn(&mut TomlValue) -> Result<(), Error> + Send + Sync + 'static, + dynamic_gas: Option, +) -> LegacyCosmosBootstrap { + let cosmos_builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); + + let chain_command_path = env::var("LEGACY_GAIA_BIN").unwrap_or_else(|_| "gaiad".to_string()); + let chain_command_paths: Vec = parse_chain_command_paths(chain_command_path); + + let account_prefix = env::var("ACCOUNT_PREFIXES").unwrap_or_else(|_| "cosmos".to_string()); + let account_prefixes = parse_chain_command_paths(account_prefix); + + let staking_denom_prefix = env::var("NATIVE_TOKENS").unwrap_or_else(|_| "stake".to_string()); + let staking_denom_prefixes = parse_chain_command_paths(staking_denom_prefix); + + LegacyCosmosBootstrap { + runtime, + cosmos_builder, + should_randomize_identifiers, + chain_store_dir: chain_store_dir.into(), + chain_command_path: chain_command_paths[chain_id % chain_command_paths.len()] + .as_str() + .into(), + account_prefix: account_prefixes[chain_id % account_prefixes.len()] + .as_str() + .into(), + compat_mode: None, + staking_denom_prefix: staking_denom_prefixes[chain_id % staking_denom_prefixes.len()] + .as_str() + .into(), + transfer_denom_prefix, + genesis_config_modifier: Box::new(genesis_modifier), + comet_config_modifier: Box::new(comet_config_modifier), + dynamic_gas, + } +} + +fn parse_chain_command_paths(chain_command_path: String) -> Vec { + let patterns: Vec = chain_command_path + .split(',') + .map(|chain_binary| chain_binary.to_string()) + .collect(); + patterns +} diff --git a/crates/cosmos/cosmos-integration-tests/src/lib.rs b/crates/cosmos/cosmos-integration-tests/src/lib.rs index 493bbc13d..cd16c95d5 100644 --- a/crates/cosmos/cosmos-integration-tests/src/lib.rs +++ b/crates/cosmos/cosmos-integration-tests/src/lib.rs @@ -1,4 +1,5 @@ #![allow(clippy::type_complexity)] +#![allow(clippy::too_many_arguments)] extern crate alloc; diff --git a/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs b/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs index b8cfee851..ad5b46c3e 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/bootstrap.rs @@ -11,7 +11,12 @@ use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; fn test_cosmos_bootstrap() -> Result<(), Error> { let runtime = init_test_runtime(); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let dynamic_gas = Some(DynamicGasConfig::default()); + + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); // TODO: load parameters from environment variables let bootstrap = Arc::new(CosmosBootstrap { @@ -25,7 +30,7 @@ fn test_cosmos_bootstrap() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), genesis_config_modifier: Box::new(|_| Ok(())), comet_config_modifier: Box::new(|_| Ok(())), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas, }); runtime.runtime.clone().block_on(async move { diff --git a/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs b/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs index 143a54bb5..ffc0955c6 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs @@ -1,8 +1,6 @@ use std::sync::Arc; -use hermes_cosmos_integration_tests::contexts::bootstrap_legacy::LegacyCosmosBootstrap; -use hermes_cosmos_integration_tests::init::init_test_runtime; -use hermes_cosmos_relayer::contexts::build::CosmosBuilder; +use hermes_cosmos_integration_tests::init::{init_bootstrap_legacy, init_test_runtime}; use hermes_error::types::Error; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; @@ -10,26 +8,18 @@ use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; 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 = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); - - // TODO: load parameters from environment variables - let bootstrap = Arc::new(LegacyCosmosBootstrap { - 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(())), - }); + let dynamic_gas = None; + + let bootstrap = Arc::new(init_bootstrap_legacy( + 0, + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + dynamic_gas, + )); runtime.runtime.clone().block_on(async move { let _chain_driver = bootstrap.bootstrap_chain("chain-1").await?; 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 f7e4467bf..464da0f81 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs @@ -19,7 +19,12 @@ use ibc_relayer_types::core::ics24_host::identifier::PortId; fn cosmos_integration_tests() -> Result<(), Error> { let runtime = init_test_runtime(); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let dynamic_gas = Some(DynamicGasConfig::default()); + + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); // TODO: load parameters from environment variables let bootstrap = Arc::new(CosmosBootstrap { @@ -33,7 +38,7 @@ fn cosmos_integration_tests() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), genesis_config_modifier: Box::new(|_| Ok(())), comet_config_modifier: Box::new(|_| Ok(())), - dynamic_gas: Some(DynamicGasConfig::default()), + dynamic_gas, }); let create_client_settings = Settings { 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 index 00f3f4e1b..7a4d2c0c1 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs @@ -4,9 +4,7 @@ use core::time::Duration; use std::sync::Arc; use hermes_cosmos_integration_tests::contexts::binary_channel::setup_legacy::LegacyCosmosBinaryChannelSetup; -use hermes_cosmos_integration_tests::contexts::bootstrap_legacy::LegacyCosmosBootstrap; -use hermes_cosmos_integration_tests::init::init_test_runtime; -use hermes_cosmos_relayer::contexts::build::CosmosBuilder; +use hermes_cosmos_integration_tests::init::{init_bootstrap_legacy, init_test_runtime}; use hermes_error::types::Error; use hermes_ibc_test_suite::tests::transfer::TestIbcTransfer; use hermes_test_components::setup::traits::run_test::CanRunTest; @@ -18,26 +16,31 @@ use ibc_relayer_types::core::ics24_host::identifier::PortId; fn cosmos_integration_tests() -> 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()); + // Use this dynamic gas configuration if running test with Osmosis + //let dynamic_gas = Some(DynamicGasConfig::new(1.1, 1.6, "osmosis", "stake")); + let dynamic_gas = None; - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let bootstrap_0 = Arc::new(init_bootstrap_legacy( + 0, + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + dynamic_gas.clone(), + )); - // TODO: load parameters from environment variables - let bootstrap = Arc::new(LegacyCosmosBootstrap { - 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(())), - }); + let bootstrap_1 = Arc::new(init_bootstrap_legacy( + 1, + runtime.clone(), + true, + "./test-data", + "coin".into(), + |_| Ok(()), + |_| Ok(()), + dynamic_gas, + )); let create_client_settings = Settings { max_clock_drift: Duration::from_secs(40), @@ -46,8 +49,8 @@ fn cosmos_integration_tests() -> Result<(), Error> { }; let setup = LegacyCosmosBinaryChannelSetup { - bootstrap_a: bootstrap.clone(), - bootstrap_b: bootstrap, + bootstrap_a: bootstrap_0, + bootstrap_b: bootstrap_1, create_client_settings, init_connection_options: Default::default(), init_channel_options: Default::default(), diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index 69fadeec5..1dc2dd409 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -4,6 +4,7 @@ use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent}; use cgp::prelude::*; use eyre::eyre; use futures::lock::Mutex; +use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig; use std::collections::HashMap; use hermes_cosmos_chain_components::types::config::tx_config::TxConfig; @@ -54,6 +55,7 @@ pub struct CosmosBuilder { pub relay_cache: Arc>>, pub batch_senders: Arc>>, + pub dynamic_gas: Option, } pub struct CosmosBuildComponents; @@ -114,7 +116,7 @@ impl ProvideRelayTypeAt for CosmosBuildComponents { } impl CosmosBuilder { - pub fn new_with_default(runtime: HermesRuntime) -> Self { + pub fn new_with_default(runtime: HermesRuntime, dynamic_gas: Option) -> Self { Self::new( Default::default(), runtime, @@ -122,6 +124,7 @@ impl CosmosBuilder { Default::default(), Default::default(), Default::default(), + dynamic_gas, ) } @@ -132,6 +135,7 @@ impl CosmosBuilder { packet_filter: PacketFilter, batch_config: BatchConfig, key_map: HashMap, + dynamic_gas: Option, ) -> Self { let config_map = HashMap::from_iter( chain_configs @@ -149,6 +153,7 @@ impl CosmosBuilder { chain_cache: Default::default(), relay_cache: Default::default(), batch_senders: Default::default(), + dynamic_gas, } } @@ -184,8 +189,10 @@ impl CosmosBuilder { let event_source_mode = chain_config.event_source.clone(); - let tx_config = TxConfig::try_from(&chain_config)?; + let mut tx_config = TxConfig::try_from(&chain_config)?; + // TODO: Eventually use Config to define dynamic gas config + tx_config.gas_config.dynamic_gas_config = self.dynamic_gas.clone(); let mut rpc_client = HttpClient::new(tx_config.rpc_address.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 d9bab7bd5..bd9eae297 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 @@ -18,14 +18,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/crates/cosmos/cosmos-wasm-relayer/tests/both_wasm_cosmos.rs b/crates/cosmos/cosmos-wasm-relayer/tests/both_wasm_cosmos.rs index d009eb722..552211988 100644 --- a/crates/cosmos/cosmos-wasm-relayer/tests/both_wasm_cosmos.rs +++ b/crates/cosmos/cosmos-wasm-relayer/tests/both_wasm_cosmos.rs @@ -27,9 +27,14 @@ fn test_both_wasm_cosmos() -> Result<(), Error> { let tokio_runtime = Arc::new(Builder::new_multi_thread().enable_all().build()?); + let dynamic_gas = None; + let runtime = HermesRuntime::new(tokio_runtime.clone()); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); let store_postfix = format!( "{}-{}", @@ -62,7 +67,7 @@ fn test_both_wasm_cosmos() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), wasm_client_byte_code, governance_proposal_authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn".into(), // TODO: don't hard code this - dynamic_gas: None, + dynamic_gas, }); let chain_driver_a = bootstrap.bootstrap_chain("chain-a").await?; diff --git a/crates/cosmos/cosmos-wasm-relayer/tests/cosmos_to_wasm_cosmos.rs b/crates/cosmos/cosmos-wasm-relayer/tests/cosmos_to_wasm_cosmos.rs index 9efb55177..42e700083 100644 --- a/crates/cosmos/cosmos-wasm-relayer/tests/cosmos_to_wasm_cosmos.rs +++ b/crates/cosmos/cosmos-wasm-relayer/tests/cosmos_to_wasm_cosmos.rs @@ -30,7 +30,12 @@ fn test_cosmos_to_wasm_cosmos() -> Result<(), Error> { let runtime = HermesRuntime::new(tokio_runtime.clone()); - let builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + let dynamic_gas = None; + + let builder = Arc::new(CosmosBuilder::new_with_default( + runtime.clone(), + dynamic_gas.clone(), + )); let store_postfix = format!( "{}-{}", @@ -54,7 +59,7 @@ fn test_cosmos_to_wasm_cosmos() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), genesis_config_modifier: Box::new(|_| Ok(())), comet_config_modifier: Box::new(|_| Ok(())), - dynamic_gas: None, + dynamic_gas: dynamic_gas.clone(), }); tokio_runtime.block_on(async move { @@ -77,7 +82,7 @@ fn test_cosmos_to_wasm_cosmos() -> Result<(), Error> { transfer_denom_prefix: "coin".into(), wasm_client_byte_code, governance_proposal_authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn".into(), // TODO: don't hard code this - dynamic_gas: None, + dynamic_gas, }); let gaia_chain_driver = gaia_bootstrap.bootstrap_chain("gaia").await?; diff --git a/tools/integration-test/src/tests/context.rs b/tools/integration-test/src/tests/context.rs index a8709c97f..0291190a9 100644 --- a/tools/integration-test/src/tests/context.rs +++ b/tools/integration-test/src/tests/context.rs @@ -47,6 +47,7 @@ where packet_filter, Default::default(), key_map, + None, ); Ok(builder) From 4134243d7c3f5ce586d9627a58c983fbc49d9001 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 21 Nov 2024 17:33:30 +0100 Subject: [PATCH 2/9] Use Cosmos Nix branch for Osmosis v27 --- flake.lock | 237 +++++++++++++++++++++++++++++++++++++++++------------ flake.nix | 2 +- 2 files changed, 184 insertions(+), 55 deletions(-) diff --git a/flake.lock b/flake.lock index 3d57d4c29..9335a9bd9 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,20 +253,26 @@ "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": 1732127958, + "narHash": "sha256-Kr/h0A92hdsnFGAX4ujwLrwlk1voYJkkBp7pHwa4/ag=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "145ce6c6a1cdbca7b32521a8bc9f5434bcbda021", + "rev": "ab6c234d71822f10df955027eafd99af2964ba8d", "type": "github" }, "original": { "owner": "informalsystems", + "ref": "luca_joss/update-osmosis-to-v27", "repo": "cosmos.nix", "type": "github" } @@ -287,11 +296,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 +552,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 +711,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 +1036,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 +1053,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 +1087,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 +1121,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 +1203,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 +1252,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 +1317,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 +1517,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1721782431, - "narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=", + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4f02464258baaf54992debfd010a7a3662a25536", + "rev": "5083ec887760adfe12af64830a66807423a859a7", "type": "github" }, "original": { @@ -1506,16 +1550,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 +1695,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1729477859, - "narHash": "sha256-r0VyeJxy4O4CgTB/PNtfQft9fPfN1VuGvnZiCxDArvg=", + "lastModified": 1732156292, + "narHash": "sha256-XuTCME5ZausokOJ28AsIoayBVD1soscdoiKweT4VY50=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "ada8266712449c4c0e6ee6fcbc442b3c217c79e1", + "rev": "2d484c7a0db32f2700e253160bcd2aaa6cdca3ba", "type": "github" }, "original": { @@ -1900,16 +1944,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 +2104,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 +2171,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 +2204,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", diff --git a/flake.nix b/flake.nix index d8e8529bd..20eae7e0b 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ rust-overlay.url = github:oxalica/rust-overlay; flake-utils.url = github:numtide/flake-utils; - cosmos-nix.url = github:informalsystems/cosmos.nix; + cosmos-nix.url = github:informalsystems/cosmos.nix/luca_joss/update-osmosis-to-v27; cosmwasm-ibc-src = { url = github:informalsystems/cosmwasm-ibc; From d534f6125ef2e2418625457fa9d06422aa4de014 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 25 Nov 2024 18:00:17 +0100 Subject: [PATCH 3/9] Apply Github suggestion --- .../src/impls/bootstrap/build_cosmos_chain.rs | 3 +++ crates/cosmos/cosmos-relayer/src/contexts/build.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) 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..4ee7394e5 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, { @@ -48,6 +50,7 @@ where .build_chain_with_config( relayer_chain_config.clone(), Some(&relayer_wallet.keypair.clone()), + bootstrap.dynamic_gas().clone(), ) .await .map_err(Bootstrap::raise_error)?; diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index 1dc2dd409..b609822e2 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -164,14 +164,19 @@ impl CosmosBuilder { .cloned() .ok_or_else(|| SpawnError::missing_chain_config(chain_id.clone()))?; - self.build_chain_with_config(chain_config, self.key_map.get(chain_id)) - .await + self.build_chain_with_config( + chain_config, + self.key_map.get(chain_id), + self.dynamic_gas.clone(), + ) + .await } pub async fn build_chain_with_config( &self, chain_config: CosmosSdkConfig, m_keypair: Option<&Secp256k1KeyPair>, + dynamic_gas_config: Option, ) -> Result { let runtime = self.runtime.runtime.clone(); let chain_id = chain_config.id.clone(); @@ -191,8 +196,7 @@ impl CosmosBuilder { let mut tx_config = TxConfig::try_from(&chain_config)?; - // TODO: Eventually use Config to define dynamic gas config - tx_config.gas_config.dynamic_gas_config = self.dynamic_gas.clone(); + tx_config.gas_config.dynamic_gas_config = dynamic_gas_config; let mut rpc_client = HttpClient::new(tx_config.rpc_address.clone())?; let compat_mode = if let Some(compat_mode) = &chain_config.compat_mode { From de371068313267205a150c5519a975eee5ed7d8c Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:08:57 +0100 Subject: [PATCH 4/9] Update Nix flake --- flake.lock | 17 ++++++++--------- flake.nix | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 9335a9bd9..8fa92b9f8 100644 --- a/flake.lock +++ b/flake.lock @@ -263,16 +263,15 @@ "wasmvm_2_1_3-src": "wasmvm_2_1_3-src" }, "locked": { - "lastModified": 1732127958, + "lastModified": 1733317488, "narHash": "sha256-Kr/h0A92hdsnFGAX4ujwLrwlk1voYJkkBp7pHwa4/ag=", "owner": "informalsystems", "repo": "cosmos.nix", - "rev": "ab6c234d71822f10df955027eafd99af2964ba8d", + "rev": "a615496057a069e03674f804e2b089ac67aac925", "type": "github" }, "original": { "owner": "informalsystems", - "ref": "luca_joss/update-osmosis-to-v27", "repo": "cosmos.nix", "type": "github" } @@ -1517,11 +1516,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1733097829, + "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a", "type": "github" }, "original": { @@ -1695,11 +1694,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1732156292, - "narHash": "sha256-XuTCME5ZausokOJ28AsIoayBVD1soscdoiKweT4VY50=", + "lastModified": 1733279627, + "narHash": "sha256-NCNDAGPkdFdu+DLErbmNbavmVW9AwkgP7azROFFSB0U=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2d484c7a0db32f2700e253160bcd2aaa6cdca3ba", + "rev": "4da5a80ef76039e80468c902f1e9f5c0eab87d96", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 20eae7e0b..d8e8529bd 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ rust-overlay.url = github:oxalica/rust-overlay; flake-utils.url = github:numtide/flake-utils; - cosmos-nix.url = github:informalsystems/cosmos.nix/luca_joss/update-osmosis-to-v27; + cosmos-nix.url = github:informalsystems/cosmos.nix; cosmwasm-ibc-src = { url = github:informalsystems/cosmwasm-ibc; From d2c031c93e396fe251155c43d2215447d041d1d6 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:10:21 +0100 Subject: [PATCH 5/9] Remove unnecessary cosmos legacy test --- .../tests/cosmos_integration_tests_legacy.rs | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs 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 0c7c289e9..000000000 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests_legacy.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![recursion_limit = "256"] -use std::sync::Arc; - -use hermes_cosmos_chain_components::types::config::gas::dynamic_gas_config::DynamicGasConfig; -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 dynamic_gas_config = Some(DynamicGasConfig::new(1.1, 1.6, "osmosis", "stake")); - - 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: "osmosisd".into(), - account_prefix: "osmo".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(())), - dynamic_gas: dynamic_gas_config, - }), - }; - - 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(()) -} From 2a00c860c945347c83910e6968e45adb68e70063 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:10:44 +0100 Subject: [PATCH 6/9] Update cosmos-integration-tests CI job to use test presets --- .github/workflows/integration-tests.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 185cb6049..f0d1999b3 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -13,6 +13,12 @@ jobs: cosmos-integration-tests: runs-on: ubuntu-20.04 timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + - preset: GaiaToGaia + - preset: OsmosisToOsmosis + - preset: OsmosisToGaia steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 @@ -32,10 +38,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 From aca2b8a90816e3270cd00616bf16705b4197344a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:13:47 +0100 Subject: [PATCH 7/9] Fix cosmos-integration-tests github action --- .github/workflows/integration-tests.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index f0d1999b3..84f77e633 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -16,9 +16,10 @@ jobs: strategy: fail-fast: false matrix: - - preset: GaiaToGaia - - preset: OsmosisToOsmosis - - preset: OsmosisToGaia + preset: + - GaiaToGaia + - OsmosisToOsmosis + - OsmosisToGaia steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 From daf2a3527504e0b2d946d4d11f16965da8bdcd24 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:22:55 +0100 Subject: [PATCH 8/9] Remove legacy bootstrap test and unnecessary code --- .../tests/bootstrap.rs | 14 +++++- .../tests/bootstrap_legacy.rs | 46 ------------------- .../tests/cosmos_integration_tests.rs | 10 ---- 3 files changed, 13 insertions(+), 57 deletions(-) delete mode 100644 crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs 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 b5d9e9d8d..000000000 --- a/crates/cosmos/cosmos-integration-tests/tests/bootstrap_legacy.rs +++ /dev/null @@ -1,46 +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(())), - dynamic_gas: None, - }), - }; - - 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 937d02b35..ba2526368 100644 --- a/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs +++ b/crates/cosmos/cosmos-integration-tests/tests/cosmos_integration_tests.rs @@ -12,16 +12,6 @@ use hermes_test_components::test_case::traits::test_case::TestCase; fn cosmos_integration_tests() -> Result<(), Error> { let runtime = init_test_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 { let setup: CosmosBinaryChannelTestDriver = init_preset_bootstraps::< From 8847fef3889491de0093979b9c24e19e3e2a5193 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 14:49:07 +0100 Subject: [PATCH 9/9] Extract setup creation in different methods --- .../cosmos-integration-tests/src/init.rs | 203 ++++++++++-------- 1 file changed, 109 insertions(+), 94 deletions(-) diff --git a/crates/cosmos/cosmos-integration-tests/src/init.rs b/crates/cosmos/cosmos-integration-tests/src/init.rs index 707bfc5c4..eb7ead302 100644 --- a/crates/cosmos/cosmos-integration-tests/src/init.rs +++ b/crates/cosmos/cosmos-integration-tests/src/init.rs @@ -121,6 +121,111 @@ pub fn build_gaia_bootstrap( } } +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, + 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 @@ -128,103 +233,13 @@ 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::GaiaToGaia => { - 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(), - }; - - Ok(setup.build_driver().await?) - } - TestPreset::OsmosisToOsmosis => { - 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(), - }; - - Ok(setup.build_driver().await?) - } - TestPreset::OsmosisToGaia => { - 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(), - }; - - Ok(setup.build_driver().await?) - } + 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, } }