Skip to content

Commit

Permalink
Port Osmosis EIP fee query feature (#3771)
Browse files Browse the repository at this point in the history
* Fix README badge (#3675)

* Fix a bug in `query_next_sequence_receive`, where if we didnt ask for a proof, then the query height was ignored (#3662)

* Enable serde feature of ibc-proto (#3678)

* Update misbehaviour-ics tests (#3681)

* Update light_client_attack_freeze_test.sh

Update script to work with ICS `feat/ics-misbehaviour-handling` branch binary at `28e0c14b`.


Signed-off-by: Simon Noetzlin <[email protected]>

* Update nix flake and remaining misbehaviour tests

* Fix env variable increment

* Use Cosmos Nix 'master' branch

---------

Signed-off-by: Simon Noetzlin <[email protected]>
Co-authored-by: Luca Joss <[email protected]>

* Bump version to v1.7.1

* Do not perform client update if consensus state already exists (#3555)

* Do not perform client update if consensus state already exists

On some chains there are a few active channels using the same connection
and therefore clients. This PR adds a check in the client update code and
not create the message if the consensus state at desired height is already present.
This helps with reducing relayer fees, state bloating, etc by eliminating redundant updates.

* Improve error message in `update client` command

* Add changelog entry for #3521

* Fix guide config files and balance outputs (#3690)

* Add per chain `clear_interval` configuration (#3693)

* Add per chain clear_interval configuration

* Add changelog entry

* Add guide entry for packet clearing

* Reword config comment

Signed-off-by: Romain Ruetschi <[email protected]>

---------

Signed-off-by: Romain Ruetschi <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* Add CompatMode configuration (#3667)

* Update test bootstrap to work with Celestia chain

* Update Nix flake and add Celestia CI job

* Add changelog entry

* Add guide section for 'compat_mode' configuration

* Apply suggestions from code review

Co-authored-by: Romain Ruetschi <[email protected]>
Signed-off-by: Luca Joss <[email protected]>

* Implement serialization and deserialization for CompatMode

* Update crates/relayer/src/util/compat_mode.rs

Co-authored-by: Romain Ruetschi <[email protected]>
Signed-off-by: Luca Joss <[email protected]>

---------

Signed-off-by: Luca Joss <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* docs: fix typos (#3687)

* docs: fix typos

* test: fix error because of typo

* Fix misbehaviour test

---------

Co-authored-by: Luca Joss <[email protected]>
Co-authored-by: Luca Joss <[email protected]>

* Update changelog

* Apply suggestions from code review

Co-authored-by: Luca Joss <[email protected]>
Signed-off-by: Romain Ruetschi <[email protected]>

* Release Hermes v1.7.2 (#3709)

* Add metric to count skipped client update messages (#3706)

* Add metric to count skipped client update messages

* Update guide with new metric

* Add changelog entry

* Update versions

* Fix cargo doc warnings and update version reference in relayer crate

* Fix clippy error

* Fix relayer-rest test

* Fix typo in changelog

* Add `broadcast_errors` metric (#3710)

* Add metric for broadcast errors

* Update the guide with the new broadcast error metric

* Add changelog entry

* Update release date

* Update changelog and summary message

* Apply github suggestion and add missing entry in Changelog

* Release Hermes v1.7.3 (#3715)

* evidence: More reliable evidence reporting + couple of bug fixes (#3702)

* evidence: Only fetch counterparty clients of chains present in the config

* Harden the evidence reporting code in the face of runtime errors

* Fix bug where the counterparty client id returned was actually the original client id

* Bump version to v1.7.3

* Release changelog

* Release Hermes v1.7.4 (#3729)

* Improve `broadcast_errors` metric (#3719)

* Use short description for 'broadcast_errors' metric

* Add changelog entry

* Fix hyperlink in doc comment

Signed-off-by: Romain Ruetschi <[email protected]>

* Fix hyperlink in doc comment

---------

Signed-off-by: Romain Ruetschi <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* Fetch the light block at trusted_height + 1 when detecting misbehavior (#3727)

* fetch the light block at trusted_height+1 when detecting misbehaviour

* Add changelog entry

* Fix typo

---------

Co-authored-by: beer-1 <[email protected]>

* Initialise v1.7.4 release

* Avoid retrieving a worker which is being removed by the idle worker clean-up process (#3725)

* prevent returning stopping workers

* clear only the specific worker

* Add ibc-go v8 to integration tests (#3694)

* Add simapp v8 to CI jobs

* Add simapp v8 to nix flake

* Handle CLI breaking changes of Cosmos SDK v0.50 in test bootstrap

* Handle genesis config 'voting_perdiod' and CLI 'query txs' changes for Cosmos SDK v0.50.1

* Use 'MsgSubmitProposal' instead of deprecated 'UpgradeProposal' to initiate a chain upgrade

* Update 'tx upgrade-chain' CLI template

* Fix 'tx chain-upgrade' tests

* Update chain upgrade for compatibility between different ibc-go versions

* Improve assertion for client upgrade tests

* Update ibc-proto-rs to v0.39.0

* Add changelog entry

* Fix and improve guide section for client upgrade

* Wait before querying client state for client upgrade tests

* Apply suggestions from code review

Co-authored-by: Romain Ruetschi <[email protected]>
Signed-off-by: Luca Joss <[email protected]>

* Rename method 'ibc_version()' to 'version_specs'

* Extract the verification of legacy version in a method

* Implement 'FromStr' instead of 'TryFrom<String>' for 'ProposalStatus'

* Fix cargo-doc warning

* Add changelog entry for CLI

* Change the '--gov-account' flag as optional but will fail if trying to upgrade a chain with ibc-go v8+

* Update guide

* Move and update changelog entry for CLI

* Return a 'Specs' struct in 'version_specs()' method

* Fix clippy errors

---------

Signed-off-by: Luca Joss <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* Update Gaia used in tests from v12 to v13 & v14 (#3700)

* Update Gaia v12 to v13 and v14 in tests

* Fix Celestia CI job

* Replace Gaia v12 with v13 and v14 in multi-chain tests (#3701)

* Add changelog entry

---------

Signed-off-by: Luca Joss <[email protected]>
Co-authored-by: beer-1 <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* Add PR 3703 to patch release

* Improve `backlog` metrics (#3722)

* Update backlog metric when packet clearing is triggered

* Fix update backlog and add unit tests

* Uncomment conditional compilation from telemetry tests

* Add changelog entry

* Update guide section regarding 'backlog_*' metrics

* Correctly update the backlog when querying commitments on chain

* Update backlog_oldest_timestamp to backlog_latest_update_timestamp

* Update changelog entry

* Fix bug in backlog update

* Guard tests module by test cfg

Signed-off-by: Romain Ruetschi <[email protected]>

* Update from GitHub suggestions

---------

Signed-off-by: Romain Ruetschi <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>

* Update changelog

* Update release summary

---------

Signed-off-by: Romain Ruetschi <[email protected]>
Signed-off-by: Luca Joss <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
Co-authored-by: beer-1 <[email protected]>

* Fix changelog

* add query for eip value

* add lcd as optional field

* initial integration

* using dynamic

* dynamic pricing

* added better logs

* use block_on

* remove lcd

* Add DynamicGas configuration

* Add test for dynamic gas configuration

* Fix dynamic gas price computation

* Remove test related changes

* Remove dynamic gas test

* Change dynamic_gas_price to dynamic_gas configuration name

* Correctly deserialize DynamicGas config

* Fix formatting following merge

* dynamic gas price: Add integration test (#3788)

* Dynamic gas fee test

* Add dynamic gas fee test to CI

* Fix issue with nested calls to `block_on` (#3789)

* Fix test for dynamic gas price

---------

Co-authored-by: Luca Joss <[email protected]>

* Avoid depending on `cosmwasm-std` and `osmosis-std`

* Cleanup

* Use rustls instead of openssl with reqwest

* Use same feature flag as tendermint-rpc for reqwest

* Cleanup feature flag for reqwest dep in chain-registry

* Undo changes to Cargo.lock

* Add dynamic gas fees metrics (#3798)

* Add simple metric for dynamic gas price after multiplication

* Add max gas price configuration to dynamic gas configuration

* Apply dynamic max gas configuration

* Add 2 new metrics for dynamic gas fees

* Add guide entry for Dynamic gas configuration and metrics

* Fix EIP query parsing

* Use chain id instead of RPC address in emitted metrics

---------

Co-authored-by: Romain Ruetschi <[email protected]>

* Add changelog entry

* Reword changelog entry

* Remove lower bound on max dynamic gas price

* Small refactor

* Fix unused variable warning

* Simplify deserialization code

* Fix wrong error message

* Fixup changelog entry

* Add example to the config

* Fix integration test framework

* Fix typo in config file

* Apply suggestions from code review

Co-authored-by: Luca Joss <[email protected]>
Signed-off-by: Romain Ruetschi <[email protected]>

* Use dynamic gas for Osmosis in auto-generated config

* Small improvement to `config auto` command output and usage

* Fix typo

Co-authored-by: Luca Joss <[email protected]>
Signed-off-by: Romain Ruetschi <[email protected]>

* Update guide template

* Fix guide

* Rename configuration 'dynamic_gas' to 'dynamic_gas_price'

* Rename 'dynamic_gas_price' subconfigurations 'max_gas_price' to 'max' and 'gas_price_multiplier' to 'multiplier'

---------

Signed-off-by: Simon Noetzlin <[email protected]>
Signed-off-by: Romain Ruetschi <[email protected]>
Signed-off-by: Luca Joss <[email protected]>
Signed-off-by: Romain Ruetschi <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
Co-authored-by: Simon Noetzlin <[email protected]>
Co-authored-by: GoodDaisy <[email protected]>
Co-authored-by: beer-1 <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Romain Ruetschi <[email protected]>
  • Loading branch information
8 people authored Jan 23, 2024
1 parent d9c939f commit 04868db
Show file tree
Hide file tree
Showing 36 changed files with 1,166 additions and 213 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- Add a new per-chain configuration table `dynamic_gas_price` which enables
querying the current gas price from the chain instead of the static `gas_price`,
when the chain has [EIP-1559][eip]-like dynamic gas price.
The new configuration setting can be configured per-chain as follows:
```toml
dynamic_gas_price = { enabled = true, multiplier = 1.1, max = 0.6 }
```
At the moment, only chains which support the `osmosis.txfees.v1beta1.Query/GetEipBaseFee`
query can be used with dynamic gas price enabled.
([\#3738](https://github.com/informalsystems/hermes/issues/3738))

[eip]: https://metamask.io/1559/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Add three metrics related to EIP gas price:
- `dynamic_gas_queried_fees` contains data on the queried values
before applying any filter
- `dynamic_gas_queried_success_fees` contains data on the queried
values if the query was successful and before applying any filter
- `dynamic_gas_paid_fees` contains data on the queried values after
applying the `max` filter
([\#3738](https://github.com/informalsystems/hermes/issues/3738))
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
command: osmosisd
account_prefix: osmo
native_token: stake
features: ''
features: dynamic-gas-fee
- package: juno
command: junod
account_prefix: juno
Expand Down
8 changes: 1 addition & 7 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ gas_price = { price = 0.025, denom = 'stake' }
# Minimum value: 1.0
gas_multiplier = 1.1

# Query the current gas price from the chain instead of using the static `gas_price` from the config.
# Useful for chains which have [EIP-1559][eip]-like dynamic gas price.
#
# At the moment, only chains which support the `osmosis.txfees.v1beta1.Query/GetEipBaseFee`
# query can be used with dynamic gas price enabled.
#
# See this page in the Hermes guide for more information:
# https://hermes.informal.systems/documentation/configuration/dynamic-gas-fees.html
#
# Default: { enabled = false, multiplier = 1.1, max = 0.6 }
dynamic_gas_price = { enabled = false, multiplier = 1.1, max = 0.6 }

# Specify how many IBC messages at most to include in a single transaction.
# Default: 30
max_msg_num = 30
Expand Down
2 changes: 1 addition & 1 deletion crates/chain-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ flex-error = { version = "0.4.4", default-features = false }
futures = { version = "0.3.27", features = ["executor"] }
http = "0.2"
itertools = "0.10.5"
reqwest = { version = "0.11.13", features = ["rustls-tls", "json"], default-features = false }
reqwest = { version = "0.11.13", features = ["rustls-tls-native-roots", "json"], default-features = false }
serde = "1.0.195"
serde_json = "1"
tokio = "1.17.0"
Expand Down
9 changes: 9 additions & 0 deletions crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::marker::Send;

use futures::future::join_all;
use http::Uri;
use ibc_relayer::config::dynamic_gas::DynamicGasPrice;
use tokio::task::{JoinError, JoinHandle};
use tracing::trace;

Expand Down Expand Up @@ -120,6 +121,13 @@ where
0.1
};

// Use EIP-1559 dynamic gas price for Osmosis
let dynamic_gas_price = if chain_data.chain_id.as_str() == "osmosis-1" {
DynamicGasPrice::unsafe_new(true, 1.1, 0.6)
} else {
DynamicGasPrice::disabled()
};

Ok(ChainConfig::CosmosSdk(CosmosSdkConfig {
id: chain_data.chain_id,
rpc_addr: rpc_data.rpc_address,
Expand All @@ -140,6 +148,7 @@ where
max_gas: Some(400000),
gas_adjustment: None,
gas_multiplier: Some(GasMultiplier::new(1.1).unwrap()),
dynamic_gas_price,
fee_granter: None,
max_msg_num: MaxMsgNum::default(),
max_tx_size: MaxTxSize::default(),
Expand Down
39 changes: 21 additions & 18 deletions crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::chain_registry::get_configs;
use abscissa_core::clap::Parser;
use abscissa_core::{Command, Runnable};
use itertools::Itertools;

use crate::conclude::Output;

Expand All @@ -25,7 +26,7 @@ fn find_key(chain_config: &ChainConfig) -> Option<String> {
/// If a is specified then it will be used without verifying that it exists.
#[derive(Clone, Command, Debug, Parser, PartialEq, Eq)]
#[clap(
override_usage = "hermes config auto [OPTIONS] --output <PATH> --chains <CHAIN_NAME:OPTIONAL_KEY_NAME>"
override_usage = "hermes config auto [OPTIONS] --output <PATH> --chain <CHAIN1_NAME:OPTIONAL_KEY_NAME> --chain <CHAIN2_NAME:OPTIONAL_KEY_NAME>"
)]
pub struct AutoCmd {
#[clap(
Expand All @@ -39,11 +40,14 @@ pub struct AutoCmd {

#[clap(
long = "chains",
alias = "chain",
required = true,
multiple = true,
value_name = "CHAIN_NAME:OPTIONAL_KEY_NAME",
help_heading = "REQUIRED",
help = "Names of the chains to include in the config. Every chain must be in the chain registry."
help = "Names of the chains to include in the configuration, together with an optional key name. \
Either repeat this argument for every chain or pass a space-separated list of chains. \
Every chain must be found in the chain registry."
)]
chain_names: Vec<String>,

Expand Down Expand Up @@ -149,23 +153,22 @@ impl Runnable for AutoCmd {
};

match store(&config, &self.path) {
Ok(_) if missing_chains_set.is_empty() => {
Output::success_msg(format!(
"Config file written successfully at '{}'",
self.path.display()
))
.exit()
},
Ok(_) => {
if missing_chains_set.is_empty() {
Output::success_msg(format!(
"Config file written successfully at '{}'",
self.path.display()
))
.exit()
} else {
Output::success_msg(format!(
"Config file written successfully at '{}'.
However, configurations for the following chains were not able to be generated: {:?}",
self.path.display(),
missing_chains_set,
))
.exit()
}
}
Output::success_msg(format!(
"Config file written successfully at '{}'. \
However, configurations for the following chains were not able to be generated: {}",
self.path.display(),
missing_chains_set.iter().join(", "),
))
.exit()
},
Err(e) => Output::error(format!(
"An error occurred while attempting to write the config file: {}",
e
Expand Down
1 change: 1 addition & 0 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dirs-next = "2.0.0"
retry = { version = "2.0.0", default-features = false }
async-stream = "0.3.5"
http = "0.2.9"
reqwest = { version = "0.11", features = ["rustls-tls-native-roots", "json"], default-features = false }
flex-error = { version = "0.4.4", default-features = false }
signature = "2.1.0"
anyhow = "1.0"
Expand Down
13 changes: 13 additions & 0 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ use crate::util::pretty::{
};
use crate::{chain::client::ClientSettings, config::Error as ConfigError};

use self::gas::dynamic_gas_price;
use self::types::app_state::GenesisAppState;
use self::types::gas::GasConfig;
use self::version::Specs;

pub mod batch;
pub mod client;
pub mod compatibility;
pub mod config;
pub mod eip_base_fee;
pub mod encode;
pub mod estimate;
pub mod fee;
Expand Down Expand Up @@ -490,6 +493,16 @@ impl CosmosSdkChain {
Ok(min_gas_price)
}

pub fn dynamic_gas_price(&self) -> GasPrice {
let gas_config = GasConfig::from(self.config());

self.rt.block_on(dynamic_gas_price(
&gas_config,
&self.config.id,
&self.config.rpc_addr,
))
}

/// The unbonding period of this chain
pub fn unbonding_period(&self) -> Result<Duration, Error> {
crate::time!(
Expand Down
Loading

0 comments on commit 04868db

Please sign in to comment.