Skip to content

Re-add missing tests and fix error code handling#586

Merged
GalRogozinski merged 3 commits intomainfrom
fix-partial-signature
Oct 28, 2025
Merged

Re-add missing tests and fix error code handling#586
GalRogozinski merged 3 commits intomainfrom
fix-partial-signature

Conversation

@GalRogozinski
Copy link
Contributor

Description

Some tests were commented out mistakingly before.
I re-added them and fixed an issue with the new error codes that made them fail.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Fixed variable shadowing bug in ReconstructSignature and re-enabled 20 previously commented tests.

Key changes:

  • Changed if err := to if err = in ssv/partial_sig_container.go:109 to prevent variable shadowing that was causing error codes to be lost
  • Re-enabled tests across validation checks (valcheckattestations, valcheckproposer), partial signature container (partialsigcontainer), duty execution (dutyexe), and runner construction (runnerconstruction)
  • The bug prevented types.Error with error code 34 (ReconstructSignatureErrorCode) from propagating correctly when signature verification failed
  • Generated JSON test files for the re-enabled tests

The variable shadowing issue was critical: when VerifyReconstructedSignature returned an error with a specific error code, the outer err variable wasn't being set because := created a new local variable. This caused AssertErrorCode tests to fail since they couldn't find the expected error code in the wrapped error.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it fixes a critical variable shadowing bug and re-enables tests
  • The fix is a one-character change (:= to =) that corrects a critical variable shadowing bug preventing error codes from propagating. The re-enabled tests validate the fix works correctly. All changes are test-related with no production code risk.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
ssv/partial_sig_container.go 5/5 Fixed variable shadowing bug where err := prevented the outer err from being set, causing error codes to be lost
ssv/spectest/all_tests.go 5/5 Re-enabled 20 previously commented test functions across validation checks, partial sig container, and runner construction
ssv/spectest/tests/partialsigcontainer/test.go 5/5 Test runner that validates partial signature container behavior using AssertErrorCode to check error codes

Sequence Diagram

sequenceDiagram
    participant Test as Test Suite
    participant PSC as PartialSigContainer
    participant Types as types.VerifyReconstructedSignature
    participant Error as types.Error (with code)

    Test->>PSC: ReconstructSignature(root, pubKey, validatorIndex)
    PSC->>PSC: Check signatures exist
    PSC->>PSC: ReconstructSignatures(operatorSignatures)
    
    Note over PSC: Before fix: err := (new variable)<br/>After fix: err = (reuse outer variable)
    
    PSC->>Types: VerifyReconstructedSignature(signature, pubKey, root)
    
    alt Verification fails
        Types-->>PSC: types.Error with ReconstructSignatureErrorCode (34)
        Note over PSC: With bug: outer err not set (shadowed)<br/>Without bug: outer err properly set
        PSC-->>Test: errors.Wrap(err, "failed to verify...")
        Test->>Test: AssertErrorCode checks err.Code == 34
        Note over Test: Bug caused tests to fail:<br/>error code was lost due to shadowing
    else Verification succeeds
        Types-->>PSC: nil
        PSC-->>Test: signature.Serialize()
    end
Loading

45 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@GalRogozinski GalRogozinski changed the title Readd missing tests and fix error code handling Re-add missing tests and fix error code handling Oct 24, 2025
@y0sher y0sher requested a review from iurii-ssv October 27, 2025 12:31
@GalRogozinski GalRogozinski merged commit 91ceedb into main Oct 28, 2025
2 checks passed
@GalRogozinski GalRogozinski deleted the fix-partial-signature branch October 28, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants