diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 019789f2cbb1..96a3c260e240 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -522,7 +522,7 @@ func missingDataColumns(bs *filesystem.BlobStorage, root [32]byte, expected map[ if len(expected) > int(params.BeaconConfig().NumberOfColumns) { return nil, errMaxDataColumnsExceeded } - indices, err := bs.Indices(root) + indices, err := bs.ColumnIndices(root) if err != nil { return nil, err } diff --git a/beacon-chain/db/filesystem/blob.go b/beacon-chain/db/filesystem/blob.go index 5fea6f44c16b..6f004587b1c2 100644 --- a/beacon-chain/db/filesystem/blob.go +++ b/beacon-chain/db/filesystem/blob.go @@ -395,6 +395,41 @@ func (bs *BlobStorage) Indices(root [32]byte) ([fieldparams.MaxBlobsPerBlock]boo return mask, nil } +// ColumnIndices retrieve the stored column indexes from our filesystem. +func (bs *BlobStorage) ColumnIndices(root [32]byte) ([fieldparams.NumberOfColumns]bool, error) { + var mask [fieldparams.NumberOfColumns]bool + rootDir := blobNamer{root: root}.dir() + entries, err := afero.ReadDir(bs.fs, rootDir) + if err != nil { + if os.IsNotExist(err) { + return mask, nil + } + return mask, err + } + for i := range entries { + if entries[i].IsDir() { + continue + } + name := entries[i].Name() + if !strings.HasSuffix(name, sszExt) { + continue + } + parts := strings.Split(name, ".") + if len(parts) != 2 { + continue + } + u, err := strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return mask, errors.Wrapf(err, "unexpected directory entry breaks listing, %s", parts[0]) + } + if u >= fieldparams.NumberOfColumns { + return mask, errIndexOutOfBounds + } + mask[u] = true + } + return mask, nil +} + // Clear deletes all files on the filesystem. func (bs *BlobStorage) Clear() error { dirs, err := listDir(bs.fs, ".") diff --git a/config/fieldparams/mainnet.go b/config/fieldparams/mainnet.go index 706334328313..2f5b0d601364 100644 --- a/config/fieldparams/mainnet.go +++ b/config/fieldparams/mainnet.go @@ -33,4 +33,5 @@ const ( BlobSize = 131072 // defined to match blob.size in bazel ssz codegen KzgCommitmentInclusionProofDepth = 17 // Merkle proof depth for blob_kzg_commitments list item NextSyncCommitteeBranchDepth = 5 // NextSyncCommitteeBranchDepth defines the depth of the next sync committee branch. + NumberOfColumns = 128 // NumberOfColumns refers to the specified number of data columns that can exist in a network. ) diff --git a/config/fieldparams/minimal.go b/config/fieldparams/minimal.go index 96ec9e28f875..13cdac3c0864 100644 --- a/config/fieldparams/minimal.go +++ b/config/fieldparams/minimal.go @@ -33,4 +33,5 @@ const ( BlobSize = 131072 // defined to match blob.size in bazel ssz codegen KzgCommitmentInclusionProofDepth = 17 // Merkle proof depth for blob_kzg_commitments list item NextSyncCommitteeBranchDepth = 5 // NextSyncCommitteeBranchDepth defines the depth of the next sync committee branch. + NumberOfColumns = 128 // NumberOfColumns refers to the specified number of data columns that can exist in a network. )