Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,23 @@ func opPush1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
return nil, nil
}

// opPush2 is a specialized version of pushN
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

opPush2 does not match the executionFunc type used by the jump table (func(pc *uint64, evm *EVM, callContext *ScopeContext)). It currently takes *EVMInterpreter as the second parameter, so assigning it to operation.execute will not compile. Update opPush2 to use the *EVM signature (similar to opPush1) so it can be referenced from the jump table.

Suggested change
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {

Copilot uses AI. Check for mistakes.
var (
codeLen = uint64(len(scope.Contract.Code))
integer = new(uint256.Int)
)
if *pc+2 < codeLen {
scope.Stack.push(integer.SetBytes2(scope.Contract.Code[*pc+1 : *pc+3]))
} else if *pc+1 < codeLen {
scope.Stack.push(integer.SetUint64(uint64(scope.Contract.Code[*pc+1]) << 8))
} else {
scope.Stack.push(integer.Clear())
}
*pc += 2
return nil, nil
}

// make push instruction function
func makePush(size uint64, pushByteSize int) executionFunc {
return func(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func newFrontierInstructionSet() JumpTable {
maxStack: maxStack(0, 1),
},
PUSH2: {
execute: makePush(2, 2),
execute: opPush2,
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

execute expects an executionFunc (func(pc *uint64, evm *EVM, callContext *ScopeContext)), but opPush2 currently has a different signature. This change will break compilation unless opPush2 is updated to match executionFunc (or you revert to makePush(2, 2)).

Suggested change
execute: opPush2,
execute: makePush(2, 2),

Copilot uses AI. Check for mistakes.
constantGas: GasFastestStep,
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),
Expand Down
Loading