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
3adecb93
Unverified
Commit
3adecb93
authored
Oct 13, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Update e2e tests for multiple trace types.
parent
672adac1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
18 deletions
+47
-18
helper.go
op-e2e/e2eutils/challenger/helper.go
+3
-6
alphabet_helper.go
op-e2e/e2eutils/disputegame/alphabet_helper.go
+6
-12
faultproof_test.go
op-e2e/faultproof_test.go
+38
-0
No files found.
op-e2e/e2eutils/challenger/helper.go
View file @
3adecb93
...
@@ -42,9 +42,6 @@ func WithFactoryAddress(addr common.Address) Option {
...
@@ -42,9 +42,6 @@ func WithFactoryAddress(addr common.Address) Option {
func
WithGameAddress
(
addr
common
.
Address
)
Option
{
func
WithGameAddress
(
addr
common
.
Address
)
Option
{
return
func
(
c
*
config
.
Config
)
{
return
func
(
c
*
config
.
Config
)
{
if
c
.
GameAllowlist
==
nil
{
c
.
GameAllowlist
=
make
([]
common
.
Address
,
0
)
}
c
.
GameAllowlist
=
append
(
c
.
GameAllowlist
,
addr
)
c
.
GameAllowlist
=
append
(
c
.
GameAllowlist
,
addr
)
}
}
}
}
...
@@ -63,7 +60,7 @@ func WithAgreeProposedOutput(agree bool) Option {
...
@@ -63,7 +60,7 @@ func WithAgreeProposedOutput(agree bool) Option {
func
WithAlphabet
(
alphabet
string
)
Option
{
func
WithAlphabet
(
alphabet
string
)
Option
{
return
func
(
c
*
config
.
Config
)
{
return
func
(
c
*
config
.
Config
)
{
c
.
TraceType
=
config
.
TraceTypeAlphabet
c
.
TraceType
s
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeAlphabet
)
c
.
AlphabetTrace
=
alphabet
c
.
AlphabetTrace
=
alphabet
}
}
}
}
...
@@ -82,7 +79,7 @@ func WithCannon(
...
@@ -82,7 +79,7 @@ func WithCannon(
)
Option
{
)
Option
{
return
func
(
c
*
config
.
Config
)
{
return
func
(
c
*
config
.
Config
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
c
.
TraceType
=
config
.
TraceTypeCannon
c
.
TraceType
s
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeCannon
)
c
.
CannonL2
=
l2Endpoint
c
.
CannonL2
=
l2Endpoint
c
.
CannonBin
=
"../cannon/bin/cannon"
c
.
CannonBin
=
"../cannon/bin/cannon"
c
.
CannonServer
=
"../op-program/bin/op-program"
c
.
CannonServer
=
"../op-program/bin/op-program"
...
@@ -126,7 +123,7 @@ func NewChallenger(t *testing.T, ctx context.Context, l1Endpoint string, name st
...
@@ -126,7 +123,7 @@ func NewChallenger(t *testing.T, ctx context.Context, l1Endpoint string, name st
func
NewChallengerConfig
(
t
*
testing
.
T
,
l1Endpoint
string
,
options
...
Option
)
*
config
.
Config
{
func
NewChallengerConfig
(
t
*
testing
.
T
,
l1Endpoint
string
,
options
...
Option
)
*
config
.
Config
{
// Use the NewConfig method to ensure we pick up any defaults that are set.
// Use the NewConfig method to ensure we pick up any defaults that are set.
cfg
:=
config
.
NewConfig
(
common
.
Address
{},
l1Endpoint
,
true
,
t
.
TempDir
()
,
config
.
TraceTypeAlphabet
)
cfg
:=
config
.
NewConfig
(
common
.
Address
{},
l1Endpoint
,
true
,
t
.
TempDir
())
cfg
.
TxMgrConfig
.
NumConfirmations
=
1
cfg
.
TxMgrConfig
.
NumConfirmations
=
1
cfg
.
TxMgrConfig
.
ReceiptQueryInterval
=
1
*
time
.
Second
cfg
.
TxMgrConfig
.
ReceiptQueryInterval
=
1
*
time
.
Second
if
cfg
.
MaxConcurrency
>
4
{
if
cfg
.
MaxConcurrency
>
4
{
...
...
op-e2e/e2eutils/disputegame/alphabet_helper.go
View file @
3adecb93
...
@@ -3,11 +3,8 @@ package disputegame
...
@@ -3,11 +3,8 @@ package disputegame
import
(
import
(
"context"
"context"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/alphabet"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"github.com/ethereum/go-ethereum/common"
)
)
type
AlphabetGameHelper
struct
{
type
AlphabetGameHelper
struct
{
...
@@ -17,15 +14,12 @@ type AlphabetGameHelper struct {
...
@@ -17,15 +14,12 @@ type AlphabetGameHelper struct {
func
(
g
*
AlphabetGameHelper
)
StartChallenger
(
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
challenger
.
Option
)
*
challenger
.
Helper
{
func
(
g
*
AlphabetGameHelper
)
StartChallenger
(
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
challenger
.
Option
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
opts
:=
[]
challenger
.
Option
{
func
(
c
*
config
.
Config
)
{
challenger
.
WithFactoryAddress
(
g
.
factoryAddr
),
c
.
GameFactoryAddress
=
g
.
factoryAddr
challenger
.
WithGameAddress
(
g
.
addr
),
c
.
GameAllowlist
=
[]
common
.
Address
{
g
.
addr
}
// By default the challenger agrees with the root claim (thus disagrees with the proposed output)
c
.
TraceType
=
config
.
TraceTypeAlphabet
// This can be overridden by passing in options
// By default the challenger agrees with the root claim (thus disagrees with the proposed output)
challenger
.
WithAlphabet
(
g
.
claimedAlphabet
),
// This can be overridden by passing in options
challenger
.
WithAgreeProposedOutput
(
false
),
c
.
AlphabetTrace
=
g
.
claimedAlphabet
c
.
AgreeWithProposedOutput
=
false
},
}
}
opts
=
append
(
opts
,
options
...
)
opts
=
append
(
opts
,
options
...
)
c
:=
challenger
.
NewChallenger
(
g
.
t
,
ctx
,
l1Endpoint
,
name
,
opts
...
)
c
:=
challenger
.
NewChallenger
(
g
.
t
,
ctx
,
l1Endpoint
,
name
,
opts
...
)
...
...
op-e2e/faultproof_test.go
View file @
3adecb93
...
@@ -2,9 +2,12 @@ package op_e2e
...
@@ -2,9 +2,12 @@ package op_e2e
import
(
import
(
"context"
"context"
"math/big"
"testing"
"testing"
"time"
"time"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/alphabet"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
"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/disputegame"
l2oo2
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/l2oo"
l2oo2
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/l2oo"
...
@@ -74,6 +77,41 @@ func TestMultipleCannonGames(t *testing.T) {
...
@@ -74,6 +77,41 @@ func TestMultipleCannonGames(t *testing.T) {
challenger
.
WaitForGameDataDeletion
(
ctx
,
game1
,
game2
)
challenger
.
WaitForGameDataDeletion
(
ctx
,
game1
,
game2
)
}
}
func
TestMultipleGameTypes
(
t
*
testing
.
T
)
{
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 both cannon and alphabet support
gameFactory
.
StartChallenger
(
ctx
,
sys
.
NodeEndpoint
(
"l1"
),
"TowerDefense"
,
challenger
.
WithCannon
(
t
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
sys
.
NodeEndpoint
(
"sequencer"
)),
challenger
.
WithAlphabet
(
disputegame
.
CorrectAlphabet
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
challenger
.
WithAgreeProposedOutput
(
true
),
)
game1
:=
gameFactory
.
StartCannonGame
(
ctx
,
common
.
Hash
{
0x01
,
0xaa
})
game2
:=
gameFactory
.
StartAlphabetGame
(
ctx
,
"xyzabc"
)
// Wait for the challenger to respond to both games
game1
.
WaitForClaimCount
(
ctx
,
2
)
game2
.
WaitForClaimCount
(
ctx
,
2
)
game1Response
:=
game1
.
GetClaimValue
(
ctx
,
1
)
game2Response
:=
game2
.
GetClaimValue
(
ctx
,
1
)
// The alphabet game always posts the same traces, so if they're different they can't both be from the alphabet.
require
.
NotEqual
(
t
,
game1Response
,
game2Response
,
"should have posted different claims"
)
// Now check they aren't both just from different cannon games by confirming the alphabet value.
correctAlphabet
:=
alphabet
.
NewTraceProvider
(
disputegame
.
CorrectAlphabet
,
uint64
(
game2
.
MaxDepth
(
ctx
)))
expectedClaim
,
err
:=
correctAlphabet
.
Get
(
ctx
,
types
.
NewPositionFromGIndex
(
big
.
NewInt
(
1
))
.
Attack
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
expectedClaim
,
game2Response
)
// We don't confirm the cannon value because generating the correct claim is expensive
// Just being different is enough to confirm the challenger isn't just playing two alphabet games incorrectly
}
func
TestChallengerCompleteDisputeGame
(
t
*
testing
.
T
)
{
func
TestChallengerCompleteDisputeGame
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
InitParallel
(
t
)
...
...
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