nspcc-dev/neo-go

step n functionality incorrect

Aperta

#3676 aperta il 13 nov 2024

 (0 commenti) (1 reazione) (0 assegnatari)Go (108 fork)auto 404
I3S4U3bughelp wantedvm

Metriche repository

Star
 (132 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Current Behavior

step n is described as https://github.com/nspcc-dev/neo-go/blob/66fbcb2f0032ae26350bf5b07231419e2195c8d5/cli/vm/cli.go#L287

However, step does a simple increase of ip + n internally, but instructions are not always 1 byte therefore the new address can be invalid. For example

NEO-GO-VM > loadnef /home/erik/code/neo3-boa/stepcontract.nef
READY: loaded 18 instructions
NEO-GO-VM 0 > ops
INDEX    OPCODE      PARAMETER
0        INITSLOT    1 local, 0 arg    <<
3        PUSH10      
4        STLOC0      
5        JMP         11 (6/06)
7        LDLOC0      
8        PUSH1       
9        SUB         
10       STLOC0      
11       LDLOC0      
12       PUSH0       
13       GT          
14       JMPIF       7 (-7/f9)
16       LDLOC0      
17       RET         

NEO-GO-VM 0 > ip
instruction pointer at 0 (INITSLOT)
NEO-GO-VM 0 > step 2
[
    {
        "type": "Integer",
        "value": "0"
    }
]
NEO-GO-VM > ip
Error: VM is not ready: no program loaded
NEO-GO-VM > reset
NEO-GO-VM > loadnef /home/erik/code/neo3-boa/stepcontract.nef
READY: loaded 18 instructions
NEO-GO-VM 0 > step 3
at breakpoint 3 (PUSH10)

Expected Behavior

I expect step 2 to execute INITSLOT + PUSH10, and step 3 to execute the previous 2 + STLOC0.

Possible Solution

run single step's in a loop to the count of n instead of setting a break point relative to ip.

Steps to Reproduce

loadhex 5701001a70220668119f706810b724f96840

Guida contributor