Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EIP-4844] Implement BlobsManager #6636

Merged
merged 7 commits into from
Jan 10, 2023
Merged

Conversation

tbenr
Copy link
Contributor

@tbenr tbenr commented Dec 20, 2022

Introduces BlobsSidecarManager which is responsible for:

  • storing unconfirmed validated BlobsSidecars coming from gossip via BlockManager
  • storing unconfirmed non_validated BlobsSidecars coming from syncing flows via BlockManager
  • creating a blobsSidecarAvailabilityChecker used in ForkChoice
  • caching validated blobs to avoid revalidation in ForkCoiche for blocks\sidecar coming from gossip.

Under kvstore and storage:

  • rename kvstore method removeUnconfirmedBlobsSidecar -> confirmBlobsSidecar
  • remove two unused blobs methods in ChainStorage and related classes
  • fix SafeFuture handling on ChainStorage fro void returning blobs methods

In StorageUpdate and StoreTransactionUpdates:

  • migrate prunedHotBlockRoots from a Set<blockRoot> to Map<blockRoot,slot> to support blobs cleanup when hot blocks are pruned

In BlockValidator (gossip):

  • implements kzg commitments validation against blobsSidecar

In BlockManager:

  • added handleBlobs method in the doImportBlock pipeline to store blobsSidecar via BlobsSidecarManager. This is done after block validity check (handleInvalidBlock) and after checking it is actually a new block not seen before (handleKnownBlock). Gossip validation result is considered to allow BlobsSidecarManager to know if the availability check needs to be done or not.
  • it handles the blobs "discard" conditions when the corresponding block import results in a rejection of the block.

Additional notes

  • we could discard blobs sending them to the BlobsPruner which will gradually delete them from BD without queue the deletions in the storageUpdateChannel which can cause slowdown if many blobs are discarded in sequence (various pending blocks on a fork that turns out to be invalid). We could implement a BlobsDeletionChannel and block BlockPruner will consume it

  • having unconfirmed affects how we handle BlobsSidecarByRange rpc method:

    • for non finalized blobs, we should have a fast way to check if corresponding blocks are in recentChainData (via containsBlock)
    • for finalized we should always lookup on the unconfirmed column to filter them out (even in the case we have only one blob per slot, it might be still unconfirmed (a proposed invalid block))
  • for the unconfirmed column I found an interesting approach that could make the confirmed-unconfirmed flag more efficient to store and update: https://groups.google.com/g/leveldb/c/qOMWvp7gyxg but would require some changes in our kvstore layer

    • the idea is to have a column key stored like <id, key, attributeId> where id is our current prefix and attributeIds is a new postfix byte from 0 to number of attributes defined + the actual value we store. The column will have multiple value serializers one for each attributeId. In our case we can have:
      • <blobsSidecarId, <SlotAndBlockRoot>, 0> -> KvStoreSerializer<Boolean> (confirmed flag)
      • <blobsSidecarId, <SlotAndBlockRoot>, 1> -> KvStoreSerializer<Bytes> (BlobsSidecar ssz data)
        so when streaming\lookingup blobs we can efficiently filter by unconfirmed flag without even try to deserialize the object if doesn't match the filter.
        This need further investigation for rocksDB.

fixes #6629
fixes #6473

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@@ -101,8 +99,7 @@
}

return validateWeakSubjectivityPeriod()
.thenCompose(
__ -> forkChoice.onBlock(block, blobsSidecar, blockImportPerformance, executionLayer))
.thenCompose(__ -> forkChoice.onBlock(block, blockImportPerformance, executionLayer))

Check notice

Code scanning / CodeQL

Useless parameter

The parameter '__' is never used.
@tbenr tbenr force-pushed the eip4844-blobsmanager branch 3 times, most recently from 8d86c8a to cf52a22 Compare December 22, 2022 15:37
@tbenr tbenr force-pushed the eip4844-blobsmanager branch 2 times, most recently from 2855fd0 to 6e3f902 Compare December 31, 2022 10:23
@tbenr tbenr force-pushed the eip4844-blobsmanager branch 2 times, most recently from 6e719ba to 4a697bf Compare January 9, 2023 16:51
@tbenr tbenr marked this pull request as ready for review January 9, 2023 16:51
Copy link
Contributor

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks definitely like an improvement. Just a few things:


@Override
public void storeUnconfirmedBlobs(final BlobsSidecar blobsSidecar) {
// remove blobs from the already validated cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We couldn't unvalidate blobs, but we could get, say, IGNORE result on the second import try and remove validation in this case. I don't understand why it's needed. From my point of view, it could only damage us in some case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it isn't required.. it is a strange case, that should never occur, so the idea was to be conservative and force a revalidation of the sidecar against commitments during subsequent block import. But since it is strictly coupled with the block via blockroot I can remove it.

tbenr added 6 commits January 10, 2023 18:22
spotlessly

continue reverting blobs cache

data availability check if commitments are empty

implement ForkChoice UT
implement BlockManager UT

revert blobs cache in ChainStorage

fix block validator UT

renaming

remove getBlobsSidecar in manager

add blobs sidecar caching
rename to blobsSidecarManager
add tests

postponing blobs storing after known\invalid block checks

expose cause

add gossip validation and fix Availability Checker

first tmp commit
@tbenr tbenr force-pushed the eip4844-blobsmanager branch from d18b324 to 5bc09d9 Compare January 10, 2023 17:23
@tbenr tbenr enabled auto-merge (squash) January 10, 2023 17:32
@tbenr tbenr merged commit 06efe10 into Consensys:master Jan 10, 2023
@tbenr tbenr deleted the eip4844-blobsmanager branch January 10, 2023 17:41
@tbenr tbenr mentioned this pull request Jan 16, 2023
58 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement BlobsSidecar lifecycle. implement beacon_block_and_blobs_sidecar gossip validation
2 participants