mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Canonical LC (#15585)
* create lc cache to track branches * save lc stuff * remove finalized data from LC cache on finalization * read lc stuff * edit tests * changelog * linter * address commments * address commments 2 * address commments 3 * address commments 4 * lint * address commments 5 x_x * set beacon lcStore to mimick registrable services * clean up the error propagation * pass the state to saveLCBootstrap since it's not saved in db yet
This commit is contained in:
@@ -253,10 +253,6 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
|
||||
// their initialization.
|
||||
beacon.finalizedStateAtStartUp = nil
|
||||
|
||||
if features.Get().EnableLightClient {
|
||||
beacon.lcStore = lightclient.NewLightClientStore(beacon.db, beacon.fetchP2P(), beacon.StateFeed())
|
||||
}
|
||||
|
||||
return beacon, nil
|
||||
}
|
||||
|
||||
@@ -349,6 +345,11 @@ func registerServices(cliCtx *cli.Context, beacon *BeaconNode, synchronizer *sta
|
||||
return errors.Wrap(err, "could not register P2P service")
|
||||
}
|
||||
|
||||
if features.Get().EnableLightClient {
|
||||
log.Debugln("Registering Light Client Store")
|
||||
beacon.registerLightClientStore()
|
||||
}
|
||||
|
||||
log.Debugln("Registering Backfill Service")
|
||||
if err := beacon.RegisterBackfillService(cliCtx, bfs); err != nil {
|
||||
return errors.Wrap(err, "could not register Back Fill service")
|
||||
@@ -1139,6 +1140,11 @@ func (b *BeaconNode) RegisterBackfillService(cliCtx *cli.Context, bfs *backfill.
|
||||
return b.services.RegisterService(bf)
|
||||
}
|
||||
|
||||
func (b *BeaconNode) registerLightClientStore() {
|
||||
lcs := lightclient.NewLightClientStore(b.fetchP2P(), b.StateFeed(), b.db)
|
||||
b.lcStore = lcs
|
||||
}
|
||||
|
||||
func hasNetworkFlag(cliCtx *cli.Context) bool {
|
||||
for _, flag := range features.NetworkFlags {
|
||||
for _, name := range flag.Names() {
|
||||
|
||||
@@ -74,7 +74,9 @@ func TestNodeStart_Ok(t *testing.T) {
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.String("datadir", tmp, "node data directory")
|
||||
set.String("suggested-fee-recipient", "0x6e35733c5af9B61374A128e6F85f553aF09ff89A", "fee recipient")
|
||||
set.Bool("enable-light-client", true, "enable light client")
|
||||
require.NoError(t, set.Set("suggested-fee-recipient", "0x6e35733c5af9B61374A128e6F85f553aF09ff89A"))
|
||||
require.NoError(t, set.Set("enable-light-client", "true"))
|
||||
|
||||
ctx, cancel := newCliContextWithCancel(&app, set)
|
||||
|
||||
@@ -88,6 +90,7 @@ func TestNodeStart_Ok(t *testing.T) {
|
||||
|
||||
node, err := New(ctx, cancel, options...)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, node.lcStore)
|
||||
node.services = &runtime.ServiceRegistry{}
|
||||
go func() {
|
||||
node.Start()
|
||||
|
||||
Reference in New Issue
Block a user