diff --git a/mod/beacon/blockchain/execution_engine.go b/mod/beacon/blockchain/execution_engine.go index d937c207e4..49a9f7b988 100644 --- a/mod/beacon/blockchain/execution_engine.go +++ b/mod/beacon/blockchain/execution_engine.go @@ -29,7 +29,7 @@ import ( // sendPostBlockFCU sends a forkchoice update to the execution client. func (s *Service[ - _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, ]) sendPostBlockFCU( ctx context.Context, st BeaconStateT, @@ -55,7 +55,7 @@ func (s *Service[ // client with attributes. func (s *Service[ _, BeaconBlockT, _, _, BeaconStateT, - _, _, _, ExecutionPayloadHeaderT, _, _, _, + _, _, ExecutionPayloadHeaderT, _, _, _, ]) sendNextFCUWithAttributes( ctx context.Context, st BeaconStateT, @@ -92,7 +92,7 @@ func (s *Service[ // sendNextFCUWithoutAttributes sends a forkchoice update to the // execution client without attributes. func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, ExecutionPayloadHeaderT, _, PayloadAttributesT, _, ]) sendNextFCUWithoutAttributes( ctx context.Context, @@ -124,7 +124,7 @@ func (s *Service[ // // TODO: This is hood and needs to be improved. func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) calculateNextTimestamp(blk BeaconBlockT) uint64 { //#nosec:G701 // not an issue in practice. return max( diff --git a/mod/beacon/blockchain/payload.go b/mod/beacon/blockchain/payload.go index 59917e12ec..ba000a8c3d 100644 --- a/mod/beacon/blockchain/payload.go +++ b/mod/beacon/blockchain/payload.go @@ -29,7 +29,7 @@ import ( // forceStartupHead sends a force head FCU to the execution client. func (s *Service[ - _, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, _, _, BeaconStateT, _, _, _, _, _, _, ]) forceStartupHead( ctx context.Context, st BeaconStateT, @@ -57,7 +57,7 @@ func (s *Service[ // handleRebuildPayloadForRejectedBlock handles the case where the incoming // block was rejected and we need to rebuild the payload for the current slot. func (s *Service[ - _, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, _, _, BeaconStateT, _, _, _, _, _, _, ]) handleRebuildPayloadForRejectedBlock( ctx context.Context, st BeaconStateT, @@ -80,7 +80,7 @@ func (s *Service[ // rejected the incoming block and it would be unsafe to use any // information from it. func (s *Service[ - _, _, _, _, BeaconStateT, _, _, _, ExecutionPayloadHeaderT, _, _, _, + _, _, _, _, BeaconStateT, _, _, ExecutionPayloadHeaderT, _, _, _, ]) rebuildPayloadForRejectedBlock( ctx context.Context, st BeaconStateT, @@ -147,7 +147,7 @@ func (s *Service[ // handleOptimisticPayloadBuild handles optimistically // building for the next slot. func (s *Service[ - _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, ]) handleOptimisticPayloadBuild( ctx context.Context, st BeaconStateT, @@ -164,7 +164,7 @@ func (s *Service[ // optimisticPayloadBuild builds a payload for the next slot. func (s *Service[ - _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, ]) optimisticPayloadBuild( ctx context.Context, st BeaconStateT, diff --git a/mod/beacon/blockchain/process.go b/mod/beacon/blockchain/process.go index b4beb943cb..15fcbde193 100644 --- a/mod/beacon/blockchain/process.go +++ b/mod/beacon/blockchain/process.go @@ -32,7 +32,7 @@ import ( // ProcessGenesisData processes the genesis state and initializes the beacon // state. func (s *Service[ - _, _, _, _, _, _, _, _, _, GenesisT, _, _, + _, _, _, _, _, _, _, _, GenesisT, _, _, ]) ProcessGenesisData( ctx context.Context, genesisData GenesisT, @@ -48,7 +48,7 @@ func (s *Service[ // ProcessBeaconBlock receives an incoming beacon block, it first validates // and then processes the block. func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) ProcessBeaconBlock( ctx context.Context, blk BeaconBlockT, @@ -98,7 +98,7 @@ func (s *Service[ // executeStateTransition runs the stf. func (s *Service[ - _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, ]) executeStateTransition( ctx context.Context, st BeaconStateT, diff --git a/mod/beacon/blockchain/receive.go b/mod/beacon/blockchain/receive.go index 4f3ecede1f..6fdbab00d9 100644 --- a/mod/beacon/blockchain/receive.go +++ b/mod/beacon/blockchain/receive.go @@ -32,7 +32,7 @@ import ( // ReceiveBlock receives a block and blobs from the // network and processes them. func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) ReceiveBlock( ctx context.Context, blk BeaconBlockT, @@ -43,7 +43,7 @@ func (s *Service[ // VerifyIncomingBlock verifies the state root of an incoming block // and logs the process. func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) VerifyIncomingBlock( ctx context.Context, blk BeaconBlockT, @@ -110,7 +110,7 @@ func (s *Service[ // verifyStateRoot verifies the state root of an incoming block. func (s *Service[ - _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, ]) verifyStateRoot( ctx context.Context, st BeaconStateT, @@ -146,7 +146,7 @@ func (s *Service[ // shouldBuildOptimisticPayloads returns true if optimistic // payload builds are enabled. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, ]) shouldBuildOptimisticPayloads() bool { return s.optimisticPayloadBuilds && s.lb.Enabled() } diff --git a/mod/beacon/blockchain/service.go b/mod/beacon/blockchain/service.go index 3193d4f927..ad500f51e1 100644 --- a/mod/beacon/blockchain/service.go +++ b/mod/beacon/blockchain/service.go @@ -33,14 +33,13 @@ import ( // Service is the blockchain service. type Service[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT], BeaconBlockT BeaconBlock[BeaconBlockBodyT, ExecutionPayloadT], BeaconBlockBodyT BeaconBlockBody[ExecutionPayloadT], BeaconBlockHeaderT BeaconBlockHeader, BeaconStateT ReadOnlyBeaconState[ BeaconStateT, BeaconBlockHeaderT, ExecutionPayloadHeaderT, ], - BlobSidecarsT BlobSidecars, DepositT any, ExecutionPayloadT ExecutionPayload, ExecutionPayloadHeaderT ExecutionPayloadHeader, @@ -58,7 +57,6 @@ type Service[ AvailabilityStoreT, BeaconBlockBodyT, BeaconStateT, - BlobSidecarsT, ] // logger is used for logging messages in the service. logger log.Logger[any] @@ -73,7 +71,6 @@ type Service[ sp StateProcessor[ BeaconBlockT, BeaconStateT, - BlobSidecarsT, *transition.Context, DepositT, ExecutionPayloadHeaderT, @@ -95,7 +92,7 @@ type Service[ // NewService creates a new validator service. func NewService[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT], BeaconBlockT BeaconBlock[BeaconBlockBodyT, ExecutionPayloadT], BeaconBlockBodyT BeaconBlockBody[ExecutionPayloadT], BeaconBlockHeaderT BeaconBlockHeader, @@ -103,7 +100,6 @@ func NewService[ BeaconStateT, BeaconBlockHeaderT, ExecutionPayloadHeaderT, ], - BlobSidecarsT BlobSidecars, DepositT any, ExecutionPayloadT ExecutionPayload, ExecutionPayloadHeaderT ExecutionPayloadHeader, @@ -119,7 +115,6 @@ func NewService[ AvailabilityStoreT, BeaconBlockBodyT, BeaconStateT, - BlobSidecarsT, ], logger log.Logger[any], cs common.ChainSpec, @@ -128,7 +123,6 @@ func NewService[ sp StateProcessor[ BeaconBlockT, BeaconStateT, - BlobSidecarsT, *transition.Context, DepositT, ExecutionPayloadHeaderT, @@ -141,13 +135,13 @@ func NewService[ optimisticPayloadBuilds bool, ) *Service[ AvailabilityStoreT, BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT, - BeaconStateT, BlobSidecarsT, DepositT, ExecutionPayloadT, - ExecutionPayloadHeaderT, GenesisT, PayloadAttributesT, WithdrawalT, + BeaconStateT, DepositT, ExecutionPayloadT, ExecutionPayloadHeaderT, + GenesisT, PayloadAttributesT, WithdrawalT, ] { return &Service[ AvailabilityStoreT, BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT, - BeaconStateT, BlobSidecarsT, DepositT, ExecutionPayloadT, - ExecutionPayloadHeaderT, GenesisT, PayloadAttributesT, WithdrawalT, + BeaconStateT, DepositT, ExecutionPayloadT, ExecutionPayloadHeaderT, + GenesisT, PayloadAttributesT, WithdrawalT, ]{ sb: sb, logger: logger, @@ -166,13 +160,13 @@ func NewService[ // Name returns the name of the service. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, ]) Name() string { return "blockchain" } func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, ]) Start(ctx context.Context) error { subBlkCh, err := s.blkBroker.Subscribe() if err != nil { @@ -187,7 +181,7 @@ func (s *Service[ } func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, GenesisT, _, _, + _, BeaconBlockT, _, _, _, _, _, _, GenesisT, _, _, ]) start( ctx context.Context, subBlkCh chan *asynctypes.Event[BeaconBlockT], @@ -213,7 +207,7 @@ func (s *Service[ } func (s *Service[ - _, _, _, _, _, _, _, _, _, GenesisT, _, _, + _, _, _, _, _, _, _, _, GenesisT, _, _, ]) handleProcessGenesisDataRequest(msg *asynctypes.Event[GenesisT]) { if msg.Error() != nil { s.logger.Error("Error processing genesis data", "error", msg.Error()) @@ -245,7 +239,7 @@ func (s *Service[ } func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) handleBeaconBlockReceived( msg *asynctypes.Event[BeaconBlockT], ) { @@ -270,7 +264,7 @@ func (s *Service[ } func (s *Service[ - _, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, + _, BeaconBlockT, _, _, _, _, _, _, _, _, _, ]) handleBeaconBlockFinalization( msg *asynctypes.Event[BeaconBlockT], ) { diff --git a/mod/beacon/blockchain/types.go b/mod/beacon/blockchain/types.go index 3b729b8321..e661704fe6 100644 --- a/mod/beacon/blockchain/types.go +++ b/mod/beacon/blockchain/types.go @@ -34,7 +34,7 @@ import ( // AvailabilityStore interface is responsible for validating and storing // sidecars for specific blocks, as well as verifying sidecars that have already // been stored. -type AvailabilityStore[BeaconBlockBodyT any, BlobSidecarsT any] interface { +type AvailabilityStore[BeaconBlockBodyT any] interface { // IsDataAvailable ensures that all blobs referenced in the block are // securely stored before it returns without an error. IsDataAvailable( @@ -179,7 +179,6 @@ type ReadOnlyBeaconState[ type StateProcessor[ BeaconBlockT, BeaconStateT, - BlobSidecarsT, ContextT, DepositT, ExecutionPayloadHeaderT any, @@ -208,10 +207,9 @@ type StateProcessor[ // StorageBackend defines an interface for accessing various storage components // required by the beacon node. type StorageBackend[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT], BeaconBlockBodyT, - BeaconStateT, - BlobSidecarsT any, + BeaconStateT any, ] interface { // AvailabilityStore returns the availability store for the given context. AvailabilityStore() AvailabilityStoreT diff --git a/mod/beacon/interfaces.go b/mod/beacon/interfaces.go deleted file mode 100644 index ebecf879a5..0000000000 --- a/mod/beacon/interfaces.go +++ /dev/null @@ -1,72 +0,0 @@ -// 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 beacon - -import ( - "context" - - "github.com/berachain/beacon-kit/mod/primitives/pkg/math" -) - -// AvailabilityStore interface is responsible for validating and storing -// sidecars for specific blocks, as well as verifying sidecars that have already -// been stored. -type AvailabilityStore[BeaconBlockBodyT any, BlobSidecarsT any] interface { - // IsDataAvailable ensures that all blobs referenced in the block are - // securely stored before it returns without an error. - IsDataAvailable( - context.Context, math.Slot, BeaconBlockBodyT, - ) bool - // Persist makes sure that the sidecar remains accessible for data - // availability checks throughout the beacon node's operation. - Persist(math.Slot, BlobSidecarsT) error -} - -// DepositStore defines the interface for deposit storage. -type DepositStore[DepositT any] interface { - // GetDepositsByIndex returns `numView` expected deposits. - GetDepositsByIndex( - startIndex uint64, - numView uint64, - ) ([]DepositT, error) - // Prune prunes the deposit store of [start, end) - Prune(start, end uint64) error - // EnqueueDeposits adds a list of deposits to the deposit store. - EnqueueDeposits(deposits []DepositT) error -} - -// StorageBackend defines an interface for accessing various storage components -// required by the beacon node. -type StorageBackend[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], - BeaconBlockBodyT, - BeaconStateT, - BlobSidecarsT, - DepositT any, - DepositStoreT DepositStore[DepositT], -] interface { - // AvailabilityStore returns the availability store for the given context. - AvailabilityStore() AvailabilityStoreT - // DepositStore retrieves the deposit store. - DepositStore() DepositStoreT - // StateFromContext retrieves the beacon state from the given context. - StateFromContext(context.Context) BeaconStateT -} diff --git a/mod/node-core/pkg/components/chain_service.go b/mod/node-core/pkg/components/chain_service.go index e843c7a442..3de0cbe7b4 100644 --- a/mod/node-core/pkg/components/chain_service.go +++ b/mod/node-core/pkg/components/chain_service.go @@ -61,7 +61,6 @@ func ProvideChainService( *BeaconBlockBody, *BeaconBlockHeader, *BeaconState, - *BlobSidecars, *Deposit, *ExecutionPayload, *ExecutionPayloadHeader, diff --git a/mod/node-core/pkg/components/types.go b/mod/node-core/pkg/components/types.go index e6d6b1cb47..960117f724 100644 --- a/mod/node-core/pkg/components/types.go +++ b/mod/node-core/pkg/components/types.go @@ -151,7 +151,6 @@ type ( *BeaconBlockBody, *BeaconBlockHeader, *BeaconState, - *BlobSidecars, *Deposit, *ExecutionPayload, *ExecutionPayloadHeader,