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
5921931c
Unverified
Commit
5921931c
authored
Aug 18, 2023
by
mergify[bot]
Committed by
GitHub
Aug 18, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into indexer.slices
parents
85551cd6
20474204
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
202 additions
and
96 deletions
+202
-96
helper.go
op-e2e/e2eutils/challenger/helper.go
+68
-0
cannon_helper.go
op-e2e/e2eutils/disputegame/cannon_helper.go
+10
-44
game_helper.go
op-e2e/e2eutils/disputegame/game_helper.go
+23
-8
helper.go
op-e2e/e2eutils/disputegame/helper.go
+6
-6
faultproof_test.go
op-e2e/faultproof_test.go
+95
-38
No files found.
op-e2e/e2eutils/challenger/helper.go
View file @
5921931c
...
...
@@ -2,15 +2,22 @@ package challenger
import
(
"context"
"crypto/ecdsa"
"encoding/json"
"errors"
"os"
"path/filepath"
"testing"
"time"
op_challenger
"github.com/ethereum-optimism/optimism/op-challenger"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
...
...
@@ -23,6 +30,67 @@ type Helper struct {
type
Option
func
(
config2
*
config
.
Config
)
func
WithFactoryAddress
(
addr
common
.
Address
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
GameFactoryAddress
=
addr
}
}
func
WithGameAddress
(
addr
common
.
Address
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
GameAddress
=
addr
}
}
func
WithPrivKey
(
key
*
ecdsa
.
PrivateKey
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
key
)
}
}
func
WithAgreeProposedOutput
(
agree
bool
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
agree
}
}
func
WithAlphabet
(
alphabet
string
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
TraceType
=
config
.
TraceTypeAlphabet
c
.
AlphabetTrace
=
alphabet
}
}
func
WithCannon
(
t
*
testing
.
T
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
l2Endpoint
string
,
)
Option
{
return
func
(
c
*
config
.
Config
)
{
require
:=
require
.
New
(
t
)
c
.
TraceType
=
config
.
TraceTypeCannon
c
.
CannonL2
=
l2Endpoint
c
.
CannonDatadir
=
t
.
TempDir
()
c
.
CannonBin
=
"../cannon/bin/cannon"
c
.
CannonServer
=
"../op-program/bin/op-program"
c
.
CannonAbsolutePreState
=
"../op-program/bin/prestate.json"
c
.
CannonSnapshotFreq
=
10
_000_000
genesisBytes
,
err
:=
json
.
Marshal
(
l2Genesis
)
require
.
NoError
(
err
,
"marshall l2 genesis config"
)
genesisFile
:=
filepath
.
Join
(
c
.
CannonDatadir
,
"l2-genesis.json"
)
require
.
NoError
(
os
.
WriteFile
(
genesisFile
,
genesisBytes
,
0644
))
c
.
CannonL2GenesisPath
=
genesisFile
rollupBytes
,
err
:=
json
.
Marshal
(
rollupCfg
)
require
.
NoError
(
err
,
"marshall rollup config"
)
rollupFile
:=
filepath
.
Join
(
c
.
CannonDatadir
,
"rollup.json"
)
require
.
NoError
(
os
.
WriteFile
(
rollupFile
,
rollupBytes
,
0644
))
c
.
CannonRollupConfigPath
=
rollupFile
}
}
func
NewChallenger
(
t
*
testing
.
T
,
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
Option
)
*
Helper
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
name
)
log
.
Info
(
"Creating challenger"
,
"l1"
,
l1Endpoint
)
...
...
op-e2e/e2eutils/disputegame/cannon_helper.go
View file @
5921931c
...
...
@@ -2,21 +2,14 @@ package disputegame
import
(
"context"
"encoding/json"
"os"
"path/filepath"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/cannon"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
type
CannonGameHelper
struct
{
...
...
@@ -24,7 +17,11 @@ type CannonGameHelper struct {
}
func
(
g
*
CannonGameHelper
)
StartChallenger
(
ctx
context
.
Context
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
l1Endpoint
string
,
l2Endpoint
string
,
name
string
,
options
...
challenger
.
Option
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
createConfigOption
(
g
.
t
,
rollupCfg
,
l2Genesis
,
g
.
factoryAddr
,
g
.
addr
,
l2Endpoint
)}
opts
:=
[]
challenger
.
Option
{
challenger
.
WithCannon
(
g
.
t
,
rollupCfg
,
l2Genesis
,
l2Endpoint
),
challenger
.
WithFactoryAddress
(
g
.
factoryAddr
),
challenger
.
WithGameAddress
(
g
.
addr
),
}
opts
=
append
(
opts
,
options
...
)
c
:=
challenger
.
NewChallenger
(
g
.
t
,
ctx
,
l1Endpoint
,
name
,
opts
...
)
g
.
t
.
Cleanup
(
func
()
{
...
...
@@ -34,7 +31,11 @@ func (g *CannonGameHelper) StartChallenger(ctx context.Context, rollupCfg *rollu
}
func
(
g
*
CannonGameHelper
)
CreateHonestActor
(
ctx
context
.
Context
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
l1Client
bind
.
ContractCaller
,
l1Endpoint
string
,
l2Endpoint
string
,
options
...
challenger
.
Option
)
*
HonestHelper
{
opts
:=
[]
challenger
.
Option
{
createConfigOption
(
g
.
t
,
rollupCfg
,
l2Genesis
,
g
.
factoryAddr
,
g
.
addr
,
l2Endpoint
)}
opts
:=
[]
challenger
.
Option
{
challenger
.
WithCannon
(
g
.
t
,
rollupCfg
,
l2Genesis
,
l2Endpoint
),
challenger
.
WithFactoryAddress
(
g
.
factoryAddr
),
challenger
.
WithGameAddress
(
g
.
addr
),
}
opts
=
append
(
opts
,
options
...
)
cfg
:=
challenger
.
NewChallengerConfig
(
g
.
t
,
l1Endpoint
,
opts
...
)
provider
,
err
:=
cannon
.
NewTraceProvider
(
ctx
,
testlog
.
Logger
(
g
.
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"CorrectTrace"
),
cfg
,
l1Client
)
...
...
@@ -47,38 +48,3 @@ func (g *CannonGameHelper) CreateHonestActor(ctx context.Context, rollupCfg *rol
correctTrace
:
provider
,
}
}
func
createConfigOption
(
t
*
testing
.
T
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
factoryAddr
common
.
Address
,
gameAddr
common
.
Address
,
l2Endpoint
string
,
)
challenger
.
Option
{
return
func
(
c
*
config
.
Config
)
{
require
:=
require
.
New
(
t
)
c
.
GameFactoryAddress
=
factoryAddr
c
.
GameAddress
=
gameAddr
c
.
TraceType
=
config
.
TraceTypeCannon
c
.
AgreeWithProposedOutput
=
false
c
.
CannonL2
=
l2Endpoint
c
.
CannonBin
=
"../cannon/bin/cannon"
c
.
CannonDatadir
=
t
.
TempDir
()
c
.
CannonServer
=
"../op-program/bin/op-program"
c
.
CannonAbsolutePreState
=
"../op-program/bin/prestate.json"
c
.
CannonSnapshotFreq
=
10
_000_000
genesisBytes
,
err
:=
json
.
Marshal
(
l2Genesis
)
require
.
NoError
(
err
,
"marshall l2 genesis config"
)
genesisFile
:=
filepath
.
Join
(
c
.
CannonDatadir
,
"l2-genesis.json"
)
require
.
NoError
(
os
.
WriteFile
(
genesisFile
,
genesisBytes
,
0644
))
c
.
CannonL2GenesisPath
=
genesisFile
rollupBytes
,
err
:=
json
.
Marshal
(
rollupCfg
)
require
.
NoError
(
err
,
"marshall rollup config"
)
rollupFile
:=
filepath
.
Join
(
c
.
CannonDatadir
,
"rollup.json"
)
require
.
NoError
(
os
.
WriteFile
(
rollupFile
,
rollupBytes
,
0644
))
c
.
CannonRollupConfigPath
=
rollupFile
}
}
op-e2e/e2eutils/disputegame/game_helper.go
View file @
5921931c
...
...
@@ -60,7 +60,7 @@ func (g *FaultGameHelper) MaxDepth(ctx context.Context) int64 {
return
depth
.
Int64
()
}
func
(
g
*
FaultGameHelper
)
WaitForClaim
(
ctx
context
.
Context
,
predicate
func
(
claim
ContractClaim
)
bool
)
{
func
(
g
*
FaultGameHelper
)
waitForClaim
(
ctx
context
.
Context
,
errorMsg
string
,
predicate
func
(
claim
ContractClaim
)
bool
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Minute
)
defer
cancel
()
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
...
...
@@ -80,7 +80,15 @@ func (g *FaultGameHelper) WaitForClaim(ctx context.Context, predicate func(claim
}
return
false
,
nil
})
g
.
require
.
NoError
(
err
)
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
)
return
claim
.
Claim
}
// getClaim retrieves the claim data for a specific index.
...
...
@@ -95,7 +103,10 @@ func (g *FaultGameHelper) getClaim(ctx context.Context, claimIdx int64) Contract
func
(
g
*
FaultGameHelper
)
WaitForClaimAtMaxDepth
(
ctx
context
.
Context
,
countered
bool
)
{
maxDepth
:=
g
.
MaxDepth
(
ctx
)
g
.
WaitForClaim
(
ctx
,
func
(
claim
ContractClaim
)
bool
{
g
.
waitForClaim
(
ctx
,
fmt
.
Sprintf
(
"Could not find claim depth %v with countered=%v"
,
maxDepth
,
countered
),
func
(
claim
ContractClaim
)
bool
{
pos
:=
types
.
NewPositionFromGIndex
(
claim
.
Position
.
Uint64
())
return
int64
(
pos
.
Depth
())
==
maxDepth
&&
claim
.
Countered
==
countered
})
...
...
@@ -141,7 +152,7 @@ func (g *FaultGameHelper) Defend(ctx context.Context, claimIdx int64, claim comm
g
.
require
.
NoError
(
err
,
"Defend transaction was not OK"
)
}
func
(
g
*
FaultGameHelper
)
LogGameData
(
ctx
context
.
Context
)
{
func
(
g
*
FaultGameHelper
)
gameData
(
ctx
context
.
Context
)
string
{
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
maxDepth
:=
int
(
g
.
MaxDepth
(
ctx
))
claimCount
,
err
:=
g
.
game
.
ClaimDataLen
(
opts
)
...
...
@@ -157,5 +168,9 @@ func (g *FaultGameHelper) LogGameData(ctx context.Context) {
}
status
,
err
:=
g
.
game
.
Status
(
opts
)
g
.
require
.
NoError
(
err
,
"Load game status"
)
g
.
t
.
Logf
(
"Game %v (%v):
\n
%v
\n
"
,
g
.
addr
,
Status
(
status
),
info
)
return
fmt
.
Sprintf
(
"Game %v (%v):
\n
%v
\n
"
,
g
.
addr
,
Status
(
status
),
info
)
}
func
(
g
*
FaultGameHelper
)
LogGameData
(
ctx
context
.
Context
)
{
g
.
t
.
Log
(
g
.
gameData
(
ctx
))
}
op-e2e/e2eutils/disputegame/helper.go
View file @
5921931c
...
...
@@ -12,7 +12,6 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/fault/cannon"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
...
...
@@ -138,7 +137,10 @@ func (h *FactoryHelper) StartCannonGame(ctx context.Context, rootClaim common.Ha
func
(
h
*
FactoryHelper
)
StartCannonGameWithCorrectRoot
(
ctx
context
.
Context
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
l1Endpoint
string
,
l2Endpoint
string
,
options
...
challenger
.
Option
)
(
*
CannonGameHelper
,
*
HonestHelper
)
{
l2BlockNumber
,
l1Head
:=
h
.
prepareCannonGame
(
ctx
)
challengerOpts
:=
[]
challenger
.
Option
{
createConfigOption
(
h
.
t
,
rollupCfg
,
l2Genesis
,
h
.
factoryAddr
,
common
.
Address
{
0xaa
},
l2Endpoint
)}
challengerOpts
:=
[]
challenger
.
Option
{
challenger
.
WithCannon
(
h
.
t
,
rollupCfg
,
l2Genesis
,
l2Endpoint
),
challenger
.
WithFactoryAddress
(
h
.
factoryAddr
),
}
challengerOpts
=
append
(
challengerOpts
,
options
...
)
cfg
:=
challenger
.
NewChallengerConfig
(
h
.
t
,
l1Endpoint
,
challengerOpts
...
)
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
...
...
@@ -211,12 +213,10 @@ func (h *FactoryHelper) createCannonGame(ctx context.Context, l2BlockNumber uint
},
}
}
func
(
h
*
FactoryHelper
)
StartChallenger
(
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
challenger
.
Option
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
func
(
c
*
config
.
Config
)
{
c
.
GameFactoryAddress
=
h
.
factoryAddr
c
.
TraceType
=
config
.
TraceTypeAlphabet
},
challenger
.
WithFactoryAddress
(
h
.
factoryAddr
),
}
opts
=
append
(
opts
,
options
...
)
c
:=
challenger
.
NewChallenger
(
h
.
t
,
ctx
,
l1Endpoint
,
name
,
opts
...
)
...
...
op-e2e/faultproof_test.go
View file @
5921931c
...
...
@@ -4,8 +4,7 @@ import (
"context"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/disputegame"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -23,11 +22,11 @@ func TestCannonMultipleGames(t *testing.T) {
gameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
// Start a challenger with the correct alphabet trace
gameFactory
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"TowerDefense"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
c
.
AlphabetTrace
=
"abcdefg"
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
}
)
gameFactory
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"TowerDefense"
,
c
hallenger
.
WithAlphabet
(
"abcdefg"
),
c
hallenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
c
hallenger
.
WithAgreeProposedOutput
(
true
),
)
game1
:=
gameFactory
.
StartAlphabetGame
(
ctx
,
"abcxyz"
)
// Wait for the challenger to respond to the first game
...
...
@@ -44,6 +43,59 @@ func TestCannonMultipleGames(t *testing.T) {
game1
.
WaitForClaimCount
(
ctx
,
4
)
}
func
TestMultipleCannonGames
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Cannon provider doesn't currently isolate different game traces"
)
InitParallel
(
t
)
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
gameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
// Start a challenger with the correct alphabet trace
gameFactory
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"TowerDefense"
,
challenger
.
WithCannon
(
t
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
sys
.
NodeEndpoint
(
"sequencer"
)),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
challenger
.
WithAgreeProposedOutput
(
true
),
)
game1
:=
gameFactory
.
StartCannonGame
(
ctx
,
common
.
Hash
{
0xaa
})
game2
:=
gameFactory
.
StartCannonGame
(
ctx
,
common
.
Hash
{
0xbb
})
game1
.
WaitForClaimCount
(
ctx
,
2
)
game2
.
WaitForClaimCount
(
ctx
,
2
)
game1Claim
:=
game1
.
GetClaimValue
(
ctx
,
1
)
game2Claim
:=
game2
.
GetClaimValue
(
ctx
,
1
)
require
.
NotEqual
(
t
,
game1Claim
,
game2Claim
,
"games should have different cannon traces"
)
// Push both games down to the step function
maxDepth
:=
game1
.
MaxDepth
(
ctx
)
for
claimCount
:=
int64
(
1
);
claimCount
<=
maxDepth
;
{
// Challenger should respond to both games
claimCount
++
game1
.
WaitForClaimCount
(
ctx
,
claimCount
)
game2
.
WaitForClaimCount
(
ctx
,
claimCount
)
// Progress both games
game1
.
Defend
(
ctx
,
claimCount
-
1
,
common
.
Hash
{
0xaa
})
game2
.
Defend
(
ctx
,
claimCount
-
1
,
common
.
Hash
{
0xaa
})
claimCount
++
}
game1
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
game2
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
gameDuration
:=
game1
.
GameDuration
(
ctx
)
sys
.
TimeTravelClock
.
AdvanceTime
(
gameDuration
)
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
game1
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game2
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game1
.
LogGameData
(
ctx
)
game2
.
LogGameData
(
ctx
)
}
func
TestResolveDisputeGame
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
...
...
@@ -59,11 +111,11 @@ func TestResolveDisputeGame(t *testing.T) {
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusInProgress
)
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"HonestAlice"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
// Agree with the proposed output, so disagree with the root claim
c
.
AlphabetTrace
=
"abcdefg"
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
}
)
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"HonestAlice"
,
c
hallenger
.
WithAgreeProposedOutput
(
true
),
c
hallenger
.
WithAlphabet
(
"abcdefg"
),
c
hallenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
game
.
WaitForClaimCount
(
ctx
,
2
)
...
...
@@ -155,15 +207,17 @@ func TestChallengerCompleteDisputeGame(t *testing.T) {
require
.
NotNil
(
t
,
game
)
gameDuration
:=
game
.
GameDuration
(
ctx
)
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"Defender"
,
func
(
c
*
config
.
Config
)
{
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Mallory
)
})
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"Defender"
,
challenger
.
WithAgreeProposedOutput
(
false
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Mallory
),
)
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"Challenger"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
// Agree with the proposed output, so disagree with the root claim
c
.
AlphabetTrace
=
test
.
otherAlphabet
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
})
game
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"Challenger"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithAlphabet
(
test
.
otherAlphabet
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
// Wait for a claim at the maximum depth that has been countered to indicate we're ready to resolve the game
game
.
WaitForClaimAtMaxDepth
(
ctx
,
test
.
expectStep
)
...
...
@@ -201,10 +255,11 @@ func TestCannonDisputeGame(t *testing.T) {
require
.
NotNil
(
t
,
game
)
game
.
LogGameData
(
ctx
)
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
sys
.
NodeEndpoint
(
"l1"
),
sys
.
NodeEndpoint
(
"sequencer"
),
"Challenger"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
// Agree with the proposed output, so disagree with the root claim
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
})
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
sys
.
NodeEndpoint
(
"l1"
),
sys
.
NodeEndpoint
(
"sequencer"
),
"Challenger"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
maxDepth
:=
game
.
MaxDepth
(
ctx
)
for
claimCount
:=
int64
(
1
);
claimCount
<
maxDepth
;
{
...
...
@@ -251,14 +306,15 @@ func TestCannonDefendStep(t *testing.T) {
l1Endpoint
:=
sys
.
NodeEndpoint
(
"l1"
)
l2Endpoint
:=
sys
.
NodeEndpoint
(
"sequencer"
)
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"Challenger"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
// Agree with the proposed output, so disagree with the root claim
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
})
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"Challenger"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
correctTrace
:=
game
.
CreateHonestActor
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Client
,
l1Endpoint
,
l2Endpoint
,
func
(
c
*
config
.
Config
)
{
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Mallory
)
}
)
correctTrace
:=
game
.
CreateHonestActor
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Client
,
l1Endpoint
,
l2Endpoint
,
c
hallenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Mallory
),
)
maxDepth
:=
game
.
MaxDepth
(
ctx
)
for
claimCount
:=
int64
(
1
);
claimCount
<
maxDepth
;
{
...
...
@@ -302,16 +358,17 @@ func TestCannonChallengeWithCorrectRoot(t *testing.T) {
l2Endpoint
:=
sys
.
NodeEndpoint
(
"sequencer"
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
game
,
correctTrace
:=
disputeGameFactory
.
StartCannonGameWithCorrectRoot
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
func
(
c
*
config
.
Config
)
{
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Mallory
)
}
)
game
,
correctTrace
:=
disputeGameFactory
.
StartCannonGameWithCorrectRoot
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
c
hallenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Mallory
),
)
require
.
NotNil
(
t
,
game
)
game
.
LogGameData
(
ctx
)
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"Challenger"
,
func
(
c
*
config
.
Config
)
{
c
.
AgreeWithProposedOutput
=
true
// Agree with the proposed output, so disagree with the root claim
c
.
TxMgrConfig
.
PrivateKey
=
e2eutils
.
EncodePrivKeyToString
(
sys
.
cfg
.
Secrets
.
Alice
)
})
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
l1Endpoint
,
l2Endpoint
,
"Challenger"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
maxDepth
:=
game
.
MaxDepth
(
ctx
)
for
claimCount
:=
int64
(
1
);
claimCount
<
maxDepth
;
{
...
...
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