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
9d457f8c
Unverified
Commit
9d457f8c
authored
May 09, 2023
by
mergify[bot]
Committed by
GitHub
May 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/impute/mainnetchains
parents
c3457b39
b11e4338
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
194 additions
and
49 deletions
+194
-49
batch_submitter.go
op-batcher/batcher/batch_submitter.go
+2
-0
flags.go
op-batcher/flags/flags.go
+19
-19
config.go
op-challenger/config/config.go
+3
-0
flags_test.go
op-challenger/flags/flags_test.go
+59
-0
main.go
op-node/cmd/main.go
+2
-0
flags.go
op-node/flags/flags.go
+3
-3
flags.go
op-program/host/flags/flags.go
+16
-16
host.go
op-program/host/host.go
+3
-0
flags.go
op-proposer/flags/flags.go
+11
-11
l2_output_submitter.go
op-proposer/proposer/l2_output_submitter.go
+1
-0
util.go
op-service/util.go
+43
-0
util_test.go
op-service/util_test.go
+32
-0
No files found.
op-batcher/batcher/batch_submitter.go
View file @
9d457f8c
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
opservice
"github.com/ethereum-optimism/optimism/op-service"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
oprpc
"github.com/ethereum-optimism/optimism/op-service/rpc"
oprpc
"github.com/ethereum-optimism/optimism/op-service/rpc"
...
@@ -33,6 +34,7 @@ func Main(version string, cliCtx *cli.Context) error {
...
@@ -33,6 +34,7 @@ func Main(version string, cliCtx *cli.Context) error {
}
}
l
:=
oplog
.
NewLogger
(
cfg
.
LogConfig
)
l
:=
oplog
.
NewLogger
(
cfg
.
LogConfig
)
opservice
.
ValidateEnvVars
(
flags
.
EnvVarPrefix
,
flags
.
Flags
,
l
)
m
:=
metrics
.
NewMetrics
(
"default"
)
m
:=
metrics
.
NewMetrics
(
"default"
)
l
.
Info
(
"Initializing Batch Submitter"
)
l
.
Info
(
"Initializing Batch Submitter"
)
...
...
op-batcher/flags/flags.go
View file @
9d457f8c
...
@@ -15,24 +15,24 @@ import (
...
@@ -15,24 +15,24 @@ import (
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
)
)
const
e
nvVarPrefix
=
"OP_BATCHER"
const
E
nvVarPrefix
=
"OP_BATCHER"
var
(
var
(
// Required flags
// Required flags
L1EthRpcFlag
=
cli
.
StringFlag
{
L1EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l1-eth-rpc"
,
Name
:
"l1-eth-rpc"
,
Usage
:
"HTTP provider URL for L1"
,
Usage
:
"HTTP provider URL for L1"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_ETH_RPC"
),
}
}
L2EthRpcFlag
=
cli
.
StringFlag
{
L2EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l2-eth-rpc"
,
Name
:
"l2-eth-rpc"
,
Usage
:
"HTTP provider URL for L2 execution engine"
,
Usage
:
"HTTP provider URL for L2 execution engine"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_ETH_RPC"
),
}
}
RollupRpcFlag
=
cli
.
StringFlag
{
RollupRpcFlag
=
cli
.
StringFlag
{
Name
:
"rollup-rpc"
,
Name
:
"rollup-rpc"
,
Usage
:
"HTTP provider URL for Rollup node"
,
Usage
:
"HTTP provider URL for Rollup node"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"ROLLUP_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"ROLLUP_RPC"
),
}
}
// Optional flags
// Optional flags
SubSafetyMarginFlag
=
cli
.
Uint64Flag
{
SubSafetyMarginFlag
=
cli
.
Uint64Flag
{
...
@@ -41,54 +41,54 @@ var (
...
@@ -41,54 +41,54 @@ var (
"from a channel's timeout and sequencing window, to guarantee safe inclusion "
+
"from a channel's timeout and sequencing window, to guarantee safe inclusion "
+
"of a channel on L1."
,
"of a channel on L1."
,
Value
:
10
,
Value
:
10
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"SUB_SAFETY_MARGIN"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"SUB_SAFETY_MARGIN"
),
}
}
PollIntervalFlag
=
cli
.
DurationFlag
{
PollIntervalFlag
=
cli
.
DurationFlag
{
Name
:
"poll-interval"
,
Name
:
"poll-interval"
,
Usage
:
"How frequently to poll L2 for new blocks"
,
Usage
:
"How frequently to poll L2 for new blocks"
,
Value
:
6
*
time
.
Second
,
Value
:
6
*
time
.
Second
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"POLL_INTERVAL"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"POLL_INTERVAL"
),
}
}
MaxPendingTransactionsFlag
=
cli
.
Uint64Flag
{
MaxPendingTransactionsFlag
=
cli
.
Uint64Flag
{
Name
:
"max-pending-tx"
,
Name
:
"max-pending-tx"
,
Usage
:
"The maximum number of pending transactions. 0 for no limit."
,
Usage
:
"The maximum number of pending transactions. 0 for no limit."
,
Value
:
1
,
Value
:
1
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"MAX_PENDING_TX"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"MAX_PENDING_TX"
),
}
}
MaxChannelDurationFlag
=
cli
.
Uint64Flag
{
MaxChannelDurationFlag
=
cli
.
Uint64Flag
{
Name
:
"max-channel-duration"
,
Name
:
"max-channel-duration"
,
Usage
:
"The maximum duration of L1-blocks to keep a channel open. 0 to disable."
,
Usage
:
"The maximum duration of L1-blocks to keep a channel open. 0 to disable."
,
Value
:
0
,
Value
:
0
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"MAX_CHANNEL_DURATION"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"MAX_CHANNEL_DURATION"
),
}
}
MaxL1TxSizeBytesFlag
=
cli
.
Uint64Flag
{
MaxL1TxSizeBytesFlag
=
cli
.
Uint64Flag
{
Name
:
"max-l1-tx-size-bytes"
,
Name
:
"max-l1-tx-size-bytes"
,
Usage
:
"The maximum size of a batch tx submitted to L1."
,
Usage
:
"The maximum size of a batch tx submitted to L1."
,
Value
:
120
_000
,
Value
:
120
_000
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"MAX_L1_TX_SIZE_BYTES"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"MAX_L1_TX_SIZE_BYTES"
),
}
}
TargetL1TxSizeBytesFlag
=
cli
.
Uint64Flag
{
TargetL1TxSizeBytesFlag
=
cli
.
Uint64Flag
{
Name
:
"target-l1-tx-size-bytes"
,
Name
:
"target-l1-tx-size-bytes"
,
Usage
:
"The target size of a batch tx submitted to L1."
,
Usage
:
"The target size of a batch tx submitted to L1."
,
Value
:
100
_000
,
Value
:
100
_000
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"TARGET_L1_TX_SIZE_BYTES"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"TARGET_L1_TX_SIZE_BYTES"
),
}
}
TargetNumFramesFlag
=
cli
.
IntFlag
{
TargetNumFramesFlag
=
cli
.
IntFlag
{
Name
:
"target-num-frames"
,
Name
:
"target-num-frames"
,
Usage
:
"The target number of frames to create per channel"
,
Usage
:
"The target number of frames to create per channel"
,
Value
:
1
,
Value
:
1
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"TARGET_NUM_FRAMES"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"TARGET_NUM_FRAMES"
),
}
}
ApproxComprRatioFlag
=
cli
.
Float64Flag
{
ApproxComprRatioFlag
=
cli
.
Float64Flag
{
Name
:
"approx-compr-ratio"
,
Name
:
"approx-compr-ratio"
,
Usage
:
"The approximate compression ratio (<= 1.0)"
,
Usage
:
"The approximate compression ratio (<= 1.0)"
,
Value
:
0.4
,
Value
:
0.4
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"APPROX_COMPR_RATIO"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"APPROX_COMPR_RATIO"
),
}
}
StoppedFlag
=
cli
.
BoolFlag
{
StoppedFlag
=
cli
.
BoolFlag
{
Name
:
"stopped"
,
Name
:
"stopped"
,
Usage
:
"Initialize the batcher in a stopped state. The batcher can be started using the admin_startBatcher RPC"
,
Usage
:
"Initialize the batcher in a stopped state. The batcher can be started using the admin_startBatcher RPC"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"STOPPED"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"STOPPED"
),
}
}
// Legacy Flags
// Legacy Flags
SequencerHDPathFlag
=
txmgr
.
SequencerHDPathFlag
SequencerHDPathFlag
=
txmgr
.
SequencerHDPathFlag
...
@@ -114,12 +114,12 @@ var optionalFlags = []cli.Flag{
...
@@ -114,12 +114,12 @@ var optionalFlags = []cli.Flag{
}
}
func
init
()
{
func
init
()
{
optionalFlags
=
append
(
optionalFlags
,
oprpc
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oprpc
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
rpc
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
rpc
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
txmgr
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
txmgr
.
CLIFlags
(
E
nvVarPrefix
)
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
}
}
...
...
op-challenger/config/config.go
View file @
9d457f8c
...
@@ -137,6 +137,9 @@ func NewConfig(
...
@@ -137,6 +137,9 @@ func NewConfig(
// NewConfigFromCLI parses the Config from the provided flags or environment variables.
// NewConfigFromCLI parses the Config from the provided flags or environment variables.
func
NewConfigFromCLI
(
ctx
*
cli
.
Context
)
(
*
Config
,
error
)
{
func
NewConfigFromCLI
(
ctx
*
cli
.
Context
)
(
*
Config
,
error
)
{
if
err
:=
flags
.
CheckRequired
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
l1EthRpc
:=
ctx
.
GlobalString
(
flags
.
L1EthRpcFlag
.
Name
)
l1EthRpc
:=
ctx
.
GlobalString
(
flags
.
L1EthRpcFlag
.
Name
)
if
l1EthRpc
==
""
{
if
l1EthRpc
==
""
{
return
nil
,
ErrMissingL1EthRPC
return
nil
,
ErrMissingL1EthRPC
...
...
op-challenger/flags/flags_test.go
0 → 100644
View file @
9d457f8c
package
flags
import
(
"reflect"
"strings"
"testing"
"github.com/urfave/cli"
)
// TestUniqueFlags asserts that all flag names are unique, to avoid accidental conflicts between the many flags.
func
TestUniqueFlags
(
t
*
testing
.
T
)
{
seenCLI
:=
make
(
map
[
string
]
struct
{})
for
_
,
flag
:=
range
Flags
{
name
:=
flag
.
GetName
()
if
_
,
ok
:=
seenCLI
[
name
];
ok
{
t
.
Errorf
(
"duplicate flag %s"
,
name
)
continue
}
seenCLI
[
name
]
=
struct
{}{}
}
}
// TestUniqueEnvVars asserts that all flag env vars are unique, to avoid accidental conflicts between the many flags.
func
TestUniqueEnvVars
(
t
*
testing
.
T
)
{
seenCLI
:=
make
(
map
[
string
]
struct
{})
for
_
,
flag
:=
range
Flags
{
envVar
:=
envVarForFlag
(
flag
)
if
_
,
ok
:=
seenCLI
[
envVar
];
envVar
!=
""
&&
ok
{
t
.
Errorf
(
"duplicate flag env var %s"
,
envVar
)
continue
}
seenCLI
[
envVar
]
=
struct
{}{}
}
}
func
TestCorrectEnvVarPrefix
(
t
*
testing
.
T
)
{
for
_
,
flag
:=
range
Flags
{
envVar
:=
envVarForFlag
(
flag
)
if
envVar
==
""
{
t
.
Errorf
(
"Failed to find EnvVar for flag %v"
,
flag
.
GetName
())
}
if
envVar
[
:
len
(
"OP_CHALLENGER_"
)]
!=
"OP_CHALLENGER_"
{
t
.
Errorf
(
"Flag %v env var (%v) does not start with OP_CHALLENGER_"
,
flag
.
GetName
(),
envVar
)
}
if
strings
.
Contains
(
envVar
,
"__"
)
{
t
.
Errorf
(
"Flag %v env var (%v) has duplicate underscores"
,
flag
.
GetName
(),
envVar
)
}
}
}
func
envVarForFlag
(
flag
cli
.
Flag
)
string
{
values
:=
reflect
.
ValueOf
(
flag
)
envVarValue
:=
values
.
FieldByName
(
"EnvVar"
)
if
envVarValue
==
(
reflect
.
Value
{})
{
return
""
}
return
envVarValue
.
String
()
}
op-node/cmd/main.go
View file @
9d457f8c
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-node/version"
"github.com/ethereum-optimism/optimism/op-node/version"
opservice
"github.com/ethereum-optimism/optimism/op-service"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
)
)
...
@@ -88,6 +89,7 @@ func RollupNodeMain(ctx *cli.Context) error {
...
@@ -88,6 +89,7 @@ func RollupNodeMain(ctx *cli.Context) error {
return
err
return
err
}
}
log
:=
oplog
.
NewLogger
(
logCfg
)
log
:=
oplog
.
NewLogger
(
logCfg
)
opservice
.
ValidateEnvVars
(
flags
.
EnvVarPrefix
,
flags
.
Flags
,
log
)
m
:=
metrics
.
NewMetrics
(
"default"
)
m
:=
metrics
.
NewMetrics
(
"default"
)
cfg
,
err
:=
opnode
.
NewConfig
(
ctx
,
log
)
cfg
,
err
:=
opnode
.
NewConfig
(
ctx
,
log
)
...
...
op-node/flags/flags.go
View file @
9d457f8c
...
@@ -14,10 +14,10 @@ import (
...
@@ -14,10 +14,10 @@ import (
// Flags
// Flags
const
e
nvVarPrefix
=
"OP_NODE"
const
E
nvVarPrefix
=
"OP_NODE"
func
prefixEnvVar
(
name
string
)
string
{
func
prefixEnvVar
(
name
string
)
string
{
return
e
nvVarPrefix
+
"_"
+
name
return
E
nvVarPrefix
+
"_"
+
name
}
}
var
(
var
(
...
@@ -251,7 +251,7 @@ var Flags []cli.Flag
...
@@ -251,7 +251,7 @@ var Flags []cli.Flag
func
init
()
{
func
init
()
{
optionalFlags
=
append
(
optionalFlags
,
p2pFlags
...
)
optionalFlags
=
append
(
optionalFlags
,
p2pFlags
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
E
nvVarPrefix
)
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
}
}
...
...
op-program/host/flags/flags.go
View file @
9d457f8c
...
@@ -13,69 +13,69 @@ import (
...
@@ -13,69 +13,69 @@ import (
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
)
)
const
e
nvVarPrefix
=
"OP_PROGRAM"
const
E
nvVarPrefix
=
"OP_PROGRAM"
var
(
var
(
RollupConfig
=
cli
.
StringFlag
{
RollupConfig
=
cli
.
StringFlag
{
Name
:
"rollup.config"
,
Name
:
"rollup.config"
,
Usage
:
"Rollup chain parameters"
,
Usage
:
"Rollup chain parameters"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"ROLLUP_CONFIG"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"ROLLUP_CONFIG"
),
}
}
Network
=
cli
.
StringFlag
{
Network
=
cli
.
StringFlag
{
Name
:
"network"
,
Name
:
"network"
,
Usage
:
fmt
.
Sprintf
(
"Predefined network selection. Available networks: %s"
,
strings
.
Join
(
chaincfg
.
AvailableNetworks
(),
", "
)),
Usage
:
fmt
.
Sprintf
(
"Predefined network selection. Available networks: %s"
,
strings
.
Join
(
chaincfg
.
AvailableNetworks
(),
", "
)),
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"NETWORK"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"NETWORK"
),
}
}
DataDir
=
cli
.
StringFlag
{
DataDir
=
cli
.
StringFlag
{
Name
:
"datadir"
,
Name
:
"datadir"
,
Usage
:
"Directory to use for preimage data storage. Default uses in-memory storage"
,
Usage
:
"Directory to use for preimage data storage. Default uses in-memory storage"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"DATADIR"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"DATADIR"
),
}
}
L2NodeAddr
=
cli
.
StringFlag
{
L2NodeAddr
=
cli
.
StringFlag
{
Name
:
"l2"
,
Name
:
"l2"
,
Usage
:
"Address of L2 JSON-RPC endpoint to use (eth and debug namespace required)"
,
Usage
:
"Address of L2 JSON-RPC endpoint to use (eth and debug namespace required)"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_RPC"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_RPC"
),
}
}
L1Head
=
cli
.
StringFlag
{
L1Head
=
cli
.
StringFlag
{
Name
:
"l1.head"
,
Name
:
"l1.head"
,
Usage
:
"Hash of the L1 head block. Derivation stops after this block is processed."
,
Usage
:
"Hash of the L1 head block. Derivation stops after this block is processed."
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_HEAD"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_HEAD"
),
}
}
L2Head
=
cli
.
StringFlag
{
L2Head
=
cli
.
StringFlag
{
Name
:
"l2.head"
,
Name
:
"l2.head"
,
Usage
:
"Hash of the agreed L2 block to start derivation from"
,
Usage
:
"Hash of the agreed L2 block to start derivation from"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_HEAD"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_HEAD"
),
}
}
L2Claim
=
cli
.
StringFlag
{
L2Claim
=
cli
.
StringFlag
{
Name
:
"l2.claim"
,
Name
:
"l2.claim"
,
Usage
:
"Claimed L2 output root to validate"
,
Usage
:
"Claimed L2 output root to validate"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_CLAIM"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_CLAIM"
),
}
}
L2BlockNumber
=
cli
.
Uint64Flag
{
L2BlockNumber
=
cli
.
Uint64Flag
{
Name
:
"l2.blocknumber"
,
Name
:
"l2.blocknumber"
,
Usage
:
"Number of the L2 block that the claim is from"
,
Usage
:
"Number of the L2 block that the claim is from"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_BLOCK_NUM"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_BLOCK_NUM"
),
}
}
L2GenesisPath
=
cli
.
StringFlag
{
L2GenesisPath
=
cli
.
StringFlag
{
Name
:
"l2.genesis"
,
Name
:
"l2.genesis"
,
Usage
:
"Path to the op-geth genesis file"
,
Usage
:
"Path to the op-geth genesis file"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2_GENESIS"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2_GENESIS"
),
}
}
L1NodeAddr
=
cli
.
StringFlag
{
L1NodeAddr
=
cli
.
StringFlag
{
Name
:
"l1"
,
Name
:
"l1"
,
Usage
:
"Address of L1 JSON-RPC endpoint to use (eth namespace required)"
,
Usage
:
"Address of L1 JSON-RPC endpoint to use (eth namespace required)"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_RPC"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_RPC"
),
}
}
L1TrustRPC
=
cli
.
BoolFlag
{
L1TrustRPC
=
cli
.
BoolFlag
{
Name
:
"l1.trustrpc"
,
Name
:
"l1.trustrpc"
,
Usage
:
"Trust the L1 RPC, sync faster at risk of malicious/buggy RPC providing bad or inconsistent L1 data"
,
Usage
:
"Trust the L1 RPC, sync faster at risk of malicious/buggy RPC providing bad or inconsistent L1 data"
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_TRUST_RPC"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_TRUST_RPC"
),
}
}
L1RPCProviderKind
=
cli
.
GenericFlag
{
L1RPCProviderKind
=
cli
.
GenericFlag
{
Name
:
"l1.rpckind"
,
Name
:
"l1.rpckind"
,
Usage
:
"The kind of RPC provider, used to inform optimal transactions receipts fetching, and thus reduce costs. Valid options: "
+
Usage
:
"The kind of RPC provider, used to inform optimal transactions receipts fetching, and thus reduce costs. Valid options: "
+
nodeflags
.
EnumString
[
sources
.
RPCProviderKind
](
sources
.
RPCProviderKinds
),
nodeflags
.
EnumString
[
sources
.
RPCProviderKind
](
sources
.
RPCProviderKinds
),
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_RPC_KIND"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_RPC_KIND"
),
Value
:
func
()
*
sources
.
RPCProviderKind
{
Value
:
func
()
*
sources
.
RPCProviderKind
{
out
:=
sources
.
RPCKindBasic
out
:=
sources
.
RPCKindBasic
return
&
out
return
&
out
...
@@ -84,12 +84,12 @@ var (
...
@@ -84,12 +84,12 @@ var (
Exec
=
cli
.
StringFlag
{
Exec
=
cli
.
StringFlag
{
Name
:
"exec"
,
Name
:
"exec"
,
Usage
:
"Run the specified client program as a separate process detached from the host. Default is to run the client program in the host process."
,
Usage
:
"Run the specified client program as a separate process detached from the host. Default is to run the client program in the host process."
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"EXEC"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"EXEC"
),
}
}
Server
=
cli
.
BoolFlag
{
Server
=
cli
.
BoolFlag
{
Name
:
"server"
,
Name
:
"server"
,
Usage
:
"Run in pre-image server mode without executing any client program."
,
Usage
:
"Run in pre-image server mode without executing any client program."
,
EnvVar
:
service
.
PrefixEnvVar
(
e
nvVarPrefix
,
"SERVER"
),
EnvVar
:
service
.
PrefixEnvVar
(
E
nvVarPrefix
,
"SERVER"
),
}
}
)
)
...
@@ -116,7 +116,7 @@ var programFlags = []cli.Flag{
...
@@ -116,7 +116,7 @@ var programFlags = []cli.Flag{
}
}
func
init
()
{
func
init
()
{
Flags
=
append
(
Flags
,
oplog
.
CLIFlags
(
e
nvVarPrefix
)
...
)
Flags
=
append
(
Flags
,
oplog
.
CLIFlags
(
E
nvVarPrefix
)
...
)
Flags
=
append
(
Flags
,
requiredFlags
...
)
Flags
=
append
(
Flags
,
requiredFlags
...
)
Flags
=
append
(
Flags
,
programFlags
...
)
Flags
=
append
(
Flags
,
programFlags
...
)
}
}
...
...
op-program/host/host.go
View file @
9d457f8c
...
@@ -15,10 +15,12 @@ import (
...
@@ -15,10 +15,12 @@ import (
cl
"github.com/ethereum-optimism/optimism/op-program/client"
cl
"github.com/ethereum-optimism/optimism/op-program/client"
"github.com/ethereum-optimism/optimism/op-program/client/driver"
"github.com/ethereum-optimism/optimism/op-program/client/driver"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum-optimism/optimism/op-program/host/flags"
"github.com/ethereum-optimism/optimism/op-program/host/kvstore"
"github.com/ethereum-optimism/optimism/op-program/host/kvstore"
"github.com/ethereum-optimism/optimism/op-program/host/prefetcher"
"github.com/ethereum-optimism/optimism/op-program/host/prefetcher"
oppio
"github.com/ethereum-optimism/optimism/op-program/io"
oppio
"github.com/ethereum-optimism/optimism/op-program/io"
"github.com/ethereum-optimism/optimism/op-program/preimage"
"github.com/ethereum-optimism/optimism/op-program/preimage"
opservice
"github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -32,6 +34,7 @@ func Main(logger log.Logger, cfg *config.Config) error {
...
@@ -32,6 +34,7 @@ func Main(logger log.Logger, cfg *config.Config) error {
if
err
:=
cfg
.
Check
();
err
!=
nil
{
if
err
:=
cfg
.
Check
();
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid config: %w"
,
err
)
return
fmt
.
Errorf
(
"invalid config: %w"
,
err
)
}
}
opservice
.
ValidateEnvVars
(
flags
.
EnvVarPrefix
,
flags
.
Flags
,
logger
)
cfg
.
Rollup
.
LogDescription
(
logger
,
chaincfg
.
L2ChainIDToNetworkName
)
cfg
.
Rollup
.
LogDescription
(
logger
,
chaincfg
.
L2ChainIDToNetworkName
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
...
op-proposer/flags/flags.go
View file @
9d457f8c
...
@@ -14,24 +14,24 @@ import (
...
@@ -14,24 +14,24 @@ import (
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
)
)
const
e
nvVarPrefix
=
"OP_PROPOSER"
const
E
nvVarPrefix
=
"OP_PROPOSER"
var
(
var
(
// Required Flags
// Required Flags
L1EthRpcFlag
=
cli
.
StringFlag
{
L1EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l1-eth-rpc"
,
Name
:
"l1-eth-rpc"
,
Usage
:
"HTTP provider URL for L1"
,
Usage
:
"HTTP provider URL for L1"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L1_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L1_ETH_RPC"
),
}
}
RollupRpcFlag
=
cli
.
StringFlag
{
RollupRpcFlag
=
cli
.
StringFlag
{
Name
:
"rollup-rpc"
,
Name
:
"rollup-rpc"
,
Usage
:
"HTTP provider URL for the rollup node"
,
Usage
:
"HTTP provider URL for the rollup node"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"ROLLUP_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"ROLLUP_RPC"
),
}
}
L2OOAddressFlag
=
cli
.
StringFlag
{
L2OOAddressFlag
=
cli
.
StringFlag
{
Name
:
"l2oo-address"
,
Name
:
"l2oo-address"
,
Usage
:
"Address of the L2OutputOracle contract"
,
Usage
:
"Address of the L2OutputOracle contract"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"L2OO_ADDRESS"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"L2OO_ADDRESS"
),
}
}
// Optional flags
// Optional flags
...
@@ -39,12 +39,12 @@ var (
...
@@ -39,12 +39,12 @@ var (
Name
:
"poll-interval"
,
Name
:
"poll-interval"
,
Usage
:
"How frequently to poll L2 for new blocks"
,
Usage
:
"How frequently to poll L2 for new blocks"
,
Value
:
6
*
time
.
Second
,
Value
:
6
*
time
.
Second
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"POLL_INTERVAL"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"POLL_INTERVAL"
),
}
}
AllowNonFinalizedFlag
=
cli
.
BoolFlag
{
AllowNonFinalizedFlag
=
cli
.
BoolFlag
{
Name
:
"allow-non-finalized"
,
Name
:
"allow-non-finalized"
,
Usage
:
"Allow the proposer to submit proposals for L2 blocks derived from non-finalized L1 blocks."
,
Usage
:
"Allow the proposer to submit proposals for L2 blocks derived from non-finalized L1 blocks."
,
EnvVar
:
opservice
.
PrefixEnvVar
(
e
nvVarPrefix
,
"ALLOW_NON_FINALIZED"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
E
nvVarPrefix
,
"ALLOW_NON_FINALIZED"
),
}
}
// Legacy Flags
// Legacy Flags
L2OutputHDPathFlag
=
txmgr
.
L2OutputHDPathFlag
L2OutputHDPathFlag
=
txmgr
.
L2OutputHDPathFlag
...
@@ -63,11 +63,11 @@ var optionalFlags = []cli.Flag{
...
@@ -63,11 +63,11 @@ var optionalFlags = []cli.Flag{
}
}
func
init
()
{
func
init
()
{
optionalFlags
=
append
(
optionalFlags
,
oprpc
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oprpc
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
E
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
txmgr
.
CLIFlags
(
e
nvVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
txmgr
.
CLIFlags
(
E
nvVarPrefix
)
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
Flags
=
append
(
requiredFlags
,
optionalFlags
...
)
}
}
...
...
op-proposer/proposer/l2_output_submitter.go
View file @
9d457f8c
...
@@ -46,6 +46,7 @@ func Main(version string, cliCtx *cli.Context) error {
...
@@ -46,6 +46,7 @@ func Main(version string, cliCtx *cli.Context) error {
}
}
l
:=
oplog
.
NewLogger
(
cfg
.
LogConfig
)
l
:=
oplog
.
NewLogger
(
cfg
.
LogConfig
)
opservice
.
ValidateEnvVars
(
flags
.
EnvVarPrefix
,
flags
.
Flags
,
l
)
m
:=
metrics
.
NewMetrics
(
"default"
)
m
:=
metrics
.
NewMetrics
(
"default"
)
l
.
Info
(
"Initializing L2 Output Submitter"
)
l
.
Info
(
"Initializing L2 Output Submitter"
)
...
...
op-service/util.go
View file @
9d457f8c
...
@@ -6,16 +6,59 @@ import (
...
@@ -6,16 +6,59 @@ import (
"fmt"
"fmt"
"os"
"os"
"os/signal"
"os/signal"
"reflect"
"strings"
"syscall"
"syscall"
"time"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli"
)
)
func
PrefixEnvVar
(
prefix
,
suffix
string
)
string
{
func
PrefixEnvVar
(
prefix
,
suffix
string
)
string
{
return
prefix
+
"_"
+
suffix
return
prefix
+
"_"
+
suffix
}
}
// ValidateEnvVars logs all env vars that are found where the env var is
// prefixed with the supplied prefix (like OP_BATCHER) but there is no
// actual env var with that name.
// It helps validate that the supplied env vars are in fact valid.
func
ValidateEnvVars
(
prefix
string
,
flags
[]
cli
.
Flag
,
log
log
.
Logger
)
{
for
_
,
envVar
:=
range
validateEnvVars
(
prefix
,
os
.
Environ
(),
cliFlagsToEnvVars
(
flags
))
{
log
.
Warn
(
"Unknown env var"
,
"prefix"
,
prefix
,
"env_var"
,
envVar
)
}
}
func
cliFlagsToEnvVars
(
flags
[]
cli
.
Flag
)
map
[
string
]
struct
{}
{
definedEnvVars
:=
make
(
map
[
string
]
struct
{})
for
_
,
flag
:=
range
flags
{
envVarField
:=
reflect
.
ValueOf
(
flag
)
.
FieldByName
(
"EnvVar"
)
if
envVarField
.
IsValid
()
{
definedEnvVars
[
envVarField
.
String
()]
=
struct
{}{}
}
}
return
definedEnvVars
}
// validateEnvVars returns a list of the unknown environment variables that match the prefix.
func
validateEnvVars
(
prefix
string
,
providedEnvVars
[]
string
,
definedEnvVars
map
[
string
]
struct
{})
[]
string
{
var
out
[]
string
for
_
,
envVar
:=
range
providedEnvVars
{
parts
:=
strings
.
Split
(
envVar
,
"="
)
if
len
(
parts
)
==
0
{
continue
}
key
:=
parts
[
0
]
if
strings
.
HasPrefix
(
key
,
prefix
)
{
if
_
,
ok
:=
definedEnvVars
[
key
];
!
ok
{
out
=
append
(
out
,
envVar
)
}
}
}
return
out
}
// ParseAddress parses an ETH address from a hex string. This method will fail if
// ParseAddress parses an ETH address from a hex string. This method will fail if
// the address is not a valid hexadecimal address.
// the address is not a valid hexadecimal address.
func
ParseAddress
(
address
string
)
(
common
.
Address
,
error
)
{
func
ParseAddress
(
address
string
)
(
common
.
Address
,
error
)
{
...
...
op-service/util_test.go
0 → 100644
View file @
9d457f8c
package
op_service
import
(
"testing"
"github.com/stretchr/testify/require"
"github.com/urfave/cli"
)
func
TestCLIFlagsToEnvVars
(
t
*
testing
.
T
)
{
flags
:=
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"test"
,
EnvVar
:
"OP_NODE_TEST_VAR"
,
},
cli
.
IntFlag
{
Name
:
"no env var"
,
},
}
res
:=
cliFlagsToEnvVars
(
flags
)
require
.
Contains
(
t
,
res
,
"OP_NODE_TEST_VAR"
)
}
func
TestValidateEnvVars
(
t
*
testing
.
T
)
{
provided
:=
[]
string
{
"OP_BATCHER_CONFIG=true"
,
"OP_BATCHER_FAKE=false"
,
"LD_PRELOAD=/lib/fake.so"
}
defined
:=
map
[
string
]
struct
{}{
"OP_BATCHER_CONFIG"
:
{},
"OP_BATCHER_OTHER"
:
{},
}
invalids
:=
validateEnvVars
(
"OP_BATCHER"
,
provided
,
defined
)
require
.
ElementsMatch
(
t
,
invalids
,
[]
string
{
"OP_BATCHER_FAKE=false"
})
}
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