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

Update optimistic import rules #5255

Merged
merged 5 commits into from
Mar 30, 2022
Merged

Conversation

ajsutton
Copy link
Contributor

PR Description

Can now import a block optimistically if it's parent has a non-default payload or if it is sufficiently old.
Also moves the logic for determining if optimistic import is allowed into the spec module since it's a function from the spec itself.

Fixed Issue(s)

fixes #5105

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.

Can now import a block optimistically if it's parent has a non-default payload or if it is sufficiently old.
Also moves the logic for determining if optimistic import is allowed into the spec module since it's a function from the spec itself.
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 with some nits

}

@Test
void isOptimisticSyncPossible_shouldBeFalseWhenBlockIsMergeButNotOldEnough() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename to canOptimisticallyImport_

}

@Test
void isOptimisticSyncPossible_shouldBeTrueWhenBlockIsMergeAndIsOldEnough() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename to canOptimisticallyImport_

Comment on lines 468 to 470
final boolean isExecutionBlock =
parentExecutionRoot.isPresent() && !parentExecutionRoot.get().isZero();
return isExecutionBlock;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the local boolean isExecutionBlock seems a bit redundant to me. The method itself has that name and should be enough to understand the objective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IntelliJ agrees. :)

@ajsutton ajsutton enabled auto-merge (squash) March 30, 2022 21:09
@ajsutton ajsutton merged commit a97aa66 into Consensys:master Mar 30, 2022
@ajsutton ajsutton deleted the new-opt-sync-rules branch March 30, 2022 21:35
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.

[Merge] Optimistically import any post-merge block
2 participants