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
9e1b6a94
Unverified
Commit
9e1b6a94
authored
Oct 10, 2024
by
mbaxter
Committed by
GitHub
Oct 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Fix 64-bit test compilation (#12416)
* cannon: Fix test compilation for 64-bit * cannon: Fix typo
parent
d1882af6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
evm_common_test.go
cannon/mipsevm/tests/evm_common_test.go
+5
-5
helpers.go
cannon/mipsevm/tests/helpers.go
+15
-7
mips.go
cannon/mipsevm/testutil/mips.go
+1
-3
No files found.
cannon/mipsevm/tests/evm_common_test.go
View file @
9e1b6a94
...
...
@@ -647,11 +647,11 @@ func TestEVMFault(t *testing.T) {
nextPC
arch
.
Word
insn
uint32
errMsg
string
memoryProofAddresses
[]
uint32
memoryProofAddresses
[]
Word
}{
{
"illegal instruction"
,
0
,
0xFF
_FF_FF_FF
,
"invalid instruction"
,
[]
uint32
{
0xa7ef00cc
}},
{
"branch in delay-slot"
,
8
,
0x11
_02_00_03
,
"branch in delay slot"
,
[]
uint32
{
0
}},
{
"jump in delay-slot"
,
8
,
0x0c
_00_00_0c
,
"jump in delay slot"
,
[]
uint32
{
0
}},
{
"illegal instruction"
,
0
,
0xFF
_FF_FF_FF
,
"invalid instruction"
,
[]
Word
{
0xa7ef00cc
}},
{
"branch in delay-slot"
,
8
,
0x11
_02_00_03
,
"branch in delay slot"
,
[]
Word
{
}},
{
"jump in delay-slot"
,
8
,
0x0c
_00_00_0c
,
"jump in delay slot"
,
[]
Word
{
}},
}
for
_
,
v
:=
range
versions
{
...
...
@@ -665,7 +665,7 @@ func TestEVMFault(t *testing.T) {
state
.
GetRegistersRef
()[
31
]
=
testutil
.
EndAddr
proofData
:=
v
.
ProofGenerator
(
t
,
goVm
.
GetState
(),
tt
.
memoryProofAddresses
...
)
require
.
Panics
(
t
,
func
()
{
_
,
_
=
goVm
.
Step
(
tru
e
)
})
require
.
Panics
(
t
,
func
()
{
_
,
_
=
goVm
.
Step
(
fals
e
)
})
testutil
.
AssertEVMReverts
(
t
,
state
,
v
.
Contracts
,
tracer
,
proofData
,
tt
.
errMsg
)
})
}
...
...
cannon/mipsevm/tests/helpers.go
View file @
9e1b6a94
...
...
@@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/arch"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/multithreaded"
mttestutil
"github.com/ethereum-optimism/optimism/cannon/mipsevm/multithreaded/testutil"
"github.com/ethereum-optimism/optimism/cannon/mipsevm/singlethreaded"
...
...
@@ -50,9 +51,9 @@ func multiThreadElfVmFactory(t require.TestingT, elfFile string, po mipsevm.Prei
return
fpvm
}
type
ProofGenerator
func
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
uint32
)
[]
byte
type
ProofGenerator
func
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
arch
.
Word
)
[]
byte
func
sing
alThreadedProofGenerator
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
uint32
)
[]
byte
{
func
sing
leThreadedProofGenerator
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
arch
.
Word
)
[]
byte
{
var
proofData
[]
byte
insnProof
:=
state
.
GetMemory
()
.
MerkleProof
(
state
.
GetPC
())
...
...
@@ -66,7 +67,7 @@ func singalThreadedProofGenerator(t require.TestingT, state mipsevm.FPVMState, m
return
proofData
}
func
multiThreadedProofGenerator
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
uint32
)
[]
byte
{
func
multiThreadedProofGenerator
(
t
require
.
TestingT
,
state
mipsevm
.
FPVMState
,
memoryProofAddresses
...
arch
.
Word
)
[]
byte
{
mtState
,
ok
:=
state
.
(
*
multithreaded
.
State
)
if
!
ok
{
require
.
Fail
(
t
,
"Failed to cast FPVMState to multithreaded State type"
)
...
...
@@ -100,7 +101,7 @@ func GetSingleThreadedTestCase(t require.TestingT) VersionedVMTestCase {
StateHashFn
:
singlethreaded
.
GetStateHashFn
(),
VMFactory
:
singleThreadedVmFactory
,
ElfVMFactory
:
singleThreadElfVmFactory
,
ProofGenerator
:
sing
al
ThreadedProofGenerator
,
ProofGenerator
:
sing
le
ThreadedProofGenerator
,
}
}
...
...
@@ -116,8 +117,15 @@ func GetMultiThreadedTestCase(t require.TestingT) VersionedVMTestCase {
}
func
GetMipsVersionTestCases
(
t
require
.
TestingT
)
[]
VersionedVMTestCase
{
if
arch
.
IsMips32
{
return
[]
VersionedVMTestCase
{
GetSingleThreadedTestCase
(
t
),
GetMultiThreadedTestCase
(
t
),
}
}
else
{
// 64-bit only supports MTCannon
return
[]
VersionedVMTestCase
{
GetMultiThreadedTestCase
(
t
),
}
}
}
cannon/mipsevm/testutil/mips.go
View file @
9e1b6a94
...
...
@@ -196,13 +196,11 @@ func AssertEVMReverts(t *testing.T, state mipsevm.FPVMState, contracts *Contract
env
.
Config
.
Tracer
=
tracer
sender
:=
common
.
Address
{
0x13
,
0x37
}
ret
,
_
,
err
:=
env
.
Call
(
vm
.
AccountRef
(
sender
),
contracts
.
Addresses
.
MIPS
,
input
,
startingGas
,
common
.
U2560
)
require
.
EqualValues
(
t
,
err
,
vm
.
ErrExecutionReverted
)
require
.
EqualValues
(
t
,
err
,
vm
.
ErrExecutionReverted
)
require
.
Greater
(
t
,
len
(
ret
),
4
,
"Return data length should be greater than 4 bytes"
)
unpacked
,
decodeErr
:=
abi
.
UnpackRevert
(
ret
)
require
.
NoError
(
t
,
decodeErr
,
"Failed to unpack revert reason"
)
require
.
Equal
(
t
,
expectedReason
,
unpacked
,
"Revert reason mismatch"
)
logs
:=
evmState
.
Logs
()
...
...
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