Skip to content

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Sep 29, 2025

Why this should be merged

In lieu of modifications to core.IntrinsicGas(), required for support of Warp in SAE. It's impossible to guarantee that the necessary options would always be passed to IntrinsicGas() if introduced, and the tx itself isn't available to the function so a hook is also a non-solution.

How this works

vm.Hooks are extended to include PreprocessingGasCharge(tx common.Hash) (uint64, error), which returns the amount of gas to be charged between core.IntrinsicGas and vm.EVM execution charges. The two entry points to execution, vm.EVM.Call() and vm.EVM.Create() are modified to first spend said charge before running upstream logic.

The new hook is defined on a separate interface definition, embedded in vm.Hooks, to allow types to implement just that method and enforce it with the var _ vm.Preprocessor = (*impl)(nil) pattern.

How this was tested

Integration tests via both core.ApplyTransaction() and core.ApplyMessage(). The former is more comprehensive, while the latter allows for inspection of interim error values.

@ARR4N ARR4N self-assigned this Sep 29, 2025
@ARR4N ARR4N marked this pull request as ready for review September 29, 2025 12:43
@ARR4N ARR4N requested review from a team and Copilot September 29, 2025 12:43
Copy link

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

Introduces a new EVM preprocessing hook mechanism to charge additional gas before transaction execution begins. This enables charging gas between core.IntrinsicGas and EVM execution, supporting Warp functionality in SAE without modifying the core intrinsic gas calculation.

  • Adds PreprocessingGasCharge() method to VM hooks interface for custom gas charging
  • Modifies EVM.Call() and EVM.Create() to spend preprocessing gas before execution
  • Provides comprehensive integration tests covering both success and error scenarios

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libevm/ethtest/evm.go Refactors state database creation into reusable helper function
libevm/ethtest/dummy.go Adds dummy implementations for chain context and consensus engine
core/vm/preprocess.libevm_test.go Comprehensive integration tests for preprocessing gas charging
core/vm/interface.libevm.go Defines StateDBRemainder interface for transaction context access
core/vm/interface.go Extends StateDB interface with StateDBRemainder methods
core/vm/hooks.libevm.go Adds Preprocessor interface and NOOPHooks implementation
core/vm/evm.libevm_test.go Updates test hook to implement new Preprocessor interface
core/vm/evm.libevm.go Implements preprocessing gas spending logic in EVM operations
core/vm/evm.go Renames methods to support preprocessing wrapper functions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

1 participant