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
a9dcc0b1
Unverified
Commit
a9dcc0b1
authored
Aug 03, 2023
by
OptimismBot
Committed by
GitHub
Aug 03, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6452 from ethereum-optimism/inphi/op-program-chain-id
op-program: Add L2 Chain ID to client boot
parents
20f11766
9e7ec4dd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
20 deletions
+119
-20
chaincfg.go
op-program/chainconfig/chaincfg.go
+26
-1
boot.go
op-program/client/boot.go
+38
-11
boot_test.go
op-program/client/boot_test.go
+43
-4
main_test.go
op-program/host/cmd/main_test.go
+3
-2
config.go
op-program/host/config/config.go
+2
-1
host_test.go
op-program/host/host_test.go
+2
-1
local.go
op-program/host/kvstore/local.go
+3
-0
local_test.go
op-program/host/kvstore/local_test.go
+2
-0
No files found.
op-program/
host/
config/chaincfg.go
→
op-program/
chain
config/chaincfg.go
View file @
a9dcc0b1
package
config
package
c
hainc
onfig
import
(
import
(
"fmt"
"math/big"
"math/big"
"strconv"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -97,3 +101,24 @@ var L2ChainConfigsByName = map[string]*params.ChainConfig{
...
@@ -97,3 +101,24 @@ var L2ChainConfigsByName = map[string]*params.ChainConfig{
"sepolia"
:
OPSepoliaChainConfig
,
"sepolia"
:
OPSepoliaChainConfig
,
"mainnet"
:
OPMainnetChainConfig
,
"mainnet"
:
OPMainnetChainConfig
,
}
}
func
RollupConfigByChainID
(
chainID
uint64
)
(
*
rollup
.
Config
,
error
)
{
network
:=
chaincfg
.
L2ChainIDToNetworkName
[
strconv
.
FormatUint
(
chainID
,
10
)]
if
network
==
""
{
return
nil
,
fmt
.
Errorf
(
"unknown chain ID: %d"
,
chainID
)
}
config
,
ok
:=
chaincfg
.
NetworksByName
[
network
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unknown network %s for chain ID %d"
,
network
,
chainID
)
}
return
&
config
,
nil
}
func
ChainConfigByChainID
(
chainID
uint64
)
(
*
params
.
ChainConfig
,
error
)
{
network
:=
chaincfg
.
L2ChainIDToNetworkName
[
strconv
.
FormatUint
(
chainID
,
10
)]
chainConfig
,
ok
:=
L2ChainConfigsByName
[
network
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unknown network %s for chain ID %d"
,
network
,
chainID
)
}
return
chainConfig
,
nil
}
op-program/client/boot.go
View file @
a9dcc0b1
...
@@ -3,9 +3,11 @@ package client
...
@@ -3,9 +3,11 @@ package client
import
(
import
(
"encoding/binary"
"encoding/binary"
"encoding/json"
"encoding/json"
"math"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-program/chainconfig"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -15,17 +17,25 @@ const (
...
@@ -15,17 +17,25 @@ const (
L2OutputRootLocalIndex
L2OutputRootLocalIndex
L2ClaimLocalIndex
L2ClaimLocalIndex
L2ClaimBlockNumberLocalIndex
L2ClaimBlockNumberLocalIndex
L2ChainIDLocalIndex
// These local keys are only used for custom chains
L2ChainConfigLocalIndex
L2ChainConfigLocalIndex
RollupConfigLocalIndex
RollupConfigLocalIndex
)
)
// CustomChainIDIndicator is used to detect when the program should load custom chain configuration
const
CustomChainIDIndicator
=
uint64
(
math
.
MaxUint64
)
type
BootInfo
struct
{
type
BootInfo
struct
{
L1Head
common
.
Hash
L1Head
common
.
Hash
L2OutputRoot
common
.
Hash
L2OutputRoot
common
.
Hash
L2Claim
common
.
Hash
L2Claim
common
.
Hash
L2ClaimBlockNumber
uint64
L2ClaimBlockNumber
uint64
L2ChainConfig
*
params
.
ChainConfig
L2ChainID
uint64
RollupConfig
*
rollup
.
Config
L2ChainConfig
*
params
.
ChainConfig
RollupConfig
*
rollup
.
Config
}
}
type
oracleClient
interface
{
type
oracleClient
interface
{
...
@@ -45,15 +55,31 @@ func (br *BootstrapClient) BootInfo() *BootInfo {
...
@@ -45,15 +55,31 @@ func (br *BootstrapClient) BootInfo() *BootInfo {
l2OutputRoot
:=
common
.
BytesToHash
(
br
.
r
.
Get
(
L2OutputRootLocalIndex
))
l2OutputRoot
:=
common
.
BytesToHash
(
br
.
r
.
Get
(
L2OutputRootLocalIndex
))
l2Claim
:=
common
.
BytesToHash
(
br
.
r
.
Get
(
L2ClaimLocalIndex
))
l2Claim
:=
common
.
BytesToHash
(
br
.
r
.
Get
(
L2ClaimLocalIndex
))
l2ClaimBlockNumber
:=
binary
.
BigEndian
.
Uint64
(
br
.
r
.
Get
(
L2ClaimBlockNumberLocalIndex
))
l2ClaimBlockNumber
:=
binary
.
BigEndian
.
Uint64
(
br
.
r
.
Get
(
L2ClaimBlockNumberLocalIndex
))
l2ChainConfig
:=
new
(
params
.
ChainConfig
)
l2ChainID
:=
binary
.
BigEndian
.
Uint64
(
br
.
r
.
Get
(
L2ChainIDLocalIndex
))
err
:=
json
.
Unmarshal
(
br
.
r
.
Get
(
L2ChainConfigLocalIndex
),
&
l2ChainConfig
)
if
err
!=
nil
{
var
l2ChainConfig
*
params
.
ChainConfig
panic
(
"failed to bootstrap l2ChainConfig"
)
var
rollupConfig
*
rollup
.
Config
}
if
l2ChainID
==
CustomChainIDIndicator
{
rollupConfig
:=
new
(
rollup
.
Config
)
l2ChainConfig
=
new
(
params
.
ChainConfig
)
err
=
json
.
Unmarshal
(
br
.
r
.
Get
(
RollupConfigLocalIndex
),
rollupConfig
)
err
:=
json
.
Unmarshal
(
br
.
r
.
Get
(
L2ChainConfigLocalIndex
),
&
l2ChainConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"failed to bootstrap rollup config"
)
panic
(
"failed to bootstrap l2ChainConfig"
)
}
rollupConfig
=
new
(
rollup
.
Config
)
err
=
json
.
Unmarshal
(
br
.
r
.
Get
(
RollupConfigLocalIndex
),
rollupConfig
)
if
err
!=
nil
{
panic
(
"failed to bootstrap rollup config"
)
}
}
else
{
var
err
error
rollupConfig
,
err
=
chainconfig
.
RollupConfigByChainID
(
l2ChainID
)
if
err
!=
nil
{
panic
(
err
)
}
l2ChainConfig
,
err
=
chainconfig
.
ChainConfigByChainID
(
l2ChainID
)
if
err
!=
nil
{
panic
(
err
)
}
}
}
return
&
BootInfo
{
return
&
BootInfo
{
...
@@ -61,6 +87,7 @@ func (br *BootstrapClient) BootInfo() *BootInfo {
...
@@ -61,6 +87,7 @@ func (br *BootstrapClient) BootInfo() *BootInfo {
L2OutputRoot
:
l2OutputRoot
,
L2OutputRoot
:
l2OutputRoot
,
L2Claim
:
l2Claim
,
L2Claim
:
l2Claim
,
L2ClaimBlockNumber
:
l2ClaimBlockNumber
,
L2ClaimBlockNumber
:
l2ClaimBlockNumber
,
L2ChainID
:
l2ChainID
,
L2ChainConfig
:
l2ChainConfig
,
L2ChainConfig
:
l2ChainConfig
,
RollupConfig
:
rollupConfig
,
RollupConfig
:
rollupConfig
,
}
}
...
...
op-program/client/boot_test.go
View file @
a9dcc0b1
...
@@ -3,12 +3,13 @@ package client
...
@@ -3,12 +3,13 @@ package client
import
(
import
(
"encoding/binary"
"encoding/binary"
"encoding/json"
"encoding/json"
"fmt"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-program/chainconfig"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -18,16 +19,46 @@ func TestBootstrapClient(t *testing.T) {
...
@@ -18,16 +19,46 @@ func TestBootstrapClient(t *testing.T) {
L2OutputRoot
:
common
.
HexToHash
(
"0x2222"
),
L2OutputRoot
:
common
.
HexToHash
(
"0x2222"
),
L2Claim
:
common
.
HexToHash
(
"0x3333"
),
L2Claim
:
common
.
HexToHash
(
"0x3333"
),
L2ClaimBlockNumber
:
1
,
L2ClaimBlockNumber
:
1
,
L2ChainConfig
:
params
.
GoerliChainConfig
,
L2ChainID
:
chaincfg
.
Goerli
.
L2ChainID
.
Uint64
(),
L2ChainConfig
:
chainconfig
.
OPGoerliChainConfig
,
RollupConfig
:
&
chaincfg
.
Goerli
,
RollupConfig
:
&
chaincfg
.
Goerli
,
}
}
mockOracle
:=
&
mockBoostrapOracle
{
bootInfo
}
mockOracle
:=
&
mockBoostrapOracle
{
bootInfo
,
false
}
readBootInfo
:=
NewBootstrapClient
(
mockOracle
)
.
BootInfo
()
readBootInfo
:=
NewBootstrapClient
(
mockOracle
)
.
BootInfo
()
require
.
EqualValues
(
t
,
bootInfo
,
readBootInfo
)
require
.
EqualValues
(
t
,
bootInfo
,
readBootInfo
)
}
}
func
TestBootstrapClient_CustomChain
(
t
*
testing
.
T
)
{
bootInfo
:=
&
BootInfo
{
L1Head
:
common
.
HexToHash
(
"0x1111"
),
L2OutputRoot
:
common
.
HexToHash
(
"0x2222"
),
L2Claim
:
common
.
HexToHash
(
"0x3333"
),
L2ClaimBlockNumber
:
1
,
L2ChainID
:
CustomChainIDIndicator
,
L2ChainConfig
:
chainconfig
.
OPGoerliChainConfig
,
RollupConfig
:
&
chaincfg
.
Goerli
,
}
mockOracle
:=
&
mockBoostrapOracle
{
bootInfo
,
true
}
readBootInfo
:=
NewBootstrapClient
(
mockOracle
)
.
BootInfo
()
require
.
EqualValues
(
t
,
bootInfo
,
readBootInfo
)
}
func
TestBootstrapClient_UnknownChainPanics
(
t
*
testing
.
T
)
{
bootInfo
:=
&
BootInfo
{
L1Head
:
common
.
HexToHash
(
"0x1111"
),
L2OutputRoot
:
common
.
HexToHash
(
"0x2222"
),
L2Claim
:
common
.
HexToHash
(
"0x3333"
),
L2ClaimBlockNumber
:
1
,
L2ChainID
:
uint64
(
0xdead
),
}
mockOracle
:=
&
mockBoostrapOracle
{
bootInfo
,
false
}
client
:=
NewBootstrapClient
(
mockOracle
)
require
.
Panics
(
t
,
func
()
{
client
.
BootInfo
()
})
}
type
mockBoostrapOracle
struct
{
type
mockBoostrapOracle
struct
{
b
*
BootInfo
b
*
BootInfo
custom
bool
}
}
func
(
o
*
mockBoostrapOracle
)
Get
(
key
preimage
.
Key
)
[]
byte
{
func
(
o
*
mockBoostrapOracle
)
Get
(
key
preimage
.
Key
)
[]
byte
{
...
@@ -40,10 +71,18 @@ func (o *mockBoostrapOracle) Get(key preimage.Key) []byte {
...
@@ -40,10 +71,18 @@ func (o *mockBoostrapOracle) Get(key preimage.Key) []byte {
return
o
.
b
.
L2Claim
[
:
]
return
o
.
b
.
L2Claim
[
:
]
case
L2ClaimBlockNumberLocalIndex
.
PreimageKey
()
:
case
L2ClaimBlockNumberLocalIndex
.
PreimageKey
()
:
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
o
.
b
.
L2ClaimBlockNumber
)
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
o
.
b
.
L2ClaimBlockNumber
)
case
L2ChainIDLocalIndex
.
PreimageKey
()
:
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
o
.
b
.
L2ChainID
)
case
L2ChainConfigLocalIndex
.
PreimageKey
()
:
case
L2ChainConfigLocalIndex
.
PreimageKey
()
:
if
!
o
.
custom
{
panic
(
fmt
.
Sprintf
(
"unexpected oracle request for preimage key %x"
,
key
.
PreimageKey
()))
}
b
,
_
:=
json
.
Marshal
(
o
.
b
.
L2ChainConfig
)
b
,
_
:=
json
.
Marshal
(
o
.
b
.
L2ChainConfig
)
return
b
return
b
case
RollupConfigLocalIndex
.
PreimageKey
()
:
case
RollupConfigLocalIndex
.
PreimageKey
()
:
if
!
o
.
custom
{
panic
(
fmt
.
Sprintf
(
"unexpected oracle request for preimage key %x"
,
key
.
PreimageKey
()))
}
b
,
_
:=
json
.
Marshal
(
o
.
b
.
RollupConfig
)
b
,
_
:=
json
.
Marshal
(
o
.
b
.
RollupConfig
)
return
b
return
b
default
:
default
:
...
...
op-program/host/cmd/main_test.go
View file @
a9dcc0b1
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-program/chainconfig"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -46,7 +47,7 @@ func TestDefaultCLIOptionsMatchDefaultConfig(t *testing.T) {
...
@@ -46,7 +47,7 @@ func TestDefaultCLIOptionsMatchDefaultConfig(t *testing.T) {
cfg
:=
configForArgs
(
t
,
addRequiredArgs
())
cfg
:=
configForArgs
(
t
,
addRequiredArgs
())
defaultCfg
:=
config
.
NewConfig
(
defaultCfg
:=
config
.
NewConfig
(
&
chaincfg
.
Goerli
,
&
chaincfg
.
Goerli
,
config
.
OPGoerliChainConfig
,
c
hainc
onfig
.
OPGoerliChainConfig
,
common
.
HexToHash
(
l1HeadValue
),
common
.
HexToHash
(
l1HeadValue
),
common
.
HexToHash
(
l2HeadValue
),
common
.
HexToHash
(
l2HeadValue
),
common
.
HexToHash
(
l2OutputRoot
),
common
.
HexToHash
(
l2OutputRoot
),
...
@@ -114,7 +115,7 @@ func TestL2Genesis(t *testing.T) {
...
@@ -114,7 +115,7 @@ func TestL2Genesis(t *testing.T) {
t
.
Run
(
"NotRequiredForGoerli"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"NotRequiredForGoerli"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--network"
,
"goerli"
))
cfg
:=
configForArgs
(
t
,
replaceRequiredArg
(
"--network"
,
"goerli"
))
require
.
Equal
(
t
,
config
.
OPGoerliChainConfig
,
cfg
.
L2ChainConfig
)
require
.
Equal
(
t
,
c
hainc
onfig
.
OPGoerliChainConfig
,
cfg
.
L2ChainConfig
)
})
})
}
}
...
...
op-program/host/config/config.go
View file @
a9dcc0b1
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
opnode
"github.com/ethereum-optimism/optimism/op-node"
opnode
"github.com/ethereum-optimism/optimism/op-node"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-program/chainconfig"
"github.com/ethereum-optimism/optimism/op-program/host/flags"
"github.com/ethereum-optimism/optimism/op-program/host/flags"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -156,7 +157,7 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
...
@@ -156,7 +157,7 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
var
l2ChainConfig
*
params
.
ChainConfig
var
l2ChainConfig
*
params
.
ChainConfig
if
l2GenesisPath
==
""
{
if
l2GenesisPath
==
""
{
networkName
:=
ctx
.
String
(
flags
.
Network
.
Name
)
networkName
:=
ctx
.
String
(
flags
.
Network
.
Name
)
l2ChainConfig
=
L2ChainConfigsByName
[
networkName
]
l2ChainConfig
=
chainconfig
.
L2ChainConfigsByName
[
networkName
]
if
l2ChainConfig
==
nil
{
if
l2ChainConfig
==
nil
{
return
nil
,
fmt
.
Errorf
(
"flag %s is required for network %s"
,
flags
.
L2GenesisPath
.
Name
,
networkName
)
return
nil
,
fmt
.
Errorf
(
"flag %s is required for network %s"
,
flags
.
L2GenesisPath
.
Name
,
networkName
)
}
}
...
...
op-program/host/host_test.go
View file @
a9dcc0b1
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-program/chainconfig"
"github.com/ethereum-optimism/optimism/op-program/client"
"github.com/ethereum-optimism/optimism/op-program/client"
"github.com/ethereum-optimism/optimism/op-program/client/l1"
"github.com/ethereum-optimism/optimism/op-program/client/l1"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum-optimism/optimism/op-program/host/config"
...
@@ -24,7 +25,7 @@ func TestServerMode(t *testing.T) {
...
@@ -24,7 +25,7 @@ func TestServerMode(t *testing.T) {
l1Head
:=
common
.
Hash
{
0x11
}
l1Head
:=
common
.
Hash
{
0x11
}
l2OutputRoot
:=
common
.
Hash
{
0x33
}
l2OutputRoot
:=
common
.
Hash
{
0x33
}
cfg
:=
config
.
NewConfig
(
&
chaincfg
.
Goerli
,
config
.
OPGoerliChainConfig
,
l1Head
,
common
.
Hash
{
0x22
},
l2OutputRoot
,
common
.
Hash
{
0x44
},
1000
)
cfg
:=
config
.
NewConfig
(
&
chaincfg
.
Goerli
,
c
hainc
onfig
.
OPGoerliChainConfig
,
l1Head
,
common
.
Hash
{
0x22
},
l2OutputRoot
,
common
.
Hash
{
0x44
},
1000
)
cfg
.
DataDir
=
dir
cfg
.
DataDir
=
dir
cfg
.
ServerMode
=
true
cfg
.
ServerMode
=
true
...
...
op-program/host/kvstore/local.go
View file @
a9dcc0b1
...
@@ -22,6 +22,7 @@ var (
...
@@ -22,6 +22,7 @@ var (
l2OutputRootKey
=
client
.
L2OutputRootLocalIndex
.
PreimageKey
()
l2OutputRootKey
=
client
.
L2OutputRootLocalIndex
.
PreimageKey
()
l2ClaimKey
=
client
.
L2ClaimLocalIndex
.
PreimageKey
()
l2ClaimKey
=
client
.
L2ClaimLocalIndex
.
PreimageKey
()
l2ClaimBlockNumberKey
=
client
.
L2ClaimBlockNumberLocalIndex
.
PreimageKey
()
l2ClaimBlockNumberKey
=
client
.
L2ClaimBlockNumberLocalIndex
.
PreimageKey
()
l2ChainIDKey
=
client
.
L2ChainIDLocalIndex
.
PreimageKey
()
l2ChainConfigKey
=
client
.
L2ChainConfigLocalIndex
.
PreimageKey
()
l2ChainConfigKey
=
client
.
L2ChainConfigLocalIndex
.
PreimageKey
()
rollupKey
=
client
.
RollupConfigLocalIndex
.
PreimageKey
()
rollupKey
=
client
.
RollupConfigLocalIndex
.
PreimageKey
()
)
)
...
@@ -36,6 +37,8 @@ func (s *LocalPreimageSource) Get(key common.Hash) ([]byte, error) {
...
@@ -36,6 +37,8 @@ func (s *LocalPreimageSource) Get(key common.Hash) ([]byte, error) {
return
s
.
config
.
L2Claim
.
Bytes
(),
nil
return
s
.
config
.
L2Claim
.
Bytes
(),
nil
case
l2ClaimBlockNumberKey
:
case
l2ClaimBlockNumberKey
:
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
s
.
config
.
L2ClaimBlockNumber
),
nil
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
s
.
config
.
L2ClaimBlockNumber
),
nil
case
l2ChainIDKey
:
return
binary
.
BigEndian
.
AppendUint64
(
nil
,
client
.
CustomChainIDIndicator
),
nil
case
l2ChainConfigKey
:
case
l2ChainConfigKey
:
return
json
.
Marshal
(
s
.
config
.
L2ChainConfig
)
return
json
.
Marshal
(
s
.
config
.
L2ChainConfig
)
case
rollupKey
:
case
rollupKey
:
...
...
op-program/host/kvstore/local_test.go
View file @
a9dcc0b1
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
"github.com/ethereum-optimism/optimism/op-program/client"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
...
@@ -32,6 +33,7 @@ func TestLocalPreimageSource(t *testing.T) {
...
@@ -32,6 +33,7 @@ func TestLocalPreimageSource(t *testing.T) {
{
"L2OutputRoot"
,
l2OutputRootKey
,
cfg
.
L2OutputRoot
.
Bytes
()},
{
"L2OutputRoot"
,
l2OutputRootKey
,
cfg
.
L2OutputRoot
.
Bytes
()},
{
"L2Claim"
,
l2ClaimKey
,
cfg
.
L2Claim
.
Bytes
()},
{
"L2Claim"
,
l2ClaimKey
,
cfg
.
L2Claim
.
Bytes
()},
{
"L2ClaimBlockNumber"
,
l2ClaimBlockNumberKey
,
binary
.
BigEndian
.
AppendUint64
(
nil
,
cfg
.
L2ClaimBlockNumber
)},
{
"L2ClaimBlockNumber"
,
l2ClaimBlockNumberKey
,
binary
.
BigEndian
.
AppendUint64
(
nil
,
cfg
.
L2ClaimBlockNumber
)},
{
"L2ChainID"
,
l2ChainIDKey
,
binary
.
BigEndian
.
AppendUint64
(
nil
,
client
.
CustomChainIDIndicator
)},
{
"Rollup"
,
rollupKey
,
asJson
(
t
,
cfg
.
Rollup
)},
{
"Rollup"
,
rollupKey
,
asJson
(
t
,
cfg
.
Rollup
)},
{
"ChainConfig"
,
l2ChainConfigKey
,
asJson
(
t
,
cfg
.
L2ChainConfig
)},
{
"ChainConfig"
,
l2ChainConfigKey
,
asJson
(
t
,
cfg
.
L2ChainConfig
)},
{
"Unknown"
,
preimage
.
LocalIndexKey
(
1000
)
.
PreimageKey
(),
nil
},
{
"Unknown"
,
preimage
.
LocalIndexKey
(
1000
)
.
PreimageKey
(),
nil
},
...
...
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