Skip to content

Commit

Permalink
[node] Don't store certs in store v2 (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim authored Dec 11, 2024
1 parent 4a98d98 commit 0b90412
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
12 changes: 0 additions & 12 deletions node/store_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,10 @@ func (s *storeV2) StoreBatch(batch *corev2.Batch, rawBundles []*RawBundles) ([]k

// Store blob shards
for _, bundles := range rawBundles {
// Store blob certificate
blobCertificateKeyBuilder, err := s.db.GetKeyBuilder(BlobCertificateTableName)
if err != nil {
return nil, fmt.Errorf("failed to get key builder for blob certificate: %v", err)
}
blobKey, err := bundles.BlobCertificate.BlobHeader.BlobKey()
if err != nil {
return nil, fmt.Errorf("failed to get blob key: %v", err)
}
blobCertificateKey := blobCertificateKeyBuilder.Key(blobKey[:])
blobCertificateBytes, err := bundles.BlobCertificate.Serialize()
if err != nil {
return nil, fmt.Errorf("failed to serialize blob certificate: %v", err)
}
keys = append(keys, blobCertificateKey)
dbBatch.PutWithTTL(blobCertificateKey, blobCertificateBytes, s.ttl)

// Store bundles
for quorum, bundle := range bundles.Bundles {
Expand Down
25 changes: 1 addition & 24 deletions node/store_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStoreBatchV2(t *testing.T) {
}()
keys, err := s.StoreBatch(batch, rawBundles)
require.NoError(t, err)
require.Len(t, keys, 10)
require.Len(t, keys, 7)

tables := db.GetTables()
require.ElementsMatch(t, []string{node.BatchHeaderTableName, node.BlobCertificateTableName, node.BundleTableName}, tables)
Expand All @@ -61,21 +61,6 @@ func TestStoreBatchV2(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, batch.BatchHeader, deserializedBatchHeader)

// Check blob certificates
blobCertKeyBuilder, err := db.GetKeyBuilder(node.BlobCertificateTableName)
require.NoError(t, err)
for _, cert := range batch.BlobCertificates {
blobKey, err := cert.BlobHeader.BlobKey()
require.NoError(t, err)
blobCertKey := blobCertKeyBuilder.Key(blobKey[:])
blobCertBytes, err := db.Get(blobCertKey)
require.NoError(t, err)
assert.NotNil(t, blobCertBytes)
deserializedBlobCert, err := corev2.DeserializeBlobCertificate(blobCertBytes)
require.NoError(t, err)
assert.Equal(t, cert, deserializedBlobCert)
}

// Check bundles
bundleKeyBuilder, err := db.GetKeyBuilder(node.BundleTableName)
require.NoError(t, err)
Expand Down Expand Up @@ -103,14 +88,6 @@ func TestStoreBatchV2(t *testing.T) {
bhhBytes, err = db.Get(batchHeaderKeyBuilder.Key(bhh[:]))
require.Error(t, err)
require.Empty(t, bhhBytes)
for _, cert := range batch.BlobCertificates {
blobKey, err := cert.BlobHeader.BlobKey()
require.NoError(t, err)
blobCertKey := blobCertKeyBuilder.Key(blobKey[:])
blobCertBytes, err := db.Get(blobCertKey)
require.Error(t, err)
require.Empty(t, blobCertBytes)
}

for _, bundles := range rawBundles {
blobKey, err := bundles.BlobCertificate.BlobHeader.BlobKey()
Expand Down

0 comments on commit 0b90412

Please sign in to comment.