From 05898800aada73143fbb738b7274ae9420400ed3 Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 12:15:20 -0400 Subject: [PATCH 1/6] bet --- mod/node-core/pkg/components/defaults.go | 1 + mod/node-core/pkg/components/runtime.go | 55 ++++------- .../pkg/components/validator_service.go | 94 +++++++++++++++++++ 3 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 mod/node-core/pkg/components/validator_service.go diff --git a/mod/node-core/pkg/components/defaults.go b/mod/node-core/pkg/components/defaults.go index 1b7b5a4c12..5f4f006050 100644 --- a/mod/node-core/pkg/components/defaults.go +++ b/mod/node-core/pkg/components/defaults.go @@ -52,5 +52,6 @@ func DefaultComponentsWithStandardTypes() []any { ProvideDBManager, ProvideDepositService, ProvideRuntime, + ProvideValidatorService, } } diff --git a/mod/node-core/pkg/components/runtime.go b/mod/node-core/pkg/components/runtime.go index 560804eb4f..57b54ff938 100644 --- a/mod/node-core/pkg/components/runtime.go +++ b/mod/node-core/pkg/components/runtime.go @@ -77,12 +77,12 @@ type BeaconKitRuntime = runtime.BeaconKitRuntime[ // RuntimeInput is the input for the runtime provider. type RuntimeInput struct { depinject.In - Cfg *config.Config BlobProcessor *dablob.Processor[ *dastore.Store[*types.BeaconBlockBody], *types.BeaconBlockBody, ] BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] + Cfg *config.Config ChainSpec primitives.ChainSpec DBManagerService *manager.DBManager[ *types.BeaconBlock, @@ -98,10 +98,15 @@ type RuntimeInput struct { event.Subscription, types.WithdrawalCredentials, ] - Signer crypto.BLSSigner EngineClient *engineclient.EngineClient[*types.ExecutionPayload] ExecutionEngine *execution.Engine[*types.ExecutionPayload] - StateProcessor blockchain.StateProcessor[ + + LocalBuilder *payloadbuilder.PayloadBuilder[ + BeaconState, *types.ExecutionPayload, *types.ExecutionPayloadHeader, + ] + Logger log.Logger + Signer crypto.BLSSigner + StateProcessor blockchain.StateProcessor[ *types.BeaconBlock, BeaconState, *datypes.BlobSidecars, @@ -116,47 +121,21 @@ type RuntimeInput struct { *types.Deposit, *depositdb.KVStore[*types.Deposit], ] - LocalBuilder *payloadbuilder.PayloadBuilder[ - BeaconState, *types.ExecutionPayload, *types.ExecutionPayloadHeader, + TelemetrySink *metrics.TelemetrySink + ValidatorService *validator.Service[ + *types.BeaconBlock, + *types.BeaconBlockBody, + BeaconState, + *datypes.BlobSidecars, + *depositdb.KVStore[*types.Deposit], + *types.ForkData, ] - TelemetrySink *metrics.TelemetrySink - Logger log.Logger } // ProvideRuntime is a depinject provider that returns a BeaconKitRuntime. func ProvideRuntime( in RuntimeInput, ) (*BeaconKitRuntime, error) { - // Build the builder service. - validatorService := validator.NewService[ - *types.BeaconBlock, - *types.BeaconBlockBody, - BeaconState, - *datypes.BlobSidecars, - *depositdb.KVStore[*types.Deposit], - *types.ForkData, - ]( - &in.Cfg.Validator, - in.Logger.With("service", "validator"), - in.ChainSpec, - in.StorageBackend, - in.BlobProcessor, - in.StateProcessor, - in.Signer, - dablob.NewSidecarFactory[ - *types.BeaconBlock, - *types.BeaconBlockBody, - ]( - in.ChainSpec, - types.KZGPositionDeneb, - in.TelemetrySink, - ), - in.LocalBuilder, - []validator.PayloadBuilder[BeaconState, *types.ExecutionPayload]{ - in.LocalBuilder, - }, - in.TelemetrySink, - ) // Build the blockchain service. chainService := blockchain.NewService[ @@ -182,7 +161,7 @@ func ProvideRuntime( // Build the service registry. svcRegistry := service.NewRegistry( service.WithLogger(in.Logger.With("service", "service-registry")), - service.WithService(validatorService), + service.WithService(in.ValidatorService), service.WithService(chainService), service.WithService(in.DepositService), service.WithService(in.EngineClient), diff --git a/mod/node-core/pkg/components/validator_service.go b/mod/node-core/pkg/components/validator_service.go new file mode 100644 index 0000000000..b88290e886 --- /dev/null +++ b/mod/node-core/pkg/components/validator_service.go @@ -0,0 +1,94 @@ +package components + +import ( + "cosmossdk.io/depinject" + "cosmossdk.io/log" + "github.com/berachain/beacon-kit/mod/beacon/blockchain" + "github.com/berachain/beacon-kit/mod/beacon/validator" + "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" + dablob "github.com/berachain/beacon-kit/mod/da/pkg/blob" + dastore "github.com/berachain/beacon-kit/mod/da/pkg/store" + datypes "github.com/berachain/beacon-kit/mod/da/pkg/types" + "github.com/berachain/beacon-kit/mod/node-core/pkg/components/metrics" + "github.com/berachain/beacon-kit/mod/node-core/pkg/config" + payloadbuilder "github.com/berachain/beacon-kit/mod/payload/pkg/builder" + "github.com/berachain/beacon-kit/mod/primitives" + "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto" + "github.com/berachain/beacon-kit/mod/primitives/pkg/transition" + depositdb "github.com/berachain/beacon-kit/mod/storage/pkg/deposit" +) + +// ValidatorServiceInput is the input for the validator service provider. +type ValidatorServiceInput struct { + depinject.In + BlobProcessor *dablob.Processor[ + *dastore.Store[*types.BeaconBlockBody], + *types.BeaconBlockBody, + ] + Cfg *config.Config + ChainSpec primitives.ChainSpec + LocalBuilder *payloadbuilder.PayloadBuilder[ + BeaconState, *types.ExecutionPayload, *types.ExecutionPayloadHeader, + ] + Logger log.Logger + StateProcessor blockchain.StateProcessor[ + *types.BeaconBlock, + BeaconState, + *datypes.BlobSidecars, + *transition.Context, + *types.Deposit, + ] + StorageBackend blockchain.StorageBackend[ + *dastore.Store[*types.BeaconBlockBody], + *types.BeaconBlockBody, + BeaconState, + *datypes.BlobSidecars, + *types.Deposit, + *depositdb.KVStore[*types.Deposit], + ] + Signer crypto.BLSSigner + TelemetrySink *metrics.TelemetrySink +} + +// ProvideValidatorService is a depinject provider for the validator service. +func ProvideValidatorService( + in ValidatorServiceInput, +) *validator.Service[ + *types.BeaconBlock, + *types.BeaconBlockBody, + BeaconState, + *datypes.BlobSidecars, + *depositdb.KVStore[*types.Deposit], + *types.ForkData, +] { + // Build the builder service. + return validator.NewService[ + *types.BeaconBlock, + *types.BeaconBlockBody, + BeaconState, + *datypes.BlobSidecars, + *depositdb.KVStore[*types.Deposit], + *types.ForkData, + ]( + &in.Cfg.Validator, + in.Logger.With("service", "validator"), + in.ChainSpec, + in.StorageBackend, + in.BlobProcessor, + in.StateProcessor, + in.Signer, + dablob.NewSidecarFactory[ + *types.BeaconBlock, + *types.BeaconBlockBody, + ]( + in.ChainSpec, + types.KZGPositionDeneb, + in.TelemetrySink, + ), + in.LocalBuilder, + []validator.PayloadBuilder[BeaconState, *types.ExecutionPayload]{ + in.LocalBuilder, + }, + in.TelemetrySink, + ) +} From 51d0e6a114f8da395e68e9a37eef237f478396d4 Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 12:21:17 -0400 Subject: [PATCH 2/6] alphabetapruning --- .../pkg/components/availability_store.go | 6 ++-- mod/node-core/pkg/components/blobs.go | 2 +- mod/node-core/pkg/components/db_manager.go | 4 +-- mod/node-core/pkg/components/defaults.go | 28 +++++++++---------- .../pkg/components/deposit_service.go | 13 ++++----- mod/node-core/pkg/components/deposit_store.go | 4 +-- mod/node-core/pkg/components/engine.go | 15 +++------- .../pkg/components/payload_builder.go | 2 +- mod/node-core/pkg/components/runtime.go | 2 -- 9 files changed, 33 insertions(+), 43 deletions(-) diff --git a/mod/node-core/pkg/components/availability_store.go b/mod/node-core/pkg/components/availability_store.go index a81efe1ed7..eaa6cdbfd1 100644 --- a/mod/node-core/pkg/components/availability_store.go +++ b/mod/node-core/pkg/components/availability_store.go @@ -75,10 +75,10 @@ func ProvideAvailibilityStore[ // function for the depinject framework. type AvailabilityPrunerInput struct { depinject.In - Logger log.Logger - ChainSpec primitives.ChainSpec - BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] AvailabilityStore *dastore.Store[*types.BeaconBlockBody] + BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] + ChainSpec primitives.ChainSpec + Logger log.Logger } // ProvideAvailabilityPruner provides a availability pruner for the depinject diff --git a/mod/node-core/pkg/components/blobs.go b/mod/node-core/pkg/components/blobs.go index b71255a99d..01108c9de2 100644 --- a/mod/node-core/pkg/components/blobs.go +++ b/mod/node-core/pkg/components/blobs.go @@ -58,9 +58,9 @@ func ProvideBlobProofVerifier( type BlobProcessorIn struct { depinject.In - Logger log.Logger BlobProofVerifier kzg.BlobProofVerifier ChainSpec primitives.ChainSpec + Logger log.Logger TelemetrySink *metrics.TelemetrySink } diff --git a/mod/node-core/pkg/components/db_manager.go b/mod/node-core/pkg/components/db_manager.go index c94ef4be19..46e1d539b0 100644 --- a/mod/node-core/pkg/components/db_manager.go +++ b/mod/node-core/pkg/components/db_manager.go @@ -35,9 +35,9 @@ import ( // DBManagerInput is the input for the dep inject framework. type DBManagerInput struct { depinject.In - Logger log.Logger - DepositPruner pruner.Pruner[*dastore.KVStore[*types.Deposit]] AvailabilityPruner pruner.Pruner[*filedb.RangeDB] + DepositPruner pruner.Pruner[*dastore.KVStore[*types.Deposit]] + Logger log.Logger } // ProvideDBManager provides a DBManager for the depinject framework. diff --git a/mod/node-core/pkg/components/defaults.go b/mod/node-core/pkg/components/defaults.go index 5f4f006050..2e6753a944 100644 --- a/mod/node-core/pkg/components/defaults.go +++ b/mod/node-core/pkg/components/defaults.go @@ -27,31 +27,31 @@ import ( func DefaultComponentsWithStandardTypes() []any { return []any{ + ProvideAvailabilityPruner, ProvideAvailibilityStore[*types.BeaconBlockBody], ProvideBlsSigner, - ProvideTrustedSetup, - ProvideDepositStore[*types.Deposit], - ProvideConfig, - ProvideEngineClient[*types.ExecutionPayload], - ProvideJWTSecret, - ProvideBlobProofVerifier, + ProvideBlockFeed[*types.BeaconBlock], ProvideBlobProcessor[*types.BeaconBlockBody], - ProvideTelemetrySink, - ProvideExecutionEngine[*types.ExecutionPayload], + ProvideBlobProofVerifier, + ProvideConfig, + ProvideDBManager, + ProvideDepositPruner, + ProvideDepositService, + ProvideDepositStore[*types.Deposit], ProvideBeaconDepositContract[ *types.Deposit, *types.ExecutionPayload, *engineprimitives.Withdrawal, types.WithdrawalCredentials, ], + ProvideEngineClient[*types.ExecutionPayload], + ProvideExecutionEngine[*types.ExecutionPayload], + ProvideJWTSecret, ProvideLocalBuilder, - ProvideStateProcessor, - ProvideBlockFeed[*types.BeaconBlock], - ProvideDepositPruner, - ProvideAvailabilityPruner, - ProvideDBManager, - ProvideDepositService, ProvideRuntime, + ProvideStateProcessor, + ProvideTelemetrySink, + ProvideTrustedSetup, ProvideValidatorService, } } diff --git a/mod/node-core/pkg/components/deposit_service.go b/mod/node-core/pkg/components/deposit_service.go index c6d33f585b..a3610dc722 100644 --- a/mod/node-core/pkg/components/deposit_service.go +++ b/mod/node-core/pkg/components/deposit_service.go @@ -37,16 +37,15 @@ import ( // DepositServiceIn is the input for the deposit service. type DepositServiceIn struct { depinject.In - - Logger log.Logger - ChainSpec primitives.ChainSpec - EngineClient *engineclient.EngineClient[*types.ExecutionPayload] - TelemetrySink *metrics.TelemetrySink - DepositStore *depositdb.KVStore[*types.Deposit] BeaconDepositContract *deposit.WrappedBeaconDepositContract[ *types.Deposit, types.WithdrawalCredentials, ] - BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] + BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] + ChainSpec primitives.ChainSpec + DepositStore *depositdb.KVStore[*types.Deposit] + EngineClient *engineclient.EngineClient[*types.ExecutionPayload] + Logger log.Logger + TelemetrySink *metrics.TelemetrySink } // ProvideDepositService provides the deposit service to the depinject diff --git a/mod/node-core/pkg/components/deposit_store.go b/mod/node-core/pkg/components/deposit_store.go index c68dd59abf..f558c8561c 100644 --- a/mod/node-core/pkg/components/deposit_store.go +++ b/mod/node-core/pkg/components/deposit_store.go @@ -70,10 +70,10 @@ func ProvideDepositStore[ // DepositPrunerInput is the input for the deposit pruner. type DepositPrunerInput struct { depinject.In - Logger log.Logger - ChainSpec primitives.ChainSpec BlockFeed *event.FeedOf[*feed.Event[*types.BeaconBlock]] + ChainSpec primitives.ChainSpec DepositStore *depositstore.KVStore[*types.Deposit] + Logger log.Logger } // ProvideDepositPruner provides a deposit pruner for the depinject framework. diff --git a/mod/node-core/pkg/components/engine.go b/mod/node-core/pkg/components/engine.go index 0cf2586214..e7c45ec132 100644 --- a/mod/node-core/pkg/components/engine.go +++ b/mod/node-core/pkg/components/engine.go @@ -40,18 +40,11 @@ import ( // EngineClientInputs is the input for the EngineClient. type EngineClientInputs struct { depinject.In - // ChainSpec is the chain spec. - ChainSpec primitives.ChainSpec - // Config is the BeaconKit configuration. - Config *config.Config - // Logger is the logger. - Logger log.Logger - // TelemetrySink is the telemetry sink. + ChainSpec primitives.ChainSpec + Config *config.Config + JWTSecret *jwt.Secret `optional:"true"` + Logger log.Logger TelemetrySink *metrics.TelemetrySink - // JWTSecret is the jwt secret. It is optional, since - // it is not required when connecting to the execution client - // over IPC. - JWTSecret *jwt.Secret `optional:"true"` } // ProvideEngineClient creates a new EngineClient. diff --git a/mod/node-core/pkg/components/payload_builder.go b/mod/node-core/pkg/components/payload_builder.go index 560091a5ea..ed5259dc34 100644 --- a/mod/node-core/pkg/components/payload_builder.go +++ b/mod/node-core/pkg/components/payload_builder.go @@ -37,8 +37,8 @@ type LocalBuilderInput struct { depinject.In Cfg *config.Config ChainSpec primitives.ChainSpec - Logger log.Logger ExecutionEngine *execution.Engine[*types.ExecutionPayload] + Logger log.Logger } func ProvideLocalBuilder( diff --git a/mod/node-core/pkg/components/runtime.go b/mod/node-core/pkg/components/runtime.go index 57b54ff938..3a67159213 100644 --- a/mod/node-core/pkg/components/runtime.go +++ b/mod/node-core/pkg/components/runtime.go @@ -38,7 +38,6 @@ import ( "github.com/berachain/beacon-kit/mod/node-core/pkg/services/version" payloadbuilder "github.com/berachain/beacon-kit/mod/payload/pkg/builder" "github.com/berachain/beacon-kit/mod/primitives" - "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto" "github.com/berachain/beacon-kit/mod/primitives/pkg/feed" "github.com/berachain/beacon-kit/mod/primitives/pkg/transition" "github.com/berachain/beacon-kit/mod/runtime/pkg/runtime" @@ -105,7 +104,6 @@ type RuntimeInput struct { BeaconState, *types.ExecutionPayload, *types.ExecutionPayloadHeader, ] Logger log.Logger - Signer crypto.BLSSigner StateProcessor blockchain.StateProcessor[ *types.BeaconBlock, BeaconState, From 2d25f244d2666f6ca0b40e07f0f7305331249929 Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 12:24:11 -0400 Subject: [PATCH 3/6] l-l-lint --- mod/node-core/pkg/components/runtime.go | 1 - .../pkg/components/validator_service.go | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mod/node-core/pkg/components/runtime.go b/mod/node-core/pkg/components/runtime.go index 3a67159213..dc60135ba4 100644 --- a/mod/node-core/pkg/components/runtime.go +++ b/mod/node-core/pkg/components/runtime.go @@ -134,7 +134,6 @@ type RuntimeInput struct { func ProvideRuntime( in RuntimeInput, ) (*BeaconKitRuntime, error) { - // Build the blockchain service. chainService := blockchain.NewService[ *dastore.Store[*types.BeaconBlockBody], diff --git a/mod/node-core/pkg/components/validator_service.go b/mod/node-core/pkg/components/validator_service.go index b88290e886..ee38663808 100644 --- a/mod/node-core/pkg/components/validator_service.go +++ b/mod/node-core/pkg/components/validator_service.go @@ -1,3 +1,23 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + package components import ( From a85ce4c8ad4f7913e80702693cc1038d4eaf5114 Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 12:50:38 -0400 Subject: [PATCH 4/6] more cleanup --- .../pkg/components/module/depinject.go | 78 ++--------------- .../pkg/components/storage_backend.go | 84 +++++++++++++++++++ 2 files changed, 92 insertions(+), 70 deletions(-) create mode 100644 mod/node-core/pkg/components/storage_backend.go diff --git a/mod/node-core/pkg/components/module/depinject.go b/mod/node-core/pkg/components/module/depinject.go index 6093a9b971..7244441d78 100644 --- a/mod/node-core/pkg/components/module/depinject.go +++ b/mod/node-core/pkg/components/module/depinject.go @@ -24,18 +24,8 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" - "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" - dastore "github.com/berachain/beacon-kit/mod/da/pkg/store" - engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" "github.com/berachain/beacon-kit/mod/node-core/pkg/components" modulev1alpha1 "github.com/berachain/beacon-kit/mod/node-core/pkg/components/module/api/module/v1alpha1" - "github.com/berachain/beacon-kit/mod/node-core/pkg/components/storage" - "github.com/berachain/beacon-kit/mod/node-core/pkg/config" - "github.com/berachain/beacon-kit/mod/primitives" - "github.com/berachain/beacon-kit/mod/state-transition/pkg/core" - "github.com/berachain/beacon-kit/mod/storage/pkg/beacondb" - "github.com/berachain/beacon-kit/mod/storage/pkg/beacondb/encoding" - depositdb "github.com/berachain/beacon-kit/mod/storage/pkg/deposit" ) // TODO: we don't allow generics here? Why? Is it fixable? @@ -43,80 +33,28 @@ import ( //nolint:gochecknoinits // required by sdk. func init() { appconfig.RegisterModule(&modulev1alpha1.Module{}, - // TODO: make storage backend its own module and remove the - // coupling between construction of runtime and module appconfig.Provide( - ProvideStorageBackend, + components.ProvideStorageBackend, ProvideModule, ), ) } -// DepInjectInput is the input for the dep inject framework. -type DepInjectInput struct { +// ModuleInput is the input for the dep inject framework. +type ModuleInput struct { depinject.In - BeaconConfig *config.Config - Runtime *components.BeaconKitRuntime + Runtime *components.BeaconKitRuntime } -// DepInjectOutput is the output for the dep inject framework. -type DepInjectOutput struct { +// ModuleOutput is the output for the dep inject framework. +type ModuleOutput struct { depinject.Out Module appmodule.AppModule } // ProvideModule is a function that provides the module to the application. -func ProvideModule(in DepInjectInput) (DepInjectOutput, error) { - return DepInjectOutput{ +func ProvideModule(in ModuleInput) (ModuleOutput, error) { + return ModuleOutput{ Module: NewAppModule(in.Runtime), }, nil } - -// StorageBackendInput is the input for the ProvideStorageBackend function. -type StorageBackendInput struct { - depinject.In - ChainSpec primitives.ChainSpec - AvailabilityStore *dastore.Store[*types.BeaconBlockBody] - Environment appmodule.Environment - DepositStore *depositdb.KVStore[*types.Deposit] -} - -// ProvideStorageBackend is the depinject provider that returns a beacon storage -// backend. -func ProvideStorageBackend( - in StorageBackendInput, -) *storage.Backend[ - *dastore.Store[*types.BeaconBlockBody], - *types.BeaconBlock, - *types.BeaconBlockBody, - core.BeaconState[ - *types.BeaconBlockHeader, *types.Eth1Data, - *types.ExecutionPayloadHeader, *types.Fork, - *types.Validator, *engineprimitives.Withdrawal, - ], - *depositdb.KVStore[*types.Deposit], -] { - payloadCodec := &encoding. - SSZInterfaceCodec[*types.ExecutionPayloadHeader]{} - return storage.NewBackend[ - *dastore.Store[*types.BeaconBlockBody], - *types.BeaconBlock, - *types.BeaconBlockBody, - core.BeaconState[ - *types.BeaconBlockHeader, *types.Eth1Data, - *types.ExecutionPayloadHeader, *types.Fork, - *types.Validator, *engineprimitives.Withdrawal, - ], - ]( - in.ChainSpec, - in.AvailabilityStore, - beacondb.New[ - *types.Fork, - *types.BeaconBlockHeader, - *types.ExecutionPayloadHeader, - *types.Eth1Data, - *types.Validator, - ](in.Environment.KVStoreService, payloadCodec), - in.DepositStore, - ) -} diff --git a/mod/node-core/pkg/components/storage_backend.go b/mod/node-core/pkg/components/storage_backend.go new file mode 100644 index 0000000000..8c9c867ebe --- /dev/null +++ b/mod/node-core/pkg/components/storage_backend.go @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package components + +import ( + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" + "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" + dastore "github.com/berachain/beacon-kit/mod/da/pkg/store" + engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" + "github.com/berachain/beacon-kit/mod/node-core/pkg/components/storage" + "github.com/berachain/beacon-kit/mod/primitives" + "github.com/berachain/beacon-kit/mod/state-transition/pkg/core" + "github.com/berachain/beacon-kit/mod/storage/pkg/beacondb" + "github.com/berachain/beacon-kit/mod/storage/pkg/beacondb/encoding" + depositdb "github.com/berachain/beacon-kit/mod/storage/pkg/deposit" +) + +// StorageBackendInput is the input for the ProvideStorageBackend function. +type StorageBackendInput struct { + depinject.In + AvailabilityStore *dastore.Store[*types.BeaconBlockBody] + ChainSpec primitives.ChainSpec + DepositStore *depositdb.KVStore[*types.Deposit] + Environment appmodule.Environment +} + +// ProvideStorageBackend is the depinject provider that returns a beacon storage +// backend. +func ProvideStorageBackend( + in StorageBackendInput, +) *storage.Backend[ + *dastore.Store[*types.BeaconBlockBody], + *types.BeaconBlock, + *types.BeaconBlockBody, + core.BeaconState[ + *types.BeaconBlockHeader, *types.Eth1Data, + *types.ExecutionPayloadHeader, *types.Fork, + *types.Validator, *engineprimitives.Withdrawal, + ], + *depositdb.KVStore[*types.Deposit], +] { + payloadCodec := &encoding. + SSZInterfaceCodec[*types.ExecutionPayloadHeader]{} + return storage.NewBackend[ + *dastore.Store[*types.BeaconBlockBody], + *types.BeaconBlock, + *types.BeaconBlockBody, + core.BeaconState[ + *types.BeaconBlockHeader, *types.Eth1Data, + *types.ExecutionPayloadHeader, *types.Fork, + *types.Validator, *engineprimitives.Withdrawal, + ], + ]( + in.ChainSpec, + in.AvailabilityStore, + beacondb.New[ + *types.Fork, + *types.BeaconBlockHeader, + *types.ExecutionPayloadHeader, + *types.Eth1Data, + *types.Validator, + ](in.Environment.KVStoreService, payloadCodec), + in.DepositStore, + ) +} From 636ad038e603eda90895e0bf07eae4c19e1ae0a2 Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 13:07:22 -0400 Subject: [PATCH 5/6] bet --- mod/node-core/pkg/builder/builder.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/mod/node-core/pkg/builder/builder.go b/mod/node-core/pkg/builder/builder.go index 99a6afb8e3..46b555f61b 100644 --- a/mod/node-core/pkg/builder/builder.go +++ b/mod/node-core/pkg/builder/builder.go @@ -29,14 +29,9 @@ import ( "github.com/berachain/beacon-kit/mod/beacon/blockchain" cmdlib "github.com/berachain/beacon-kit/mod/cli/pkg/commands" consensustypes "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" - "github.com/berachain/beacon-kit/mod/da/pkg/kzg/noop" dastore "github.com/berachain/beacon-kit/mod/da/pkg/store" datypes "github.com/berachain/beacon-kit/mod/da/pkg/types" - engineclient "github.com/berachain/beacon-kit/mod/execution/pkg/client" - "github.com/berachain/beacon-kit/mod/execution/pkg/deposit" "github.com/berachain/beacon-kit/mod/node-core/pkg/components" - "github.com/berachain/beacon-kit/mod/node-core/pkg/components/metrics" - "github.com/berachain/beacon-kit/mod/node-core/pkg/components/signer" "github.com/berachain/beacon-kit/mod/node-core/pkg/node" "github.com/berachain/beacon-kit/mod/node-core/pkg/types" "github.com/berachain/beacon-kit/mod/primitives" @@ -46,7 +41,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/types/module" - gokzg4844 "github.com/crate-crypto/go-kzg-4844" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -108,17 +102,6 @@ func (nb *NodeBuilder[NodeT]) buildRootCmd() (*cobra.Command, error) { log.NewLogger(os.Stdout), viper.GetViper(), nb.chainSpec, - &depositdb.KVStore[*consensustypes.Deposit]{}, - &engineclient.EngineClient[*consensustypes.ExecutionPayload]{}, - &gokzg4844.JSONTrustedSetup{}, - &noop.Verifier{}, - &dastore.Store[*consensustypes.BeaconBlockBody]{}, - &signer.BLSSigner{}, - &metrics.TelemetrySink{}, - &deposit.WrappedBeaconDepositContract[ - *consensustypes.Deposit, - consensustypes.WithdrawalCredentials, - ]{}, &runtime.BeaconKitRuntime[ *dastore.Store[*consensustypes.BeaconBlockBody], *consensustypes.BeaconBlock, @@ -141,15 +124,6 @@ func (nb *NodeBuilder[NodeT]) buildRootCmd() (*cobra.Command, error) { components.ProvideClientContext, components.ProvideKeyring, components.ProvideConfig, - components.ProvideLocalBuilder, - components.ProvideStateProcessor, - components.ProvideExecutionEngine[*consensustypes.ExecutionPayload], - components.ProvideBlockFeed[*consensustypes.BeaconBlock], - components.ProvideDepositPruner, - components.ProvideAvailabilityPruner, - components.ProvideBlobProcessor[*consensustypes.BeaconBlockBody], - components.ProvideDBManager, - components.ProvideDepositService, ), ), &autoCliOpts, From 96eaa6026fdc596c90089591336ffe1c0a325ebf Mon Sep 17 00:00:00 2001 From: ocnc-two Date: Tue, 11 Jun 2024 13:35:45 -0400 Subject: [PATCH 6/6] lint --- mod/node-core/pkg/builder/builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/node-core/pkg/builder/builder.go b/mod/node-core/pkg/builder/builder.go index 46b555f61b..f1b5ae2984 100644 --- a/mod/node-core/pkg/builder/builder.go +++ b/mod/node-core/pkg/builder/builder.go @@ -81,7 +81,7 @@ func (nb *NodeBuilder[NodeT]) Build() (NodeT, error) { // buildRootCmd builds the root command for the application. // -//nolint:funlen // fix later + func (nb *NodeBuilder[NodeT]) buildRootCmd() (*cobra.Command, error) { var ( autoCliOpts autocli.AppOptions