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

NDRS-571: LinearChainSync: Verify parent hashes. #508

Merged
merged 3 commits into from
Nov 9, 2020

Conversation

afck
Copy link
Contributor

@afck afck commented Nov 8, 2020

@@ -445,12 +450,16 @@ where
self.block_downloaded(rng, effect_builder, block.header())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this is yet another place where syncing while reusing local storage would fail – we would not execute blocks that we already have in the storage, so we would not get consensus instances they would have created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we do the same thing we do with incoming blocks: just call block_downloaded. I think that will execute them?

fn current_block(&self) -> Option<&BlockHeader> {
match &self.state {
State::SyncingTrustedHash { current_block, .. } => Option::as_ref(&*current_block),
State::SyncingDescendants { current_block, .. } => Some(&*current_block),
Copy link
Collaborator

Choose a reason for hiding this comment

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

How come you can do Option::as_ref(…) above and Some(…) here? Can you use the same version in both places?

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 the problem I ran into is that Box has as_ref, too, so if you call it on a Box<Option<_>>, it will call the Box one and return an &Option<_>. SyncingDescendants' current_block is not an Option anymore.

@@ -86,7 +86,7 @@ enum State {
/// Linear chain block being downloaded.
linear_chain_block: Box<Option<BlockHeader>>,
/// Block we received from a node and are currently executing.
current_block: Box<Option<BlockHeader>>,
current_block: Box<BlockHeader>,
Copy link
Collaborator

@goral09 goral09 Nov 9, 2020

Choose a reason for hiding this comment

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

If I understand correctly, it's not a current block anymore but the last block we had successfully downloaded and handled. The comment is also off.

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 didn't change when it gets set, except that I also set it when transitioning to SyncingDescendants.
Actually, the comment on the other current_block above also isn't correct, is it? current_block is not set when we start downloading it, but when we download its deploys. And it stays until we download the next block's deploys.

I still think the name is kind of okay; not sure what's the alternative? latest_block?

Also, do we need linear_chain_block at all?

Copy link
Collaborator

@goral09 goral09 left a comment

Choose a reason for hiding this comment

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

Neat.

@afck
Copy link
Contributor Author

afck commented Nov 9, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 9, 2020

Build succeeded:

@bors bors bot merged commit d044ad0 into casper-network:master Nov 9, 2020
@afck afck deleted the sync_parent branch November 9, 2020 11:22
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