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
5efa3f9b
Unverified
Commit
5efa3f9b
authored
Nov 14, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
e2e: Add e2e tests for output root based claims.
parent
fb3da809
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
18 deletions
+181
-18
helper.go
op-e2e/e2eutils/challenger/helper.go
+41
-18
helper.go
op-e2e/e2eutils/disputegame/helper.go
+41
-0
output_cannon_helper.go
op-e2e/e2eutils/disputegame/output_cannon_helper.go
+67
-0
faultproof_test.go
op-e2e/faultproof_test.go
+32
-0
No files found.
op-e2e/e2eutils/challenger/helper.go
View file @
5efa3f9b
...
@@ -78,8 +78,19 @@ func WithCannon(
...
@@ -78,8 +78,19 @@ func WithCannon(
l2Endpoint
string
,
l2Endpoint
string
,
)
Option
{
)
Option
{
return
func
(
c
*
config
.
Config
)
{
return
func
(
c
*
config
.
Config
)
{
require
:=
require
.
New
(
t
)
c
.
TraceTypes
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeCannon
)
c
.
TraceTypes
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeCannon
)
applyCannonConfig
(
c
,
t
,
rollupCfg
,
l2Genesis
,
l2Endpoint
)
}
}
func
applyCannonConfig
(
c
*
config
.
Config
,
t
*
testing
.
T
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
l2Endpoint
string
,
)
{
require
:=
require
.
New
(
t
)
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"
...
@@ -97,6 +108,18 @@ func WithCannon(
...
@@ -97,6 +108,18 @@ func WithCannon(
rollupFile
:=
filepath
.
Join
(
c
.
Datadir
,
"rollup.json"
)
rollupFile
:=
filepath
.
Join
(
c
.
Datadir
,
"rollup.json"
)
require
.
NoError
(
os
.
WriteFile
(
rollupFile
,
rollupBytes
,
0644
))
require
.
NoError
(
os
.
WriteFile
(
rollupFile
,
rollupBytes
,
0644
))
c
.
CannonRollupConfigPath
=
rollupFile
c
.
CannonRollupConfigPath
=
rollupFile
}
func
WithOutputCannon
(
t
*
testing
.
T
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
rollupEndpoint
string
,
l2Endpoint
string
)
Option
{
return
func
(
c
*
config
.
Config
)
{
c
.
TraceTypes
=
append
(
c
.
TraceTypes
,
config
.
TraceTypeOutputCannon
)
c
.
RollupRpc
=
rollupEndpoint
applyCannonConfig
(
c
,
t
,
rollupCfg
,
l2Genesis
,
l2Endpoint
)
}
}
}
}
...
...
op-e2e/e2eutils/disputegame/helper.go
View file @
5efa3f9b
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/dial"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -33,6 +34,7 @@ import (
...
@@ -33,6 +34,7 @@ import (
const
alphabetGameType
uint8
=
255
const
alphabetGameType
uint8
=
255
const
cannonGameType
uint8
=
0
const
cannonGameType
uint8
=
0
const
outputCannonGameType
uint8
=
0
// TODO(client-pod#43): This should be a unique game type
const
alphabetGameDepth
=
4
const
alphabetGameDepth
=
4
var
lastAlphabetTraceIndex
=
big
.
NewInt
(
1
<<
alphabetGameDepth
-
1
)
var
lastAlphabetTraceIndex
=
big
.
NewInt
(
1
<<
alphabetGameDepth
-
1
)
...
@@ -141,6 +143,45 @@ func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet s
...
@@ -141,6 +143,45 @@ func (h *FactoryHelper) StartAlphabetGame(ctx context.Context, claimedAlphabet s
}
}
}
}
func
(
h
*
FactoryHelper
)
StartOutputCannonGame
(
ctx
context
.
Context
,
rollupEndpoint
string
,
rootClaim
common
.
Hash
)
*
OutputCannonGameHelper
{
l2BlockNumber
:=
h
.
waitForProposals
(
ctx
)
l1Head
:=
h
.
checkpointL1Block
(
ctx
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
1
*
time
.
Minute
)
defer
cancel
()
extraData
:=
make
([]
byte
,
64
)
binary
.
BigEndian
.
PutUint64
(
extraData
[
24
:
],
l2BlockNumber
)
binary
.
BigEndian
.
PutUint64
(
extraData
[
56
:
],
l1Head
.
Uint64
())
tx
,
err
:=
transactions
.
PadGasEstimate
(
h
.
opts
,
2
,
func
(
opts
*
bind
.
TransactOpts
)
(
*
types
.
Transaction
,
error
)
{
return
h
.
factory
.
Create
(
opts
,
outputCannonGameType
,
rootClaim
,
extraData
)
})
h
.
require
.
NoError
(
err
,
"create fault dispute game"
)
rcpt
,
err
:=
wait
.
ForReceiptOK
(
ctx
,
h
.
client
,
tx
.
Hash
())
h
.
require
.
NoError
(
err
,
"wait for create fault dispute 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
.
NewFaultDisputeGame
(
createdEvent
.
DisputeProxy
,
h
.
client
)
h
.
require
.
NoError
(
err
)
rollupClient
,
err
:=
dial
.
DialRollupClientWithTimeout
(
ctx
,
30
*
time
.
Second
,
testlog
.
Logger
(
h
.
t
,
log
.
LvlInfo
),
rollupEndpoint
)
return
&
OutputCannonGameHelper
{
FaultGameHelper
:
FaultGameHelper
{
t
:
h
.
t
,
require
:
h
.
require
,
client
:
h
.
client
,
opts
:
h
.
opts
,
game
:
game
,
factoryAddr
:
h
.
factoryAddr
,
addr
:
createdEvent
.
DisputeProxy
,
},
rollupClient
:
rollupClient
,
}
}
func
(
h
*
FactoryHelper
)
StartCannonGame
(
ctx
context
.
Context
,
rootClaim
common
.
Hash
)
*
CannonGameHelper
{
func
(
h
*
FactoryHelper
)
StartCannonGame
(
ctx
context
.
Context
,
rootClaim
common
.
Hash
)
*
CannonGameHelper
{
l2BlockNumber
,
l1Head
:=
h
.
prepareCannonGame
(
ctx
)
l2BlockNumber
,
l1Head
:=
h
.
prepareCannonGame
(
ctx
)
return
h
.
createCannonGame
(
ctx
,
l2BlockNumber
,
l1Head
,
rootClaim
)
return
h
.
createCannonGame
(
ctx
,
l2BlockNumber
,
l1Head
,
rootClaim
)
...
...
op-e2e/e2eutils/disputegame/output_cannon_helper.go
0 → 100644
View file @
5efa3f9b
package
disputegame
import
(
"context"
"math/big"
"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-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core"
)
type
OutputCannonGameHelper
struct
{
FaultGameHelper
rollupClient
*
sources
.
RollupClient
}
func
(
g
*
OutputCannonGameHelper
)
StartChallenger
(
ctx
context
.
Context
,
rollupCfg
*
rollup
.
Config
,
l2Genesis
*
core
.
Genesis
,
rollupEndpoint
string
,
l1Endpoint
string
,
l2Endpoint
string
,
name
string
,
options
...
challenger
.
Option
,
)
*
challenger
.
Helper
{
opts
:=
[]
challenger
.
Option
{
challenger
.
WithOutputCannon
(
g
.
t
,
rollupCfg
,
l2Genesis
,
rollupEndpoint
,
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
()
{
_
=
c
.
Close
()
})
return
c
}
func
(
g
*
OutputCannonGameHelper
)
WaitForCorrectOutputRoot
(
ctx
context
.
Context
,
claimIdx
int64
)
{
g
.
WaitForClaimCount
(
ctx
,
claimIdx
+
1
)
claim
:=
g
.
getClaim
(
ctx
,
claimIdx
)
err
,
blockNum
:=
g
.
blockNumForClaim
(
ctx
,
claim
)
output
,
err
:=
g
.
rollupClient
.
OutputAtBlock
(
ctx
,
blockNum
)
g
.
require
.
NoErrorf
(
err
,
"Failed to get output at block %v"
,
blockNum
)
g
.
require
.
EqualValuesf
(
output
.
OutputRoot
,
claim
.
Claim
,
"Incorrect output root at claim %v. Expected to be from block %v"
,
claimIdx
,
blockNum
)
}
func
(
g
*
OutputCannonGameHelper
)
blockNumForClaim
(
ctx
context
.
Context
,
claim
ContractClaim
)
(
error
,
uint64
)
{
proposals
,
err
:=
g
.
game
.
Proposals
(
&
bind
.
CallOpts
{
Context
:
ctx
})
g
.
require
.
NoError
(
err
,
"failed to retrieve proposals"
)
prestateBlockNum
:=
proposals
.
Starting
.
L2BlockNumber
disputedBlockNum
:=
proposals
.
Disputed
.
L2BlockNumber
gameDepth
:=
g
.
MaxDepth
(
ctx
)
// TODO(client-pod#43): Load this from the contract
topDepth
:=
gameDepth
/
2
traceIdx
:=
types
.
NewPositionFromGIndex
(
claim
.
Position
)
.
TraceIndex
(
int
(
topDepth
))
blockNum
:=
new
(
big
.
Int
)
.
Add
(
prestateBlockNum
,
traceIdx
)
.
Uint64
()
+
1
if
blockNum
>
disputedBlockNum
.
Uint64
()
{
blockNum
=
disputedBlockNum
.
Uint64
()
}
return
err
,
blockNum
}
op-e2e/faultproof_test.go
View file @
5efa3f9b
...
@@ -592,6 +592,38 @@ func TestCannonChallengeWithCorrectRoot(t *testing.T) {
...
@@ -592,6 +592,38 @@ func TestCannonChallengeWithCorrectRoot(t *testing.T) {
require
.
EqualValues
(
t
,
disputegame
.
StatusChallengerWins
,
game
.
Status
(
ctx
))
require
.
EqualValues
(
t
,
disputegame
.
StatusChallengerWins
,
game
.
Status
(
ctx
))
}
}
func
TestOutputCannonGame
(
t
*
testing
.
T
)
{
InitParallel
(
t
,
UsesCannon
,
UseExecutor
(
0
))
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
rollupEndpoint
:=
sys
.
RollupNodes
[
"sequencer"
]
.
HTTPEndpoint
()
l1Endpoint
:=
sys
.
NodeEndpoint
(
"l1"
)
l2Endpoint
:=
sys
.
NodeEndpoint
(
"sequencer"
)
require
.
NotEqual
(
t
,
rollupEndpoint
,
l2Endpoint
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
.
cfg
.
L1Deployments
,
l1Client
)
game
:=
disputeGameFactory
.
StartOutputCannonGame
(
ctx
,
rollupEndpoint
,
common
.
Hash
{
0x01
})
game
.
LogGameData
(
ctx
)
game
.
StartChallenger
(
ctx
,
sys
.
RollupConfig
,
sys
.
L2GenesisCfg
,
rollupEndpoint
,
l1Endpoint
,
l2Endpoint
,
"Challenger"
,
// Agree with the proposed output, so disagree with the root claim
challenger
.
WithAgreeProposedOutput
(
true
),
challenger
.
WithPrivKey
(
sys
.
cfg
.
Secrets
.
Alice
),
)
game
.
LogGameData
(
ctx
)
maxDepth
:=
game
.
MaxDepth
(
ctx
)
// Challenger should post an output root to counter claims down to the leaf level of the top game
// TODO(client-pod#43): Load the depth of the top game from the contract instead of deriving it
for
i
:=
int64
(
1
);
i
<=
maxDepth
/
2
+
1
;
i
+=
2
{
game
.
WaitForCorrectOutputRoot
(
ctx
,
i
)
game
.
Attack
(
ctx
,
i
,
common
.
Hash
{
0xaa
})
game
.
LogGameData
(
ctx
)
}
}
func
startFaultDisputeSystem
(
t
*
testing
.
T
)
(
*
System
,
*
ethclient
.
Client
)
{
func
startFaultDisputeSystem
(
t
*
testing
.
T
)
(
*
System
,
*
ethclient
.
Client
)
{
cfg
:=
DefaultSystemConfig
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
delete
(
cfg
.
Nodes
,
"verifier"
)
delete
(
cfg
.
Nodes
,
"verifier"
)
...
...
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