step n functionality incorrect #1421

Open
opened 2025-12-28 17:16:23 +00:00 by sami · 0 comments
Owner

Originally created by @ixje on GitHub (Nov 13, 2024).

Current Behavior

step n is described as
nspcc-dev/neo-go@66fbcb2f00/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

Originally created by @ixje on GitHub (Nov 13, 2024). ## 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`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#1421
No description provided.