From 9ce2c90313e14354b547f37a0caf9436f9fe12b9 Mon Sep 17 00:00:00 2001 From: shotes Date: Tue, 17 Dec 2024 12:16:52 -0600 Subject: [PATCH] validate index size --- da/blob/types.go | 1 + da/blob/verifier.go | 3 +++ da/types/sidecar.go | 4 ++++ node-core/components/interfaces.go | 1 + 4 files changed, 9 insertions(+) diff --git a/da/blob/types.go b/da/blob/types.go index cbeca83996..b9835e477f 100644 --- a/da/blob/types.go +++ b/da/blob/types.go @@ -53,6 +53,7 @@ type ConsensusSidecars[BlobSidecarsT any] interface { } type Sidecar interface { + GetIndex() uint64 GetBlob() eip4844.Blob GetKzgProof() eip4844.KZGProof GetKzgCommitment() eip4844.KZGCommitment diff --git a/da/blob/verifier.go b/da/blob/verifier.go index f9566ddcf3..9c1f30a27e 100644 --- a/da/blob/verifier.go +++ b/da/blob/verifier.go @@ -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) } diff --git a/da/types/sidecar.go b/da/types/sidecar.go index 7f6d16fa21..8a9967a2d6 100644 --- a/da/types/sidecar.go +++ b/da/types/sidecar.go @@ -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 } diff --git a/node-core/components/interfaces.go b/node-core/components/interfaces.go index 9b640b2d75..18f5c16bf5 100644 --- a/node-core/components/interfaces.go +++ b/node-core/components/interfaces.go @@ -203,6 +203,7 @@ type ( } BlobSidecar interface { + GetIndex() uint64 GetSignedBeaconBlockHeader() *ctypes.SignedBeaconBlockHeader GetBlob() eip4844.Blob GetKzgProof() eip4844.KZGProof