fix(txsubmission): handle client MsgDone in server agent to avoid mempool stall#164
Open
nemo83 wants to merge 1 commit into
Open
fix(txsubmission): handle client MsgDone in server agent to avoid mempool stall#164nemo83 wants to merge 1 commit into
nemo83 wants to merge 1 commit into
Conversation
…pool stall
The N2N TxSubmission server agent never handled a client MsgDone. When a peer
terminated the protocol with MsgDone while the server was blocking-waiting in
TxIdsBlocking, TxSubmissionState.TxIdsBlocking.nextState() returned `this`, so
the agent stayed wedged in TxIdsBlocking forever. Because the client holds
agency in that state, the server could never send another RequestTxIds
("Cannot request tx IDs in state: TxIdsBlocking"), and since the agent never
became Done, MiniProtoServerInboundHandler kept it registered ("No agent found
to handle protocol ..."). Net effect: the node silently stops ingesting mempool
transactions while chain-sync/block-fetch keep working.
Fix: transition to Done on MsgDone from the client-agency states
(TxIdsBlocking per spec; TxIdsNonBlocking/Txs defensively), and handle MsgDone
in TxSubmissionServerAgent.processResponse so it terminates cleanly instead of
logging "Unexpected message type". Once Done, the inbound handler stops routing
to the agent and a fresh agent is created when the peer reconnects.
Adds unit tests for the MsgDone -> Done transition.
|
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.


Problem
The N2N TxSubmission server agent never handled a client
MsgDone. When a peerterminates the tx-submission mini-protocol with
MsgDonewhile the server isblocking-waiting in
TxIdsBlocking, the state machine dropped it on the floor:TxSubmissionState.TxIdsBlocking.nextState()only transitioned onReplyTxIds, soMsgDonereturnedthis→ the agent stayed wedged inTxIdsBlockingforever.TxIdsBlockingthe client holds agency, so the server can never send anotherRequestTxIds→ repeatedWARN Cannot request tx IDs in state: TxIdsBlocking.Done,MiniProtoServerInboundHandlerkeeps itregistered and later logs
No agent found to handle protocol ....TxSubmissionServerAgent.processResponse()had noMsgDonebranch, so it also loggedWARN Unexpected message type: MsgDone.Net effect: the node silently stops ingesting mempool transactions while
chain-sync and block-fetch keep working normally. Observed in production: the mempool
feed went dead and never recovered until the process was restarted.
Fix
TxSubmissionState: transition toDoneonMsgDonefrom the client-agency states —TxIdsBlocking(per the node-to-node tx-submission spec), plusTxIdsNonBlockingandTxsdefensively.TxSubmissionServerAgent.processResponse: handleMsgDoneexplicitly (clear in-flightbookkeeping, log at INFO) instead of falling through to
Unexpected message type.Once the agent reaches
Done, the inbound handler stops routing to it and a fresh agentis created when the peer reconnects — restoring mempool ingestion automatically.
Tests
Adds unit tests to
TxSubmissionServerAgentTest:testMsgDoneFromTxIdsBlockingTransitionsToDone— drives the agent intoTxIdsBlocking,sends
MsgDone, asserts it reachesDone/isDone().testMsgDoneStateTransitionsForAllClientAgencyStates— asserts theMsgDone → Donetransition for
TxIdsBlocking,TxIdsNonBlocking, andTxs.Full suite for the class passes (15 tests, 0 failures).
Scope / risk
Low and localized (2 main-source files). It only adds handling for a legal protocol
message that was previously dropped; the happy path is unchanged.