Skip to content

Commit

Permalink
wrap up post blob sync actions in batch mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Feb 14, 2024
1 parent 1b713c3 commit 45ec5ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 11 additions & 0 deletions beacon-chain/sync/backfill/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/das"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/sync"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -136,6 +137,16 @@ func (b batch) withResults(results verifiedROBlocks, bs *blobSync) batch {
return b.withState(batchImportable)
}

func (b batch) postBlobSync() batch {
if b.blobsNeeded() > 0 {
log.WithFields(b.logFields()).WithField("blobs_missing", b.blobsNeeded()).Error("batch still missing blobs after downloading from peer")
b.bs = nil
b.results = []blocks.ROBlock{}
return b.withState(batchErrRetryable)
}
return b.withState(batchImportable)
}

func (b batch) withState(s batchState) batch {
if s == batchSequenced {
b.scheduled = time.Now()
Expand Down
7 changes: 1 addition & 6 deletions beacon-chain/sync/backfill/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ func (w *p2pWorker) handleBlobs(ctx context.Context, b batch) batch {
backfillBlobsApproximateBytes.Add(float64(sz))
log.WithFields(b.logFields()).WithField("dlbytes", sz).Debug("backfill batch blob bytes downloaded")
}
if b.blobsNeeded() > 0 {
log.WithFields(b.logFields()).WithField("blobs_missing", b.blobsNeeded()).Error("batch still missing blobs after downloading from peer")
b.bs = nil
return b.withState(batchErrRetryable)
}
return b.withState(batchImportable)
return b.postBlobSync()
}

func newP2pWorker(id workerId, p p2p.P2P, todo, done chan batch, c *startup.Clock, v *verifier, cm sync.ContextByteVersions, nbv verification.NewBlobVerifier, bfs *filesystem.BlobStorage) *p2pWorker {
Expand Down

0 comments on commit 45ec5ae

Please sign in to comment.