nspcc-dev/neo-go

step n functionality incorrect

オープン

#3,676 opened on 2024/11/13

 (0 件のコメント) (1 件のリアクション) (0 人の担当者)Go (108 件のフォーク)auto 404
I3S4U3bughelp wantedvm

Repository metrics

Stars
 (132 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド