diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index bff6d8c61..5c80fffaa 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -26,7 +26,6 @@ go_library( "//beacon-chain/db/slasherkv:go_default_library", "//beacon-chain/deterministic-genesis:go_default_library", "//beacon-chain/execution:go_default_library", - "//beacon-chain/forkchoice:go_default_library", "//beacon-chain/forkchoice/doubly-linked-tree:go_default_library", "//beacon-chain/forkchoice/protoarray:go_default_library", "//beacon-chain/gateway:go_default_library", diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 3e39d978f..0609905c5 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -28,7 +28,6 @@ import ( "github.com/prysmaticlabs/prysm/v3/beacon-chain/db/slasherkv" interopcoldstart "github.com/prysmaticlabs/prysm/v3/beacon-chain/deterministic-genesis" "github.com/prysmaticlabs/prysm/v3/beacon-chain/execution" - "github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice" doublylinkedtree "github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice/doubly-linked-tree" "github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/v3/beacon-chain/gateway" @@ -100,7 +99,6 @@ type BeaconNode struct { stateFeed *event.Feed blockFeed *event.Feed opFeed *event.Feed - forkChoiceStore forkchoice.ForkChoicer stateGen *stategen.State collector *bcnodeCollector slasherBlockHeadersFeed *event.Feed @@ -229,9 +227,6 @@ func New(cliCtx *cli.Context, opts ...Option) (*BeaconNode, error) { return nil, err } - log.Debugln("Starting Fork Choice") - beacon.startForkChoice() - log.Debugln("Registering Blockchain Service") if err := beacon.registerBlockchainService(); err != nil { return nil, err @@ -355,14 +350,6 @@ func (b *BeaconNode) Close() { close(b.stop) } -func (b *BeaconNode) startForkChoice() { - if !features.Get().DisableForkchoiceDoublyLinkedTree { - b.forkChoiceStore = doublylinkedtree.New() - } else { - b.forkChoiceStore = protoarray.New() - } -} - func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error { baseDir := cliCtx.String(cmd.DataDirFlag.Name) dbPath := filepath.Join(baseDir, kv.BeaconNodeDbDirName) @@ -609,13 +596,19 @@ func (b *BeaconNode) registerBlockchainService() error { blockchain.WithSlashingPool(b.slashingsPool), blockchain.WithP2PBroadcaster(b.fetchP2P()), blockchain.WithStateNotifier(b), - blockchain.WithForkChoiceStore(b.forkChoiceStore), blockchain.WithAttestationService(attService), blockchain.WithStateGen(b.stateGen), blockchain.WithSlasherAttestationsFeed(b.slasherAttestationsFeed), blockchain.WithFinalizedStateAtStartUp(b.finalizedStateAtStartUp), blockchain.WithProposerIdsCache(b.proposerIdsCache), ) + + if features.Get().DisableForkchoiceDoublyLinkedTree { + opts = append(opts, blockchain.WithForkChoiceStore(protoarray.New())) + } else { + opts = append(opts, blockchain.WithForkChoiceStore(doublylinkedtree.New())) + } + blockchainService, err := blockchain.NewService(b.ctx, opts...) if err != nil { return errors.Wrap(err, "could not register blockchain service") @@ -843,7 +836,7 @@ func (b *BeaconNode) registerRPCService() error { return b.services.RegisterService(rpcService) } -func (b *BeaconNode) registerPrometheusService(cliCtx *cli.Context) error { +func (b *BeaconNode) registerPrometheusService(_ *cli.Context) error { var additionalHandlers []prometheus.Handler var p *p2p.Service if err := b.services.FetchService(&p); err != nil {