Skip to content

Commit

Permalink
chore: merge upstream gas escalator and run test (#14)
Browse files Browse the repository at this point in the history
Fixes some issues @tkporter brought up in
hyperlane-xyz/hyperlane-monorepo#3852 (review):
1. Holding mutex lock across gas escalations (fixed upstream, I just
merged the changes)
2. Silently ignoring nonce related errors: added a `warn` log. These
error are only expected to occur if the original tx landed onchain
though
3. I ran the unit test that comes with this middleware, and similar to
what Trevor pointed out, sending a tx returns a `PendingTransaction`
whose tx hash will not reflect the hash of the tx that lands onchain.
However I manually checked by polling anvil and emitting logs that the
gas is escalated and the final tx is finalized
  • Loading branch information
daniel-savu authored Jun 27, 2024
1 parent 950dd34 commit 86d61d6
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 195 deletions.
1 change: 1 addition & 0 deletions 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 ethers-middleware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ serde = { version = "1.0.124", default-features = false, features = ["derive"] }
thiserror = { version = "1.0", default-features = false }
futures-util = { version = "^0.3" }
futures-locks = { version = "0.7", default-features = false }
futures-channel.workspace = "0.3.28"
tracing = { version = "0.1.37", default-features = false }
tracing-futures = { version = "0.2.5", default-features = false }

Expand Down
1 change: 0 additions & 1 deletion ethers-middleware/src/gas_escalator/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl LinearGasPrice {
impl GasEscalator for LinearGasPrice {
fn get_gas_price(&self, initial_price: U256, time_elapsed: u64) -> U256 {
let mut result = initial_price + self.increase_by * (time_elapsed / self.every_secs);
dbg!(time_elapsed, self.every_secs);
if let Some(max_price) = self.max_price {
result = std::cmp::min(result, max_price);
}
Expand Down
Loading

0 comments on commit 86d61d6

Please sign in to comment.