diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 8a451b706f..a357799e4e 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -936,9 +936,9 @@ func decodePair(x byte) (int, int) { } q, r := k/16, k%16 if q < r { - return q + 2, r + 2 + return q + 1, r + 1 } - return r + 2, 30 - q + return r + 1, 29 - q } func opDupN(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) { diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index e6a3405f6a..0f91a205f5 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -1037,10 +1037,9 @@ func TestEIP8024_Execution(t *testing.T) { }, }, { - //NOTE: Spec test seems wrong. Added additional stack item to make it pass. name: "EXCHANGE", - codeHex: "6000600160026003e801", - wantVals: []uint64{3, 2, 0, 1}, + codeHex: "600060016002e801", + wantVals: []uint64{2, 0, 1}, }, { name: "INVALID_SWAPN_LOW", @@ -1080,18 +1079,17 @@ func TestEIP8024_Execution(t *testing.T) { }, { name: "UNDERFLOW_DUPN", - codeHex: "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5fe600", // (n=17, need 17 items have 16) + codeHex: "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5fe600", // (n=17, need 17 items, have 16) wantErr: true, }, { name: "UNDERFLOW_SWAPN", - codeHex: "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5fe700", // (n=17, need 18 items have 17) + codeHex: "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5fe700", // (n=17, need 18 items, have 17) wantErr: true, }, { - // Note: This is the spec test case, but we expect it to fail name: "UNDERFLOW_EXCHANGE", - codeHex: "600060016002e801", // (n,m=2,3 need at least 4 items have 3) + codeHex: "60016002e801", // (n,m)=(1,2), need 3 items, have 2 wantErr: true, }, {