fix: report function selector on estimation failure#114
Draft
rubydusa wants to merge 1 commit into
Draft
Conversation
`GasKillerReport::report_error` previously hard-coded `function_selector` to zero, so any failed estimation produced a report indistinguishable from a selector-less call. The selector is needed to identify which method was attempted when estimation fails. Fetch the selector up front in `get_report` and thread it through both the success path (already passed via `ReportDetails`) and the error path. The existing in-`gaskiller_reporter` selector lookup is removed since the caller now supplies it, avoiding a redundant `get_transaction_by_hash`. Closes #22 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
ci is failing because of new foundry release: see |
Collaborator
Author
|
put on draft as long as #96 isn't merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22.
Summary
GasKillerReport::report_errorpreviously hard-codedfunction_selectortoFixedBytes::default()(0x00000000). On the success path the selector was correctly extracted from the transaction's input, but every error report carried zero — so a failed estimation looked indistinguishable from a selector-less call, and there was no way to tell which method triggered the failure.The fix lifts the selector lookup into
get_reportso it's available on both branches:get_reportcalls a new helperfetch_function_selector(provider, tx_hash)once at the top.gaskiller_reporter(replacing the in-place lookup there) and intoreport_erroron the failure path.gas_estimate_blockis only reachable now if the transaction fetch itself fails, in which case there's no selector to report and we fall back toFixedBytes::default().The in-
gaskiller_reporterget_transaction_by_hashcall is removed since the caller now supplies the selector — net no extra RPC roundtrips.Behavioural notes
gaskiller_reporterwith\"could not get function selector\", now degrade gracefully —function_selector()returnsNone, we useunwrap_or_default()(zero), and the rest of the pipeline runs. Upstream filters ingas_estimate_tx(smart-contract check) andgas_estimate_block(to.is_some()) already exclude these in the common case, so this should mostly be defence-in-depth.gas_estimate_tx): ifget_transaction_by_hashitself fails (network error, missing tx),get_reportnow propagatesErrinstead of silently producing a zero-selector error report. The CLI already handled top-levelErrvia?.Verification
cargo test -p gas-analyzer-anvil --lib— 11/11 pass locally (against Sepolia viaRPC_URL, Foundry v1.5.1).cargo test(default workspace, EvmSketch path) — pass.cargo clippy -p gas-analyzer-anvil --all-targets -- -D warnings— clean.cargo clippy --workspace --exclude gas-killer-wasm --exclude gas-analyzer-anvil --all-targets -- -D warnings— clean (matches CI lint).cargo fmt --all -- --check— clean.🤖 Generated with Claude Code