mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
* PeerDAS: Implement sync * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Satyajit's comment. * Partially fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Fix Potuz's comment. * Add tests for `sendDataColumnSidecarsRequest`. * Fix Satyajit's comment. * Implement `TestSendDataColumnSidecarsRequest`. * Implement `TestFetchDataColumnSidecarsFromPeers`. * Implement `TestUpdateResults`. * Implement `TestSelectPeers`. * Implement `TestCategorizeIndices`. * Fix James' comment. * Fix James's comment. * Fix James' commit. * Fix James' comment. * Fix James' comment. * Fix flakiness in `TestSelectPeers`. * Update cmd/beacon-chain/flags/config.go Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> * Fix Preston's comment. * Fix James's comment. * Implement `TestFetchDataColumnSidecars`. * Revert "Fix Potuz's comment." This reverts commitc45230b455. * Fix Potuz's comment. * Revert "Fix James' comment." This reverts commita3f919205a. * Fix James' comment. * Fix Preston's comment. * Fix James' comment. * `selectPeers`: Avoid map with key but empty value. * Fix typo. * Fix Potuz's comment. * Fix Potuz's comment. * Fix James' comment. * Add DataColumnStorage and SubscribeAllDataSubnets flag. * Add extra flags * Fix Potuz's and Preston's comment. * Add rate limiter check. --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package verify
|
|
|
|
import (
|
|
"github.com/OffchainLabs/prysm/v6/config/params"
|
|
"github.com/OffchainLabs/prysm/v6/consensus-types/blocks"
|
|
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
|
|
"github.com/OffchainLabs/prysm/v6/runtime/version"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
var (
|
|
errBlobVerification = errors.New("unable to verify blobs")
|
|
ErrIncorrectBlobIndex = errors.New("incorrect blob index")
|
|
ErrBlobBlockMisaligned = errors.Wrap(errBlobVerification, "root of block header in blob sidecar does not match block root")
|
|
ErrMismatchedBlobCommitments = errors.Wrap(errBlobVerification, "commitments at given slot, root and index do not match")
|
|
)
|
|
|
|
// BlobAlignsWithBlock verifies if the blob aligns with the block.
|
|
func BlobAlignsWithBlock(blob blocks.ROBlob, block blocks.ROBlock) error {
|
|
blockVersion := block.Version()
|
|
|
|
if blockVersion < version.Deneb || blockVersion >= version.Fulu {
|
|
return nil
|
|
}
|
|
|
|
maxBlobsPerBlock := params.BeaconConfig().MaxBlobsPerBlock(blob.Slot())
|
|
if blob.Index >= uint64(maxBlobsPerBlock) {
|
|
return errors.Wrapf(ErrIncorrectBlobIndex, "index %d exceeds MAX_BLOBS_PER_BLOCK %d", blob.Index, maxBlobsPerBlock)
|
|
}
|
|
|
|
if blob.BlockRoot() != block.Root() {
|
|
return ErrBlobBlockMisaligned
|
|
}
|
|
|
|
// Verify commitment byte values match
|
|
// TODO: verify commitment inclusion proof - actually replace this with a better rpc blob verification stack altogether.
|
|
commits, err := block.Block().Body().BlobKzgCommitments()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
blockCommitment := bytesutil.ToBytes48(commits[blob.Index])
|
|
blobCommitment := bytesutil.ToBytes48(blob.KzgCommitment)
|
|
if blobCommitment != blockCommitment {
|
|
return errors.Wrapf(ErrMismatchedBlobCommitments, "commitment %#x != block commitment %#x, at index %d for block root %#x at slot %d ", blobCommitment, blockCommitment, blob.Index, block.Root(), blob.Slot())
|
|
}
|
|
return nil
|
|
}
|