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 17, 2024
1 parent 60f16c2 commit 9ce2c90
Show file tree
Hide file tree
Showing 4 changed files with 9 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
3 changes: 3 additions & 0 deletions da/blob/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func (bv *verifier[_, BlobSidecarsT]) verifySidecars(
// check that sidecars block headers match with header of the
// corresponding block
for i, s := range sidecars.GetSidecars() {
if s.GetIndex() >= bv.chainSpec.MaxBlobsPerBlock() {
return fmt.Errorf("invalid sidecar Index: %d", i)
}
if !s.GetSignedBeaconBlockHeader().GetHeader().Equals(blkHeader) {
return fmt.Errorf("unequal block header: idx: %d", i)
}
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 @@ -203,6 +203,7 @@ type (
}

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

0 comments on commit 9ce2c90

Please sign in to comment.