-
Notifications
You must be signed in to change notification settings - Fork 313
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
Set initial canonical block root #9203
Set initial canonical block root #9203
Conversation
2684ed2
to
fca73a8
Compare
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. Added a few questions and some NITs. But overall looks good to go.
|
||
@Override | ||
public void onSlot(final UInt64 slot) { | ||
if (!slot.mod(UInt64.valueOf(32)).equals(ONE)) { |
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.
Wouldn't be better to use spec.getSlotsPerEpoch(slot)
instead of hardcoded 32?
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.
we could store slotsPerEpoch at initialisation, it wont change with current spec
final StoreTransaction transaction = recentChainData.startStoreTransaction(); | ||
recentChainData.getBestBlockRoot().ifPresent(transaction::setLatestCanonicalBlockRoot); | ||
transaction | ||
.commit() | ||
.finish(error -> LOG.error("Failed to store latest canonical block root", error)); |
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.
One thought: should we compare our current canonical block root value before starting a tx? Just thinking that if it hasn't changed there is no benefit in updating it.
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.
if it hasn't changed we may as well just update the variable regardless, its simpler imo...
|
||
applyToNodes(this::updateBestDescendantOfParent); | ||
|
||
// let's peak the best descendant of the initial canonical block root |
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.
NIT: did you mean pick
?
.map(this::getNodeByIndex) | ||
.orElse(initialCanonicalProtoNode.get()); | ||
|
||
// add a single weight to from the best descendant up to the root |
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.
NIT: add a single weight to ??? Maybe missing "it" or "the node"?
private static Optional<Bytes32> getInitialCanonicalBlockRoot( | ||
final StoreConfig config, final Optional<Bytes32> initialCanonicalBlockRoot) { | ||
if (config.getInitialCanonicalBlockRoot().isPresent()) { | ||
LOG.warn( |
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.
Why are we using WARN? Isn't this something we want to happen? It does not require intervention and is expected. I'd move it to INFO.
Signed-off-by: Paul Harris <[email protected]>
StoredLatestCanonicalBlockUpdater
on everyslot%32 == 1
protoArray.setInitialCanonicalBlockRoot
it "breaks the tie" by adding 1 to weight on all the nodes on the canonical chain identified by that block rootfixes #9198
Documentation
doc-change-required
label to this PR if updates are required.Changelog