Implement Warp intrinsic gas via libevm hooks#5287
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR switches Coreth and Subnet-EVM to use libevm/core.IntrinsicGas (with newly added libevm hook support) to ensure Warp intrinsic gas is charged consistently with upstream behavior, and wires Avalanche-specific access list/predicate gas logic through the libevm hooks layer.
Changes:
- Replace in-repo
core.IntrinsicGasusage/implementation withlibevm/core.IntrinsicGasacross Coreth + Subnet-EVM execution, txpool validation, predicate checks, and block verification. - Add a
RulesExtra.AccessListGashook implementation (Coreth + Subnet-EVM) to preserve predicate-based access list intrinsic gas accounting. - Bump
github.com/ava-labs/libevmdependency and update Bazel deps to include the needed libevm packages.
Reviewed changes
Copilot reviewed 27 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| graft/subnet-evm/plugin/evm/wrapped_block.go | Use libevmcore.IntrinsicGas when verifying per-block intrinsic gas totals. |
| graft/subnet-evm/plugin/evm/BUILD.bazel | Add Bazel dep on @com_github_ava_labs_libevm//core. |
| graft/subnet-evm/params/hooks_libevm.go | Implement AccessListGas hook to include predicate-based gas; use safe addition + overflow error from libevm. |
| graft/subnet-evm/params/BUILD.bazel | Add Bazel deps on @com_github_ava_labs_libevm//common/math and @com_github_ava_labs_libevm//core. |
| graft/subnet-evm/go.mod | Bump libevm pseudo-version. |
| graft/subnet-evm/go.sum | Update checksums for bumped libevm version. |
| graft/subnet-evm/core/txpool/validation.go | Use libevmcore.IntrinsicGas for tx metadata/intrinsic gas validation. |
| graft/subnet-evm/core/txpool/BUILD.bazel | Add Bazel dep on @com_github_ava_labs_libevm//core. |
| graft/subnet-evm/core/state_transition.go | Remove local IntrinsicGas implementation; call libevmcore.IntrinsicGas during state transition precheck. |
| graft/subnet-evm/core/predicate_check.go | Use libevmcore.IntrinsicGas when checking predicate-related intrinsic gas affordability. |
| graft/subnet-evm/core/error.go | Align ErrGasUintOverflow with libevmcore.ErrGasUintOverflow. |
| graft/subnet-evm/core/bench_test.go | Update benchmark helper to use libevmcore.IntrinsicGas. |
| graft/subnet-evm/core/BUILD.bazel | Ensure tests include @com_github_ava_labs_libevm//core dep. |
| graft/evm/go.mod | Bump libevm pseudo-version for the graft/evm module. |
| graft/evm/go.sum | Update checksums for bumped libevm version. |
| graft/coreth/plugin/evm/wrapped_block.go | Use libevmcore.IntrinsicGas when verifying per-block intrinsic gas totals. |
| graft/coreth/plugin/evm/BUILD.bazel | Add Bazel dep on @com_github_ava_labs_libevm//core. |
| graft/coreth/params/hooks_libevm.go | Implement AccessListGas hook for predicate-aware access list intrinsic gas. |
| graft/coreth/params/BUILD.bazel | Add Bazel deps on @com_github_ava_labs_libevm//common/math and @com_github_ava_labs_libevm//core. |
| graft/coreth/go.mod | Bump libevm pseudo-version. |
| graft/coreth/go.sum | Update checksums for bumped libevm version. |
| graft/coreth/core/txpool/validation.go | Use libevmcore.IntrinsicGas for tx intrinsic gas validation. |
| graft/coreth/core/txpool/BUILD.bazel | Add Bazel dep on @com_github_ava_labs_libevm//core. |
| graft/coreth/core/state_transition.go | Remove local IntrinsicGas implementation; call libevmcore.IntrinsicGas during transition. |
| graft/coreth/core/predicate_check.go | Use libevmcore.IntrinsicGas for predicate intrinsic gas affordability check. |
| graft/coreth/core/error.go | Align ErrGasUintOverflow with libevmcore.ErrGasUintOverflow. |
| graft/coreth/core/bench_test.go | Update benchmark helper to use libevmcore.IntrinsicGas. |
| graft/coreth/core/BUILD.bazel | Ensure tests include @com_github_ava_labs_libevm//core dep. |
| go.mod | Bump libevm pseudo-version at repo root. |
| go.sum | Update checksums for bumped libevm version at repo root. |
| go.work.sum | Update workspace checksums (indirectly affected by module resolution changes). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alarso16
approved these changes
Apr 27, 2026
Contributor
alarso16
left a comment
There was a problem hiding this comment.
I don't see any behavior change, so good with me. I left a nit that applies to all the files
| "github.com/ava-labs/avalanchego/graft/coreth/core" | ||
| "github.com/ava-labs/avalanchego/graft/coreth/params" | ||
| "github.com/ava-labs/libevm/common" | ||
| libevmcore "github.com/ava-labs/libevm/core" |
Contributor
There was a problem hiding this comment.
I vote ethcore, similar to ethparams below
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.
Why this should be merged
We need to adhere warp intrinsic gas charges in SAE. We have discovered that
IntrinsicGasin Coreth and Subnet-EVM potentially charges less gas than the original upstream implementation (see #5194). We have added relevant hooks to libevm. This PR implements the hook in Coreth + Subnet-EVM that will replace theIntrinsicGasimplementation incorepackage.How this was tested
UTs + test PR
Need to be documented in RELEASES.md?
No
This PR should not be merged until ava-labs/libevm#282 is merged