Skip to content

Commit

Permalink
Cosmos gas price config (#3042)
Browse files Browse the repository at this point in the history
### Description

Adds a cosmos-specific config item for setting the minimum gas price, in
the format returned by the `cosmos.base.node.v1beta1.Service/Config`
cosmos-sdk grpc endpoint.

### Related issues

- Fixes hyperlane-xyz/issues#810

### Backward compatibility

No. Will break existing cosmos configs.


### Testing

None yet, will test in e2e
  • Loading branch information
daniel-savu authored Dec 19, 2023
1 parent 8e44bc1 commit d18f7ae
Show file tree
Hide file tree
Showing 30 changed files with 311 additions and 99 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

## Problem
Expand Down
105 changes: 64 additions & 41 deletions rust/Cargo.lock

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

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async-trait = "0.1"
auto_impl = "1.0"
backtrace = "0.3"
base64 = "0.21.2"
bigdecimal = "0.4.2"
bincode = "1.3"
borsh = "0.9"
bs58 = "0.5.0"
Expand Down
1 change: 1 addition & 0 deletions rust/agents/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ hyperlane-base = { path = "../../hyperlane-base" }
hyperlane-ethereum = { path = "../../chains/hyperlane-ethereum" }

[dev-dependencies]
once_cell.workspace = true
tokio-test.workspace = true
hyperlane-test = { path = "../../hyperlane-test" }
hyperlane-base = { path = "../../hyperlane-base", features = ["test-utils"] }
Expand Down
7 changes: 4 additions & 3 deletions rust/agents/relayer/src/msg/gas_payment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use async_trait::async_trait;
use eyre::Result;
use hyperlane_base::db::HyperlaneRocksDB;
use hyperlane_core::{
GasPaymentKey, HyperlaneMessage, InterchainGasExpenditure, InterchainGasPayment,
TxCostEstimate, TxOutcome, U256,
FixedPointNumber, GasPaymentKey, HyperlaneMessage, InterchainGasExpenditure,
InterchainGasPayment, TxCostEstimate, TxOutcome, U256,
};
use tracing::{debug, error, trace};

Expand Down Expand Up @@ -135,7 +135,8 @@ impl GasPaymentEnforcer {
self.db.process_gas_expenditure(InterchainGasExpenditure {
message_id: message.id(),
gas_used: outcome.gas_used,
tokens_used: outcome.gas_used * outcome.gas_price,
tokens_used: (FixedPointNumber::try_from(outcome.gas_used)? * outcome.gas_price)
.try_into()?,
})?;
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions rust/agents/relayer/src/msg/gas_payment/policies/minimum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async fn test_gas_payment_policy_minimum() {
&current_expenditure,
&TxCostEstimate {
gas_limit: U256::from(100000u32),
gas_price: U256::from(100000u32),
gas_price: U256::from(100000u32).try_into().unwrap(),
l2_gas_limit: None,
},
)
Expand All @@ -83,7 +83,7 @@ async fn test_gas_payment_policy_minimum() {
&current_expenditure,
&TxCostEstimate {
gas_limit: U256::from(100000u32),
gas_price: U256::from(100001u32),
gas_price: U256::from(100001u32).try_into().unwrap(),
l2_gas_limit: None,
},
)
Expand All @@ -101,7 +101,7 @@ async fn test_gas_payment_policy_minimum() {
&current_expenditure,
&TxCostEstimate {
gas_limit: U256::from(100000u32),
gas_price: U256::from(100001u32),
gas_price: U256::from(100001u32).try_into().unwrap(),
l2_gas_limit: Some(U256::from(22222u32)),
},
)
Expand Down
Loading

0 comments on commit d18f7ae

Please sign in to comment.