Skip to content

Commit

Permalink
Fix length check between kzg commitments and exist (#14581)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored Oct 25, 2024
1 parent 48fe9d9 commit 53f1f11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- wait for the async StreamEvent writer to exit before leaving the http handler, avoiding race condition panics [pr](https://github.com/prysmaticlabs/prysm/pull/14557)
- Certain deb files were returning a 404 which made building new docker images without an existing
cache impossible. This has been fixed with updates to rules_oci and bazel-lib.
- Fixed an issue where the length check between block body KZG commitments and the existing cache from the database was incompatible.

### Security

Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/execution/engine_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ func (s *Service) ReconstructBlobSidecars(ctx context.Context, block interfaces.
if err != nil {
return nil, errors.Wrap(err, "could not get blob KZG commitments")
}
if len(kzgCommitments) != len(exists) {
return nil, fmt.Errorf("mismatched lengths: KZG commitments %d, exists %d", len(kzgCommitments), len(exists))
if len(kzgCommitments) > len(exists) {
return nil, fmt.Errorf("length of KZG commitments (%d) is greater than length of exists (%d)", len(kzgCommitments), len(exists))
}

// Collect KZG hashes for non-existing blobs
Expand Down
12 changes: 12 additions & 0 deletions beacon-chain/execution/engine_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,18 @@ func TestReconstructBlobSidecars(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 3, len(verifiedBlobs))
})

t.Run("kzg is longer than exist", func(t *testing.T) {
srv := createBlobServer(t, 3)
defer srv.Close()

rpcClient, client := setupRpcClient(t, srv.URL, client)
defer rpcClient.Close()

exists := []bool{true, false, true, false, true}
_, err := client.ReconstructBlobSidecars(ctx, sb, r, exists)
require.ErrorContains(t, "length of KZG commitments (6) is greater than length of exists (5)", err)
})
}

func createRandomKzgCommitments(t *testing.T, num int) [][]byte {
Expand Down

0 comments on commit 53f1f11

Please sign in to comment.