-
Notifications
You must be signed in to change notification settings - Fork 6
Consensus justification #44
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
Open
MatheusFranco99
wants to merge
4
commits into
main
Choose a base branch
from
consensus-justification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| ## All SIPS | ||
|
|
||
| | SIP # | Title | Status | | ||
| |---------------------------------------|-----------------------------|--------| | ||
| | [1](./sips/dkg.md) | DKG | open-for-discussion | | ||
| | [2](./sips/msg_struct_encoding.md) | Message struct and encoding | open-for-discussion | | ||
| | [3](./sips/qbft_sync.md) | QBFT Sync | open-for-discussion | | ||
| | [4](./sips/change_operator.md) | Change operators set | open-for-discussion | | ||
| | [5](./sips/ecies_share_encryption.md) | ECIES Share Encryption | open-for-discussion | | ||
| | [6](./sips/constant_qbft_timeout.md) | Constant QBFT timeout | open-for-discussion | | ||
| | [7](./sips/fork_support.md) | Fork Support | open-for-discussion | | ||
| | [8](./sips/pre_consensus_livness.md) | Pre-Consensus livness fix | open-for-discussion | | ||
| | SIP # | Title | Status | | ||
| |-----------------------------------------|-----------------------------|---------------------| | ||
| | [1](./sips/dkg.md) | DKG | open-for-discussion | | ||
| | [2](./sips/msg_struct_encoding.md) | Message struct and encoding | open-for-discussion | | ||
| | [3](./sips/qbft_sync.md) | QBFT Sync | open-for-discussion | | ||
| | [4](./sips/change_operator.md) | Change operators set | open-for-discussion | | ||
| | [5](./sips/ecies_share_encryption.md) | ECIES Share Encryption | open-for-discussion | | ||
| | [6](./sips/constant_qbft_timeout.md) | Constant QBFT timeout | open-for-discussion | | ||
| | [7](./sips/fork_support.md) | Fork Support | open-for-discussion | | ||
| | [8](./sips/pre_consensus_livness.md) | Pre-Consensus livness fix | open-for-discussion | | ||
| | [11](./sips/consensus_justification.md) | Consensus justification | open-for-discussion | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| ## Core | ||
|
|
||
| | SIP # | Title | Status | | ||
| |------------------------------------|-----------------------------|--------| | ||
| | [1](./sips/dkg.md) | DKG | open-for-discussion | | ||
| | [2](./sips/msg_struct_encoding.md) | Message struct and encoding | open-for-discussion | | ||
| | [3](./sips/qbft_sync.md) | QBFT Sync | open-for-discussion | | ||
| | [4](./sips/change_operator.md) | Change operators set | open-for-discussion | | ||
| | [5](./sips/ecies_share_encryption.md) | ECIES Share Encryption | open-for-discussion | | ||
| | [6](./sips/constant_qbft_timeout.md) | Constant QBFT timeout | open-for-discussion | | ||
| | [7](./sips/fork_support.md) | Fork Support | open-for-discussion | | ||
| | [8](./sips/pre_consensus_livness.md) | Pre-Consensus livness fix | open-for-discussion | | ||
| | SIP # | Title | Status | | ||
| |-----------------------------------------|-----------------------------|---------------------| | ||
| | [1](./sips/dkg.md) | DKG | open-for-discussion | | ||
| | [2](./sips/msg_struct_encoding.md) | Message struct and encoding | open-for-discussion | | ||
| | [3](./sips/qbft_sync.md) | QBFT Sync | open-for-discussion | | ||
| | [4](./sips/change_operator.md) | Change operators set | open-for-discussion | | ||
| | [5](./sips/ecies_share_encryption.md) | ECIES Share Encryption | open-for-discussion | | ||
| | [6](./sips/constant_qbft_timeout.md) | Constant QBFT timeout | open-for-discussion | | ||
| | [7](./sips/fork_support.md) | Fork Support | open-for-discussion | | ||
| | [8](./sips/pre_consensus_livness.md) | Pre-Consensus livness fix | open-for-discussion | | ||
| | [11](./sips/consensus_justification.md) | Consensus justification | open-for-discussion | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| | Author | Title | Category | Status | Date | | ||
| | -------------- | ----------------------- | -------- | ------------------- | ---------- | | ||
| | Matheus Franco | Consensus Justification | Core | open-for-discussion | 2024-03-08 | | ||
|
|
||
| ## Summary | ||
|
|
||
| Drop decided messages and include a consensus justification nested in post-consensus messages. | ||
|
|
||
| ## Motivation | ||
|
|
||
| Decided messages represent $16$% of the exchanged messages in the network and also significantly increase the thresholds of allowed messages in message validation. Furthermore, it's not a necessary part of the protocol and the speed-up that it provides can be provided by a simpler justification in the post-consensus message. | ||
|
|
||
| ## Rationale | ||
|
|
||
| As it's done with the pre-consensus justification, that is included in the *Proposal* message, we propose including a consensus justification (an aggregated commit message) in the post-consensus message instead of sending decided messages. | ||
|
|
||
| First of all, the decided messages are useful to allow nodes to start the post-consensus phase if they are "behind" in the protocol execution due to not receiving messages. However, a consensus justification inside a post-consensus message allows a node to accomplish the same result while progressing even further due to the post-consensus signature. Moreover, this proposal aligns the design decisions of the (pre-consensus, consensus) and (consensus, post-consensus) inter-phases. | ||
|
|
||
| ## Improvements | ||
|
|
||
| This proposal reduces the number of messages exchanged in the network by $16$%. | ||
|
|
||
| ## Spec change | ||
|
|
||
| ### Message structure | ||
|
|
||
| **Adding a justification in post-consensus messages** | ||
|
|
||
| Within a `SignedPartialSignatureMessage.PartialSignatureMessages`, all `PartialSignatureMessage` objects refer to the same `QBFT Instance`. Thus, we can simply add the justification to the `SignedPartialSignatureMessage` as follows: | ||
|
|
||
| ```go | ||
| type SignedPartialSignatureMessage struct { | ||
| Message PartialSignatureMessages | ||
| Signature Signature `ssz-size:"96"` | ||
| Signer OperatorID | ||
| Justification *SignedMessage // Aggregated commit message (or []*SignedMessage if we ever use another asymmetric scheme that doesn't allow aggregation) | ||
| } | ||
| ``` | ||
|
|
||
| It could even be added to the `PartialSignatureMessages` types. The difference is that this would *hold* the `SignedPartialSignatureMessage.Signature` also to the consensus justification. | ||
|
|
||
| ### New post-consensus logic | ||
|
|
||
| To implement the justification logic, once a post-consensus message is received, if the consensus has not been decided yet, we ask the consensus module to process a justification in a similar way that a decided message is processed (except y the feature of holding a state and broadcasting new decided messages). If the processing is successful, we update the runner state and continue with the current post-consensus logic. | ||
|
|
||
| ```go | ||
| func (b *BaseRunner) basePostConsensusMsgProcessing(runner Runner, signedMsg *types.SignedPartialSignatureMessage) (bool, [][32]byte, error) { | ||
|
|
||
| if !b.hasRunningDuty() { | ||
| // do nothing | ||
| } | ||
|
|
||
| // If has not decided yet, process the justification | ||
| if b.State.DecidedValue == nil && b.State != nil && b.State.RunningInstance != nil { | ||
| // Process | ||
| decidedMsg, err := b.QBFTController.ProcessConsensusJustification(signedMsg.Justification) | ||
| if err != nil { | ||
| // return error | ||
| } | ||
|
|
||
| // Decode | ||
| decidedValue = &types.ConsensusData{} | ||
| // ... | ||
|
|
||
| // Set state | ||
| b.highestDecidedSlot = decidedValue.Duty.Slot | ||
| b.State.DecidedValue = decidedValue | ||
| } | ||
| // Follow-up with the current post-consensus processing | ||
| } | ||
| ``` | ||
|
|
||
| The justification may be large and there's no need for it in pre-consensus messages. Thus, we also recommend adding a check in the pre-consensus processing to assert that there's no consensus justification. This is useful as a part of a protection against buffer DoS attacks. | ||
|
|
||
| ```go | ||
| func (b *BaseRunner) basePreConsensusMsgProcessing(runner Runner, signedMsg *types.SignedPartialSignatureMessage) (bool, [][32]byte, error) { | ||
| if signedMsg.Justification != nil { | ||
| // Return error | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
|
|
||
| ## Drawbacks | ||
|
|
||
| - The post-consensus messages would be bigger due to the aggregated commit message. | ||
| - Exporters use decided messages to compute statistics of the network. Therefore, the proposal implies not only a protocol change but also changes in the exporter implementation. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How do I validate this and decide on a stalled instance?
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.
Added