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
1744978c
Unverified
Commit
1744978c
authored
Jul 24, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests
parent
715e630b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
16 deletions
+48
-16
engine_backend_test.go
op-program/client/l2/engine_backend_test.go
+9
-2
stub_oracle.go
op-program/client/l2/test/stub_oracle.go
+12
-5
main_test.go
op-program/host/cmd/main_test.go
+22
-7
config.go
op-program/host/config/config.go
+5
-2
No files found.
op-program/client/l2/engine_backend_test.go
View file @
1744978c
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi"
"github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi"
"github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi/test"
"github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi/test"
...
@@ -199,7 +200,8 @@ func setupOracleBackedChainWithLowerHead(t *testing.T, blockCount int, headBlock
...
@@ -199,7 +200,8 @@ func setupOracleBackedChainWithLowerHead(t *testing.T, blockCount int, headBlock
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
chainCfg
,
blocks
,
oracle
:=
setupOracle
(
t
,
blockCount
,
headBlockNumber
)
chainCfg
,
blocks
,
oracle
:=
setupOracle
(
t
,
blockCount
,
headBlockNumber
)
head
:=
blocks
[
headBlockNumber
]
.
Hash
()
head
:=
blocks
[
headBlockNumber
]
.
Hash
()
chain
,
err
:=
NewOracleBackedL2Chain
(
logger
,
oracle
,
chainCfg
,
head
)
stubOutput
:=
eth
.
OutputV0
{
BlockHash
:
head
}
chain
,
err
:=
NewOracleBackedL2Chain
(
logger
,
oracle
,
chainCfg
,
common
.
Hash
(
eth
.
OutputRoot
(
&
stubOutput
)))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
return
blocks
,
chain
return
blocks
,
chain
}
}
...
@@ -232,7 +234,12 @@ func setupOracle(t *testing.T, blockCount int, headBlockNumber int) (*params.Cha
...
@@ -232,7 +234,12 @@ func setupOracle(t *testing.T, blockCount int, headBlockNumber int) (*params.Cha
genesisBlock
:=
l2Genesis
.
MustCommit
(
db
)
genesisBlock
:=
l2Genesis
.
MustCommit
(
db
)
blocks
,
_
:=
core
.
GenerateChain
(
chainCfg
,
genesisBlock
,
consensus
,
db
,
blockCount
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{})
blocks
,
_
:=
core
.
GenerateChain
(
chainCfg
,
genesisBlock
,
consensus
,
db
,
blockCount
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{})
blocks
=
append
([]
*
types
.
Block
{
genesisBlock
},
blocks
...
)
blocks
=
append
([]
*
types
.
Block
{
genesisBlock
},
blocks
...
)
oracle
:=
l2test
.
NewStubOracleWithBlocks
(
t
,
blocks
[
:
headBlockNumber
+
1
],
db
)
var
outputs
[]
eth
.
Output
for
_
,
block
:=
range
blocks
{
outputs
=
append
(
outputs
,
&
eth
.
OutputV0
{
BlockHash
:
block
.
Hash
()})
}
oracle
:=
l2test
.
NewStubOracleWithBlocks
(
t
,
blocks
[
:
headBlockNumber
+
1
],
outputs
,
db
)
return
chainCfg
,
blocks
,
oracle
return
chainCfg
,
blocks
,
oracle
}
}
...
...
op-program/client/l2/test/stub_oracle.go
View file @
1744978c
...
@@ -17,9 +17,9 @@ type stateOracle interface {
...
@@ -17,9 +17,9 @@ type stateOracle interface {
}
}
type
StubBlockOracle
struct
{
type
StubBlockOracle
struct
{
t
*
testing
.
T
t
*
testing
.
T
Blocks
map
[
common
.
Hash
]
*
types
.
Block
Blocks
map
[
common
.
Hash
]
*
types
.
Block
L2
Outputs
map
[
common
.
Hash
]
eth
.
Output
Outputs
map
[
common
.
Hash
]
eth
.
Output
stateOracle
stateOracle
}
}
...
@@ -28,18 +28,25 @@ func NewStubOracle(t *testing.T) (*StubBlockOracle, *StubStateOracle) {
...
@@ -28,18 +28,25 @@ func NewStubOracle(t *testing.T) (*StubBlockOracle, *StubStateOracle) {
blockOracle
:=
StubBlockOracle
{
blockOracle
:=
StubBlockOracle
{
t
:
t
,
t
:
t
,
Blocks
:
make
(
map
[
common
.
Hash
]
*
types
.
Block
),
Blocks
:
make
(
map
[
common
.
Hash
]
*
types
.
Block
),
Outputs
:
make
(
map
[
common
.
Hash
]
eth
.
Output
),
stateOracle
:
stateOracle
,
stateOracle
:
stateOracle
,
}
}
return
&
blockOracle
,
stateOracle
return
&
blockOracle
,
stateOracle
}
}
func
NewStubOracleWithBlocks
(
t
*
testing
.
T
,
chain
[]
*
types
.
Block
,
db
ethdb
.
Database
)
*
StubBlockOracle
{
func
NewStubOracleWithBlocks
(
t
*
testing
.
T
,
chain
[]
*
types
.
Block
,
outputs
[]
eth
.
Output
,
db
ethdb
.
Database
)
*
StubBlockOracle
{
blocks
:=
make
(
map
[
common
.
Hash
]
*
types
.
Block
,
len
(
chain
))
blocks
:=
make
(
map
[
common
.
Hash
]
*
types
.
Block
,
len
(
chain
))
for
_
,
block
:=
range
chain
{
for
_
,
block
:=
range
chain
{
blocks
[
block
.
Hash
()]
=
block
blocks
[
block
.
Hash
()]
=
block
}
}
o
:=
make
(
map
[
common
.
Hash
]
eth
.
Output
,
len
(
outputs
))
for
_
,
output
:=
range
outputs
{
o
[
common
.
Hash
(
eth
.
OutputRoot
(
output
))]
=
output
}
return
&
StubBlockOracle
{
return
&
StubBlockOracle
{
t
:
t
,
Blocks
:
blocks
,
Blocks
:
blocks
,
Outputs
:
o
,
stateOracle
:
&
KvStateOracle
{
t
:
t
,
Source
:
db
},
stateOracle
:
&
KvStateOracle
{
t
:
t
,
Source
:
db
},
}
}
}
}
...
@@ -53,7 +60,7 @@ func (o StubBlockOracle) BlockByHash(blockHash common.Hash) *types.Block {
...
@@ -53,7 +60,7 @@ func (o StubBlockOracle) BlockByHash(blockHash common.Hash) *types.Block {
}
}
func
(
o
StubBlockOracle
)
L2OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
func
(
o
StubBlockOracle
)
L2OutputByRoot
(
root
common
.
Hash
)
eth
.
Output
{
output
,
ok
:=
o
.
L2
Outputs
[
root
]
output
,
ok
:=
o
.
Outputs
[
root
]
if
!
ok
{
if
!
ok
{
o
.
t
.
Fatalf
(
"requested unknown output root %s"
,
root
)
o
.
t
.
Fatalf
(
"requested unknown output root %s"
,
root
)
}
}
...
...
op-program/host/cmd/main_test.go
View file @
1744978c
...
@@ -23,9 +23,8 @@ var (
...
@@ -23,9 +23,8 @@ var (
l2OutputRoot
=
common
.
HexToHash
(
"0x444444"
)
.
Hex
()
l2OutputRoot
=
common
.
HexToHash
(
"0x444444"
)
.
Hex
()
l2ClaimBlockNumber
=
uint64
(
1203
)
l2ClaimBlockNumber
=
uint64
(
1203
)
// Note: This is actually the L1 goerli genesis config. Just using it as an arbitrary, valid genesis config
// Note: This is actually the L1 goerli genesis config. Just using it as an arbitrary, valid genesis config
l2Genesis
=
core
.
DefaultGoerliGenesisBlock
()
l2Genesis
=
core
.
DefaultGoerliGenesisBlock
()
l2GenesisConfig
=
l2Genesis
.
Config
l2GenesisConfig
=
l2Genesis
.
Config
l2OutputOracleAddress
=
common
.
HexToAddress
(
"0x1234567890123456789012345678901234567890"
)
.
Hex
()
)
)
func
TestLogLevel
(
t
*
testing
.
T
)
{
func
TestLogLevel
(
t
*
testing
.
T
)
{
...
@@ -124,14 +123,14 @@ func TestL2Genesis(t *testing.T) {
...
@@ -124,14 +123,14 @@ func TestL2Genesis(t *testing.T) {
})
})
}
}
func
TestL2
OutputRoot
(
t
*
testing
.
T
)
{
func
TestL2
Head
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag l2.
outputroot
is required"
,
addRequiredArgsExcept
(
"--l2.head"
))
verifyArgsInvalid
(
t
,
"flag l2.
head
is required"
,
addRequiredArgsExcept
(
"--l2.head"
))
})
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--l2.
outputroot
"
,
l2HeadValue
))
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--l2.
head
"
,
l2HeadValue
))
require
.
Equal
(
t
,
common
.
HexToHash
(
l2HeadValue
),
cfg
.
L2
OutputRoot
)
require
.
Equal
(
t
,
common
.
HexToHash
(
l2HeadValue
),
cfg
.
L2
Head
)
})
})
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
...
@@ -139,6 +138,21 @@ func TestL2OutputRoot(t *testing.T) {
...
@@ -139,6 +138,21 @@ func TestL2OutputRoot(t *testing.T) {
})
})
}
}
func
TestL2OutputRoot
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag l2.outputroot is required"
,
addRequiredArgsExcept
(
"--l2.outputroot"
))
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--l2.outputroot"
,
l2OutputRoot
))
require
.
Equal
(
t
,
common
.
HexToHash
(
l2OutputRoot
),
cfg
.
L2OutputRoot
)
})
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
config
.
ErrInvalidL2OutputRoot
.
Error
(),
replaceRequiredArg
(
"--l2.outputroot"
,
"something"
))
})
}
func
TestL1Head
(
t
*
testing
.
T
)
{
func
TestL1Head
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag l1.head is required"
,
addRequiredArgsExcept
(
"--l1.head"
))
verifyArgsInvalid
(
t
,
"flag l1.head is required"
,
addRequiredArgsExcept
(
"--l1.head"
))
...
@@ -310,6 +324,7 @@ func requiredArgs() map[string]string {
...
@@ -310,6 +324,7 @@ func requiredArgs() map[string]string {
"--network"
:
"goerli"
,
"--network"
:
"goerli"
,
"--l1.head"
:
l1HeadValue
,
"--l1.head"
:
l1HeadValue
,
"--l2.head"
:
l2HeadValue
,
"--l2.head"
:
l2HeadValue
,
"--l2.outputroot"
:
l2OutputRoot
,
"--l2.claim"
:
l2ClaimValue
,
"--l2.claim"
:
l2ClaimValue
,
"--l2.blocknumber"
:
strconv
.
FormatUint
(
l2ClaimBlockNumber
,
10
),
"--l2.blocknumber"
:
strconv
.
FormatUint
(
l2ClaimBlockNumber
,
10
),
}
}
...
...
op-program/host/config/config.go
View file @
1744978c
...
@@ -43,7 +43,7 @@ type Config struct {
...
@@ -43,7 +43,7 @@ type Config struct {
L1RPCKind
sources
.
RPCProviderKind
L1RPCKind
sources
.
RPCProviderKind
// L2Head is the l2 block hash contained in the L2 Output referenced by the L2OutputRoot
// L2Head is the l2 block hash contained in the L2 Output referenced by the L2OutputRoot
// TODO(inphi): This can be made optional with hardcoded rollup configs and output oracle addresses
// TODO(inphi): This can be made optional with hardcoded rollup configs and output oracle addresses
by searching the oracle for the l2 output root
L2Head
common
.
Hash
L2Head
common
.
Hash
// L2OutputRoot is the agreed L2 output root to start derivation from
// L2OutputRoot is the agreed L2 output root to start derivation from
L2OutputRoot
common
.
Hash
L2OutputRoot
common
.
Hash
...
@@ -74,6 +74,9 @@ func (c *Config) Check() error {
...
@@ -74,6 +74,9 @@ func (c *Config) Check() error {
if
c
.
L1Head
==
(
common
.
Hash
{})
{
if
c
.
L1Head
==
(
common
.
Hash
{})
{
return
ErrInvalidL1Head
return
ErrInvalidL1Head
}
}
if
c
.
L2Head
==
(
common
.
Hash
{})
{
return
ErrInvalidL2Head
}
if
c
.
L2OutputRoot
==
(
common
.
Hash
{})
{
if
c
.
L2OutputRoot
==
(
common
.
Hash
{})
{
return
ErrInvalidL2OutputRoot
return
ErrInvalidL2OutputRoot
}
}
...
@@ -136,7 +139,7 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
...
@@ -136,7 +139,7 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
if
l2Head
==
(
common
.
Hash
{})
{
if
l2Head
==
(
common
.
Hash
{})
{
return
nil
,
ErrInvalidL2Head
return
nil
,
ErrInvalidL2Head
}
}
l2OutputRoot
:=
common
.
HexToHash
(
ctx
.
String
(
flags
.
L2
Head
.
Name
))
l2OutputRoot
:=
common
.
HexToHash
(
ctx
.
String
(
flags
.
L2
OutputRoot
.
Name
))
if
l2OutputRoot
==
(
common
.
Hash
{})
{
if
l2OutputRoot
==
(
common
.
Hash
{})
{
return
nil
,
ErrInvalidL2OutputRoot
return
nil
,
ErrInvalidL2OutputRoot
}
}
...
...
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