Skip to content

fix(ethers-core): more accurate priority fee defaults#35

Merged
daniel-savu merged 8 commits intohyperlanefrom
kunal/better-priority-fees-defaults
May 20, 2025
Merged

fix(ethers-core): more accurate priority fee defaults#35
daniel-savu merged 8 commits intohyperlanefrom
kunal/better-priority-fees-defaults

Conversation

@aroralanuk
Copy link
Copy Markdown

Motivation

@christianangelopoulos spotted us overpaying priority fees on low-cost chains because of the default minimum of 0.1 gwei.

Looking deeper into this, there's some hardcoded/unnecessary logic that doesn't suit our needs well for transaction submission on EVM chains.

Solution

Idea is to make it estimate closer to that in alloy/metamask:

  • @christianangelopoulos set the EIP1559_FEE_ESTIMATION_DEFAULT_PRIORITY_FEE to 1wei if say the rewards isn't provided (bc 0 may be problematic for some chains)
  • @christianangelopoulos set base_fee as 2 x last block base fee (conservative compared to metamask's 1.25x for fast mode)
  • max_fee is now unconditionally priority_fee + base_fee (to not starve off base_fee)
  • updated the base_fee to always be non-zero
  • remove outlier rejection from median calculation (median is robust to outliers)
  • 1.2x multipler for median priority fee (conservative compared to metamask which used 0.97x even for fast mode)

Tests

Unit

Note: Failing tests are etherscan API-related, not relevant for this PR.

@aroralanuk aroralanuk marked this pull request as ready for review February 18, 2025 14:17
@christianangelopoulos
Copy link
Copy Markdown

looks good to me — I like the EIP1559_PRIORITY_FEE_MULTIPLIER to ensure deliverability without too much added overhead cost

Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs Outdated
Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs Outdated
Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs
Comment thread ethers-core/src/utils/mod.rs
@daniel-savu daniel-savu merged commit f0440eb into hyperlane May 20, 2025
4 of 10 checks passed
github-merge-queue Bot pushed a commit to hyperlane-xyz/hyperlane-monorepo that referenced this pull request May 21, 2025
### Description

Applies changes from hyperlane-xyz/ethers-rs#35
- tested on Base and we now pay 80x less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants