Skip to content
Merged
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
6 changes: 3 additions & 3 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func opDupN(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {

//The n‘th stack item is duplicated at the top of the stack.
scope.Stack.push(scope.Stack.Back(n - 1))
*pc += 2
*pc += 1
return nil, nil
}

Expand Down Expand Up @@ -993,7 +993,7 @@ func opSwapN(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
indexTop := scope.Stack.len() - 1
indexN := scope.Stack.len() - 1 - n
scope.Stack.data[indexTop], scope.Stack.data[indexN] = scope.Stack.data[indexN], scope.Stack.data[indexTop]
*pc += 2
*pc += 1
return nil, nil
}

Expand Down Expand Up @@ -1025,7 +1025,7 @@ func opExchange(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
indexN := scope.Stack.len() - 1 - n
indexM := scope.Stack.len() - 1 - m
scope.Stack.data[indexN], scope.Stack.data[indexM] = scope.Stack.data[indexM], scope.Stack.data[indexN]
*pc += 2
*pc += 1
return nil, nil
}

Expand Down
12 changes: 8 additions & 4 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,11 @@ func TestEIP8024_Execution(t *testing.T) {
codeHex: "e8", // no operand
wantErr: true,
},
{
name: "PC_INCREMENT",
codeHex: "600060006000e80115",
wantVals: []uint64{1, 0, 0},
},
}

for _, tc := range tests {
Expand All @@ -1123,17 +1128,15 @@ func TestEIP8024_Execution(t *testing.T) {
return
case 0x60:
_, err = opPush1(&pc, evm, scope)
pc++
case 0x80:
dup1 := makeDup(1)
_, err = dup1(&pc, evm, scope)
pc++
case 0x56:
_, err = opJump(&pc, evm, scope)
pc++
case 0x5b:
_, err = opJumpdest(&pc, evm, scope)
pc++
case 0x15:
_, err = opIszero(&pc, evm, scope)
case 0xe6:
_, err = opDupN(&pc, evm, scope)
case 0xe7:
Expand All @@ -1143,6 +1146,7 @@ func TestEIP8024_Execution(t *testing.T) {
default:
err = &ErrInvalidOpCode{opcode: OpCode(op)}
}
pc++
}
if tc.wantErr {
if err == nil {
Expand Down