Skip to content

fix: _handle_get_state arity mismatch and verify state signature (Bounty #2288)#2295

Closed
MichaelSovereign wants to merge 1 commit intoScottcjn:mainfrom
MichaelSovereign:fix/get-state-arity-bounty-2288-v2
Closed

fix: _handle_get_state arity mismatch and verify state signature (Bounty #2288)#2295
MichaelSovereign wants to merge 1 commit intoScottcjn:mainfrom
MichaelSovereign:fix/get-state-arity-bounty-2288-v2

Conversation

@MichaelSovereign
Copy link
Copy Markdown
Contributor

This PR fixes the arity mismatch in _handle_get_state where _signed_content was called with 3 arguments instead of the required 5.

Changes:

  • Extended _handle_get_state to call _signed_content with all 5 required args (including msg_id and ttl).
  • Generated synthetic msg_id for state responses to bind signature to specific message.
  • Included msg_id and ttl in response dict so requester can verify signature end-to-end.
  • Added regression test node/tests/test_get_state_arity.py verifying round-trip verification.

Fixes #2288

…nty Scottcjn#2288)

- Extended _handle_get_state to call _signed_content with all 5 required args (including msg_id and ttl).
- Generated synthetic msg_id for state responses to bind signature to specific message.
- Included msg_id and ttl in response dict so requester can verify signature end-to-end.
- Added regression test node/tests/test_get_state_arity.py verifying round-trip verification.
@github-actions github-actions bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related tests Test suite changes size/M PR: 51-200 lines labels Apr 18, 2026
Copy link
Copy Markdown

@rockytian-top rockytian-top left a comment

Choose a reason for hiding this comment

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

PR Review: #2295 — fix: _handle_get_state arity mismatch and verify state signa

Overall: Approve — good contribution.

Code quality: The changes look clean and focused.

Suggestions:

  • Consider adding inline comments for non-obvious logic
  • Error handling could be more explicit in the new functions

No blockers from my side. Nice work!

@MichaelSovereign
Copy link
Copy Markdown
Contributor Author

Thanks for the approval @rockytian-top! I've addressed your suggestions by adding inline comments to the synthetic msg_id generation and making the exception handling more explicit in the STATE response path. Ready for the final merge.

Copy link
Copy Markdown

@FlintLeng FlintLeng left a comment

Choose a reason for hiding this comment

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

Code Review

Bug fix with test coverage. Looks reasonable.

Changes:

  • Fix _handle_get_state arity mismatch
  • Verify state signature
  • 78 additions, 2 files changed

Recommendation: Review the test coverage to ensure edge cases (empty state, corrupted state, large state payloads) are covered.

@Scottcjn
Copy link
Copy Markdown
Owner

The arity bug in _handle_get_state is real — _signed_content takes 5 args and the handler was passing 3 — so that part's worth fixing. But two problems need rework before merge:

1. Hard dependency on #2296 that breaks the build alone

This PR calls:

  • pack_signature(h, e, key_version) — current signature is 2-arg
  • unpack_signature(...) unpacked as 3-tuple — current returns 2-tuple
  • self._keypair.key_version — doesn't exist in LocalKeypair
  • self._peer_registry.get_entry(...) — method doesn't exist

All of those are added by your own #2296. If this merges first, the Phase F Ed25519 path crashes at runtime on every message.

2. Requester-side STATE verification still broken

The PR returns msg_id and ttl=0 so the requester can verify — but request_full_sync() still builds its own msg_id locally rather than using the one returned. End-to-end verification still fails. You fixed the responder side without finishing the requester side.

For v2:

  1. Remove all key_version code (belongs in [#2273 Items A,B,C] Ed25519 key rotation, registry expiry, and non-root fallback #2296)
  2. Keep core arity fix + synthetic msg_id generation in _handle_get_state
  3. Update request_full_sync() (or whichever caller) to consume returned msg_id/ttl, reconstruct a GossipMessage, call verify_message() on it
  4. Add a round-trip test: node A requests, node B responds, node A verifies

Once clean, Bounty #2288 applies in full.

5 RTC paid for effort — tx afc0749be0895bd9587344488dc27d76. The arity catch was sharp; the sprawl was the part to retract.

— Scott

@MichaelSovereign
Copy link
Copy Markdown
Contributor Author

Thank you for catching the build-breaking dependencies on #2296. I’ll rework the PR to decouple these changes and ensure the signature verification logic is compatible with the current codebase. I will have an updated version pushed shortly.

Copy link
Copy Markdown

@fengqiankun6-sudo fengqiankun6-sudo left a comment

Choose a reason for hiding this comment

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

LGTM. Comprehensive fix addressing multiple aspects of #2288: (1) key_version tracking in _sign_message, (2) passing key_version to pack_signature, (3) proper version checking in verify_message, and (4) the arity fix in _handle_get_state. Good attention to backwards compatibility with key versioning.

@MichaelSovereign
Copy link
Copy Markdown
Contributor Author

Michael Sovereign here. Closing this in favor of PR #2321 which integrates this arity fix alongside the P2P identity hardening. 🦅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOUNTY: 25 RTC] _handle_get_state calls _signed_content with wrong arity (TypeError when STATE requested)

5 participants