Skip to content

Commit

Permalink
validate index size
Browse files Browse the repository at this point in the history
  • Loading branch information
shotes committed Dec 18, 2024
1 parent c08698e commit add2c6b
Show file tree
Hide file tree
Showing 4 changed files with 11 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 @@ -53,6 +53,7 @@ type ConsensusSidecars[BlobSidecarsT any] 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 @@ -83,6 +83,11 @@ func (bv *verifier[_, BlobSidecarsT]) 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
1 change: 1 addition & 0 deletions node-core/components/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ type (
}

BlobSidecar interface {
GetIndex() uint64
GetSignedBeaconBlockHeader() *ctypes.SignedBeaconBlockHeader
GetBlob() eip4844.Blob
GetKzgProof() eip4844.KZGProof
Expand Down

0 comments on commit add2c6b

Please sign in to comment.