Skip to content

Make alloy gas estimator configurable#4081

Merged
fafk merged 7 commits intomainfrom
make-alloy-gas-estimator-configurable
Jan 26, 2026
Merged

Make alloy gas estimator configurable#4081
fafk merged 7 commits intomainfrom
make-alloy-gas-estimator-configurable

Conversation

@fafk
Copy link
Copy Markdown
Contributor

@fafk fafk commented Jan 23, 2026

Description

Adds the ability to configure past_blocks and reward_percentile parameters for the EIP-1559 gas price estimator. Previously, alloy's hardcoded defaults (10 blocks, 20th percentile) were always used.

Changes

[x] Add configurable_alloy.rs - a gas estimator that calls eth_feeHistory with custom parameters, then uses alloy's default estimation algorithm
[x] Extend GasEstimatorType::Alloy config variant with optional past-blocks and reward-percentile fields
[x] Default values match alloy's hardcoded constants (10 blocks, 20.0 percentile) for backwards compatibility

@fafk fafk requested a review from a team as a code owner January 23, 2026 09:00
Copy link
Copy Markdown
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 introduces a configurable gas estimator based on alloy. There is a logic error in the implementation of the new estimator in configurable_alloy.rs. The base fee is calculated using the oldest block in the fee history range instead of the latest, which could lead to inaccurate gas price estimations. A specific fix is suggested in the review comments.

Comment thread crates/shared/src/gas_price_estimation/configurable_alloy.rs
@fafk fafk marked this pull request as draft January 23, 2026 09:03
Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

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

Change looks good overall. Just some comments how to integrate it into the existing code base.

Comment thread crates/driver/src/infra/blockchain/gas.rs
Comment on lines +53 to +56
#[instrument(skip(self), fields(
past_blocks = %self.config.past_blocks,
reward_percentile = %self.config.reward_percentile
))]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fields only get printed when a log inside the instrumented function actually emits a log, right?
If they would always get logged I don't think we should have this as this will never change during the runtime of the process and will result in tons of logs.

Copy link
Copy Markdown
Contributor Author

@fafk fafk Jan 23, 2026

Choose a reason for hiding this comment

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

The fields only get printed when a log inside the instrumented function actually emits a log, right?

Yes.

These are also attached the spans, so you can see it in Tempo.

Comment thread crates/driver/src/infra/config/file/mod.rs Outdated
Comment thread crates/shared/src/gas_price_estimation/configurable_alloy.rs
Comment thread crates/shared/src/gas_price_estimation/configurable_alloy.rs
@fafk fafk marked this pull request as ready for review January 23, 2026 09:50
Comment thread crates/driver/src/infra/config/file/mod.rs
Comment thread crates/shared/src/gas_price_estimation/configurable_alloy.rs Outdated
@fafk fafk added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit c46ae07 Jan 26, 2026
19 checks passed
@fafk fafk deleted the make-alloy-gas-estimator-configurable branch January 26, 2026 09:57
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 26, 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.

3 participants