-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor QBFT Identifier as type with fixed length #536
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
base: main
Are you sure you want to change the base?
Conversation
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.
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 {
1d00db1 to
47cd151
Compare
|
This pull request has been marked as stale due to 60 days of inactivity. |
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