Skip to content

Commit

Permalink
Remove uses of context.Background() (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrik01 authored Jan 27, 2025
1 parent 74518b1 commit 9097bf3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions beacon/blockchain/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *Service) ProcessProposal(
// the currently active fork). ProcessProposal should only
// keep the state changes as candidates (which is what we do in
// VerifyIncomingBlock).
err = s.VerifyIncomingBlobSidecars(sidecars, blk.GetHeader(), blk.GetBody().GetBlobKzgCommitments())
err = s.VerifyIncomingBlobSidecars(ctx, sidecars, blk.GetHeader(), blk.GetBody().GetBlobKzgCommitments())
if err != nil {
s.logger.Error("failed to verify incoming blob sidecars", "error", err)
return err
Expand Down Expand Up @@ -168,14 +168,15 @@ func (s *Service) VerifyIncomingBlockSignature(
// VerifyIncomingBlobSidecars verifies the BlobSidecars of an incoming
// proposal and logs the process.
func (s *Service) VerifyIncomingBlobSidecars(
ctx context.Context,
sidecars datypes.BlobSidecars,
blkHeader *ctypes.BeaconBlockHeader,
kzgCommitments eip4844.KZGCommitments[common.ExecutionHash],
) error {
s.logger.Info("Received incoming blob sidecars")

// Verify the blobs and ensure they match the local state.
err := s.blobProcessor.VerifySidecars(sidecars, blkHeader, kzgCommitments)
err := s.blobProcessor.VerifySidecars(ctx, sidecars, blkHeader, kzgCommitments)
if err != nil {
s.logger.Error(
"rejecting incoming blob sidecars",
Expand Down
3 changes: 3 additions & 0 deletions da/blob/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package blob

import (
"context"
"time"

"github.com/berachain/beacon-kit/chain"
Expand Down Expand Up @@ -66,6 +67,7 @@ func NewProcessor(

// VerifySidecars verifies the blobs and ensures they match the local state.
func (sp *Processor) VerifySidecars(
ctx context.Context,
sidecars datypes.BlobSidecars,
blkHeader *ctypes.BeaconBlockHeader,
kzgCommitments eip4844.KZGCommitments[common.ExecutionHash],
Expand All @@ -81,6 +83,7 @@ func (sp *Processor) VerifySidecars(

// Verify the blobs and ensure they match the local state.
return sp.verifier.verifySidecars(
ctx,
sidecars,
blkHeader,
kzgCommitments,
Expand Down
3 changes: 2 additions & 1 deletion da/blob/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func newVerifier(
// verifySidecars verifies the blobs for both inclusion as well
// as the KZG proofs.
func (bv *verifier) verifySidecars(
ctx context.Context,
sidecars datypes.BlobSidecars,
blkHeader *ctypes.BeaconBlockHeader,
kzgCommitments eip4844.KZGCommitments[common.ExecutionHash],
Expand All @@ -71,7 +72,7 @@ func (bv *verifier) verifySidecars(
bv.proofVerifier.GetImplementation(),
)

g, _ := errgroup.WithContext(context.Background())
g, _ := errgroup.WithContext(ctx)

// Create lookup table for each blob sidecar commitment.
blobSidecarCommitments := make(map[eip4844.KZGCommitment]struct{})
Expand Down
3 changes: 3 additions & 0 deletions da/da/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package da

import (
"context"

ctypes "github.com/berachain/beacon-kit/consensus-types/types"
dastore "github.com/berachain/beacon-kit/da/store"
datypes "github.com/berachain/beacon-kit/da/types"
Expand All @@ -38,6 +40,7 @@ type BlobProcessor interface {
) error
// VerifySidecars verifies the blobs and ensures they match the local state.
VerifySidecars(
ctx context.Context,
sidecars datypes.BlobSidecars,
blkHeader *ctypes.BeaconBlockHeader,
kzgCommitments eip4844.KZGCommitments[common.ExecutionHash],
Expand Down
1 change: 1 addition & 0 deletions node-core/components/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ type (
// VerifySidecars verifies the blobs and ensures they match the local
// state.
VerifySidecars(
ctx context.Context,
sidecars datypes.BlobSidecars,
blkHeader *ctypes.BeaconBlockHeader,
kzgCommitments eip4844.KZGCommitments[common.ExecutionHash],
Expand Down
2 changes: 1 addition & 1 deletion state-transition/core/state_processor_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (sp *StateProcessor[ContextT]) processExecutionPayload(
body = blk.GetBody()
payload = body.GetExecutionPayload()
header *ctypes.ExecutionPayloadHeader
g, gCtx = errgroup.WithContext(context.Background())
g, gCtx = errgroup.WithContext(ctx)
)

payloadTimestamp := payload.GetTimestamp().Unwrap()
Expand Down

0 comments on commit 9097bf3

Please sign in to comment.