diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index ae1d97ab5a..9d16718548 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -226,6 +226,15 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco return nil, err } + if beacon.finalizedStateAtStartUp != nil { + log.Debugln("Pruning old blobs") + if err := beacon.BlobStorage.Prune(beacon.finalizedStateAtStartUp.Slot()); err != nil { + return nil, err + } + } else { + log.Warn("No finalized beacon state at startup, cannot prune blobs") + } + log.Debugln("Registering P2P Service") if err := beacon.registerP2P(cliCtx); err != nil { return nil, err diff --git a/beacon-chain/node/node_test.go b/beacon-chain/node/node_test.go index 921a1b29d9..d18b8ff97a 100644 --- a/beacon-chain/node/node_test.go +++ b/beacon-chain/node/node_test.go @@ -59,7 +59,7 @@ func TestNodeClose_OK(t *testing.T) { cmd.ValidatorMonitorIndicesFlag.Value.SetInt(1) ctx, cancel := newCliContextWithCancel(&app, set) - node, err := New(ctx, cancel) + node, err := New(ctx, cancel, WithBlobStorage(filesystem.NewEphemeralBlobStorage(t))) require.NoError(t, err) node.Close() @@ -127,7 +127,8 @@ func TestNodeStart_Ok_registerDeterministicGenesisService(t *testing.T) { ctx, cancel := newCliContextWithCancel(&app, set) node, err := New(ctx, cancel, WithBlockchainFlagOptions([]blockchain.Option{}), WithBuilderFlagOptions([]builder.Option{}), - WithExecutionChainOptions([]execution.Option{})) + WithExecutionChainOptions([]execution.Option{}), + WithBlobStorage(filesystem.NewEphemeralBlobStorage(t))) require.NoError(t, err) node.services = &runtime.ServiceRegistry{} go func() {