Skip to content

fix(net): reject unknown inventory type in P2P inv/fetch-inv handling#6851

Open
xxo1shine wants to merge 1 commit into
tronprotocol:release_v4.8.2from
xxo1shine:fix/p2p-reject-unknown-inventory-type
Open

fix(net): reject unknown inventory type in P2P inv/fetch-inv handling#6851
xxo1shine wants to merge 1 commit into
tronprotocol:release_v4.8.2from
xxo1shine:fix/p2p-reject-unknown-inventory-type

Conversation

@xxo1shine

Copy link
Copy Markdown
Collaborator

What does this PR do?
Validate the inventory type at the inbound entry points and reject any value other than TRX or BLOCK with P2pException(BAD_MESSAGE), before the type is used for cache insertion or outbound fetch construction:

  • P2pEventHandlerImpl.checkInvRateLimit: add else branch for unknown type
  • InventoryMsgHandler.check: add type allowlist check
  • FetchInvDataMsgHandler.check: validate raw getInventoryType() instead of getInvMessageType() (which mapped non-BLOCK types to TRX)

Use getTypeValue() when building the error message to avoid calling getNumber() on an UNRECOGNIZED enum value. Add regression tests for all three entry points.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

Validate the inventory type at the inbound entry points and reject any value
other than TRX or BLOCK with P2pException(BAD_MESSAGE), before the type is
used for cache insertion or outbound fetch construction:
- P2pEventHandlerImpl.checkInvRateLimit: add else branch for unknown type
- InventoryMsgHandler.check: add type allowlist check
- FetchInvDataMsgHandler.check: validate raw getInventoryType() instead of
  getInvMessageType() (which mapped non-BLOCK types to TRX)

Use getTypeValue() when building the error message to avoid calling
getNumber() on an UNRECOGNIZED enum value. Add regression tests for all
three entry points.
@github-actions github-actions Bot requested a review from 317787106 June 22, 2026 11:23
@halibobo1205 halibobo1205 added the topic:net p2p net work, synchronization label Jun 23, 2026
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Jun 23, 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.

LGTM

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

Labels

topic:net p2p net work, synchronization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants