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
12dd92cb
Unverified
Commit
12dd92cb
authored
Sep 13, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Add unit test for the poisoned pre-state case
parent
174bfbd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
game_solver_test.go
op-challenger/game/fault/solver/game_solver_test.go
+27
-0
No files found.
op-challenger/game/fault/solver/game_solver_test.go
View file @
12dd92cb
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/hex"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
faulttest
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/test"
faulttest
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/test"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
@@ -84,6 +85,32 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -84,6 +85,32 @@ func TestCalculateNextActions(t *testing.T) {
lastHonestClaim
.
Attack
(
common
.
Hash
{
0xdd
})
.
ExpectStepAttack
()
lastHonestClaim
.
Attack
(
common
.
Hash
{
0xdd
})
.
ExpectStepAttack
()
},
},
},
},
{
name
:
"PoisonedPreState"
,
agreeWithOutputRoot
:
true
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
// Create a cannon state that is exited and resolved that the output root was invalid
maliciousState
:=
mipsevm
.
State
{
Memory
:
mipsevm
.
NewMemory
(),
ExitCode
:
1
,
Exited
:
true
,
}
maliciousStateHash
,
_
:=
maliciousState
.
EncodeWitness
()
.
StateHash
()
// Dishonest actor counters their own claims to set up a situation with an invalid prestate
// The honest actor should attack all claims that support the root claim (disagree with the output root)
builder
.
Seq
()
.
ExpectAttack
()
.
// This expected action is the winning move.
Attack
(
maliciousStateHash
)
.
Defend
(
maliciousStateHash
)
.
ExpectAttack
()
.
Attack
(
maliciousStateHash
)
.
Attack
(
maliciousStateHash
)
.
ExpectStepAttack
()
// The attempt to step against our malicious leaf node will fail because the pre-state won't match our
// malicious state hash. However, it is the very first expected action, attacking the root claim with
// the correct hash that wins the game since it will be the left-most uncountered claim.
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
...
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