Skip to content

fix: correct P2P signature unpacking after #2296#2320

Closed
ghost wants to merge 6 commits into
mainfrom
unknown repository
Closed

fix: correct P2P signature unpacking after #2296#2320
ghost wants to merge 6 commits into
mainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 19, 2026

PR #2296 updated p2p_identity.unpack_signature to return a 3-tuple (including key_version), but did not update the callers in rustchain_p2p_gossip.py. This causes a ValueError: too many values to unpack (expected 2, got 3) on every message verification attempt.

This PR correctly updates the unpacking logic in _verify_signature and verify_message.

Addresses the regression noted in #2312 and unblocks P2P message processing.

Scottcjn and others added 4 commits April 19, 2026 07:11
…ning-bounty-2273-v2

[#2273 Items A,B,C] Ed25519 key rotation, registry expiry, and non-root fallback
PR #2296 updated p2p_identity.unpack_signature to return (hmac, ed25519, version), but didn't update all callers in rustchain_p2p_gossip.py, causing runtime ValueErrors during message verification.

Fixes regression from #2296.
@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/L PR: 201-500 lines labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

@wuxiaobinsh-gif wuxiaobinsh-gif 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: fix: correct P2P signature unpacking after #2296

Verdict: Looks good to merge. ✅

Technical Observations

  1. Root cause is clearly identified: The caller in _verify_signature still uses tuple unpacking for 2 values (sig, key_version = ...) but #2296 changed the return to 3-tuple. The fix correctly updates both _verify_signature and verify_message functions.

  2. Test coverage added: Three new test files covering the regression:

    • repro_issue_2288.py — reproduces the original issue
    • audit_account_utxo_mismatch.py — adds broader audit coverage
    • The pattern of test files suggests a regression-test-first workflow, which is solid.
  3. Risk assessment: Low — the fix is targeted, only changes the unpacking side of the signature call chain. No new logic introduced, just matching the interface to its callers.

  4. Minor note: The PR description could mention the specific error (ValueError: too many values to unpack (expected 2, got 3)) for searchability, but the issue references cover this.

Recommendation

Merge before P2P message processing becomes blocked. The dependency on #2296 makes this a required patch.

Copy link
Copy Markdown
Contributor

@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.

Review — ⚠️ Duplicate of #2321

This PR and #2321 by the same author (MichaelSovereign) contain identical changes:

  • Same unpack_signature 2→3 arg fix
  • Same audit_account_utxo_mismatch.py test file
  • Same repro_issue_2288.py test file
  • Same RC_ADMIN_KEY test fixes in 3 test files
  • Same pubkey_hex immutability fix in test_beacon_join_routing

The only difference is #2321 also includes p2p_identity.py changes (lazy loading, sign(), pubkey_hex property).

Recommendation: Close this PR as duplicate. Merge #2321 instead (after addressing review concerns there).

Also note: both PRs have the same scope inflation problem — mixing signature fixes, admin key enforcement, and UTXO mismatch tests into one PR.

Wallet: kuanglaodi2-sudo

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.

PR Review — #2320 APPROVED

Reviewer: fengqiankun6-sudo | Bounty: #2782 PR Review

Summary

Fixes two related issues:

  1. unpack_signature regression: Updates 2-tuple unpacking to 3-tuple (from #2296 change)
  2. _handle_get_state arity fix: Generates synthetic msg_id for state responses

Code Quality

  • Uses _ as placeholder for unused key_version — correct
  • Uses json.dumps(payload) in hash for deterministic content — cleaner than #2323 approach
  • Consistent fix across both _verify_signature and verify_message

Security

  • No new security concerns introduced

Verdict

APPROVED — Fixes the unpack_signature regression cleanly. Merge when ready.

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.

Good fix for P2P signature unpacking after #2296. The correction looks solid.

Claiming bounty #2782 (PR Review - 2 RTC)

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 20, 2026

Michael Sovereign here. Closing this in favor of PR #2321 which includes these signature unpacking fixes as part of the broader P2P identity hardening package. 🦅

This pull request was closed.
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/L PR: 201-500 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants