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

Move away from no blobs placeholders to storing earliestBlobSidecar separately #7128

Merged
merged 48 commits into from
May 19, 2023

Conversation

zilm13
Copy link
Contributor

@zilm13 zilm13 commented May 10, 2023

PR Description

TODO:

  • deal with TODOs
  • add tests

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.

zilm13 and others added 30 commits May 2, 2023 00:47
@zilm13 zilm13 marked this pull request as ready for review May 13, 2023 20:21
@zilm13
Copy link
Contributor Author

zilm13 commented May 13, 2023

Ready for review
I'm a bit messed with all of our storage types: Store, RecentChainData, HotDao, FinalizedDao, Database, so be careful on review

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

Some comments

new ConcurrentHashMap<>();
private Optional<UInt64> maybeEarliestBlobSidecarSlot = Optional.empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

better to put it as volatile? can different threads access this non-final field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if alwaysRun fragment is executed in the same time (and it's the only other usage) when we do import, we definitely have problems in the whole class. I'm not sure we need volatile here

if (!blobSidecars.isEmpty()) {
this.blobSidecars.put(block.getSlotAndBlockRoot(), blobSidecars);
}
if (maybeEarliestBlobSidecarTransactionSlot.isEmpty()) {
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 be maybeEarliestBlobSidecarSlot from method param?
If I am right, why no tests are 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.

No
We don't set it again if it's already set, that's an idea.
We set it only once.
We could override it later only when pruning.
I think it's a correct logic as we don't want to move it to the right on every batch

Copy link
Contributor Author

@zilm13 zilm13 May 16, 2023

Choose a reason for hiding this comment

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

As an option, we could check if new value is smaller and change it only in this condition.
Also we could consider moving earliestBlobSidecar to the separate method but I dislike it as I want to force anyone saving blobSidecars to provide it. I think it's safer

this.blobSidecars.put(block.getSlotAndBlockRoot(), blobSidecars);
}
if (maybeEarliestBlobSidecarTransactionSlot.isEmpty()) {
maybeEarliestBlobSidecarTransactionSlot = maybeEarliestBlobSidecarSlot;
Copy link
Contributor

Choose a reason for hiding this comment

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

this. just to be clear?

@@ -164,6 +164,11 @@ public int getBlobSidecarsCount(final Optional<SignedBeaconBlock> signedBeaconBl
.orElse(0);
}

public UInt64 computeDenebStartSlot() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use a feature not a milestone in the name. Something like computeFirstSlotWithBlobSupport

@@ -408,10 +409,20 @@ private BlockImportResult importBlockAndState(
}

final StoreTransaction transaction = recentChainData.startStoreTransaction();
final UInt64 earliestAffectedSlot =
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd definitely put a comment here to explain why we are doing this way. Or move the computation on a dedicated private method with a self-explanatory name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment to applyBlockToStore method, do you think it could be enough?

Comment on lines 322 to 326
final Optional<UInt64> maybeEarliestBlobSidecarSlotDb = dao.getEarliestBlobSidecarSlot();
if (maybeEarliestBlobSidecarSlotDb.isEmpty() && maybeEarliestBlobSidecar.isPresent()) {
updater.setEarliestBlobSidecarSlot(maybeEarliestBlobSidecar.get());
}
updater.commit();
Copy link
Contributor

Choose a reason for hiding this comment

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

what about

maybeEarliestBlobSidecar.ifPresent(earliestBlobSidecar -> {
if(dao.getEarliestBlobSidecarSlot().isEmpty()) {
updater.setEarliestBlobSidecarSlot(earliestBlobSidecar);
}
});

so we query only if need?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed to the same idea but I like this code more

      if (maybeEarliestBlobSidecar.isPresent() && dao.getEarliestBlobSidecarSlot().isEmpty()) {
        updater.setEarliestBlobSidecarSlot(maybeEarliestBlobSidecar.get());
      }

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

LGTM

@zilm13 zilm13 merged commit 372ca02 into Consensys:master May 19, 2023
4 checks passed
@zilm13 zilm13 deleted the storage/fix-earliest-blobsidecar branch May 19, 2023 05:10
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.

None yet

2 participants