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
fccf2360
Unverified
Commit
fccf2360
authored
Jan 04, 2024
by
Adrian Sutton
Committed by
GitHub
Jan 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-program: Allow l2 claim to be all zeros. (#8814)
parent
53fd3b49
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
9 deletions
+49
-9
output_cannon_test.go
op-e2e/faultproofs/output_cannon_test.go
+29
-0
main_test.go
op-program/host/cmd/main_test.go
+10
-0
config.go
op-program/host/config/config.go
+7
-6
config_test.go
op-program/host/config/config_test.go
+3
-3
No files found.
op-e2e/faultproofs/output_cannon_test.go
View file @
fccf2360
...
...
@@ -70,6 +70,35 @@ func TestOutputCannonGame(t *testing.T) {
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
}
func
TestOutputCannon_ChallengeAllZeroClaim
(
t
*
testing
.
T
)
{
// The dishonest actor always posts claims with all zeros.
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
,
op_e2e
.
UseExecutor
(
outputCannonTestExecutor
))
ctx
:=
context
.
Background
()
sys
,
l1Client
:=
startFaultDisputeSystem
(
t
)
t
.
Cleanup
(
sys
.
Close
)
disputeGameFactory
:=
disputegame
.
NewFactoryHelper
(
t
,
ctx
,
sys
)
game
:=
disputeGameFactory
.
StartOutputCannonGame
(
ctx
,
"sequencer"
,
3
,
common
.
Hash
{})
game
.
LogGameData
(
ctx
)
claim
:=
game
.
DisputeLastBlock
(
ctx
)
game
.
StartChallenger
(
ctx
,
"sequencer"
,
"Challenger"
,
challenger
.
WithPrivKey
(
sys
.
Cfg
.
Secrets
.
Alice
))
game
.
DefendClaim
(
ctx
,
claim
,
func
(
parent
*
disputegame
.
ClaimHelper
)
*
disputegame
.
ClaimHelper
{
if
parent
.
IsBottomGameRoot
(
ctx
)
{
return
parent
.
Attack
(
ctx
,
common
.
Hash
{})
}
return
parent
.
Defend
(
ctx
,
common
.
Hash
{})
})
game
.
LogGameData
(
ctx
)
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
require
.
NoError
(
t
,
wait
.
ForNextBlock
(
ctx
,
l1Client
))
game
.
WaitForGameStatus
(
ctx
,
disputegame
.
StatusChallengerWins
)
game
.
LogGameData
(
ctx
)
}
func
TestOutputCannon_PublishCannonRootClaim
(
t
*
testing
.
T
)
{
op_e2e
.
InitParallel
(
t
,
op_e2e
.
UsesCannon
,
op_e2e
.
UseExecutor
(
outputCannonTestExecutor
))
tests
:=
[]
struct
{
...
...
op-program/host/cmd/main_test.go
View file @
fccf2360
...
...
@@ -239,6 +239,16 @@ func TestL2Claim(t *testing.T) {
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
config
.
ErrInvalidL2Claim
.
Error
(),
replaceRequiredArg
(
"--l2.claim"
,
"something"
))
})
t
.
Run
(
"Allows all zero without prefix"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--l2.claim"
,
"0000000000000000000000000000000000000000000000000000000000000000"
))
require
.
EqualValues
(
t
,
common
.
Hash
{},
cfg
.
L2Claim
)
})
t
.
Run
(
"Allows all zero with prefix"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--l2.claim"
,
"0x0000000000000000000000000000000000000000000000000000000000000000"
))
require
.
EqualValues
(
t
,
common
.
Hash
{},
cfg
.
L2Claim
)
})
}
func
TestL2BlockNumber
(
t
*
testing
.
T
)
{
...
...
op-program/host/config/config.go
View file @
fccf2360
...
...
@@ -85,9 +85,6 @@ func (c *Config) Check() error {
if
c
.
L2OutputRoot
==
(
common
.
Hash
{})
{
return
ErrInvalidL2OutputRoot
}
if
c
.
L2Claim
==
(
common
.
Hash
{})
{
return
ErrInvalidL2Claim
}
if
c
.
L2ClaimBlockNumber
==
0
{
return
ErrInvalidL2ClaimBlock
}
...
...
@@ -151,9 +148,13 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
if
l2OutputRoot
==
(
common
.
Hash
{})
{
return
nil
,
ErrInvalidL2OutputRoot
}
l2Claim
:=
common
.
HexToHash
(
ctx
.
String
(
flags
.
L2Claim
.
Name
))
if
l2Claim
==
(
common
.
Hash
{})
{
return
nil
,
ErrInvalidL2Claim
strClaim
:=
ctx
.
String
(
flags
.
L2Claim
.
Name
)
l2Claim
:=
common
.
HexToHash
(
strClaim
)
// Require a valid hash, with the zero hash explicitly allowed.
if
l2Claim
==
(
common
.
Hash
{})
&&
strClaim
!=
"0x0000000000000000000000000000000000000000000000000000000000000000"
&&
strClaim
!=
"0000000000000000000000000000000000000000000000000000000000000000"
{
return
nil
,
fmt
.
Errorf
(
"%w: %v"
,
ErrInvalidL2Claim
,
strClaim
)
}
l2ClaimBlockNum
:=
ctx
.
Uint64
(
flags
.
L2BlockNumber
.
Name
)
l1Head
:=
common
.
HexToHash
(
ctx
.
String
(
flags
.
L1Head
.
Name
))
...
...
op-program/host/config/config_test.go
View file @
fccf2360
...
...
@@ -65,11 +65,11 @@ func TestL2OutputRootRequired(t *testing.T) {
require
.
ErrorIs
(
t
,
err
,
ErrInvalidL2OutputRoot
)
}
func
TestL2ClaimRequired
(
t
*
testing
.
T
)
{
// The L2 claim may be provided by a dishonest actor so we must treat 0x00...00 as a real value.
func
TestL2ClaimMayBeDefaultValue
(
t
*
testing
.
T
)
{
config
:=
validConfig
()
config
.
L2Claim
=
common
.
Hash
{}
err
:=
config
.
Check
()
require
.
ErrorIs
(
t
,
err
,
ErrInvalidL2Claim
)
require
.
NoError
(
t
,
config
.
Check
())
}
func
TestL2ClaimBlockNumberRequired
(
t
*
testing
.
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