Skip to content

feat(net): enforce single contract and disallow unused auths field - #7064

Merged
lvs0075 merged 1 commit into
tronprotocol:release_v4.8.3from
halibobo1205:feature/tx-contract-auths-validation
Oct 27, 2026
Merged

lvs0075 merged 1 commit into
tronprotocol:release_v4.8.3from
halibobo1205:feature/tx-contract-auths-validation

Conversation

@halibobo1205

Copy link
Copy Markdown
Collaborator

Follow-up to #7022 (P2P side), as noted in #7022 (comment).

What does this PR do?

  • TransactionsMsgHandler.check() rejects a TRXS message with BAD_TRX if any of its transactions does not carry exactly one contract, using ActuatorConstant.CONTRACT_SIZE_NOT_EQUAL_TO_ONE from feat(api): improve request handling and validation #7022. Previously, only an empty contract list was rejected here; later, Manager.processTransaction rejected more than one contract.
  • Transactions that set raw_data.auths are no longer admitted (TransactionCapsule.hasAuths()):
    • TransactionsMsgHandler.processMessage skips them; the other transactions of the message are processed as before;
    • Manager.pushTransaction rejects them at the start with ContractValidateException, which also covers the broadcast APIs.

Why are these changes required?

Both rules are already documented in the protocol (docs/protobuf-protocol-document.md): contract supports only size 1, and auths is deprecated and unused by the node. #7022 checks the contract count up front on the API paths; this applies the same check when a TRXS message is received, and stops admitting transactions that set the deprecated auths field to the pending pool.

This PR has been tested by:

  • Unit Tests

Follow up

Extra details
None

@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.3 milestone Oct 26, 2026
@halibobo1205 halibobo1205 added topic:net p2p net work, synchronization topic:api rpc/http related issue labels Oct 26, 2026

@waynercheung waynercheung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified locally at 0113f21: all 27 tests in TransactionsMsgHandlerTest and all 42 tests in ManagerTest passed. No blocking issues found.

break;
}
TransactionCapsule capsule = new TransactionCapsule(trx);
if (capsule.hasAuths()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[NIT] Consider counting transactions skipped for auths and emitting one DEBUG summary per TRXS message when the count is nonzero. This would help diagnose missing transactions without adding per-transaction logs.

Transaction withAuths = base.toBuilder().setRawData(base.getRawData().toBuilder()
.addAuths(Protocol.authority.getDefaultInstance())).build();
ContractValidateException pending = assertThrows(ContractValidateException.class,
() -> dbManager.pushTransaction(new TransactionCapsule(withAuths)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[NIT] Consider signing the transaction before the pending-rejection assertion and reusing that same signed transaction for the block-acceptance assertion. This would demonstrate the intended admission/block-validity boundary using an otherwise valid signed transaction.

@lvs0075
lvs0075 merged commit ce0cd24 into tronprotocol:release_v4.8.3 Oct 27, 2026
16 of 17 checks passed
@github-project-automation github-project-automation Bot moved this to Done in java-tron Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:api rpc/http related issue topic:net p2p net work, synchronization

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants