Skip to content

Conversation

@zilm13
Copy link
Contributor

@zilm13 zilm13 commented Sep 17, 2025

PR Description

Part of #9835

Start from VersionedHashDBSource

  • it's used from KvStoreDatabase for every actions with VersionedHash'es
  • it's initialized with VersionedHashDBSourceFactory starting from VersionedDatabaseFactory
  • method getSidecarIdentifier will be used later to get corresponding Blob
  • not adding VersionedHash-es to Store, because it would be difficult to keep it update along with blobSidecars. Also DataColumnSidecars are not a part of the Store and niche of VersionedHash usage is only getBlobs RPC.

Fixed Issue(s)

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.

Note

Add VersionedHash storage/lookup tests and integrate versioned-hash assertions for blob/data-column sidecars, plus minor KZG fixture tweak and small spec/util helpers.

  • Storage/tests:
    • Add VersionedHashDBSourceTest and VersionedHashDBSourceFactoryTest covering activation, add/remove, and serialization of sidecar identifier metadata; wire via CustodyGroupCountChannel.
    • Extend DatabaseTest to assert VersionedHash presence/absence for canonical and non-canonical BlobSidecar and DataColumnSidecar, including pruning flows; add helpers to activate and verify versioned-hash mappings and combined availability checks.
    • Update ChainStorageTest to verify SidecarIdentifier retrieval by VersionedHash for finalized historical blob sidecars.
  • Spec/util:
    • DataStructureUtil: add randomVersionedHash(), refactor randomVersionedHashes, and overload randomDataColumnSidecar(...) to accept existing commitments.
    • BlobSidecar: add getSlotAndBlockRootAndBlobIndex() helper.
  • KZG test fixture:
    • NoOpKZG.blobToKzgCommitment now derives commitment from the blob’s first 48 bytes instead of returning zeros.

Written by Cursor Bugbot for commit 0e97154. This will update automatically on new commits. Configure here.

CustodyGroupCountChannel.class,
new CustodyGroupCountChannel() {
@Override
public void onGroupCountUpdate(int custodyGroupCount, int samplingGroupCount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a question here: do we receive this event here quick enough even when the node is a supernode due to number of ETH attached and not just due to explicit custody param?

I'm worried if we are able to set the flag quick enough and avoid loosing versioned hashed

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, I was thinking about this. We could have race here. We could try to pass supernode flag earlier at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we save how much we custody in a db var, so that it can go up only as per spec? I just remember this, maybe i'm wrong

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, we save, but we cannot put db read in constructor (or can?). I mean it's slow

.getKZGCommitment());
} else {
this.dataColumnSidecarToVersionedHash = pair -> VersionedHash.EMPTY;
}
Copy link
Contributor

@tbenr tbenr Sep 18, 2025

Choose a reason for hiding this comment

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

I wander if we need to provide a noop version. Is there a situation where we call these ToVersionedHash functions and it is legit to have a NOOP one? would it be a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's basically is fulu milestone supported. I don't understand where could it fail

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean we can provide the actual function without checking if supported. Cose if we end up calling those functions we are obviously in that milestone. If not is a bug (but in this version we will return empty instead of failing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yeah, you are right, until it's called it cannot fail, I will update the code

private final Function<BlobSidecar, VersionedHash> blobSidecarToVersionedHash;
private final Function<Pair<DataColumnSidecar, UInt64>, VersionedHash>
dataColumnSidecarToVersionedHash;
private final AtomicBoolean storeSidecarHashes = new AtomicBoolean(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we control the activation of the blobSidecar's versioned hashes storage too? not sure, we want to activate this for blobs by default...

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, blobSidecar is available by default.
But for dataColumnSidecars we need to have all sidecars (to be precise at least 64) to restore blob, so it makes sense there.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if you are not running an L2 you won't need that api and you wont need to store those indices. I thought that api call by versionedhashes was essentially optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It replaces getBlobSidecars, it's not in debug space ethereum/beacon-APIs#546
So by spec we should support it by default from my understanding

Bytes.wrap(Longs.toByteArray(sidecar.getSlot().longValue())),
sidecar.getBlockRoot(),
Bytes.wrap(Longs.toByteArray(blobIndex.longValue())));
}
Copy link
Contributor

@tbenr tbenr Sep 18, 2025

Choose a reason for hiding this comment

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

thinking about is it is wise to use DataColumnSlotAndIdentifier here too so we make sure we save data that is by design matches the key we use to lookup blobs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Semantically it will be more correct to use SlotAndBlockRootAndBlobIndex for both but it's not SSZ and doesn't have handy serialization/deserealization

@zilm13 zilm13 mentioned this pull request Sep 25, 2025
2 tasks
@zilm13
Copy link
Contributor Author

zilm13 commented Sep 25, 2025

Finished
Splitting because of the size.
First part is #9931

@zilm13 zilm13 changed the title Add VersionedHashDBSource for VersionedHash column handling VersionedHashDBSource tests Sep 30, 2025
@zilm13 zilm13 marked this pull request as ready for review September 30, 2025 19:04
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@rolfyone rolfyone left a comment

Choose a reason for hiding this comment

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

LGTM

dataColumnSidecar.getIndex().increment()),
updater);
verifyNoMoreInteractions(dao, updater, commitmentToVersionedHashFunction);
}
Copy link

Choose a reason for hiding this comment

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

Bug: Sidecar Deduplication Test Fails Due to Random KZG Commitments

The addSidecarVersionedHashes and addNonCanonicalSidecarVersionedHashes tests create a second DataColumnSidecar with new random KZG commitments. This prevents correctly testing the deduplication logic for sidecars from the same block, as all data column sidecars for a given block should share the same KZG commitments.

Additional Locations (1)

Fix in Cursor Fix in Web

@zilm13 zilm13 merged commit 2d80867 into Consensys:master Oct 1, 2025
19 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2025
@zilm13 zilm13 deleted the db-versioned-hash branch October 1, 2025 12:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants