From 18223786e863efa11e76aa615b3aa43c4effb6b7 Mon Sep 17 00:00:00 2001 From: Maurelian Date: Fri, 14 Oct 2022 10:19:21 -0500 Subject: [PATCH] Add --rollup.historicalhttp CLI flag --- cmd/geth/main.go | 1 + cmd/utils/flags.go | 9 +++++++++ eth/backend.go | 28 +++++++++++++++++++++------- eth/ethconfig/config.go | 1 + 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e766bbd32f..23d3a93ba4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -155,6 +155,7 @@ var ( utils.MinerNotifyFullFlag, utils.IgnoreLegacyReceiptsFlag, utils.RollupSequencerHTTPFlag, + utils.RollupHistoricalRPCFlag, utils.RollupDisableTxPoolGossipFlag, configFileFlag, }, utils.NetworkFlags, utils.DatabasePathFlags) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8de9da1d26..a84e6a9eb9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -889,6 +889,12 @@ var ( Category: flags.RollupCategory, } + RollupHistoricalRPCFlag = &cli.StringFlag{ + Name: "rollup.historicalrpc", + Usage: "RPC endpoint for historical data.", + Category: flags.RollupCategory, + } + RollupDisableTxPoolGossipFlag = &cli.BoolFlag{ Name: "rollup.disabletxpoolgossip", Usage: "Disable transaction pool gossip.", @@ -1876,6 +1882,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if ctx.IsSet(RollupSequencerHTTPFlag.Name) && !ctx.IsSet(MiningEnabledFlag.Name) { cfg.RollupSequencerHTTP = ctx.String(RollupSequencerHTTPFlag.Name) } + if ctx.IsSet(RollupHistoricalRPCFlag.Name) { + cfg.RollupHistoricalRPC = ctx.String(RollupHistoricalRPCFlag.Name) + } cfg.RollupDisableTxPoolGossip = ctx.Bool(RollupDisableTxPoolGossipFlag.Name) // Override any default configs for hard coded networks. switch { diff --git a/eth/backend.go b/eth/backend.go index 8bfe04795f..544c140664 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -68,13 +68,14 @@ type Ethereum struct { config *ethconfig.Config // Handlers - txPool *core.TxPool - blockchain *core.BlockChain - handler *handler - ethDialCandidates enode.Iterator - snapDialCandidates enode.Iterator - merger *consensus.Merger - seqRPCService *rpc.Client + txPool *core.TxPool + blockchain *core.BlockChain + handler *handler + ethDialCandidates enode.Iterator + snapDialCandidates enode.Iterator + merger *consensus.Merger + seqRPCService *rpc.Client + historicalRPCService *rpc.Client // DB interfaces chainDb ethdb.Database // Block chain database @@ -270,6 +271,16 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { eth.seqRPCService = client } + if config.RollupHistoricalRPC != "" { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + client, err := rpc.DialContext(ctx, config.RollupHistoricalRPC) + cancel() + if err != nil { + return nil, err + } + eth.historicalRPCService = client + } + // Start the RPC service eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, config.NetworkId) @@ -564,6 +575,9 @@ func (s *Ethereum) Stop() error { if s.seqRPCService != nil { s.seqRPCService.Close() } + if s.historicalRPCService != nil { + s.historicalRPCService.Close() + } // Clean shutdown marker as the last thing before closing db s.shutdownTracker.Stop() diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 659fd62ad5..38056d31c9 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -216,6 +216,7 @@ type Config struct { OverrideTerminalTotalDifficultyPassed *bool `toml:",omitempty"` RollupSequencerHTTP string + RollupHistoricalRPC string RollupDisableTxPoolGossip bool }