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
4a02eb4d
Unverified
Commit
4a02eb4d
authored
Jun 27, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Fix oracle tests for mipsevm
parent
62fba98a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
11 deletions
+58
-11
oracle.bin
cannon/mipsevm/open_mips_tests/test/bin/oracle.bin
+0
-0
oracle.asm
cannon/mipsevm/open_mips_tests/test/oracle.asm
+43
-9
state_test.go
cannon/mipsevm/state_test.go
+15
-2
No files found.
cannon/mipsevm/open_mips_tests/test/bin/oracle.bin
View file @
4a02eb4d
No preview for this file type
cannon/mipsevm/open_mips_tests/test/oracle.asm
View file @
4a02eb4d
.
section
.
test
,
"x"
.
section
.
test
,
"x"
.
balign
4
.
balign
4
.
set
noreorder
.
set
noreorder
.
global
test
.
global
test
.
ent
test
.
ent
test
#
load
hash
at
0x30001000
#
load
hash
at
0x30001000
#
0x47173285
a8d7341e
5
e972fc6
77286384
f802f8ef
42
a5ec5f
03
bbfa25
4
cb01fad
=
"hello world"
#
0x47173285
a8d7341e
5
e972fc6
77286384
f802f8ef
42
a5ec5f
03
bbfa25
4
cb01fad
=
keccak
(
"hello world"
)
#
0x02173285
a8d7341e
5
e972fc6
77286384
f802f8ef
42
a5ec5f
03
bbfa25
4
cb01fad
=
keccak
(
"hello world"
).
key
test
:
test
:
lui
$
s0
,
0x3000
lui
$
s0
,
0x3000
ori
$
s0
,
0x1000
ori
$
s0
,
0x1000
lui
$
t0
,
0x
47
17
lui
$
t0
,
0x
02
17
ori
$
t0
,
0x3285
ori
$
t0
,
0x3285
sw
$
t0
,
0
(
$
s0
)
sw
$
t0
,
0
(
$
s0
)
lui
$
t0
,
0xa8d7
lui
$
t0
,
0xa8d7
...
@@ -35,20 +36,53 @@ test:
...
@@ -35,20 +36,53 @@ test:
ori
$
t0
,
0x1fad
ori
$
t0
,
0x1fad
sw
$
t0
,
0x1c
(
$
s0
)
sw
$
t0
,
0x1c
(
$
s0
)
#
syscall
4020
to
trigger
#
preimage
request
-
write
(
fdPreimageWrite
,
preimageData
,
32
)
li
$
v0
,
4020
li
$
a0
,
6
li
$
a1
,
0x30001000
li
$
t0
,
8
li
$
a2
,
4
$
writeloop
:
li
$
v0
,
4004
syscall
syscall
addiu
$
a1
,
$
a1
,
4
addiu
$
t0
,
$
t0
,
-
1
bnez
$
t0
,
$
writeloop
nop
#
preimage
response
to
0x30002000
-
read
(
fdPreimageRead
,
addr
,
count
)
#
read
preimage
length
li
$
a0
,
5
li
$
a1
,
0x31000000
li
$
a2
,
4
li
$
v0
,
4003
syscall
li
$
a1
,
0x31000004
li
$
v0
,
4003
syscall
#
read
the
preimage
data
li
$
a1
,
0x31000008
li
$
t0
,
3
$
readloop
:
li
$
v0
,
4003
syscall
addiu
$
a1
,
$
a1
,
4
addiu
$
t0
,
$
t0
,
-
1
bnez
$
t0
,
$
readloop
nop
#
length
at
0x31000000
#
length
at
0x31000000
.
We
also
check
that
the
lower
32
bits
are
zero
lui
$
s1
,
0x3100
lui
$
s1
,
0x3100
lw
$
t0
,
0
(
$
s1
)
lw
$
t0
,
0
(
$
s1
)
sltiu
$
t6
,
$
t0
,
1
li
$
s1
,
0x31000004
lw
$
t0
,
0
(
$
s1
)
#
should
be
len
(
"hello world"
)
==
11
#
should
be
len
(
"hello world"
)
==
11
li
$
t4
,
11
li
$
t4
,
11
subu
$
t5
,
$
t0
,
$
t4
subu
$
t5
,
$
t0
,
$
t4
sltiu
$
v0
,
$
t5
,
1
sltiu
$
v0
,
$
t5
,
1
and
$
v0
,
$
v0
,
$
t6
#
data
at
0x3100000
4
#
data
at
0x3100000
8
lw
$
t0
,
4
(
$
s1
)
lw
$
t0
,
4
(
$
s1
)
lui
$
t4
,
0x6865
lui
$
t4
,
0x6865
ori
$
t4
,
0x6c6c
ori
$
t4
,
0x6c6c
...
...
cannon/mipsevm/state_test.go
View file @
4a02eb4d
...
@@ -31,8 +31,9 @@ func TestState(t *testing.T) {
...
@@ -31,8 +31,9 @@ func TestState(t *testing.T) {
for
_
,
f
:=
range
testFiles
{
for
_
,
f
:=
range
testFiles
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
var
oracle
PreimageOracle
if
f
.
Name
()
==
"oracle.bin"
{
if
f
.
Name
()
==
"oracle.bin"
{
t
.
Skip
(
"oracle test needs to be updated to use syscall pre-image oracle"
)
oracle
=
staticOracle
(
t
,
[]
byte
(
"hello world"
)
)
}
}
// TODO: currently tests are compiled as flat binary objects
// TODO: currently tests are compiled as flat binary objects
// We can use more standard tooling to compile them to ELF files and get remove maketests.py
// We can use more standard tooling to compile them to ELF files and get remove maketests.py
...
@@ -50,7 +51,7 @@ func TestState(t *testing.T) {
...
@@ -50,7 +51,7 @@ func TestState(t *testing.T) {
// set the return address ($ra) to jump into when test completes
// set the return address ($ra) to jump into when test completes
state
.
Registers
[
31
]
=
endAddr
state
.
Registers
[
31
]
=
endAddr
us
:=
NewInstrumentedState
(
state
,
nil
,
os
.
Stdout
,
os
.
Stderr
)
us
:=
NewInstrumentedState
(
state
,
oracle
,
os
.
Stdout
,
os
.
Stderr
)
for
i
:=
0
;
i
<
1000
;
i
++
{
for
i
:=
0
;
i
<
1000
;
i
++
{
if
us
.
state
.
PC
==
endAddr
{
if
us
.
state
.
PC
==
endAddr
{
...
@@ -196,3 +197,15 @@ func TestClaim(t *testing.T) {
...
@@ -196,3 +197,15 @@ func TestClaim(t *testing.T) {
require
.
Equal
(
t
,
expectedStdOut
,
stdOutBuf
.
String
(),
"stdout"
)
require
.
Equal
(
t
,
expectedStdOut
,
stdOutBuf
.
String
(),
"stdout"
)
require
.
Equal
(
t
,
expectedStdErr
,
stdErrBuf
.
String
(),
"stderr"
)
require
.
Equal
(
t
,
expectedStdErr
,
stdErrBuf
.
String
(),
"stderr"
)
}
}
func
staticOracle
(
t
*
testing
.
T
,
preimageData
[]
byte
)
*
testOracle
{
return
&
testOracle
{
hint
:
func
(
v
[]
byte
)
{},
getPreimage
:
func
(
k
[
32
]
byte
)
[]
byte
{
if
k
!=
preimage
.
Keccak256Key
(
crypto
.
Keccak256Hash
(
preimageData
))
.
PreimageKey
()
{
t
.
Fatalf
(
"invalid preimage request for %x"
,
k
)
}
return
preimageData
},
}
}
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