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
8201484f
Unverified
Commit
8201484f
authored
Sep 15, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Add e2e test for the poisoned post-state case.
parent
cf1f0b10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
1 deletion
+111
-1
agent.go
op-challenger/game/fault/agent.go
+7
-1
game_helper.go
op-e2e/e2eutils/disputegame/game_helper.go
+44
-0
faultproof_test.go
op-e2e/faultproof_test.go
+60
-0
No files found.
op-challenger/game/fault/agent.go
View file @
8201484f
...
...
@@ -9,6 +9,7 @@ import (
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
gameTypes
"github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum-optimism/optimism/op-challenger/metrics"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
...
...
@@ -66,7 +67,12 @@ func (a *Agent) Act(ctx context.Context) error {
// Perform the actions
for
_
,
action
:=
range
actions
{
log
:=
a
.
log
.
New
(
"action"
,
action
.
Type
,
"is_attack"
,
action
.
IsAttack
,
"parent"
,
action
.
ParentIdx
,
"value"
,
action
.
Value
)
log
:=
a
.
log
.
New
(
"action"
,
action
.
Type
,
"is_attack"
,
action
.
IsAttack
,
"parent"
,
action
.
ParentIdx
)
if
action
.
Type
==
types
.
ActionTypeStep
{
log
=
log
.
New
(
"prestate"
,
common
.
Bytes2Hex
(
action
.
PreState
),
"proof"
,
common
.
Bytes2Hex
(
action
.
ProofData
))
}
else
{
log
=
log
.
New
(
"value"
,
action
.
Value
)
}
if
action
.
OracleData
!=
nil
{
a
.
log
.
Info
(
"Updating oracle data"
,
"oracleKey"
,
action
.
OracleData
.
OracleKey
,
"oracleData"
,
action
.
OracleData
.
OracleData
)
...
...
op-e2e/e2eutils/disputegame/game_helper.go
View file @
8201484f
...
...
@@ -89,6 +89,31 @@ func (g *FaultGameHelper) waitForClaim(ctx context.Context, errorMsg string, pre
}
}
func
(
g
*
FaultGameHelper
)
waitForNoClaim
(
ctx
context
.
Context
,
errorMsg
string
,
predicate
func
(
claim
ContractClaim
)
bool
)
{
timedCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
3
*
time
.
Minute
)
defer
cancel
()
err
:=
wait
.
For
(
timedCtx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
count
,
err
:=
g
.
game
.
ClaimDataLen
(
&
bind
.
CallOpts
{
Context
:
timedCtx
})
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"retrieve number of claims: %w"
,
err
)
}
// Search backwards because the new claims are at the end and more likely the ones we will fail on.
for
i
:=
count
.
Int64
()
-
1
;
i
>=
0
;
i
--
{
claimData
,
err
:=
g
.
game
.
ClaimData
(
&
bind
.
CallOpts
{
Context
:
timedCtx
},
big
.
NewInt
(
i
))
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"retrieve claim %v: %w"
,
i
,
err
)
}
if
predicate
(
claimData
)
{
return
false
,
nil
}
}
return
true
,
nil
})
if
err
!=
nil
{
// Avoid waiting time capturing game data when there's no error
g
.
require
.
NoErrorf
(
err
,
"%v
\n
%v"
,
errorMsg
,
g
.
gameData
(
ctx
))
}
}
func
(
g
*
FaultGameHelper
)
GetClaimValue
(
ctx
context
.
Context
,
claimIdx
int64
)
common
.
Hash
{
g
.
WaitForClaimCount
(
ctx
,
claimIdx
+
1
)
claim
:=
g
.
getClaim
(
ctx
,
claimIdx
)
...
...
@@ -105,6 +130,16 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract
return
claimData
}
func
(
g
*
FaultGameHelper
)
WaitForClaimAtDepth
(
ctx
context
.
Context
,
depth
int
)
{
g
.
waitForClaim
(
ctx
,
fmt
.
Sprintf
(
"Could not find claim depth %v"
,
depth
),
func
(
claim
ContractClaim
)
bool
{
pos
:=
types
.
NewPositionFromGIndex
(
claim
.
Position
.
Uint64
())
return
pos
.
Depth
()
==
depth
})
}
func
(
g
*
FaultGameHelper
)
WaitForClaimAtMaxDepth
(
ctx
context
.
Context
,
countered
bool
)
{
maxDepth
:=
g
.
MaxDepth
(
ctx
)
g
.
waitForClaim
(
...
...
@@ -116,6 +151,15 @@ func (g *FaultGameHelper) WaitForClaimAtMaxDepth(ctx context.Context, countered
})
}
func
(
g
*
FaultGameHelper
)
WaitForAllClaimsCountered
(
ctx
context
.
Context
)
{
g
.
waitForNoClaim
(
ctx
,
"Did not find all claims countered"
,
func
(
claim
ContractClaim
)
bool
{
return
!
claim
.
Countered
})
}
func
(
g
*
FaultGameHelper
)
Resolve
(
ctx
context
.
Context
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
...
...
op-e2e/faultproof_test.go
View file @
8201484f
...
...
@@ -341,6 +341,66 @@ func TestCannonProposedOutputRootInvalid(t *testing.T) {
}
}
func
TestCannonPoisonedPostState
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Known failure case"
)
InitParallel
(
t
)
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
l1Endpoint
:=
sys
.
NodeEndpoint
(
"l1"
)
l2Endpoint
:=
sys
.
NodeEndpoint
(
"sequencer"
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
game
,
correctTrace
:=
disputeGameFactory
.
StartCannonGameWithCorrectRoot
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
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 defend
game
.
Attack
(
ctx
,
2
,
common
.
Hash
{
0x03
,
0xaa
})
// Start the honest challenger
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"Honest"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Bob
),
)
// Start dishonest challenger that posts correct claims
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"DishonestCorrect"
,
// Disagree with the proposed output, so agree with the root claim
challenger
.
WithAgreeProposedOutput
(
false
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Mallory
),
)
// Give the challengers time to progress down the full game depth
depth
:=
game
.
MaxDepth
(
ctx
)
for
i
:=
3
;
i
<=
int
(
depth
);
i
++
{
game
.
WaitForClaimAtDepth
(
ctx
,
i
)
game
.
LogGameData
(
ctx
)
}
// Wait for all the leaf nodes to be countered
// Wait for the challengers to drive the game down to the leaf node which should be countered
game
.
WaitForAllClaimsCountered
(
ctx
)
// Time travel past when the game will be resolvable.
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
LogGameData
(
ctx
)
}
// setupDisputeGameForInvalidOutputRoot sets up an L2 chain with at least one valid output root followed by an invalid output root.
// A cannon dispute game is started to dispute the invalid output root with the correct root claim provided.
// An honest challenger is run to defend the root claim (ie disagree with the invalid output root).
...
...
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