Skip to content

Implement Warp intrinsic gas via libevm hooks#5287

Open
ceyonur wants to merge 7 commits intomasterfrom
ceyonur/warp-intrinsic-gas
Open

Implement Warp intrinsic gas via libevm hooks#5287
ceyonur wants to merge 7 commits intomasterfrom
ceyonur/warp-intrinsic-gas

Conversation

@ceyonur
Copy link
Copy Markdown
Contributor

@ceyonur ceyonur commented Apr 15, 2026

Why this should be merged

We need to adhere warp intrinsic gas charges in SAE. We have discovered that IntrinsicGas in 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 the IntrinsicGas implementation in core package.

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

@ceyonur ceyonur changed the title add intrinsic gas hooks Implement Warp intrinsic gas via libevm hooks Apr 16, 2026
@ceyonur ceyonur added the DO NOT MERGE This PR must not be merged in its current state label Apr 16, 2026
@ceyonur ceyonur marked this pull request as ready for review April 16, 2026 16:09
@ceyonur ceyonur requested review from a team as code owners April 16, 2026 16:09
Copilot AI review requested due to automatic review settings April 16, 2026 16:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.IntrinsicGas usage/implementation with libevm/core.IntrinsicGas across Coreth + Subnet-EVM execution, txpool validation, predicate checks, and block verification.
  • Add a RulesExtra.AccessListGas hook implementation (Coreth + Subnet-EVM) to preserve predicate-based access list intrinsic gas accounting.
  • Bump github.com/ava-labs/libevm dependency 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.

@ceyonur ceyonur removed the DO NOT MERGE This PR must not be merged in its current state label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

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

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

I vote ethcore, similar to ethparams below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants