Skip to content

Conversation

@MatheusFranco99
Copy link
Contributor

@MatheusFranco99 MatheusFranco99 commented Apr 24, 2025

Overview

This PR introduces the Identifier as 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 nil or with length 0, which is now impossible to try.

Closes #533

Copy link

Copilot AI left a 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 {

@MatheusFranco99 MatheusFranco99 force-pushed the fix-identifier-length branch from 1d00db1 to 47cd151 Compare June 11, 2025 10:05
@github-actions
Copy link

This pull request has been marked as stale due to 60 days of inactivity.

@github-actions github-actions bot added the stale label Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid QBFT identifiers in tests

4 participants