The statement distribution subsystem spawn two processes large-statement-responder (handled by legacy_v1 module) and candidate-responder (handled by v2 module).
The main Statement Distribution struct holds two receive only "channels"
type StatmentDistribution struct {
v2ReqReceiver // receiver for incoming candidate requests
}
and each channel goes to its respective spawned process, in order to receive the outputs of each process we need to hold another receive channel for each process.
v2OutCh := make(chan any, 1)
go runv2RespondTask(sd.v2ReqReceiver, v2OutCh) // candidate-responder
The v2OutCh will be used by the MuxedMessage handler
This goroutine will run as long for the entire node lifetime
This goroutine needs to manage other goroutines (each one for a specific requester) bounded to the MaxParallelAttestedCandidateRequest constant.
Try to decode the request message, if error then apply COST_INVALID_REQUEST reputation change
Also it is required to check if the peer is currently being served, if so drop the request. For that we need a shared hash map, whenever a request is accepted the peer is inserted in the map and removed when the request is signaled as finished.
Issue summary
The statement distribution subsystem spawn two processes
large-statement-responder
(handled bylegacy_v1
module) andcandidate-responder
(handled byv2
module).The main Statement Distribution struct holds two receive only "channels"
and each channel goes to its respective spawned process, in order to receive the outputs of each process we need to hold another receive channel for each process.
The
v2OutCh
will be used by theMuxedMessage
handlerV2RespondTask (
candidate-responder
)Define a
MaxParallelAttestedCandidateRequest
(https://github.com/paritytech/polkadot-sdk/blob/9584dbda9ed5fc91b1837f35f401659239fdaff1/polkadot/node/network/protocol/src/request_response/mod.rs#L160)This goroutine will run as long for the entire node lifetime
This goroutine needs to manage other goroutines (each one for a specific requester) bounded to the
MaxParallelAttestedCandidateRequest
constant.Try to decode the request message, if error then apply
COST_INVALID_REQUEST
reputation changeAlso it is required to check if the peer is currently being served, if so drop the request. For that we need a shared hash map, whenever a request is accepted the peer is inserted in the map and removed when the request is signaled as finished.
Other links
https://github.com/paritytech/polkadot-sdk/blob/9584dbda9ed5fc91b1837f35f401659239fdaff1/polkadot/node/network/statement-distribution/src/v2/mod.rs#L3446