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
6c16d493
Unverified
Commit
6c16d493
authored
Nov 21, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Update tests.
parent
e61a90c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
evm_test.go
cannon/mipsevm/evm_test.go
+5
-5
witness.go
cannon/mipsevm/witness.go
+3
-1
No files found.
cannon/mipsevm/evm_test.go
View file @
6c16d493
...
...
@@ -80,13 +80,13 @@ func (m *MIPSEVM) Step(t *testing.T, stepWitness *StepWitness) []byte {
if
stepWitness
.
HasPreimage
()
{
t
.
Logf
(
"reading preimage key %x at offset %d"
,
stepWitness
.
PreimageKey
,
stepWitness
.
PreimageOffset
)
poInput
,
err
:=
encodePreimageOracleInput
(
t
,
stepWitness
,
0
)
poInput
,
err
:=
encodePreimageOracleInput
(
t
,
stepWitness
,
LocalContext
{}
)
require
.
NoError
(
t
,
err
,
"encode preimage oracle input"
)
_
,
leftOverGas
,
err
:=
m
.
env
.
Call
(
vm
.
AccountRef
(
sender
),
m
.
addrs
.
Oracle
,
poInput
,
startingGas
,
big
.
NewInt
(
0
))
require
.
NoErrorf
(
t
,
err
,
"evm should not fail, took %d gas"
,
startingGas
-
leftOverGas
)
}
input
:=
encodeStepInput
(
t
,
stepWitness
,
0
)
input
:=
encodeStepInput
(
t
,
stepWitness
,
LocalContext
{}
)
ret
,
leftOverGas
,
err
:=
m
.
env
.
Call
(
vm
.
AccountRef
(
sender
),
m
.
addrs
.
MIPS
,
input
,
startingGas
,
big
.
NewInt
(
0
))
require
.
NoError
(
t
,
err
,
"evm should not fail"
)
require
.
Len
(
t
,
ret
,
32
,
"expecting 32-byte state hash"
)
...
...
@@ -109,7 +109,7 @@ func encodeStepInput(t *testing.T, wit *StepWitness, localContext LocalContext)
mipsAbi
,
err
:=
bindings
.
MIPSMetaData
.
GetAbi
()
require
.
NoError
(
t
,
err
)
input
,
err
:=
mipsAbi
.
Pack
(
"step"
,
wit
.
State
,
wit
.
MemProof
,
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
localContext
))
)
input
,
err
:=
mipsAbi
.
Pack
(
"step"
,
wit
.
State
,
wit
.
MemProof
,
localContext
)
require
.
NoError
(
t
,
err
)
return
input
}
...
...
@@ -132,7 +132,7 @@ func encodePreimageOracleInput(t *testing.T, wit *StepWitness, localContext Loca
copy
(
tmp
[
:
],
preimagePart
)
input
,
err
:=
preimageAbi
.
Pack
(
"loadLocalData"
,
new
(
big
.
Int
)
.
SetBytes
(
wit
.
PreimageKey
[
1
:
]),
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
localContext
))
,
localContext
,
tmp
,
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
len
(
preimagePart
))),
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
wit
.
PreimageOffset
)),
...
...
@@ -292,7 +292,7 @@ func TestEVMFault(t *testing.T) {
State
:
initialState
.
EncodeWitness
(),
MemProof
:
insnProof
[
:
],
}
input
:=
encodeStepInput
(
t
,
stepWitness
,
0
)
input
:=
encodeStepInput
(
t
,
stepWitness
,
LocalContext
{}
)
startingGas
:=
uint64
(
30
_000_000
)
_
,
_
,
err
:=
env
.
Call
(
vm
.
AccountRef
(
sender
),
addrs
.
MIPS
,
input
,
startingGas
,
big
.
NewInt
(
0
))
...
...
cannon/mipsevm/witness.go
View file @
6c16d493
package
mipsevm
type
LocalContext
uint64
import
"github.com/ethereum/go-ethereum/common"
type
LocalContext
common
.
Hash
type
StepWitness
struct
{
// encoded state witness
...
...
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