From 6b239b6d797aeb1b7441afbc038e4a36fe98a0a8 Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Mon, 9 Dec 2024 16:19:11 +0000 Subject: [PATCH] throwaway: Use concrete types for blocks, does not compile --- beacon/blockchain/deposit.go | 6 +- beacon/blockchain/execution_engine.go | 14 +-- beacon/blockchain/payload.go | 15 +-- beacon/blockchain/process.go | 66 +++++++++++-- beacon/blockchain/pruning.go | 5 +- beacon/blockchain/receive.go | 15 +-- beacon/blockchain/service.go | 57 ++++++++---- beacon/blockchain/types.go | 15 ++- cmd/beacond/defaults.go | 3 +- cmd/beacond/types.go | 2 + consensus/cometbft/service/middleware/abci.go | 15 ++- .../cometbft/service/middleware/middleware.go | 5 +- .../cometbft/service/process_proposal.go | 92 +++++++++++++++---- consensus/cometbft/service/service.go | 2 + da/blob/processor.go | 8 +- da/blob/types.go | 5 +- node-api/backend/backend.go | 8 +- node-api/backend/types.go | 5 +- node-api/block_store/types.go | 5 +- node-core/components/api.go | 2 +- node-core/components/blobs.go | 4 +- node-core/components/chain_service.go | 27 ++++-- node-core/components/interfaces.go | 6 +- node-core/components/service_registry.go | 12 ++- 24 files changed, 277 insertions(+), 117 deletions(-) diff --git a/beacon/blockchain/deposit.go b/beacon/blockchain/deposit.go index 0e3b790d88..45b440fb83 100644 --- a/beacon/blockchain/deposit.go +++ b/beacon/blockchain/deposit.go @@ -34,7 +34,7 @@ import ( const defaultRetryInterval = 20 * time.Second func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) depositFetcher( ctx context.Context, blockNum math.U64, @@ -52,7 +52,7 @@ func (s *Service[ } func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) fetchAndStoreDeposits( ctx context.Context, blockNum math.U64, @@ -92,7 +92,7 @@ func (s *Service[ } func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) depositCatchupFetcher(ctx context.Context) { ticker := time.NewTicker(defaultRetryInterval) defer ticker.Stop() diff --git a/beacon/blockchain/execution_engine.go b/beacon/blockchain/execution_engine.go index c0d5d5bb22..25eae1015e 100644 --- a/beacon/blockchain/execution_engine.go +++ b/beacon/blockchain/execution_engine.go @@ -26,16 +26,18 @@ import ( payloadtime "github.com/berachain/beacon-kit/beacon/payload-time" "github.com/berachain/beacon-kit/config/spec" + "github.com/berachain/beacon-kit/consensus-types/types" + consensusTypes "github.com/berachain/beacon-kit/consensus/types" engineprimitives "github.com/berachain/beacon-kit/engine-primitives/engine-primitives" ) // sendPostBlockFCU sends a forkchoice update to the execution client. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) sendPostBlockFCU( ctx context.Context, st BeaconStateT, - blk ConsensusBlockT, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], ) { lph, err := st.GetLatestExecutionPayloadHeader() if err != nil { @@ -57,11 +59,11 @@ func (s *Service[ // client with attributes. func (s *Service[ _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, - _, _, ExecutionPayloadHeaderT, _, _, + _, _, ExecutionPayloadHeaderT, _, _, _, _, ]) sendNextFCUWithAttributes( ctx context.Context, st BeaconStateT, - blk ConsensusBlockT, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], lph ExecutionPayloadHeaderT, ) { beaconBlk := blk.GetBeaconBlock() @@ -115,10 +117,10 @@ func (s *Service[ // execution client without attributes. func (s *Service[ _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, - ExecutionPayloadHeaderT, _, PayloadAttributesT, + ExecutionPayloadHeaderT, _, _, _, PayloadAttributesT, ]) sendNextFCUWithoutAttributes( ctx context.Context, - blk ConsensusBlockT, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], lph ExecutionPayloadHeaderT, ) { beaconBlk := blk.GetBeaconBlock() diff --git a/beacon/blockchain/payload.go b/beacon/blockchain/payload.go index 2d33d4a471..092827b9b3 100644 --- a/beacon/blockchain/payload.go +++ b/beacon/blockchain/payload.go @@ -23,12 +23,13 @@ package blockchain import ( "context" + "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/primitives/math" ) // forceStartupHead sends a force head FCU to the execution client. func (s *Service[ - _, _, _, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, _, _, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) forceStartupHead( ctx context.Context, st BeaconStateT, @@ -56,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, @@ -82,7 +83,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, @@ -140,11 +141,11 @@ func (s *Service[ // handleOptimisticPayloadBuild handles optimistically // building for the next slot. func (s *Service[ - _, _, _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) handleOptimisticPayloadBuild( ctx context.Context, st BeaconStateT, - blk BeaconBlockT, + blk *types.BeaconBlock, nextPayloadTimestamp math.U64, ) { if err := s.optimisticPayloadBuild( @@ -163,11 +164,11 @@ func (s *Service[ // optimisticPayloadBuild builds a payload for the next slot. func (s *Service[ - _, _, _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, _, BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) optimisticPayloadBuild( ctx context.Context, st BeaconStateT, - blk BeaconBlockT, + blk *types.BeaconBlock, nextPayloadTimestamp math.U64, ) error { // We are building for the next slot, so we increment the slot relative diff --git a/beacon/blockchain/process.go b/beacon/blockchain/process.go index d9d77aa350..77b7eea23b 100644 --- a/beacon/blockchain/process.go +++ b/beacon/blockchain/process.go @@ -25,13 +25,17 @@ import ( "encoding/json" "time" + "github.com/berachain/beacon-kit/consensus-types/types" + consensusTypes "github.com/berachain/beacon-kit/consensus/types" + datypes "github.com/berachain/beacon-kit/da/types" "github.com/berachain/beacon-kit/primitives/transition" + cmtabci "github.com/cometbft/cometbft/abci/types" ) // ProcessGenesisData processes the genesis state and initializes the beacon // state. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, GenesisT, _, + _, _, _, _, _, _, _, _, _, _, _, _, GenesisT, _, _, _, ]) ProcessGenesisData( ctx context.Context, bytes []byte, @@ -49,13 +53,63 @@ func (s *Service[ ) } +func (s *Service[ + _, _, ConsensusBlockT, BeaconBlockT, _, _, _, _, _, _, _, _, GenesisT, ConsensusSidecarsT, _, _, +]) ProcessProposal( + ctx context.Context, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], + cs *consensusTypes.ConsensusSidecars[*datypes.BlobSidecars, *types.BeaconBlockHeader], +) (*cmtabci.ProcessProposalResponse, error) { + s.logger.Info("!!!!!!!! ProcessProposal called") + s.logger.Info("blk", blk) + s.logger.Info("sidecars", cs) + + // verifySidecars + // + sidecars := cs.GetSidecars() + if !sidecars.IsNil() && sidecars.Len() > 0 { + s.logger.Info("Received incoming blob sidecars") + + // TODO: Remove this once we cleanup generics + var sidecarI interface{} = cs + data, ok := sidecarI.(ConsensusSidecarsT) + if !ok { + panic("could not convert sidecar to ConsensusSidecarsT") + } + + // Verify the blobs and ensure they match the local state. + if err := s.blobProcessor.VerifySidecars(data); err != nil { + s.logger.Error( + "rejecting incoming blob sidecars", + "reason", err, + ) + return nil, err + } + + s.logger.Info( + "Blob sidecars verification succeeded - accepting incoming blob sidecars", + "num_blobs", + sidecars.Len(), + ) + } + + err := s.VerifyIncomingBlock(ctx, blk) + if err != nil { + s.logger.Error("failed to verify incoming block", "error", err) + return nil, err + } + + return nil, nil + +} + // ProcessBeaconBlock receives an incoming beacon block, it first validates // and then processes the block. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) ProcessBeaconBlock( ctx context.Context, - blk ConsensusBlockT, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], ) (transition.ValidatorUpdates, error) { beaconBlk := blk.GetBeaconBlock() @@ -104,11 +158,11 @@ func (s *Service[ // executeStateTransition runs the stf. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) executeStateTransition( ctx context.Context, st BeaconStateT, - blk ConsensusBlockT, + blk consensusTypes.ConsensusBlock[*types.BeaconBlock], ) (transition.ValidatorUpdates, error) { startTime := time.Now() defer s.metrics.measureStateTransitionDuration(startTime) @@ -142,7 +196,7 @@ func (s *Service[ ConsensusTime: blk.GetConsensusTime(), }, st, - blk.GetBeaconBlock(), + *blk.GetBeaconBlock(), ) return valUpdates, err } diff --git a/beacon/blockchain/pruning.go b/beacon/blockchain/pruning.go index 8973c0c0b7..db4a169357 100644 --- a/beacon/blockchain/pruning.go +++ b/beacon/blockchain/pruning.go @@ -21,14 +21,15 @@ package blockchain import ( + "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/execution/deposit" "github.com/berachain/beacon-kit/primitives/common" "github.com/berachain/beacon-kit/primitives/math" ) func (s *Service[ - _, _, ConsensusBlockT, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, -]) processPruning(beaconBlk BeaconBlockT) error { + _, _, ConsensusBlockT, BeaconBlockT, _, _, _, _, _, _, _, _, _, _, _, _, +]) processPruning(beaconBlk *types.BeaconBlock) error { // prune availability store start, end := availabilityPruneRangeFn( beaconBlk.GetSlot().Unwrap(), s.chainSpec) diff --git a/beacon/blockchain/receive.go b/beacon/blockchain/receive.go index b33e1fd26e..67dfae31ff 100644 --- a/beacon/blockchain/receive.go +++ b/beacon/blockchain/receive.go @@ -25,6 +25,8 @@ import ( "time" payloadtime "github.com/berachain/beacon-kit/beacon/payload-time" + "github.com/berachain/beacon-kit/consensus-types/types" + ctypes "github.com/berachain/beacon-kit/consensus/types" engineerrors "github.com/berachain/beacon-kit/engine-primitives/errors" "github.com/berachain/beacon-kit/errors" "github.com/berachain/beacon-kit/primitives/transition" @@ -34,10 +36,10 @@ import ( // and logs the process. func (s *Service[ _, _, ConsensusBlockT, BeaconBlockT, _, _, _, _, _, _, _, - ExecutionPayloadHeaderT, _, _, + ExecutionPayloadHeaderT, _, _, _, _, ]) VerifyIncomingBlock( ctx context.Context, - blk ConsensusBlockT, + blk ctypes.ConsensusBlock[*types.BeaconBlock], ) error { var ( beaconBlk = blk.GetBeaconBlock() @@ -132,15 +134,16 @@ func (s *Service[ // verifyStateRoot verifies the state root of an incoming block. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, ]) verifyStateRoot( ctx context.Context, st BeaconStateT, - blk ConsensusBlockT, + blk ctypes.ConsensusBlock[*types.BeaconBlock], ) error { startTime := time.Now() defer s.metrics.measureStateRootVerificationTime(startTime) _, err := s.stateProcessor.Transition( + // We run with a non-optimistic engine here to ensure // that the proposer does not try to push through a bad block. &transition.Context{ @@ -152,7 +155,7 @@ func (s *Service[ ProposerAddress: blk.GetProposerAddress(), ConsensusTime: blk.GetConsensusTime(), }, - st, blk.GetBeaconBlock(), + st, *blk.GetBeaconBlock(), ) if errors.Is(err, engineerrors.ErrAcceptedPayloadStatus) { // It is safe for the validator to ignore this error since @@ -169,7 +172,7 @@ func (s *Service[ // shouldBuildOptimisticPayloads returns true if optimistic // payload builds are enabled. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) shouldBuildOptimisticPayloads() bool { return s.optimisticPayloadBuilds && s.localBuilder.Enabled() } diff --git a/beacon/blockchain/service.go b/beacon/blockchain/service.go index 35d4e35b58..fc0fbe46b1 100644 --- a/beacon/blockchain/service.go +++ b/beacon/blockchain/service.go @@ -25,6 +25,9 @@ import ( "sync" asynctypes "github.com/berachain/beacon-kit/async/types" + "github.com/berachain/beacon-kit/consensus-types/types" + ctypes "github.com/berachain/beacon-kit/consensus/types" + "github.com/berachain/beacon-kit/da/da" "github.com/berachain/beacon-kit/execution/deposit" "github.com/berachain/beacon-kit/log" "github.com/berachain/beacon-kit/node-api/backend" @@ -38,7 +41,7 @@ import ( // Service is the blockchain service. type Service[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT], + AvailabilityStoreT AvailabilityStore, DepositStoreT backend.DepositStore[DepositT], ConsensusBlockT ConsensusBlock[BeaconBlockT], BeaconBlockT BeaconBlock[BeaconBlockBodyT], @@ -51,12 +54,14 @@ type Service[ BeaconStateT ReadOnlyBeaconState[ BeaconStateT, BeaconBlockHeaderT, ExecutionPayloadHeaderT, ], - BlockStoreT blockstore.BlockStore[BeaconBlockT], + BlockStoreT blockstore.BlockStore[*types.BeaconBlock], DepositT deposit.Deposit[DepositT, WithdrawalCredentialsT], WithdrawalCredentialsT any, ExecutionPayloadT ExecutionPayload, ExecutionPayloadHeaderT ExecutionPayloadHeader, GenesisT Genesis[DepositT, ExecutionPayloadHeaderT], + ConsensusSidecarsT da.ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], + BlobSidecarsT da.BlobSidecar, PayloadAttributesT PayloadAttributes, ] struct { // homeDir is the directory for config and data" @@ -68,6 +73,10 @@ type Service[ BeaconStateT, DepositStoreT, ] + blobProcessor da.BlobProcessor[ + AvailabilityStoreT, + ConsensusSidecarsT, BlobSidecarsT, + ] // store is the block store for the service. // TODO: Remove this and use the block store from the storage backend. blockStore BlockStoreT @@ -112,14 +121,14 @@ type Service[ forceStartupSyncOnce *sync.Once // subFinalBlkReceived is a channel holding FinalBeaconBlockReceived events. - subFinalBlkReceived chan async.Event[ConsensusBlockT] + subFinalBlkReceived chan async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]] // subBlockReceived is a channel holding BeaconBlockReceived events. - subBlockReceived chan async.Event[ConsensusBlockT] + subBlockReceived chan async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]] } // NewService creates a new validator service. func NewService[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT], + AvailabilityStoreT AvailabilityStore, DepositStoreT backend.DepositStore[DepositT], ConsensusBlockT ConsensusBlock[BeaconBlockT], BeaconBlockT BeaconBlock[BeaconBlockBodyT], @@ -133,13 +142,15 @@ func NewService[ BeaconStateT, BeaconBlockHeaderT, ExecutionPayloadHeaderT, ], - BlockStoreT blockstore.BlockStore[BeaconBlockT], + BlockStoreT blockstore.BlockStore[*types.BeaconBlock], DepositT deposit.Deposit[DepositT, WithdrawalCredentialsT], WithdrawalCredentialsT any, ExecutionPayloadT ExecutionPayload, ExecutionPayloadHeaderT ExecutionPayloadHeader, GenesisT Genesis[DepositT, ExecutionPayloadHeaderT], PayloadAttributesT PayloadAttributes, + ConsensusSidecarsT da.ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], + BlobSidecarsT da.BlobSidecar, ]( homeDir string, storageBackend StorageBackend[ @@ -147,6 +158,10 @@ func NewService[ BeaconStateT, DepositStoreT, ], + blobProcessor da.BlobProcessor[ + AvailabilityStoreT, + ConsensusSidecarsT, BlobSidecarsT, + ], blockStore BlockStoreT, depositStore deposit.Store[DepositT], depositContract deposit.Contract[DepositT], @@ -157,7 +172,7 @@ func NewService[ executionEngine ExecutionEngine[PayloadAttributesT], localBuilder LocalBuilder[BeaconStateT], stateProcessor StateProcessor[ - BeaconBlockT, + *types.BeaconBlock, BeaconStateT, *transition.Context, DepositT, @@ -169,17 +184,19 @@ func NewService[ AvailabilityStoreT, DepositStoreT, ConsensusBlockT, BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT, BeaconStateT, BlockStoreT, DepositT, WithdrawalCredentialsT, - ExecutionPayloadT, ExecutionPayloadHeaderT, GenesisT, PayloadAttributesT, + ExecutionPayloadT, ExecutionPayloadHeaderT, GenesisT, + ConsensusSidecarsT, BlobSidecarsT, PayloadAttributesT, ] { return &Service[ AvailabilityStoreT, DepositStoreT, ConsensusBlockT, BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT, BeaconStateT, BlockStoreT, DepositT, WithdrawalCredentialsT, ExecutionPayloadT, ExecutionPayloadHeaderT, - GenesisT, PayloadAttributesT, + GenesisT, ConsensusSidecarsT, BlobSidecarsT, PayloadAttributesT, ]{ homeDir: homeDir, storageBackend: storageBackend, + blobProcessor: blobProcessor, blockStore: blockStore, depositStore: depositStore, depositContract: depositContract, @@ -194,14 +211,14 @@ func NewService[ metrics: newChainMetrics(telemetrySink), optimisticPayloadBuilds: optimisticPayloadBuilds, forceStartupSyncOnce: new(sync.Once), - subFinalBlkReceived: make(chan async.Event[ConsensusBlockT]), - subBlockReceived: make(chan async.Event[ConsensusBlockT]), + subFinalBlkReceived: make(chan async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]]), + subBlockReceived: make(chan async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]]), } } // Name returns the name of the service. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) Name() string { return "blockchain" } @@ -210,7 +227,7 @@ func (s *Service[ // BeaconBlockReceived, and FinalBeaconBlockReceived events, and begins // the main event loop to handle them accordingly. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) Start(ctx context.Context) error { if err := s.dispatcher.Subscribe( async.BeaconBlockReceived, s.subBlockReceived, @@ -235,7 +252,7 @@ func (s *Service[ // eventLoop listens for events and handles them accordingly. func (s *Service[ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) eventLoop(ctx context.Context) { for { select { @@ -256,9 +273,9 @@ func (s *Service[ // handleBeaconBlockReceived emits a BeaconBlockVerified event with the error // result from VerifyIncomingBlock. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) handleBeaconBlockReceived( - msg async.Event[ConsensusBlockT], + msg async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]], ) { // If the block is nil, exit early. if msg.Error() != nil { @@ -266,13 +283,15 @@ func (s *Service[ return } + data := msg.Data() + // emit a BeaconBlockVerified event with // the error result from VerifyIncomingBlock if err := s.dispatcher.Publish( async.NewEvent( msg.Context(), async.BeaconBlockVerified, - msg.Data().GetBeaconBlock(), + data.GetBeaconBlock(), s.VerifyIncomingBlock(msg.Context(), msg.Data()), ), ); err != nil { @@ -287,9 +306,9 @@ func (s *Service[ // a FinalValidatorUpdatesProcessed event containing the resulting validator // updates. func (s *Service[ - _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, + _, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) handleBeaconBlockFinalization( - msg async.Event[ConsensusBlockT], + msg async.Event[ctypes.ConsensusBlock[*types.BeaconBlock]], ) { var ( valUpdates transition.ValidatorUpdates diff --git a/beacon/blockchain/types.go b/beacon/blockchain/types.go index 222833f4e4..a581aa8743 100644 --- a/beacon/blockchain/types.go +++ b/beacon/blockchain/types.go @@ -24,21 +24,25 @@ import ( "context" "time" + "github.com/berachain/beacon-kit/consensus-types/types" + consensusTypes "github.com/berachain/beacon-kit/consensus/types" + datypes "github.com/berachain/beacon-kit/da/types" engineprimitives "github.com/berachain/beacon-kit/engine-primitives/engine-primitives" "github.com/berachain/beacon-kit/primitives/common" "github.com/berachain/beacon-kit/primitives/constraints" "github.com/berachain/beacon-kit/primitives/math" "github.com/berachain/beacon-kit/primitives/transition" + cmtabci "github.com/cometbft/cometbft/abci/types" ) // 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] interface { +type AvailabilityStore 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, + context.Context, math.Slot, *types.BeaconBlockBody, ) bool // Prune prunes the deposit store of [start, end) Prune(start, end uint64) error @@ -210,7 +214,7 @@ type StateProcessor[ Transition( ContextT, BeaconStateT, - BeaconBlockT, + types.BeaconBlock, ) (transition.ValidatorUpdates, error) } @@ -244,6 +248,11 @@ type TelemetrySink interface { type BlockchainI[GenesisT any] interface { ProcessGenesisData( context.Context, []byte) (transition.ValidatorUpdates, error) + ProcessProposal( + context.Context, + consensusTypes.ConsensusBlock[*types.BeaconBlock], + *consensusTypes.ConsensusSidecars[*datypes.BlobSidecars, *types.BeaconBlockHeader], + ) (*cmtabci.ProcessProposalResponse, error) } type ValidatorUpdates = transition.ValidatorUpdates diff --git a/cmd/beacond/defaults.go b/cmd/beacond/defaults.go index 9b5609b470..fb15772943 100644 --- a/cmd/beacond/defaults.go +++ b/cmd/beacond/defaults.go @@ -53,7 +53,8 @@ func DefaultComponents() []any { *AvailabilityStore, *ConsensusBlock, *BeaconBlock, *BeaconBlockBody, *BeaconBlockHeader, *BeaconState, *BeaconStateMarshallable, - *BlobSidecars, *BlockStore, *Deposit, WithdrawalCredentials, + *BlobSidecar, *BlobSidecars, *ConsensusSidecars, *BlockStore, + *Deposit, WithdrawalCredentials, *DepositStore, *DepositContract, *ExecutionPayload, *ExecutionPayloadHeader, *Genesis, *KVStore, *Logger, *StorageBackend, *BlockStore, diff --git a/cmd/beacond/types.go b/cmd/beacond/types.go index 52c2ecd333..12936c3257 100644 --- a/cmd/beacond/types.go +++ b/cmd/beacond/types.go @@ -92,6 +92,8 @@ type ( *ExecutionPayload, *ExecutionPayloadHeader, *Genesis, + *ConsensusSidecars, + *BlobSidecars, *PayloadAttributes, ] diff --git a/consensus/cometbft/service/middleware/abci.go b/consensus/cometbft/service/middleware/abci.go index 8759db0323..d7c33879ab 100644 --- a/consensus/cometbft/service/middleware/abci.go +++ b/consensus/cometbft/service/middleware/abci.go @@ -22,13 +22,8 @@ package middleware import ( "context" - "time" - "github.com/berachain/beacon-kit/consensus/cometbft/service/encoding" - "github.com/berachain/beacon-kit/consensus/types" "github.com/berachain/beacon-kit/errors" - "github.com/berachain/beacon-kit/primitives/async" - "github.com/berachain/beacon-kit/primitives/math" "github.com/berachain/beacon-kit/primitives/transition" cmtabci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,7 +41,7 @@ func (h *ABCIMiddleware[ ctx sdk.Context, req *cmtabci.ProcessProposalRequest, ) (*cmtabci.ProcessProposalResponse, error) { - var ( + /*var ( startTime = time.Now() awaitCtx, cancel = context.WithTimeout(ctx, AwaitTimeout) ) @@ -121,7 +116,8 @@ func (h *ABCIMiddleware[ if err != nil { return h.createProcessProposalResponse(err) } - return h.createProcessProposalResponse(nil) + return h.createProcessProposalResponse(nil)*/ + return nil, nil } // waitForBeaconBlockVerification waits for the built beacon block to be @@ -179,7 +175,7 @@ func (h *ABCIMiddleware[ ctx sdk.Context, req *cmtabci.FinalizeBlockRequest, ) (transition.ValidatorUpdates, error) { - awaitCtx, cancel := context.WithTimeout(ctx, AwaitTimeout) + /*awaitCtx, cancel := context.WithTimeout(ctx, AwaitTimeout) defer cancel() // flush the channel to ensure that we are not handling old data. if numMsgs := async.ClearChan(h.subFinalValidatorUpdates); numMsgs > 0 { @@ -225,7 +221,8 @@ func (h *ABCIMiddleware[ } // wait for the final validator updates. - return h.waitForFinalValidatorUpdates(awaitCtx) + return h.waitForFinalValidatorUpdates(awaitCtx)*/ + return nil, nil } // waitForFinalValidatorUpdates waits for the final validator updates to be diff --git a/consensus/cometbft/service/middleware/middleware.go b/consensus/cometbft/service/middleware/middleware.go index 74fbc0c657..9a5a61fb4f 100644 --- a/consensus/cometbft/service/middleware/middleware.go +++ b/consensus/cometbft/service/middleware/middleware.go @@ -24,6 +24,7 @@ import ( "context" "github.com/berachain/beacon-kit/async/types" + ctypes "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/log" "github.com/berachain/beacon-kit/primitives/async" "github.com/berachain/beacon-kit/primitives/common" @@ -32,7 +33,7 @@ import ( // ABCIMiddleware is a middleware between ABCI and the validator logic. type ABCIMiddleware[ - BeaconBlockT BeaconBlock[BeaconBlockT, BeaconBlockHeaderT], + BeaconBlockT BeaconBlock[*ctypes.BeaconBlock, BeaconBlockHeaderT], BeaconBlockHeaderT any, BlobSidecarsT BlobSidecars[BlobSidecarsT], GenesisT json.Unmarshaler, @@ -57,7 +58,7 @@ type ABCIMiddleware[ // NewABCIMiddleware creates a new instance of the Handler struct. func NewABCIMiddleware[ - BeaconBlockT BeaconBlock[BeaconBlockT, BeaconBlockHeaderT], + BeaconBlockT BeaconBlock[*ctypes.BeaconBlock, BeaconBlockHeaderT], BeaconBlockHeaderT any, BlobSidecarsT BlobSidecars[BlobSidecarsT], GenesisT json.Unmarshaler, diff --git a/consensus/cometbft/service/process_proposal.go b/consensus/cometbft/service/process_proposal.go index 44ae7d5510..90e5cb5057 100644 --- a/consensus/cometbft/service/process_proposal.go +++ b/consensus/cometbft/service/process_proposal.go @@ -23,14 +23,34 @@ package cometbft import ( "context" "fmt" + "time" + "github.com/berachain/beacon-kit/consensus-types/types" + "github.com/berachain/beacon-kit/consensus/cometbft/service/encoding" + consensusTypes "github.com/berachain/beacon-kit/consensus/types" + datypes "github.com/berachain/beacon-kit/da/types" + "github.com/berachain/beacon-kit/errors" + "github.com/berachain/beacon-kit/primitives/math" cmtabci "github.com/cometbft/cometbft/abci/types" ) +const ( + // BeaconBlockTxIndex represents the index of the beacon block transaction. + // It is the first transaction in the tx list. + BeaconBlockTxIndex uint = iota + // BlobSidecarsTxIndex represents the index of the blob sidecar transaction. + // It follows the beacon block transaction in the tx list. + BlobSidecarsTxIndex +) + func (s *Service[LoggerT]) processProposal( - _ context.Context, + ctx context.Context, req *cmtabci.ProcessProposalRequest, ) (*cmtabci.ProcessProposalResponse, error) { + startTime := time.Now() + defer s.telemetrySink.MeasureSince( + "beacon_kit.runtime.process_proposal_duration", startTime) + // CometBFT must never call ProcessProposal with a height of 0. if req.Height < 1 { return nil, fmt.Errorf( @@ -59,26 +79,62 @@ func (s *Service[LoggerT]) processProposal( ), ) - resp, err := s.Middleware.ProcessProposal( - s.processProposalState.Context(), + const BeaconBlockTxIndex = 0 + + // Decode the beacon block. + blk, err := encoding. + UnmarshalBeaconBlockFromABCIRequest[*types.BeaconBlock]( req, + BeaconBlockTxIndex, + s.chainSpec.ActiveForkVersionForSlot(math.U64(req.Height)), ) if err != nil { - s.logger.Error( - "failed to process proposal", - "height", - req.Height, - "time", - req.Time, - "hash", - fmt.Sprintf("%X", req.Hash), - "err", - err, - ) - return &cmtabci.ProcessProposalResponse{ - Status: cmtabci.PROCESS_PROPOSAL_STATUS_REJECT, - }, nil + return createProcessProposalResponse(errors.WrapNonFatal(err)) + } + + var consensusBlk consensusTypes.ConsensusBlock[*types.BeaconBlock] + consensusBlk = *consensusBlk.New( + blk, + req.GetProposerAddress(), + req.GetTime(), + ) + + // Decode the blob sidecars. + sidecars, err := encoding. + UnmarshalBlobSidecarsFromABCIRequest[*datypes.BlobSidecars]( + req, + BlobSidecarsTxIndex, + ) + if err != nil { + return createProcessProposalResponse(errors.WrapNonFatal(err)) + } + var consensusSidecars *consensusTypes.ConsensusSidecars[ + *datypes.BlobSidecars, + *types.BeaconBlockHeader, + ] + consensusSidecars = consensusSidecars.New( + sidecars, + blk.GetHeader(), + ) + + _, err = s.Blockchain.ProcessProposal(ctx, consensusBlk, consensusSidecars) + if err != nil { + return nil, err } - return resp, nil + return createProcessProposalResponse(nil) + +} + +// createResponse generates the appropriate ProcessProposalResponse based on the +// error. +func createProcessProposalResponse( + err error, +) (*cmtabci.ProcessProposalResponse, error) { + status := cmtabci.PROCESS_PROPOSAL_STATUS_REJECT + if !errors.IsFatal(err) { + status = cmtabci.PROCESS_PROPOSAL_STATUS_ACCEPT + err = nil + } + return &cmtabci.ProcessProposalResponse{Status: status}, err } diff --git a/consensus/cometbft/service/service.go b/consensus/cometbft/service/service.go index 53a5035569..2571e95466 100644 --- a/consensus/cometbft/service/service.go +++ b/consensus/cometbft/service/service.go @@ -57,6 +57,7 @@ type Service[ ] struct { node *node.Node cmtCfg *cmtcfg.Config + chainSpec common.ChainSpec telemetrySink TelemetrySink logger LoggerT @@ -117,6 +118,7 @@ func NewService[ Blockchain: blockchain, BlockBuilder: blockBuilder, cmtCfg: cmtCfg, + chainSpec: cs, telemetrySink: telemetrySink, paramStore: params.NewConsensusParamsStore(cs), } diff --git a/da/blob/processor.go b/da/blob/processor.go index d647f19cdd..0f22645294 100644 --- a/da/blob/processor.go +++ b/da/blob/processor.go @@ -32,9 +32,7 @@ import ( // Processor is the blob processor that handles the processing and verification // of blob sidecars. type Processor[ - AvailabilityStoreT AvailabilityStore[ - BeaconBlockBodyT, BlobSidecarsT, - ], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], ConsensusSidecarsT ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], @@ -56,9 +54,7 @@ type Processor[ // NewProcessor creates a new blob processor. func NewProcessor[ - AvailabilityStoreT AvailabilityStore[ - BeaconBlockBodyT, BlobSidecarsT, - ], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], ConsensusSidecarsT ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], diff --git a/da/blob/types.go b/da/blob/types.go index de6f61c285..f6f688b25d 100644 --- a/da/blob/types.go +++ b/da/blob/types.go @@ -24,6 +24,7 @@ import ( "context" "time" + ctypes "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/primitives/common" "github.com/berachain/beacon-kit/primitives/eip4844" "github.com/berachain/beacon-kit/primitives/math" @@ -32,10 +33,10 @@ import ( // The 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[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 + IsDataAvailable(context.Context, math.Slot, *ctypes.BeaconBlockBody) bool // Persist makes sure that the sidecar remains accessible for data // availability checks throughout the beacon node's operation. Persist(math.Slot, BlobSidecarsT) error diff --git a/node-api/backend/backend.go b/node-api/backend/backend.go index c594b0a2f7..3e003abcb1 100644 --- a/node-api/backend/backend.go +++ b/node-api/backend/backend.go @@ -31,9 +31,7 @@ import ( // It serves as a wrapper around the storage backend and provides an abstraction // over building the query context for a given state. type Backend[ - AvailabilityStoreT AvailabilityStore[ - BeaconBlockBodyT, BlobSidecarsT, - ], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockT any, BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], @@ -69,9 +67,7 @@ type Backend[ // New creates and returns a new Backend instance. func New[ - AvailabilityStoreT AvailabilityStore[ - BeaconBlockBodyT, BlobSidecarsT, - ], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockT any, BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], diff --git a/node-api/backend/types.go b/node-api/backend/types.go index 2423ee299e..5784bb6814 100644 --- a/node-api/backend/types.go +++ b/node-api/backend/types.go @@ -23,6 +23,7 @@ package backend import ( "context" + ctypes "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/primitives/common" "github.com/berachain/beacon-kit/primitives/constraints" "github.com/berachain/beacon-kit/primitives/math" @@ -33,11 +34,11 @@ import ( // The 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, BlobSidecarsT any] interface { +type AvailabilityStore[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, + context.Context, math.Slot, *ctypes.BeaconBlockBody, ) bool // Persist makes sure that the sidecar remains accessible for data // availability checks throughout the beacon node's operation. diff --git a/node-api/block_store/types.go b/node-api/block_store/types.go index 58f91f1f45..10afd6c9b5 100644 --- a/node-api/block_store/types.go +++ b/node-api/block_store/types.go @@ -21,6 +21,7 @@ package blockstore import ( + "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/primitives/async" "github.com/berachain/beacon-kit/primitives/constraints" "github.com/berachain/beacon-kit/primitives/math" @@ -34,9 +35,9 @@ type BeaconBlock interface { } // BlockStore is a generic interface for a block store. -type BlockStore[BeaconBlockT BeaconBlock] interface { +type BlockStore[BeaconBlockT any] interface { // Set sets a block at a given index. - Set(blk BeaconBlockT) error + Set(blk *types.BeaconBlock) error } // Event is an interface for block events. diff --git a/node-core/components/api.go b/node-core/components/api.go index 0885aeadda..819516a4f4 100644 --- a/node-core/components/api.go +++ b/node-core/components/api.go @@ -55,7 +55,7 @@ type NodeAPIBackendInput[ } func ProvideNodeAPIBackend[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockT any, BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], diff --git a/node-core/components/blobs.go b/node-core/components/blobs.go index 0488aaff6f..94855a6afe 100644 --- a/node-core/components/blobs.go +++ b/node-core/components/blobs.go @@ -71,7 +71,7 @@ type BlobProcessorIn[ // ProvideBlobProcessor is a function that provides the BlobProcessor to the // depinject framework. func ProvideBlobProcessor[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockBodyT any, BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], ConsensusSidecarsT ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], @@ -120,7 +120,7 @@ type DAServiceIn[ // ProvideDAService is a function that provides the BlobService to the // depinject framework. func ProvideDAService[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], BeaconBlockBodyT any, BeaconBlockHeaderT any, ConsensusSidecarsT ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], diff --git a/node-core/components/chain_service.go b/node-core/components/chain_service.go index b678fe0a7f..248522471f 100644 --- a/node-core/components/chain_service.go +++ b/node-core/components/chain_service.go @@ -24,6 +24,8 @@ import ( "cosmossdk.io/depinject" "github.com/berachain/beacon-kit/beacon/blockchain" "github.com/berachain/beacon-kit/config" + "github.com/berachain/beacon-kit/consensus-types/types" + "github.com/berachain/beacon-kit/da/da" engineprimitives "github.com/berachain/beacon-kit/engine-primitives/engine-primitives" "github.com/berachain/beacon-kit/execution/client" "github.com/berachain/beacon-kit/execution/deposit" @@ -50,9 +52,12 @@ type ChainServiceInput[ LoggerT any, WithdrawalT Withdrawal[WithdrawalT], WithdrawalsT Withdrawals[WithdrawalT], - BeaconBlockStoreT BlockStore[BeaconBlockT], + BeaconBlockStoreT BlockStore[*types.BeaconBlock], DepositStoreT any, DepositContractT any, + AvailabilityStoreT any, + ConsensusSidecarsT any, + BlobSidecarsT any, ] struct { depinject.In @@ -74,10 +79,13 @@ type ChainServiceInput[ Logger LoggerT Signer crypto.BLSSigner StateProcessor StateProcessor[ - BeaconBlockT, BeaconStateT, *Context, + *types.BeaconBlock, BeaconStateT, *Context, DepositT, ExecutionPayloadHeaderT, ] - StorageBackend StorageBackendT + StorageBackend StorageBackendT + BlobProcessor BlobProcessor[ + AvailabilityStoreT, ConsensusSidecarsT, BlobSidecarsT, + ] TelemetrySink *metrics.TelemetrySink BlockStore BeaconBlockStoreT DepositStore DepositStoreT @@ -86,9 +94,9 @@ type ChainServiceInput[ // ProvideChainService is a depinject provider for the blockchain service. func ProvideChainService[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], ConsensusBlockT ConsensusBlock[BeaconBlockT], - BeaconBlockT BeaconBlock[BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT], + BeaconBlockT BeaconBlock[*types.BeaconBlock, BeaconBlockBodyT, BeaconBlockHeaderT], BeaconBlockBodyT BeaconBlockBody[ BeaconBlockBodyT, *AttestationData, DepositT, *Eth1Data, ExecutionPayloadT, *SlashingInfo, @@ -100,7 +108,9 @@ func ProvideChainService[ *Validator, Validators, WithdrawalT, ], BeaconStateMarshallableT any, - BlobSidecarsT any, + BlobSidecarT BlobSidecar[BeaconBlockHeaderT], + BlobSidecarsT BlobSidecars[BlobSidecarsT, BlobSidecarT], + ConsensusSidecarsT da.ConsensusSidecars[BlobSidecarsT, BeaconBlockHeaderT], BlockStoreT any, DepositT deposit.Deposit[DepositT, WithdrawalCredentialsT], WithdrawalCredentialsT WithdrawalCredentials, @@ -116,7 +126,7 @@ func ProvideChainService[ StorageBackendT StorageBackend[ AvailabilityStoreT, BeaconStateT, BlockStoreT, DepositStoreT, ], - BeaconBlockStoreT BlockStore[BeaconBlockT], + BeaconBlockStoreT BlockStore[*types.BeaconBlock], WithdrawalT Withdrawal[WithdrawalT], WithdrawalsT Withdrawals[WithdrawalT], ]( @@ -124,6 +134,7 @@ func ProvideChainService[ BeaconBlockT, BeaconStateT, DepositT, ExecutionPayloadT, ExecutionPayloadHeaderT, StorageBackendT, LoggerT, WithdrawalT, WithdrawalsT, BeaconBlockStoreT, DepositStoreT, DepositContractT, + AvailabilityStoreT, ConsensusSidecarsT, BlobSidecarsT, ], ) *blockchain.Service[ AvailabilityStoreT, DepositStoreT, @@ -131,6 +142,7 @@ func ProvideChainService[ BeaconBlockHeaderT, BeaconStateT, BeaconBlockStoreT, DepositT, WithdrawalCredentialsT, ExecutionPayloadT, ExecutionPayloadHeaderT, GenesisT, + ConsensusSidecarsT, BlobSidecarsT, *engineprimitives.PayloadAttributes[WithdrawalT], ] { return blockchain.NewService[ @@ -151,6 +163,7 @@ func ProvideChainService[ ]( cast.ToString(in.AppOpts.Get(flags.FlagHome)), in.StorageBackend, + in.BlobProcessor, in.BlockStore, in.DepositStore, in.BeaconDepositContract, diff --git a/node-core/components/interfaces.go b/node-core/components/interfaces.go index a10f8dc3dd..09a3f71f6d 100644 --- a/node-core/components/interfaces.go +++ b/node-core/components/interfaces.go @@ -25,6 +25,7 @@ import ( "context" "encoding/json" + ctypes "github.com/berachain/beacon-kit/consensus-types/types" engineprimitives "github.com/berachain/beacon-kit/engine-primitives/engine-primitives" "github.com/berachain/beacon-kit/log" "github.com/berachain/beacon-kit/node-api/handlers" @@ -34,6 +35,7 @@ import ( "github.com/berachain/beacon-kit/primitives/constraints" "github.com/berachain/beacon-kit/primitives/crypto" "github.com/berachain/beacon-kit/primitives/eip4844" + "github.com/berachain/beacon-kit/primitives/math" "github.com/berachain/beacon-kit/primitives/transition" v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1" @@ -70,11 +72,11 @@ type ( } // AvailabilityStore is the interface for the availability store. - AvailabilityStore[BeaconBlockBodyT any, BlobSidecarsT any] interface { + AvailabilityStore[BlobSidecarsT any] interface { IndexDB // 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 + IsDataAvailable(context.Context, math.Slot, *ctypes.BeaconBlockBody) bool // Persist makes sure that the sidecar remains accessible for data // availability checks throughout the beacon node's operation. Persist(math.Slot, BlobSidecarsT) error diff --git a/node-core/components/service_registry.go b/node-core/components/service_registry.go index b26dc8a986..3f9f53381c 100644 --- a/node-core/components/service_registry.go +++ b/node-core/components/service_registry.go @@ -24,6 +24,7 @@ import ( "cosmossdk.io/depinject" "github.com/berachain/beacon-kit/beacon/blockchain" "github.com/berachain/beacon-kit/beacon/validator" + "github.com/berachain/beacon-kit/consensus-types/types" cometbft "github.com/berachain/beacon-kit/consensus/cometbft/service" "github.com/berachain/beacon-kit/consensus/cometbft/service/middleware" "github.com/berachain/beacon-kit/da/da" @@ -39,15 +40,15 @@ import ( // ServiceRegistryInput is the input for the service registry provider. type ServiceRegistryInput[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], ConsensusBlockT ConsensusBlock[BeaconBlockT], - BeaconBlockT BeaconBlock[BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT], + BeaconBlockT BeaconBlock[*types.BeaconBlock, BeaconBlockBodyT, BeaconBlockHeaderT], BeaconBlockBodyT BeaconBlockBody[ BeaconBlockBodyT, *AttestationData, DepositT, *Eth1Data, ExecutionPayloadT, *SlashingInfo, ], BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], - BeaconBlockStoreT BlockStore[BeaconBlockT], + BeaconBlockStoreT BlockStore[*types.BeaconBlock], BeaconStateT BeaconState[ BeaconStateT, BeaconBlockHeaderT, BeaconStateMarshallableT, *Eth1Data, ExecutionPayloadHeaderT, *Fork, KVStoreT, @@ -80,6 +81,7 @@ type ServiceRegistryInput[ BeaconBlockHeaderT, BeaconStateT, BeaconBlockStoreT, DepositT, WithdrawalCredentials, ExecutionPayloadT, ExecutionPayloadHeaderT, GenesisT, + ConsensusSidecarsT, BlobSidecarsT, *engineprimitives.PayloadAttributes[WithdrawalT], ] DAService *da.Service[ @@ -110,7 +112,7 @@ type ServiceRegistryInput[ // ProvideServiceRegistry is the depinject provider for the service registry. func ProvideServiceRegistry[ - AvailabilityStoreT AvailabilityStore[BeaconBlockBodyT, BlobSidecarsT], + AvailabilityStoreT AvailabilityStore[BlobSidecarsT], ConsensusBlockT ConsensusBlock[BeaconBlockT], BeaconBlockT BeaconBlock[BeaconBlockT, BeaconBlockBodyT, BeaconBlockHeaderT], BeaconBlockBodyT BeaconBlockBody[ @@ -118,7 +120,7 @@ func ProvideServiceRegistry[ *Eth1Data, ExecutionPayloadT, *SlashingInfo, ], BeaconBlockHeaderT BeaconBlockHeader[BeaconBlockHeaderT], - BeaconBlockStoreT BlockStore[BeaconBlockT], + BeaconBlockStoreT BlockStore[*types.BeaconBlock], BeaconStateT BeaconState[ BeaconStateT, BeaconBlockHeaderT, BeaconStateMarshallableT, *Eth1Data, ExecutionPayloadHeaderT, *Fork, KVStoreT,