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
b7325840
Unverified
Commit
b7325840
authored
Dec 22, 2023
by
Adrian Sutton
Committed by
GitHub
Dec 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Migrate poisoned post-state test to output_cannon game type. (#8717)
parent
e5066e33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
69 deletions
+80
-69
output_game_helper.go
op-e2e/e2eutils/disputegame/output_game_helper.go
+12
-4
cannon_test.go
op-e2e/faultproofs/cannon_test.go
+0
-65
output_cannon_test.go
op-e2e/faultproofs/output_cannon_test.go
+68
-0
No files found.
op-e2e/e2eutils/disputegame/output_game_helper.go
View file @
b7325840
...
...
@@ -394,16 +394,24 @@ func (g *OutputGameHelper) waitForNewClaim(ctx context.Context, checkPoint int64
func
(
g
*
OutputGameHelper
)
Attack
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
tx
,
err
:=
g
.
game
.
Attack
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
g
.
require
.
NoError
(
err
,
"Attack transaction did not send"
)
if
err
!=
nil
{
g
.
require
.
NoErrorf
(
err
,
"Attack transaction did not send. Game state:
\n
%v"
,
g
.
gameData
(
ctx
))
}
_
,
err
=
wait
.
ForReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
g
.
require
.
NoError
(
err
,
"Attack transaction was not OK"
)
if
err
!=
nil
{
g
.
require
.
NoErrorf
(
err
,
"Attack transaction was not OK. Game state:
\n
%v"
,
g
.
gameData
(
ctx
))
}
}
func
(
g
*
OutputGameHelper
)
Defend
(
ctx
context
.
Context
,
claimIdx
int64
,
claim
common
.
Hash
)
{
tx
,
err
:=
g
.
game
.
Defend
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
claim
)
g
.
require
.
NoError
(
err
,
"Defend transaction did not send"
)
if
err
!=
nil
{
g
.
require
.
NoErrorf
(
err
,
"Defend transaction did not send. Game state:
\n
%v"
,
g
.
gameData
(
ctx
))
}
_
,
err
=
wait
.
ForReceiptOK
(
ctx
,
g
.
client
,
tx
.
Hash
())
g
.
require
.
NoError
(
err
,
"Defend transaction was not OK"
)
if
err
!=
nil
{
g
.
require
.
NoErrorf
(
err
,
"Defend transaction was not OK. Game state:
\n
%v"
,
g
.
gameData
(
ctx
))
}
}
type
ErrWithData
interface
{
...
...
op-e2e/faultproofs/cannon_test.go
View file @
b7325840
...
...
@@ -171,71 +171,6 @@ func TestCannonProposedOutputRootInvalid(t *testing.T) {
}
}
func
TestCannonPoisonedPostState
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
,
op_e2e
.
UseExecutor
(
0
))
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
)
game
,
correctTrace
:=
disputeGameFactory
.
StartCannonGameWithCorrectRoot
(
ctx
,
"sequencer"
,
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Mallory
),
)
require
.
NotNil
(
t
,
game
)
game
.
LogGameData
(
ctx
)
// Honest first attack at "honest" level
correctTrace
.
Attack
(
ctx
,
0
)
// Honest defense at "dishonest" level
correctTrace
.
Defend
(
ctx
,
1
)
// Dishonest attack at "honest" level - honest move would be to ignore
game
.
Attack
(
ctx
,
2
,
common
.
Hash
{
0x03
,
0xaa
})
// Honest attack at "dishonest" level - honest move would be to ignore
correctTrace
.
Attack
(
ctx
,
3
)
// Start the honest challenger
game
.
StartChallenger
(
ctx
,
"sequencer"
,
"Honest"
,
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Bob
))
// Start dishonest challenger that posts correct claims
// It participates in the subgame root the honest claim index 4
func
()
{
claimCount
:=
int64
(
5
)
depth
:=
game
.
MaxDepth
(
ctx
)
for
{
game
.
LogGameData
(
ctx
)
claimCount
++
// Wait for the challenger to counter
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Respond with our own move
correctTrace
.
Defend
(
ctx
,
claimCount
-
1
)
claimCount
++
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Defender moves last. If we're at max depth, then we're done
pos
:=
game
.
GetClaimPosition
(
ctx
,
claimCount
-
1
)
if
int64
(
pos
.
Depth
())
==
depth
{
break
}
}
}()
// Wait for the challenger to drive the subgame at 4 to the leaf node, which should be countered
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
// Time travel past when the game will be resolvable.
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
game
.
WaitForInactivity
(
ctx
,
10
,
true
)
game
.
LogGameData
(
ctx
)
require
.
EqualValues
(
t
,
disputegame
.
StatusChallengerWins
,
game
.
Status
(
ctx
))
}
func
TestCannonChallengeWithCorrectRoot
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
,
op_e2e
.
UseExecutor
(
0
))
ctx
:=
context
.
Background
()
...
...
op-e2e/faultproofs/output_cannon_test.go
View file @
b7325840
...
...
@@ -269,3 +269,71 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) {
})
}
}
func
TestOutputCannonPoisonedPostState
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
,
op_e2e
.
UseExecutor
(
outputCannonTestExecutor
))
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
)
// Root claim is dishonest
game
:=
disputeGameFactory
.
StartOutputCannonGame
(
ctx
,
"sequencer"
,
1
,
common
.
Hash
{
0xaa
})
correctTrace
:=
game
.
CreateHonestActor
(
ctx
,
"sequencer"
,
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Alice
))
// Honest first attack at "honest" level
correctTrace
.
Attack
(
ctx
,
0
)
// Honest defense at "dishonest" level
correctTrace
.
Defend
(
ctx
,
1
)
// Dishonest attack at "honest" level - honest move would be to ignore
game
.
Attack
(
ctx
,
2
,
common
.
Hash
{
0x03
,
0xaa
})
// Honest attack at "dishonest" level - honest move would be to ignore
correctTrace
.
Attack
(
ctx
,
3
)
game
.
LogGameData
(
ctx
)
// Start the honest challenger
game
.
StartChallenger
(
ctx
,
"sequencer"
,
"Honest"
,
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Bob
))
// Start dishonest challenger that posts correct claims
// It participates in the subgame root the honest claim index 4
claimCount
:=
int64
(
5
)
depth
:=
game
.
MaxDepth
(
ctx
)
splitDepth
:=
game
.
SplitDepth
(
ctx
)
for
{
game
.
LogGameData
(
ctx
)
claimCount
++
// Wait for the challenger to counter
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Respond with our own move
if
claimCount
==
splitDepth
+
4
{
// Root of the cannon game must have the right VM status code (so it can't be honest).
// Note this occurs when there are splitDepth + 4 claims because there are multiple forks in this game.
game
.
Attack
(
ctx
,
claimCount
-
1
,
common
.
Hash
{
0x01
})
}
else
{
correctTrace
.
Defend
(
ctx
,
claimCount
-
1
)
}
claimCount
++
game
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Defender moves last. If we're at max depth, then we're done
pos
:=
game
.
GetClaimPosition
(
ctx
,
claimCount
-
1
)
if
int64
(
pos
.
Depth
())
==
depth
{
break
}
}
// Wait for the challenger to drive the subgame at 4 to the leaf node, which should be countered
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
// Time travel past when the game will be resolvable.
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
game
.
LogGameData
(
ctx
)
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
}
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