Skip to content

NO-TICK: Add capability of turning Block into FinalizedBlock.#172

Merged
goral09 merged 8 commits into
casper-network:masterfrom
goral09:block_exec_proto_height
Aug 26, 2020
Merged

NO-TICK: Add capability of turning Block into FinalizedBlock.#172
goral09 merged 8 commits into
casper-network:masterfrom
goral09:block_exec_proto_height

Conversation

@goral09

@goral09 goral09 commented Aug 26, 2020

Copy link
Copy Markdown
Contributor

This is necessary for node syncing/joining catch-up mechanism. We want to download Block(s) (linear chain blocks) and execute them.

This is necessary for node syncing/joining catch-up mechanism. We want to download `Block`(s) (linear chain blocks) and execute them.
ProtoBlock hash may be a default `Digest` for finalized blocks created out of the linear chain blocks while height is universal and the same on all nodes.

@afck afck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving… but I'm more and more convinced that it was a mistake to add parent_hash to ProtoBlock in the first place. Can we remove it?

Comment thread node/src/types/block.rs Outdated
@goral09 goral09 requested review from Fraser999 and afck August 26, 2020 15:08

@afck afck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! Looks good to me!
(Although I'm sure we'll realize tomorrow why this was a mistake. 😅)

You could probably even re-enable a too_many_arguments lint somewhere now.

Deploy buffer shouldn't warn about this case b/c it's never a replay attack (no deploys).
@goral09

goral09 commented Aug 26, 2020

Copy link
Copy Markdown
Contributor Author

Awesome! Looks good to me!
(Although I'm sure we'll realize tomorrow why this was a mistake. )

You could probably even re-enable a too_many_arguments lint somewhere now.

You were right, I hit the same problem I had when I tried to fix the node over the weekend – deploy buffer was logging ERRORs b/c it was receiving a signal that a proto block has been finalized that it (deploy buffer) hadn't seen before. This is happening because when it receives multiple proto blocks that are the same – empty deploy buffer and a random bit – but it would store it only once (it's tracked in the HashMap).

I added a logic to detect these cases and not log errors. See 3082e05.

If you're still OK with merging it, let me know.

Comment thread node/src/components/deploy_buffer.rs Outdated
// TODO: Events are not guaranteed to be handled in order, so this could happen!
error!("finalized block that hasn't been processed!");
let is_empty_proto = block == ProtoBlock::empty_random_bit_false()
|| block == ProtoBlock::empty_random_bit_true();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not define some block.is_empty() helper function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great idea! :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

afck
afck previously approved these changes Aug 26, 2020

@afck afck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, if I understand correctly I'm still fine with merging this: Those error messages didn't really make sense, did they?

I think the complication that removing the parent hash will add is that we now will need to give a list of not-yet-finalized ancestors to the deploy buffer after all, instead of just one, because it points to its ancestors anyway?

@goral09

goral09 commented Aug 26, 2020

Copy link
Copy Markdown
Contributor Author

Yes, if I understand correctly I'm still fine with merging this: Those error messages didn't really make sense, did they?

Yes, for the scenario that I am describing they didn't make any sense.

I think the complication that removing the parent hash will add is that we now will need to give a list of not-yet-finalized ancestors to the deploy buffer after all, instead of just one, because it points to its ancestors anyway?

At the moment, deploy buffer is given past_blocks: HashSet<ProtoBlockHash> so it has to filter those out before returning. There's no parent in the ProtoBlock. I think that the idea was to give deploy buffer all (hashes of lists of) deploy hashes that were proposed between now and the LFB (b/c deploy buffer can learn about LFB as well) and it would filter out what has been already proposed.

@afck afck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, do you mind if we talk about this again tomorrow, before merging? I'm still pretty confused.

Is the issue really about empty blocks specifically? Or did it just show up because all empty blocks are equal? And it will happen for other equal proto blocks, too — which can happen legitimately, because two sibling blocks are allowed to have the same value?

(If someone else approves it, feel free to merge it, of course! I'm just currently unable to wrap my head around this. 😅)

@afck afck self-requested a review August 26, 2020 17:05
@afck afck dismissed their stale review August 26, 2020 17:06

See comment above.

@goral09

goral09 commented Aug 26, 2020

Copy link
Copy Markdown
Contributor Author

It's only about empty proto blocks – although there are two variants of empty proto block:

  1. no deploys, random_bit=false
  2. no deploys, random_bit=true

If two proto blocks like this are created in a row then the error will be logged.

@goral09 goral09 merged commit 6dcf4d8 into casper-network:master Aug 26, 2020
@goral09 goral09 deleted the block_exec_proto_height branch August 26, 2020 17:19
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
Co-authored-by: JC <jc@pnkr.io>
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.

3 participants