-
Notifications
You must be signed in to change notification settings - Fork 265
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
Move away from no blobs placeholders to storing earliestBlobSidecar separately #7128
Conversation
…art of storage comparison)
…from HistoricalBatchFetcher
…ng test from StoreTest and improve ChainStorageTest
Ready for review |
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
final Optional<UInt64> maybeEarliestBlobSidecarSlotDb = dao.getEarliestBlobSidecarSlot(); | ||
if (maybeEarliestBlobSidecarSlotDb.isEmpty() && maybeEarliestBlobSidecar.isPresent()) { | ||
updater.setEarliestBlobSidecarSlot(maybeEarliestBlobSidecar.get()); | ||
} | ||
updater.commit(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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());
}
…smaller than existing tx/db value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Description
TODO:
deal with TODOsadd testsFixed Issue(s)
Documentation
doc-change-required
label to this PR if updates are required.Changelog