Refactor QBFT Identifier as type with fixed length#536
Open
MatheusFranco99 wants to merge 8 commits intomainfrom
Open
Refactor QBFT Identifier as type with fixed length#536MatheusFranco99 wants to merge 8 commits intomainfrom
MatheusFranco99 wants to merge 8 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the QBFT identifier from a variable-length []byte to a fixed-length Identifier type, updating SSZ encoding/decoding logic, related offsets, and tests accordingly. Key changes include:
- Transitioning the Identifier field to a fixed-length type with updated SSZ tags.
- Adjusting SSZ offset calculations in encoding/decoding functions to match the new fixed layout.
- Removing tests that validated nil or zero-length identifiers since these cases are no longer possible.
Reviewed Changes
Copilot reviewed 1995 out of 2008 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| qbft/spectest/all_tests.go | Removed tests for nil/empty identifier. |
| qbft/messages_encoding.go | Updated SSZ encoding/decoding offsets and length checks. |
| qbft/messages.go | Changed Identifier from []byte to Identifier and updated tags. |
| qbft/message_container_test.go | Adjusted tests to work with the Identifier type. |
| qbft/instance_test.go | Updated instance tests to use a fixed testing identifier. |
| qbft/instance.go | Modified constructor signature to accept Identifier type. |
| qbft/controller.go | Updated Identifier field type and validation to use fixed length. |
Files not reviewed (13)
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide duplicate msg.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide duplicate signer.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide future instance.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide has quorum.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide invalid full data.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide invalid msg.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide invalid value (should pass).json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide late decided smaller quorum.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide no quorum.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide unknown signer.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide wrong msg type.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller decide wrong sig.json: Language not supported
- qbft/spectest/generate/state_comparison/tests_ControllerSpecTest/qbft controller full flow after decided.json: Language not supported
Comments suppressed due to low confidence (2)
qbft/controller.go:133
- [nitpick] The error message 'message doesn't belong to Identifier' is unclear; consider updating it to a more descriptive message, for example 'message does not match controller identifier'.
if !bytes.Equal(c.Identifier[:], msg.QBFTMessage.Identifier[:]) {
qbft/messages_encoding.go:125
- [nitpick] The hardcoded offset value 128 is used as the expected starting point for subsequent fields; consider defining a named constant to improve clarity and maintainability.
if o6 != 128 {
13 tasks
6 tasks
1d00db1 to
47cd151
Compare
y0sher
approved these changes
Jun 11, 2025
|
This pull request has been marked as stale due to 60 days of inactivity. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PR introduces the
Identifieras a QBFT type with a fixed length for identifying QBFT instances, for example in messages, state and controller, instead of the previously used[]byte.SSZ Changes
Since the identifier now has a fixed length, the SSZ encoding changes as it's no longer necessary extra 4 bytes to indicate the length.
Thus, the auto-generated encoding files changed as well as the structures' maximum size values.
Tests
Two tests were removed as they tested setting the identifier field as
nilor with length 0, which is now impossible to try.Closes #533