refactor(net): truncate oversized signatures#34
Open
Federico2014 wants to merge 1 commit into
Open
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Follow-up to tronprotocol#6782. For transaction signatures longer than 68 bytes, truncate the trailing bytes to exactly 68 instead of rejecting the transaction. Signatures shorter than 65 bytes are no longer rejected up front — they fall through to downstream signature verification, which still rejects them.
TransactionCapsule.sanitizeSignatures()truncates each oversized signature to 68 bytes; signatures already in range are untouched (no rebuild, no transaction-id change).TransactionsMessage.sanitizeSignature()sanitizes every contained transaction and rewrites the wire bytes when anything changed.Wallet.broadcastTransactionandTransactionsMsgHandler.checkcall sanitize first, then drop the now-redundant per-signature length validation.RelayService(peer hello handshake) keeps the strict[65, 68]check inline;SignUtils.isValidLengthis removed since no caller remains.Why are these changes required?
The strict admission filter from tronprotocol#6782 also rejects historical transactions whose signatures legitimately carry trailing padding beyond 68 bytes. Truncating those bytes preserves the canonical 65-byte r/s/v while still admitting the transaction, matching the sanitize pattern introduced in tronprotocol#6797.
This PR has been tested by:
SanitizeSignaturesTest(capsule + message-level, 8 cases)WalletMockTest.testBroadcastTxInvalidSigLengthTransactionsMsgHandlerTest.testInvalidSigLength./gradlew :framework:checkstyleMain :framework:checkstyleTestFollow up
None.
Extra details
Peer hello handshake (
RelayService) intentionally stays strict — hello signatures are not on the transaction admission path and have no historical padding to accommodate.Summary by cubic
Truncate transaction signatures longer than 68 bytes at admission instead of rejecting them to restore compatibility with historical transactions. Upfront length checks are removed; undersized signatures still fail during downstream verification.
Written for commit 6ff34e6. Summary will update on new commits. Review in cubic