mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Add more blob and block checks for by range (#13043)
* Add more blob and block checks for by range * Update beacon-chain/sync/initial-sync/blocks_fetcher.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * Update beacon-chain/sync/initial-sync/blocks_fetcher.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * Update beacon-chain/sync/initial-sync/blocks_fetcher_test.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
This commit is contained in:
@@ -398,6 +398,7 @@ var errMissingBlobsForBlockCommitments = errors.Wrap(errBlobVerification, "blobs
|
||||
var errMismatchedBlobBlockRoot = errors.Wrap(errBlobVerification, "BlockRoot in BlobSidecar does not match the expected root")
|
||||
var errMissingBlobIndex = errors.Wrap(errBlobVerification, "missing expected blob index")
|
||||
var errMismatchedBlobCommitments = errors.Wrap(errBlobVerification, "commitments at given slot, root and index do not match")
|
||||
var errMismatchedProposerIndex = errors.Wrap(errBlobVerification, "proposer index does not match")
|
||||
|
||||
func verifyAndPopulateBlobs(bwb []blocks2.BlockWithVerifiedBlobs, blobs []*p2ppb.BlobSidecar, blobWindowStart primitives.Slot) ([]blocks2.BlockWithVerifiedBlobs, error) {
|
||||
// Assumes bwb has already been sorted by sortedBlockWithVerifiedBlobSlice.
|
||||
@@ -437,6 +438,14 @@ func verifyAndPopulateBlobs(bwb []blocks2.BlockWithVerifiedBlobs, blobs []*p2ppb
|
||||
return nil, errors.Wrapf(errMismatchedBlobBlockRoot,
|
||||
"block root %#x != BlobSidecar.BlockRoot %#x at slot %d", bb.Block.Root(), bl.BlockRoot, block.Slot())
|
||||
}
|
||||
if bytesutil.ToBytes32(bl.BlockParentRoot) != block.ParentRoot() {
|
||||
return nil, errors.Wrapf(errMismatchedBlobBlockRoot,
|
||||
"block parent root %#x != BlobSidecar.BlockParentRoot %#x at slot %d", block.ParentRoot(), bl.BlockParentRoot, block.Slot())
|
||||
}
|
||||
if bl.ProposerIndex != block.ProposerIndex() {
|
||||
return nil, errors.Wrapf(errMismatchedProposerIndex,
|
||||
"block proposer index %d != BlobSidecar.ProposerIndex %d at slot %d", block.ProposerIndex(), bl.ProposerIndex, block.Slot())
|
||||
}
|
||||
if ci != int(bl.Index) {
|
||||
return nil, errors.Wrapf(errMissingBlobIndex,
|
||||
"did not receive blob index %d for block root %#x at slot %d", ci, bb.Block.Root(), block.Slot())
|
||||
|
||||
@@ -1091,6 +1091,16 @@ func TestVerifyAndPopulateBlobs(t *testing.T) {
|
||||
_, err = verifyAndPopulateBlobs(bwb, blobs, firstBlockSlot)
|
||||
require.ErrorIs(t, err, errMissingBlobIndex)
|
||||
|
||||
bwb, blobs = testSequenceBlockWithBlob(t, 10)
|
||||
blobs[lastBlobIdx].ProposerIndex = 100
|
||||
_, err = verifyAndPopulateBlobs(bwb, blobs, firstBlockSlot)
|
||||
require.ErrorIs(t, err, errMismatchedProposerIndex)
|
||||
|
||||
bwb, blobs = testSequenceBlockWithBlob(t, 10)
|
||||
blobs[lastBlobIdx].BlockParentRoot = blobs[0].BlockParentRoot
|
||||
_, err = verifyAndPopulateBlobs(bwb, blobs, firstBlockSlot)
|
||||
require.ErrorIs(t, err, errMismatchedBlobBlockRoot)
|
||||
|
||||
var emptyKzg [48]byte
|
||||
bwb, blobs = testSequenceBlockWithBlob(t, 10)
|
||||
blobs[lastBlobIdx].KzgCommitment = emptyKzg[:]
|
||||
|
||||
Reference in New Issue
Block a user