From 72e67e53b18e697b6e421e9eba303fb821064a8f Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 12 Nov 2024 23:38:16 +0700 Subject: [PATCH] op-bootnode: remove op-bootnode service (#12901) --- README.md | 1 - op-bootnode/.gitignore | 1 - op-bootnode/Makefile | 22 --- op-bootnode/bootnode/entrypoint.go | 134 ------------------ op-bootnode/cmd/main.go | 28 ---- op-bootnode/flags/flags.go | 25 ---- .../op-stack-go/Dockerfile.dockerignore | 1 - 7 files changed, 212 deletions(-) delete mode 100644 op-bootnode/.gitignore delete mode 100644 op-bootnode/Makefile delete mode 100644 op-bootnode/bootnode/entrypoint.go delete mode 100644 op-bootnode/cmd/main.go delete mode 100644 op-bootnode/flags/flags.go diff --git a/README.md b/README.md index 42a880f5f427..bda740f63c2c 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ The Optimism Immunefi program offers up to $2,000,042 for in-scope critical vuln
 ├── docs: A collection of documents including audits and post-mortems
 ├── op-batcher: L2-Batch Submitter, submits bundles of batches to L1
-├── op-bootnode: Standalone op-node discovery bootnode
 ├── op-chain-ops: State surgery utilities
 ├── op-challenger: Dispute game challenge agent
 ├── op-e2e: End-to-End testing of all bedrock components in Go
diff --git a/op-bootnode/.gitignore b/op-bootnode/.gitignore
deleted file mode 100644
index ba077a4031ad..000000000000
--- a/op-bootnode/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/op-bootnode/Makefile b/op-bootnode/Makefile
deleted file mode 100644
index f9f276e9ed11..000000000000
--- a/op-bootnode/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-GITCOMMIT ?= $(shell git rev-parse HEAD)
-GITDATE ?= $(shell git show -s --format='%ct')
-VERSION ?= v0.0.0
-
-LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
-LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)
-LDFLAGSSTRING +=-X main.Version=$(VERSION)
-LDFLAGS := -ldflags "$(LDFLAGSSTRING)"
-
-op-bootnode:
-	env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/op-bootnode ./cmd
-
-clean:
-	rm -f bin/op-bootnode
-
-test:
-	go test -v ./...
-
-.PHONY: \
-	op-bootnode \
-	clean \
-	test
diff --git a/op-bootnode/bootnode/entrypoint.go b/op-bootnode/bootnode/entrypoint.go
deleted file mode 100644
index 0c33383c70c7..000000000000
--- a/op-bootnode/bootnode/entrypoint.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package bootnode
-
-import (
-	"context"
-	"errors"
-	"fmt"
-
-	"github.com/libp2p/go-libp2p/core/peer"
-	"github.com/urfave/cli/v2"
-
-	"github.com/ethereum/go-ethereum/common"
-	"github.com/ethereum/go-ethereum/log"
-	"github.com/ethereum/go-ethereum/rpc"
-
-	opnode "github.com/ethereum-optimism/optimism/op-node"
-	"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"
-	"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
-	"github.com/ethereum-optimism/optimism/op-service/eth"
-	oplog "github.com/ethereum-optimism/optimism/op-service/log"
-	opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
-	oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
-)
-
-type gossipNoop struct{}
-
-func (g *gossipNoop) OnUnsafeL2Payload(_ context.Context, _ peer.ID, _ *eth.ExecutionPayloadEnvelope) 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.ExecutionPayloadEnvelope, error) {
-	return nil, errors.New("P2P req/resp is not supported in bootnodes")
-}
-
-func Main(cliCtx *cli.Context) error {
-	log.Info("Initializing bootnode")
-	logCfg := oplog.ReadCLIConfig(cliCtx)
-	logger := oplog.NewLogger(oplog.AppOut(cliCtx), logCfg)
-	oplog.SetGlobalLogHandler(logger.Handler())
-	m := metrics.NewMetrics("default")
-	ctx := context.Background()
-
-	config, err := opnode.NewRollupConfigFromCLI(logger, cliCtx)
-	if err != nil {
-		return err
-	}
-	if err = validateConfig(config); err != nil {
-		return err
-	}
-
-	p2pConfig, err := p2pcli.NewConfig(cliCtx, config)
-	if err != nil {
-		return fmt.Errorf("failed to load p2p config: %w", err)
-	}
-	if p2pConfig.EnableReqRespSync {
-		logger.Warn("req-resp sync is enabled, bootnode does not support this feature")
-		p2pConfig.EnableReqRespSync = false
-	}
-
-	p2pNode, err := p2p.NewNodeP2P(ctx, config, logger, p2pConfig, &gossipNoop{}, &l2Chain{}, &gossipConfig{}, m, false)
-	if err != nil || p2pNode == nil {
-		return err
-	}
-	if p2pNode.Dv5Udp() == nil {
-		return fmt.Errorf("uninitialized discovery service")
-	}
-
-	rpcCfg := oprpc.ReadCLIConfig(cliCtx)
-	if err := rpcCfg.Check(); err != nil {
-		return fmt.Errorf("failed to validate RPC config")
-	}
-	rpcServer := oprpc.NewServer(rpcCfg.ListenAddr, rpcCfg.ListenPort, "", oprpc.WithLogger(logger))
-	if rpcCfg.EnableAdmin {
-		logger.Info("Admin RPC enabled but does nothing for the bootnode")
-	}
-	rpcServer.AddAPI(rpc.API{
-		Namespace:     p2p.NamespaceRPC,
-		Version:       "",
-		Service:       p2p.NewP2PAPIBackend(p2pNode, logger, m),
-		Authenticated: false,
-	})
-	if err := rpcServer.Start(); err != nil {
-		return fmt.Errorf("failed to start the RPC server")
-	}
-	defer func() {
-		if err := rpcServer.Stop(); err != nil {
-			log.Error("failed to stop RPC server", "err", err)
-		}
-	}()
-
-	go p2pNode.DiscoveryProcess(ctx, logger, config, p2pConfig.TargetPeers())
-
-	metricsCfg := opmetrics.ReadCLIConfig(cliCtx)
-	if metricsCfg.Enabled {
-		log.Debug("starting metrics server", "addr", metricsCfg.ListenAddr, "port", metricsCfg.ListenPort)
-		metricsSrv, err := m.StartServer(metricsCfg.ListenAddr, metricsCfg.ListenPort)
-		if err != nil {
-			return fmt.Errorf("failed to start metrics server: %w", err)
-		}
-		defer func() {
-			if err := metricsSrv.Stop(context.Background()); err != nil {
-				log.Error("failed to stop metrics server", "err", err)
-			}
-		}()
-		log.Info("started metrics server", "addr", metricsSrv.Addr())
-		m.RecordUp()
-	}
-
-	return ctxinterrupt.Wait(ctx)
-}
-
-// 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
-}
diff --git a/op-bootnode/cmd/main.go b/op-bootnode/cmd/main.go
deleted file mode 100644
index 1dbc82010cfc..000000000000
--- a/op-bootnode/cmd/main.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package main
-
-import (
-	"os"
-
-	"github.com/ethereum/go-ethereum/log"
-	"github.com/urfave/cli/v2"
-
-	"github.com/ethereum-optimism/optimism/op-bootnode/bootnode"
-	"github.com/ethereum-optimism/optimism/op-bootnode/flags"
-	oplog "github.com/ethereum-optimism/optimism/op-service/log"
-)
-
-func main() {
-	oplog.SetupDefaults()
-
-	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)
-	}
-}
diff --git a/op-bootnode/flags/flags.go b/op-bootnode/flags/flags.go
deleted file mode 100644
index 5fbe0d538b33..000000000000
--- a/op-bootnode/flags/flags.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package flags
-
-import (
-	"github.com/urfave/cli/v2"
-
-	"github.com/ethereum-optimism/optimism/op-node/flags"
-	opflags "github.com/ethereum-optimism/optimism/op-service/flags"
-	oplog "github.com/ethereum-optimism/optimism/op-service/log"
-	opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
-	oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
-)
-
-const envVarPrefix = "OP_BOOTNODE"
-
-var Flags = []cli.Flag{
-	opflags.CLINetworkFlag(envVarPrefix, ""),
-	opflags.CLIRollupConfigFlag(envVarPrefix, ""),
-}
-
-func init() {
-	Flags = append(Flags, flags.P2PFlags(envVarPrefix)...)
-	Flags = append(Flags, opmetrics.CLIFlags(envVarPrefix)...)
-	Flags = append(Flags, oplog.CLIFlags(envVarPrefix)...)
-	Flags = append(Flags, oprpc.CLIFlags(envVarPrefix)...)
-}
diff --git a/ops/docker/op-stack-go/Dockerfile.dockerignore b/ops/docker/op-stack-go/Dockerfile.dockerignore
index e5eceaea73b8..bd700e291e49 100644
--- a/ops/docker/op-stack-go/Dockerfile.dockerignore
+++ b/ops/docker/op-stack-go/Dockerfile.dockerignore
@@ -4,7 +4,6 @@
 
 !/cannon
 !/op-batcher
-!/op-bootnode
 !/op-chain-ops
 !/op-deployer
 !/op-challenger