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
98d5d768
Commit
98d5d768
authored
Dec 06, 2023
by
refcell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(op-e2e): output alphabet e2e tests
fix(op-e2e): fix output alphabet test on refactor
parent
ae158218
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
0 deletions
+149
-0
helper.go
op-e2e/e2eutils/challenger/helper.go
+8
-0
helper.go
op-e2e/e2eutils/disputegame/helper.go
+49
-0
output_alphabet_helper.go
op-e2e/e2eutils/disputegame/output_alphabet_helper.go
+31
-0
output_alphabet_test.go
op-e2e/faultproofs/output_alphabet_test.go
+61
-0
No files found.
op-e2e/e2eutils/challenger/helper.go
View file @
98d5d768
...
@@ -119,6 +119,14 @@ func WithOutputCannon(
...
@@ -119,6 +119,14 @@ func WithOutputCannon(
}
}
}
}
func
WithOutputAlphabet
(
alphabet
string
,
rollupEndpoint
string
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
TraceTypes
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeOutputAlphabet
)
c
.
RollupRpc
=
rollupEndpoint
c
.
AlphabetTrace
=
alphabet
}
}
func
NewChallenger
(
t
*
testing
.
T
,
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
Option
)
*
Helper
{
func
NewChallenger
(
t
*
testing
.
T
,
ctx
context
.
Context
,
l1Endpoint
string
,
name
string
,
options
...
Option
)
*
Helper
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
.
New
(
"role"
,
name
)
log
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
.
New
(
"role"
,
name
)
log
.
Info
(
"Creating challenger"
,
"l1"
,
l1Endpoint
)
log
.
Info
(
"Creating challenger"
,
"l1"
,
l1Endpoint
)
...
...
op-e2e/e2eutils/disputegame/helper.go
View file @
98d5d768
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
const
alphabetGameType
uint8
=
255
const
alphabetGameType
uint8
=
255
const
cannonGameType
uint8
=
0
const
cannonGameType
uint8
=
0
const
outputCannonGameType
uint8
=
1
const
outputCannonGameType
uint8
=
1
const
outputAlphabetGameType
uint8
=
254
const
alphabetGameDepth
=
4
const
alphabetGameDepth
=
4
var
lastAlphabetTraceIndex
=
big
.
NewInt
(
1
<<
alphabetGameDepth
-
1
)
var
lastAlphabetTraceIndex
=
big
.
NewInt
(
1
<<
alphabetGameDepth
-
1
)
...
@@ -197,7 +198,55 @@ func (h *FactoryHelper) StartOutputCannonGame(ctx context.Context, l2Node string
...
@@ -197,7 +198,55 @@ func (h *FactoryHelper) StartOutputCannonGame(ctx context.Context, l2Node string
system
:
h
.
system
,
system
:
h
.
system
,
},
},
}
}
}
func
(
h
*
FactoryHelper
)
StartOutputAlphabetGame
(
ctx
context
.
Context
,
l2Node
string
,
claimedAlphabet
string
)
*
OutputAlphabetGameHelper
{
logger
:=
testlog
.
Logger
(
h
.
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"OutputAlphabetGameHelper"
)
rollupClient
:=
h
.
system
.
RollupClient
(
l2Node
)
extraData
,
_
:=
h
.
createBisectionGameExtraData
(
ctx
,
rollupClient
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
1
*
time
.
Minute
)
defer
cancel
()
trace
:=
alphabet
.
NewTraceProvider
(
claimedAlphabet
,
alphabetGameDepth
)
pos
:=
faultTypes
.
NewPosition
(
alphabetGameDepth
,
lastAlphabetTraceIndex
)
rootClaim
,
err
:=
trace
.
Get
(
ctx
,
pos
)
h
.
require
.
NoError
(
err
,
"get root claim"
)
tx
,
err
:=
transactions
.
PadGasEstimate
(
h
.
opts
,
2
,
func
(
opts
*
bind
.
TransactOpts
)
(
*
types
.
Transaction
,
error
)
{
return
h
.
factory
.
Create
(
opts
,
outputAlphabetGameType
,
rootClaim
,
extraData
)
})
h
.
require
.
NoError
(
err
,
"create output bisection game"
)
rcpt
,
err
:=
wait
.
ForReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
h
.
require
.
NoError
(
err
,
"wait for create output bisection game receipt to be OK"
)
h
.
require
.
Len
(
rcpt
.
Logs
,
1
,
"should have emitted a single DisputeGameCreated event"
)
createdEvent
,
err
:=
h
.
factory
.
ParseDisputeGameCreated
(
*
rcpt
.
Logs
[
0
])
h
.
require
.
NoError
(
err
)
game
,
err
:=
bindings
.
NewOutputBisectionGame
(
createdEvent
.
DisputeProxy
,
h
.
client
)
h
.
require
.
NoError
(
err
)
prestateBlock
,
err
:=
game
.
GENESISBLOCKNUMBER
(
&
bind
.
CallOpts
{
Context
:
ctx
})
h
.
require
.
NoError
(
err
,
"Failed to load genesis block number"
)
poststateBlock
,
err
:=
game
.
L2BlockNumber
(
&
bind
.
CallOpts
{
Context
:
ctx
})
h
.
require
.
NoError
(
err
,
"Failed to load l2 block number"
)
splitDepth
,
err
:=
game
.
SPLITDEPTH
(
&
bind
.
CallOpts
{
Context
:
ctx
})
h
.
require
.
NoError
(
err
,
"Failed to load split depth"
)
provider
:=
outputs
.
NewTraceProviderFromInputs
(
logger
,
rollupClient
,
splitDepth
.
Uint64
(),
prestateBlock
.
Uint64
(),
poststateBlock
.
Uint64
())
return
&
OutputAlphabetGameHelper
{
OutputGameHelper
:
OutputGameHelper
{
t
:
h
.
t
,
require
:
h
.
require
,
client
:
h
.
client
,
opts
:
h
.
opts
,
game
:
game
,
factoryAddr
:
h
.
factoryAddr
,
addr
:
createdEvent
.
DisputeProxy
,
correctOutputProvider
:
provider
,
system
:
h
.
system
,
},
claimedAlphabet
:
claimedAlphabet
,
}
}
}
func
(
h
*
FactoryHelper
)
StartCannonGame
(
ctx
context
.
Context
,
rootClaim
common
.
Hash
)
*
CannonGameHelper
{
func
(
h
*
FactoryHelper
)
StartCannonGame
(
ctx
context
.
Context
,
rootClaim
common
.
Hash
)
*
CannonGameHelper
{
...
...
op-e2e/e2eutils/disputegame/output_alphabet_helper.go
0 → 100644
View file @
98d5d768
package
disputegame
import
(
"context"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
)
type
OutputAlphabetGameHelper
struct
{
OutputGameHelper
claimedAlphabet
string
}
func
(
g
*
OutputAlphabetGameHelper
)
StartChallenger
(
ctx
context
.
Context
,
l2Node
string
,
name
string
,
options
...
challenger
.
Option
,
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
challenger
.
WithOutputAlphabet
(
g
.
claimedAlphabet
,
g
.
system
.
RollupEndpoint
(
l2Node
)),
challenger
.
WithFactoryAddress
(
g
.
factoryAddr
),
challenger
.
WithGameAddress
(
g
.
addr
),
}
opts
=
append
(
opts
,
options
...
)
c
:=
challenger
.
NewChallenger
(
g
.
t
,
ctx
,
g
.
system
.
NodeEndpoint
(
"l1"
),
name
,
opts
...
)
g
.
t
.
Cleanup
(
func
()
{
_
=
c
.
Close
()
})
return
c
}
op-e2e/faultproofs/output_alphabet_test.go
0 → 100644
View file @
98d5d768
package
faultproofs
import
(
"context"
"testing"
op_e2e
"github.com/ethereum-optimism/optimism/op-e2e"
"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"
"github.com/stretchr/testify/require"
)
func
TestOutputAlphabetGame
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UseExecutor
(
1
))
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
)
game
:=
disputeGameFactory
.
StartOutputAlphabetGame
(
ctx
,
"sequencer"
,
"abcdexyz"
)
game
.
LogGameData
(
ctx
)
opts
:=
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Alice
)
game
.
StartChallenger
(
ctx
,
"sequencer"
,
"Challenger"
,
opts
)
game
.
LogGameData
(
ctx
)
// Challenger should post an output root to counter claims down to the leaf level of the top game
splitDepth
:=
game
.
SplitDepth
(
ctx
)
for
i
:=
int64
(
1
);
i
<
splitDepth
;
i
+=
2
{
game
.
WaitForCorrectOutputRoot
(
ctx
,
i
)
game
.
Attack
(
ctx
,
i
,
common
.
Hash
{
0xaa
})
game
.
LogGameData
(
ctx
)
}
// Wait for the challenger to post the first claim in the alphabet trace
game
.
WaitForClaimAtDepth
(
ctx
,
int
(
splitDepth
+
1
))
game
.
LogGameData
(
ctx
)
game
.
Attack
(
ctx
,
splitDepth
+
1
,
common
.
Hash
{
0x00
,
0xcc
})
gameDepth
:=
game
.
MaxDepth
(
ctx
)
for
i
:=
splitDepth
+
3
;
i
<
gameDepth
;
i
+=
2
{
// Wait for challenger to respond
game
.
WaitForClaimAtDepth
(
ctx
,
int
(
i
))
game
.
LogGameData
(
ctx
)
// Respond to push the game down to the max depth
game
.
Defend
(
ctx
,
i
,
common
.
Hash
{
0x00
,
0xdd
})
game
.
LogGameData
(
ctx
)
}
game
.
LogGameData
(
ctx
)
// Challenger should be able to call step and counter the leaf claim.
game
.
WaitForClaimAtMaxDepth
(
ctx
,
true
)
game
.
LogGameData
(
ctx
)
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
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