Skip to content

Commit

Permalink
chore(blobs): Validate Index field in BlobSidecar during processi…
Browse files Browse the repository at this point in the history
…ng (#2289)
  • Loading branch information
shotes authored Dec 20, 2024
1 parent 7e5f02d commit 0a2b137
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions da/blob/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type ConsensusSidecars interface {
}

type Sidecar interface {
GetIndex() uint64
GetBlob() eip4844.Blob
GetKzgProof() eip4844.KZGProof
GetKzgCommitment() eip4844.KZGCommitment
Expand Down
5 changes: 5 additions & 0 deletions da/blob/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func (bv *verifier) verifySidecars(
// Verifying that sidecars block headers match with header of the
// corresponding block concurrently.
for i, s := range sidecars.GetSidecars() {
// This check happens outside the goroutines so that we do not
// process the inclusion proofs before validating the index.
if s.GetIndex() >= bv.chainSpec.MaxBlobsPerBlock() {
return fmt.Errorf("invalid sidecar Index: %d", i)
}
g.Go(func() error {
var sigHeader = s.GetSignedBeaconBlockHeader()

Expand Down
4 changes: 4 additions & 0 deletions da/types/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (b *BlobSidecar) HasValidInclusionProof(
)
}

func (b *BlobSidecar) GetIndex() uint64 {
return b.Index
}

func (b *BlobSidecar) GetBlob() eip4844.Blob {
return b.Blob
}
Expand Down

0 comments on commit 0a2b137

Please sign in to comment.