core: drop OLDPUSH1, it's no longer needed

Fixes #927.
This commit is contained in:
Roman Khimov 2020-06-05 13:04:20 +03:00
parent 0a09a20900
commit 35b30ccfdf
6 changed files with 3 additions and 15 deletions

View file

@ -51,7 +51,7 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
NextConsensus: nextConsensus, NextConsensus: nextConsensus,
Script: transaction.Witness{ Script: transaction.Witness{
InvocationScript: []byte{}, InvocationScript: []byte{},
VerificationScript: []byte{byte(opcode.OLDPUSH1)}, VerificationScript: []byte{byte(opcode.PUSH1)},
}, },
} }

Binary file not shown.

View file

@ -77,12 +77,6 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) {
var numtoread int var numtoread int
switch instr { switch instr {
case opcode.OLDPUSH1:
// OLDPUSH1 is used during transition to NEO3 in verification scripts.
// FIXME remove #927
if len(c.prog) == 1 {
return opcode.PUSH1, nil, nil
}
case opcode.PUSHDATA1: case opcode.PUSHDATA1:
if c.nextip >= len(c.prog) { if c.nextip >= len(c.prog) {
err = errNoInstParam err = errNoInstParam

View file

@ -135,12 +135,8 @@ func testFile(t *testing.T, filename string) {
require.NoErrorf(t, json.Unmarshal(data, ut), "file: %s", filename) require.NoErrorf(t, json.Unmarshal(data, ut), "file: %s", filename)
t.Run(ut.Category+":"+ut.Name, func(t *testing.T) { t.Run(ut.Category+":"+ut.Name, func(t *testing.T) {
isRot := strings.HasSuffix(filename, "ROT.json")
for i := range ut.Tests { for i := range ut.Tests {
test := ut.Tests[i] test := ut.Tests[i]
if isRot && test.Name == "Without push" {
return // FIXME #927 single ROT is interpreted as PUSH1
}
t.Run(ut.Tests[i].Name, func(t *testing.T) { t.Run(ut.Tests[i].Name, func(t *testing.T) {
prog := []byte(test.Script) prog := []byte(test.Script)
vm := load(prog) vm := load(prog)

View file

@ -1,6 +1,6 @@
package opcode package opcode
//go:generate stringer -type=Opcode //go:generate stringer -type=Opcode -linecomment
// Opcode represents a single operation code for the NEO virtual machine. // Opcode represents a single operation code for the NEO virtual machine.
type Opcode byte type Opcode byte
@ -87,7 +87,6 @@ const (
TUCK Opcode = 0x4E TUCK Opcode = 0x4E
SWAP Opcode = 0x50 SWAP Opcode = 0x50
ROT Opcode = 0x51 ROT Opcode = 0x51
OLDPUSH1 Opcode = 0x51 // FIXME remove #927
ROLL Opcode = 0x52 ROLL Opcode = 0x52
REVERSE3 Opcode = 0x53 REVERSE3 Opcode = 0x53
REVERSE4 Opcode = 0x54 REVERSE4 Opcode = 0x54

View file

@ -1,4 +1,4 @@
// Code generated by "stringer -type Opcode -linecomment"; DO NOT EDIT. // Code generated by "stringer -type=Opcode -linecomment"; DO NOT EDIT.
package opcode package opcode
@ -77,7 +77,6 @@ func _() {
_ = x[TUCK-78] _ = x[TUCK-78]
_ = x[SWAP-80] _ = x[SWAP-80]
_ = x[ROT-81] _ = x[ROT-81]
_ = x[OLDPUSH1-81]
_ = x[ROLL-82] _ = x[ROLL-82]
_ = x[REVERSE3-83] _ = x[REVERSE3-83]
_ = x[REVERSE4-84] _ = x[REVERSE4-84]