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

feat: implemented BlockHeader (BFT-357) #12

Merged
merged 23 commits into from
Oct 26, 2023
Merged

feat: implemented BlockHeader (BFT-357) #12

merged 23 commits into from
Oct 26, 2023

Conversation

pompon0
Copy link
Collaborator

@pompon0 pompon0 commented Oct 25, 2023

Implemented https://www.notion.so/matterlabs/5d238e08fbed476b8550f697d9c39df6?v=51a4bffaba05499e8ca11bd625fff54a&p=16c93154366c4a3994457b44043dea71&pm=s with some differences. Summary of changes:

  • Replaced Block with BlockHeader with just a hash of the payload
  • Made consensus messages include the whole BlockHeader, rather than just hash (since it is small, once we moved the payload out)
  • Introduced a strongly typed Payload
  • Added protocol_version to the BlockHeader (and relevant checks to the consensus) - currently hardcoded to 0

Minor fixes:

  • split the leader::Error and replica::Error into per-method errors (since the error types returned by each are disjoint)
  • relaxed the "stringly" typed assertions from sync_block tests (if needed they should use strongly typed errors instead)
  • added "size" to the protobuf encoding of BitVec, so that the encoded BitVec value is context free

@pompon0 pompon0 changed the title Gprusak block header feat: implemented BlockHeader Oct 25, 2023
@pompon0 pompon0 changed the title feat: implemented BlockHeader feat: implemented BlockHeader (BFT-357) Oct 25, 2023
Copy link
Member

@brunoffranca brunoffranca left a comment

Choose a reason for hiding this comment

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

Looks good, I only have a few minor nits.

Comment on lines 8 to 9
/// Currently it is stored in the BlockHeader (TODO: consider whether it should be present in every
/// consensus message).
Copy link
Member

Choose a reason for hiding this comment

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

Instead of letting it as a TODO, let's think about it now. What are the arguments in favor? (I assume the only argument against is bigger messages)

Copy link
Collaborator Author

@pompon0 pompon0 Oct 26, 2023

Choose a reason for hiding this comment

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

The argument in favor is that if we have a new version which changes the semantics of the consensus message it may happen that the validator running old binary will sign a message that will be incorrectly interpreted by a validator running a new binary.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should do it then.

/// Currently it is stored in the BlockHeader (TODO: consider whether it should be present in every
/// consensus message).
/// Currently it also determines the format and semantics of the block payload
/// (TODO: consider whether the payload should be versioned separately).
Copy link
Member

Choose a reason for hiding this comment

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

We discussed this on the last team meeting and were in agreement that we should keep just one version for both consensus and execution layers. I said that I was going to try to find some reason to have separate versions, but I couldn't find any.
Do you still feel that we need to think this through more or are you happy committing to one protocol version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had some afterthoughts after that discussion in the context of the above: if we keep the version (only) in the block, then some messages don't include the version at all. And if we (hypothetically) added version to both header and the messages, then forcing them to be the same wouldn't bring any benefit and might be constraining. Not a strong opinion, just writing down my thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

Well, if we include the version in every message, then we don't need to include it in the block header. The block header is never sent by itself over the wire, either it is sent in a leader prepare or in a final block (which would contain the version in the commit QC). It would even make some sense since the protocol version isn't technically a property of the block, but of the nodes.

node/libs/roles/src/validator/messages/block.rs Outdated Show resolved Hide resolved
node/libs/roles/src/validator/messages/consensus.rs Outdated Show resolved Hide resolved
node/libs/roles/src/validator/tests.rs Outdated Show resolved Hide resolved
node/libs/roles/src/validator/tests.rs Outdated Show resolved Hide resolved
node/libs/storage/src/types.rs Outdated Show resolved Hide resolved
node/actors/consensus/src/leader/state_machine.rs Outdated Show resolved Hide resolved
node/actors/consensus/src/leader/tests.rs Show resolved Hide resolved
node/actors/sync_blocks/src/peers/tests.rs Show resolved Hide resolved
node/libs/roles/src/validator/messages/block.rs Outdated Show resolved Hide resolved
node/libs/schema/src/std_conv.rs Outdated Show resolved Hide resolved
slowli
slowli previously approved these changes Oct 26, 2023
@pompon0 pompon0 merged commit 9735904 into main Oct 26, 2023
3 of 4 checks passed
@pompon0 pompon0 deleted the gprusak-block-header branch October 26, 2023 16:31
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