diff --git a/les/checkpointoracle/oracle.go b/les/checkpointoracle/oracle.go index 73bd8f35d409..8f2dda3937f7 100644 --- a/les/checkpointoracle/oracle.go +++ b/les/checkpointoracle/oracle.go @@ -51,16 +51,6 @@ type CheckpointOracle struct { // New creates a checkpoint oracle handler with given configs and callback. func New(config *params.CheckpointOracleConfig, getLocal func(uint64) params.TrustedCheckpoint) *CheckpointOracle { - if config == nil { - log.Info("Checkpoint registrar is not enabled") - return nil - } - if config.Address == (common.Address{}) || uint64(len(config.Signers)) < config.Threshold { - log.Warn("Invalid checkpoint registrar config") - return nil - } - log.Info("Configured checkpoint registrar", "address", config.Address, "signers", len(config.Signers), "threshold", config.Threshold) - return &CheckpointOracle{ config: config, getLocal: getLocal, diff --git a/les/commons.go b/les/commons.go index 9f14f82a473a..003e196d2b82 100644 --- a/les/commons.go +++ b/les/commons.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/les/checkpointoracle" "github.com/ethereum/go-ethereum/light" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discv5" @@ -149,14 +150,24 @@ func (c *lesCommons) localCheckpoint(index uint64) params.TrustedCheckpoint { } // setupOracle sets up the checkpoint oracle contract client. -func (c *lesCommons) setupOracle(node *node.Node, genesis common.Hash, config *eth.Config) *checkpointoracle.CheckpointOracle { - cfg := config.CheckpointOracle - if cfg == nil { - cfg = params.CheckpointOracles[genesis] +func (c *lesCommons) setupOracle(node *node.Node, genesis common.Hash, ethconfig *eth.Config) *checkpointoracle.CheckpointOracle { + config := ethconfig.CheckpointOracle + if config == nil { + // Try loading default config. + config = params.CheckpointOracles[genesis] } - oracle := checkpointoracle.New(cfg, c.localCheckpoint) + if config == nil { + log.Info("Checkpoint registrar is not enabled") + return nil + } + if config.Address == (common.Address{}) || uint64(len(config.Signers)) < config.Threshold { + log.Warn("Invalid checkpoint registrar config") + return nil + } + oracle := checkpointoracle.New(config, c.localCheckpoint) rpcClient, _ := node.Attach() client := ethclient.NewClient(rpcClient) oracle.Start(client) + log.Info("Configured checkpoint registrar", "address", config.Address, "signers", len(config.Signers), "threshold", config.Threshold) return oracle }