-
Notifications
You must be signed in to change notification settings - Fork 152
Vendor gas-estimation crate into shared module #4043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
|
/gemini review |
There was a problem hiding this 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.
There was a problem hiding this 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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
| // Estimated base fee for the pending block (block currently being mined) | ||
| pub base_fee_per_gas: f64, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
squadgazzz
left a comment
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, please review
Description
Remove the external
gas-estimationdependency by vendoring necessary functionality into theshared/gas_price_estimationmodule. This simplifies gas estimation by removing theNativeestimator and its complex percentile-based calculations.Changes
GasPrice1559,GasPriceEstimating, andPriorityGasPriceEstimatingintoshared/gas_price_estimationNodeGasPriceEstimatorto replaceweb3.legacyusagegas-estimationdependency from all crate manifestsNativegas estimator configuration optiongas_estimation::toshared::gas_price_estimation::GasPriceEstimatingtrait (removeestimate_with_limitsmethod)How to test
Existing tests