Commit 8c8619aa authored by protolambda's avatar protolambda

mipsevm: fix lint issues

parent c4e3b0f7
...@@ -32,6 +32,9 @@ func LoadContracts() (*Contracts, error) { ...@@ -32,6 +32,9 @@ func LoadContracts() (*Contracts, error) {
return nil, err return nil, err
} }
oracle, err := LoadContract("Oracle") oracle, err := LoadContract("Oracle")
if err != nil {
return nil, err
}
return &Contracts{ return &Contracts{
MIPS: mips, MIPS: mips,
Oracle: oracle, Oracle: oracle,
......
...@@ -38,8 +38,6 @@ type UnicornState struct { ...@@ -38,8 +38,6 @@ type UnicornState struct {
lastPreimageKey [32]byte lastPreimageKey [32]byte
// offset we last read from, or max uint32 if nothing is read this step // offset we last read from, or max uint32 if nothing is read this step
lastPreimageOffset uint32 lastPreimageOffset uint32
onStep func()
} }
const ( const (
...@@ -239,8 +237,8 @@ func NewUnicornState(mu uc.Unicorn, state *State, po PreimageOracle, stdOut, std ...@@ -239,8 +237,8 @@ func NewUnicornState(mu uc.Unicorn, state *State, po PreimageOracle, stdOut, std
v1 = MipsEINVAL // cmd not recognized by this kernel v1 = MipsEINVAL // cmd not recognized by this kernel
} }
} }
mu.RegWrite(uc.MIPS_REG_V0, uint64(v0)) _ = mu.RegWrite(uc.MIPS_REG_V0, uint64(v0))
mu.RegWrite(uc.MIPS_REG_A3, uint64(v1)) _ = mu.RegWrite(uc.MIPS_REG_A3, uint64(v1))
}, 0, ^uint64(0)) }, 0, ^uint64(0))
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to set up interrupt/syscall hook: %w", err) return nil, fmt.Errorf("failed to set up interrupt/syscall hook: %w", err)
...@@ -358,6 +356,9 @@ func (m *UnicornState) Step(proof bool) (wit *StepWitness) { ...@@ -358,6 +356,9 @@ func (m *UnicornState) Step(proof bool) (wit *StepWitness) {
Timeout: 0, // 0 to disable, value is in ms. Timeout: 0, // 0 to disable, value is in ms.
Count: 1, Count: 1,
}) })
if err != nil {
panic("failed to run unicorn")
}
if proof { if proof {
wit.memProof = append(wit.memProof, m.memProof[:]...) wit.memProof = append(wit.memProof, m.memProof[:]...)
......
...@@ -20,9 +20,10 @@ func TestUnicornDelaySlot(t *testing.T) { ...@@ -20,9 +20,10 @@ func TestUnicornDelaySlot(t *testing.T) {
require.NoError(t, mu.MemWrite(4, []byte{0x20, 0x09, 0x0a, 0xFF}), "addi $t1 $r0 0x0aff") require.NoError(t, mu.MemWrite(4, []byte{0x20, 0x09, 0x0a, 0xFF}), "addi $t1 $r0 0x0aff")
require.NoError(t, mu.MemWrite(32, []byte{0x20, 0x09, 0x0b, 0xFF}), "addi $t1 $r0 0x0bff") require.NoError(t, mu.MemWrite(32, []byte{0x20, 0x09, 0x0b, 0xFF}), "addi $t1 $r0 0x0bff")
mu.HookAdd(uc.HOOK_CODE, func(mu uc.Unicorn, addr uint64, size uint32) { _, err = mu.HookAdd(uc.HOOK_CODE, func(mu uc.Unicorn, addr uint64, size uint32) {
t.Logf("addr: %08x", addr) t.Logf("addr: %08x", addr)
}, uint64(0), ^uint64(0)) }, uint64(0), ^uint64(0))
require.NoError(t, err)
// stop at instruction in addr=4, the delay slot // stop at instruction in addr=4, the delay slot
require.NoError(t, mu.StartWithOptions(uint64(0), uint64(4), &uc.UcOptions{ require.NoError(t, mu.StartWithOptions(uint64(0), uint64(4), &uc.UcOptions{
Timeout: 0, // 0 to disable, value is in ms. Timeout: 0, // 0 to disable, value is in ms.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment