Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8c8619aa
Unverified
Commit
8c8619aa
authored
May 01, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mipsevm: fix lint issues
parent
c4e3b0f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
evm.go
mipsevm/evm.go
+3
-0
unicorn.go
mipsevm/unicorn.go
+5
-4
unicorn_test.go
mipsevm/unicorn_test.go
+2
-1
No files found.
mipsevm/evm.go
View file @
8c8619aa
...
@@ -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
,
...
...
mipsevm/unicorn.go
View file @
8c8619aa
...
@@ -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
[
:
]
...
)
...
...
mipsevm/unicorn_test.go
View file @
8c8619aa
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment