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
6e714be7
Unverified
Commit
6e714be7
authored
Jun 07, 2023
by
OptimismBot
Committed by
GitHub
Jun 07, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5798 from mdehoog/bootnode
op-bootnode
parents
c79a1dec
81917281
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
160 additions
and
0 deletions
+160
-0
config.yml
.circleci/config.yml
+4
-0
entrypoint.go
op-bootnode/bootnode/entrypoint.go
+87
-0
main.go
op-bootnode/cmd/main.go
+33
-0
flags.go
op-bootnode/flags/flags.go
+36
-0
No files found.
.circleci/config.yml
View file @
6e714be7
...
@@ -1303,6 +1303,9 @@ workflows:
...
@@ -1303,6 +1303,9 @@ workflows:
-
go-lint
:
-
go-lint
:
name
:
op-batcher-lint
name
:
op-batcher-lint
module
:
op-batcher
module
:
op-batcher
-
go-lint
:
name
:
op-bootnode-lint
module
:
op-bootnode
-
go-lint
:
-
go-lint
:
name
:
op-bindings-lint
name
:
op-bindings-lint
module
:
op-bindings
module
:
op-bindings
...
@@ -1366,6 +1369,7 @@ workflows:
...
@@ -1366,6 +1369,7 @@ workflows:
-
bedrock-go-tests
:
-
bedrock-go-tests
:
requires
:
requires
:
-
op-batcher-lint
-
op-batcher-lint
-
op-bootnode-lint
-
op-bindings-lint
-
op-bindings-lint
-
op-chain-ops-lint
-
op-chain-ops-lint
-
op-e2e-lint
-
op-e2e-lint
...
...
op-bootnode/bootnode/entrypoint.go
0 → 100644
View file @
6e714be7
package
bootnode
import
(
"context"
"errors"
"fmt"
opnode
"github.com/ethereum-optimism/optimism/op-node"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/p2p"
p2pcli
"github.com/ethereum-optimism/optimism/op-node/p2p/cli"
"github.com/ethereum-optimism/optimism/op-node/rollup"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/opio"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/urfave/cli"
)
type
gossipNoop
struct
{}
func
(
g
*
gossipNoop
)
OnUnsafeL2Payload
(
_
context
.
Context
,
_
peer
.
ID
,
_
*
eth
.
ExecutionPayload
)
error
{
return
nil
}
type
gossipConfig
struct
{}
func
(
g
*
gossipConfig
)
P2PSequencerAddress
()
common
.
Address
{
return
common
.
Address
{}
}
type
l2Chain
struct
{}
func
(
l
*
l2Chain
)
PayloadByNumber
(
_
context
.
Context
,
_
uint64
)
(
*
eth
.
ExecutionPayload
,
error
)
{
return
nil
,
nil
}
func
Main
(
cliCtx
*
cli
.
Context
)
error
{
log
.
Info
(
"Initializing bootnode"
)
logCfg
:=
oplog
.
ReadCLIConfig
(
cliCtx
)
logger
:=
oplog
.
NewLogger
(
logCfg
)
m
:=
metrics
.
NewMetrics
(
"default"
)
ctx
:=
context
.
Background
()
config
,
err
:=
opnode
.
NewRollupConfig
(
cliCtx
)
if
err
!=
nil
{
return
err
}
if
err
=
validateConfig
(
config
);
err
!=
nil
{
return
err
}
p2pConfig
,
err
:=
p2pcli
.
NewConfig
(
cliCtx
,
config
.
BlockTime
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to load p2p config: %w"
,
err
)
}
p2pNode
,
err
:=
p2p
.
NewNodeP2P
(
ctx
,
config
,
logger
,
p2pConfig
,
&
gossipNoop
{},
&
l2Chain
{},
&
gossipConfig
{},
m
)
if
err
!=
nil
||
p2pNode
==
nil
{
return
err
}
if
p2pNode
.
Dv5Udp
()
==
nil
{
return
fmt
.
Errorf
(
"uninitialized discovery service"
)
}
go
p2pNode
.
DiscoveryProcess
(
ctx
,
logger
,
config
,
p2pConfig
.
TargetPeers
())
opio
.
BlockOnInterrupts
()
return
nil
}
// validateConfig ensures the minimal config required to run a bootnode
func
validateConfig
(
config
*
rollup
.
Config
)
error
{
if
config
.
L2ChainID
==
nil
||
config
.
L2ChainID
.
Uint64
()
==
0
{
return
errors
.
New
(
"chain ID is not set"
)
}
if
config
.
Genesis
.
L2Time
<=
0
{
return
errors
.
New
(
"genesis timestamp is not set"
)
}
if
config
.
BlockTime
<=
0
{
return
errors
.
New
(
"block time is not set"
)
}
return
nil
}
op-bootnode/cmd/main.go
0 → 100644
View file @
6e714be7
package
main
import
(
"os"
"github.com/ethereum-optimism/optimism/op-bootnode/bootnode"
"github.com/ethereum-optimism/optimism/op-bootnode/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli"
)
func
main
()
{
// Set up logger with a default INFO level in case we fail to parse flags,
// otherwise the final critical log won't show what the parsing error was.
log
.
Root
()
.
SetHandler
(
log
.
LvlFilterHandler
(
log
.
LvlInfo
,
log
.
StreamHandler
(
os
.
Stdout
,
log
.
TerminalFormat
(
true
)),
),
)
app
:=
cli
.
NewApp
()
app
.
Flags
=
flags
.
Flags
app
.
Name
=
"bootnode"
app
.
Usage
=
"Rollup Bootnode"
app
.
Description
=
"Broadcasts incoming P2P peers to each other, enabling peer bootstrapping."
app
.
Action
=
bootnode
.
Main
err
:=
app
.
Run
(
os
.
Args
)
if
err
!=
nil
{
log
.
Crit
(
"Application failed"
,
"message"
,
err
)
}
}
op-bootnode/flags/flags.go
0 → 100644
View file @
6e714be7
package
flags
import
(
"fmt"
"strings"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/flags"
opservice
"github.com/ethereum-optimism/optimism/op-service"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/urfave/cli"
)
const
envVarPrefix
=
"OP_BOOTNODE"
var
(
RollupConfig
=
cli
.
StringFlag
{
Name
:
flags
.
RollupConfig
.
Name
,
Usage
:
"Rollup chain parameters"
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ROLLUP_CONFIG"
),
}
Network
=
cli
.
StringFlag
{
Name
:
flags
.
Network
.
Name
,
Usage
:
fmt
.
Sprintf
(
"Predefined network selection. Available networks: %s"
,
strings
.
Join
(
chaincfg
.
AvailableNetworks
(),
", "
)),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"NETWORK"
),
}
)
var
Flags
=
[]
cli
.
Flag
{
RollupConfig
,
Network
,
}
func
init
()
{
Flags
=
append
(
Flags
,
oplog
.
CLIFlags
(
envVarPrefix
)
...
)
}
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