Skip to content

Conversation

@jmg-duarte
Copy link
Contributor

@jmg-duarte jmg-duarte commented Jan 12, 2026

Description

Remove the external gas-estimation dependency by vendoring necessary functionality into the shared/gas_price_estimation module. This simplifies gas estimation by removing the Native estimator and its complex percentile-based calculations.

Changes

  • Vendor GasPrice1559, GasPriceEstimating, and PriorityGasPriceEstimating into shared/gas_price_estimation
  • Add NodeGasPriceEstimator to replace web3.legacy usage
  • Remove gas-estimation dependency from all crate manifests
  • Remove Native gas estimator configuration option
  • Update all imports from gas_estimation:: to shared::gas_price_estimation::
  • Simplify GasPriceEstimating trait (remove estimate_with_limits method)
  • Adjust driver tests to handle gas price variations (15% tolerance)

How to test

Existing tests

jmg-duarte and others added 2 commits January 12, 2026 15:16
Removed external gas-estimation dependency by vendoring its code into
shared/gas_price_estimation module:
- Inlined GasPriceEstimating and PriorityGasPriceEstimating traits
- Vendored GasPrice1559 type into price module
- Created NodeGasPriceEstimator to replace web3 legacy gas estimation
- Removed NativeGasEstimator and Native gas estimator config option
- Updated driver and refunder crates to use vendored implementations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jmg-duarte
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant step in migrating away from ethcontract by vendoring the gas-estimation crate's functionality directly into the shared crate. The changes are well-structured, removing the old dependency and updating all usage sites to the new vendored implementation. The removal of NativeGasEstimator and its replacement with NodeGasPriceEstimator and making Alloy the default is a notable change that simplifies the configuration. Overall, the refactoring is clean and aligns with the goal of moving towards Alloy APIs. I've found two issues that need to be addressed: a critical syntax error that prevents compilation and an outdated error message.

@jmg-duarte jmg-duarte changed the title Migrate shared off of ethcontract Vendor gas-estimation crate into shared module Jan 12, 2026
Base automatically changed from jmgd/alloy/shared to main January 13, 2026 16:30
@jmg-duarte jmg-duarte marked this pull request as ready for review January 14, 2026 17:37
@jmg-duarte jmg-duarte requested a review from a team as a code owner January 14, 2026 17:37
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a large but well-executed refactoring to vendor the gas-estimation crate into the shared module, successfully removing an external dependency. The core logic has been cleanly moved, and the GasPriceEstimating trait has been simplified. My review focuses on a new test helper function where I've found a critical compilation error and a potential panic, along with a minor suggestion to improve test diagnostics. The rest of the changes look solid.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
&[infra::mempool::Config {
min_priority_fee: Default::default(),
gas_price_cap: eth::U256::MAX,
gas_price_cap: eth::U256::from(1000000000000_u128),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added this ad-hoc to make sure the mempool parameters that affect the gas price estimator config are in sync with the driver under test and the gas estimator struct the test logic compares against but is there a better way to make sure these are in sync rather than hardcoding magic numbers here?

Copy link
Contributor Author

@jmg-duarte jmg-duarte Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an idea but it's orthogonal to the current PR.

IMO, in crates/driver/src/tests/setup/driver.rs we shouldn't be writing the config TOML manually, we should pass a config and serialize it into a file. Makes it easier to navigate to with the editors and to inspect as well

Comment on lines +11 to +12
// Estimated base fee for the pending block (block currently being mined)
pub base_fee_per_gas: f64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we discussed dropping this field. Is this no longer the plan or intended as a follow up item?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up, the gas-2 branch does it. I wanted to keep this branch mostly similar to the original crate to simplify the review

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assuming the comments below will be addressed.

};

pub struct AlloyGasPriceEstimator(AlloyProvider);
/// Estimates the gas price based on alloy's logic for computing a reasonable EIP-1559 gas price.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it would be great to understand already from these docs how the Node estimation is different from EIP-1559. Maybe mentioning major mechanics would be sufficient here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed, please review

@jmg-duarte jmg-duarte added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 94fcfd8 Jan 16, 2026
19 checks passed
@jmg-duarte jmg-duarte deleted the jmgd/alloy/gas branch January 16, 2026 14:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants