Skip to content

Conversation

@jmg-duarte
Copy link
Contributor

Description

Vendors the gas-estimation crate code into the shared/gas_price_estimation module as part of the migration away from ethcontract/web3 APIs to Alloy. The external gas-estimation crate depends on web3, so vendoring its core types and traits allows us to reimplement gas price estimation using Alloy APIs without the web3 dependency.

Changes

  • Removed gas-estimation dependency from workspace Cargo.toml
  • Removed gas-estimation dependency from driver, refunder, and shared crates
  • Vendored GasPriceEstimating trait into shared/gas_price_estimation
  • Vendored PriorityGasPriceEstimating into shared/gas_price_estimation/priority
  • Moved GasPrice1559 type to shared/gas_price_estimation/price module
  • Created NodeGasPriceEstimator to replace Web3 legacy gas price estimation
  • Removed NativeGasEstimator and its configuration options (Native gas estimator type)
  • Updated driver's gas estimation to use NodeGasPriceEstimator instead of NativeGasEstimator
  • Updated refunder to use NodeGasPriceEstimator instead of web3 legacy estimator
  • Updated all import paths across the codebase to use vendored implementations

How to test

Existing tests

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

@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.

"alloy" => Ok(GasEstimatorType::Alloy),
"native" => Ok(GasEstimatorType::Native),
_ => Url::parse(s).map(GasEstimatorType::Driver).map_err(|e| {
format!("expected 'web3', 'native', or a valid driver URL; got {s:?}: {e}")

Choose a reason for hiding this comment

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

medium

The error message for parsing GasEstimatorType is outdated. It incorrectly lists "native" as a valid option while it has been removed, and it omits the valid "alloy" option. This could be confusing for users. The message should be updated to reflect the currently available string-based estimators.

                format!("expected 'web3', 'alloy', or a valid driver URL; got {s:?}: {e}")

@jmg-duarte jmg-duarte changed the title Migrate shared off of ethcontract Vendor gas-estimation crate into shared module Jan 12, 2026
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.

2 participants