Skip to content

feat(net): add P2P message deduplication and length validation#9

Open
xxo1shine wants to merge 1 commit intobase-codefrom
feature/p2p-msg-validation
Open

feat(net): add P2P message deduplication and length validation#9
xxo1shine wants to merge 1 commit intobase-codefrom
feature/p2p-msg-validation

Conversation

@xxo1shine
Copy link
Copy Markdown
Owner

  • FetchInvDataMsgHandler: reject messages with duplicate hashes
  • TransactionsMsgHandler: reject messages with duplicate transactions
  • SyncBlockChainMsgHandler: reject blockIds list exceeding 30 entries
  • Add MAX_SYNC_CHAIN_IDS = 30 constant to NetConstants
  • Add unit tests covering duplicate rejection and boundary values

All violations throw P2pException(BAD_MESSAGE), triggering peer disconnect via existing P2pEventHandlerImpl error path.

What does this PR do?

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

- FetchInvDataMsgHandler: reject messages with duplicate hashes
- TransactionsMsgHandler: reject messages with duplicate transactions
- SyncBlockChainMsgHandler: reject blockIds list exceeding 30 entries
- Add MAX_SYNC_CHAIN_IDS = 30 constant to NetConstants
- Add unit tests covering duplicate rejection and boundary values

All violations throw P2pException(BAD_MESSAGE), triggering peer disconnect via existing P2pEventHandlerImpl error path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xxo1shine xxo1shine force-pushed the feature/p2p-msg-validation branch from 3b9032e to 88e09fc Compare April 15, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant