Skip to content

Commit

Permalink
Remove hardcoded EIP endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Nov 14, 2024
1 parent ccb3a02 commit 276573f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
14 changes: 10 additions & 4 deletions crates/cosmos/cosmos-chain-components/src/impls/queries/eip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ where
+ CanRaiseError<core::num::ParseFloatError>
+ CanRaiseError<EipQueryError>,
{
async fn query_eip_base_fee(chain: &Chain, path: &str) -> Result<f64, Chain::Error> {
let url = format!("{}{path}", chain.rpc_address());
async fn query_eip_base_fee(chain: &Chain, _denom: &str) -> Result<f64, Chain::Error> {
let url = format!(
"{}abci_query?path=\"/osmosis.txfees.v1beta1.Query/GetEipBaseFee\"",
chain.rpc_address()
);

let response = reqwest::get(&url).await.map_err(Chain::raise_error)?;

Expand Down Expand Up @@ -178,8 +181,11 @@ where
+ CanRaiseError<core::num::ParseFloatError>
+ CanRaiseError<EipQueryError>,
{
async fn query_eip_base_fee(chain: &Chain, path: &str) -> Result<f64, Chain::Error> {
let url = format!("{}{path}", chain.rpc_address());
async fn query_eip_base_fee(chain: &Chain, denom: &str) -> Result<f64, Chain::Error> {
let url = format!(
"{}abci_query?path=\"/feemarket.feemarket.v1.Query/GasPrices\"&denom={denom}",
chain.rpc_address()
);

let response = reqwest::get(&url).await.map_err(Chain::raise_error)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ where
let adjusted_gas_limit =
adjust_estimated_gas(gas_config.gas_multiplier, gas_config.max_gas, gas_used);

// TODO: do not hardcode path to be compatible with both Skip and Osmosis endpoints
let base_fee = chain
.query_eip_base_fee(&format!(
"abci_query?path=\"/feemarket.feemarket.v1.Query/GasPrices\"&denom={}",
gas_config.gas_price.denom
))
.query_eip_base_fee(gas_config.gas_price.denom.as_str())
.await
.map_err(Chain::raise_error)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ use cgp::prelude::*;
#[derive_component(EipQuerierComponent, EipQuerier<Chain>)]
#[async_trait]
pub trait CanQueryEipBaseFee: Async + HasErrorType {
async fn query_eip_base_fee(&self, path: &str) -> Result<f64, Self::Error>;
async fn query_eip_base_fee(&self, denom: &str) -> Result<f64, Self::Error>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ where
relayer_wallet,
)?;

tracing::info!("Relayer config: {:?}", relayer_chain_config);

// TODO: Have a more reliable way to wait for the bootstrapped full node to
// start up. If we don't wait, the building of the chain would fail during
// the spawning of `ChainHandle`, as the v1 relayer tries to perform health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use crate::bootstrap::traits::fields::chain_store_dir::ChainStoreDirGetter;
pub use crate::bootstrap::traits::fields::denom::{
DenomForStaking, DenomForTransfer, DenomPrefixGetter, GenesisDenomGetterComponent,
};
use crate::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas;
pub use crate::bootstrap::traits::fields::hd_path::WalletHdPathComponent;
use crate::bootstrap::traits::fields::random_id::RandomIdFlagGetter;
pub use crate::bootstrap::traits::generator::generate_chain_id::ChainIdGeneratorComponent;
Expand Down Expand Up @@ -119,7 +120,8 @@ where
+ CanRaiseError<KeyringError>
+ CanRaiseError<serde_json::Error>
+ CanRaiseError<toml::ser::Error>
+ CanRaiseError<toml::de::Error>,
+ CanRaiseError<toml::de::Error>
+ HasDynamicGas,
Components: DelegatesToCosmosSdkBootstrapComponents
+ ProvideChainType<Bootstrap, Chain = Chain>
+ ProvideChainDriverType<Bootstrap, ChainDriver = ChainDriver>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use crate::bootstrap::traits::fields::chain_store_dir::ChainStoreDirGetter;
pub use crate::bootstrap::traits::fields::denom::{
DenomForStaking, DenomForTransfer, DenomPrefixGetter, GenesisDenomGetterComponent,
};
use crate::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas;
pub use crate::bootstrap::traits::fields::hd_path::WalletHdPathComponent;
use crate::bootstrap::traits::fields::random_id::RandomIdFlagGetter;
pub use crate::bootstrap::traits::generator::generate_chain_id::ChainIdGeneratorComponent;
Expand Down Expand Up @@ -111,7 +112,8 @@ where
+ CanRaiseError<KeyringError>
+ CanRaiseError<serde_json::Error>
+ CanRaiseError<toml::ser::Error>
+ CanRaiseError<toml::de::Error>,
+ CanRaiseError<toml::de::Error>
+ HasDynamicGas,
Components: DelegatesToLegacyCosmosSdkBootstrapComponents
+ ProvideChainType<Bootstrap, Chain = Chain>
+ ProvideChainDriverType<Bootstrap, ChainDriver = ChainDriver>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use hermes_runtime_components::traits::runtime::HasRuntime;
use serde_json::{Error as JsonError, Value};

use crate::bootstrap::traits::fields::denom::{DenomForStaking, DenomForTransfer, HasDenomPrefix};
use crate::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas;
use crate::bootstrap::traits::initializers::init_genesis_config::ChainGenesisConfigInitializer;
use crate::bootstrap::traits::modifiers::modify_genesis_config::CanModifyCosmosGenesisConfig;
use crate::bootstrap::traits::types::genesis_config::HasChainGenesisConfigType;
Expand All @@ -24,6 +25,7 @@ where
+ HasDenomPrefix<DenomForTransfer>
+ CanRaiseError<Runtime::Error>
+ CanRaiseError<JsonError>
+ HasDynamicGas
+ CanRaiseError<&'static str>,
Runtime: HasFilePathType + CanReadFileAsString + CanWriteStringToFile,
Bootstrap::ChainGenesisConfig: From<CosmosGenesisConfig>,
Expand All @@ -49,6 +51,11 @@ where

bootstrap.modify_genesis_config(&mut config_json)?;

// If dynamic gas pricing is not enabled in the relayer, disable it on the chain
if bootstrap.dynamic_gas().is_none() {
disable_fee_market(&mut config_json).map_err(Bootstrap::raise_error)?;
}

let modified_config_string =
serde_json::to_string_pretty(&config_json).map_err(Bootstrap::raise_error)?;

Expand Down

0 comments on commit 276573f

Please sign in to comment.