ChainSafe / ChainSafe/gossamer
feat(statement-distribution): implement `v2::task_responder`
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
## Issue summary
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"
```go
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.
```go
v2OutCh := make(chan any, 1)
go runv2RespondTask(sd.v2ReqReceiver, v2OutCh) // candidate-responder
```
The `v2OutCh` will be used by the `MuxedMessage` handler
#### V2RespondTask (`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 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.
### Other links
https://github.com/paritytech/polkadot-sdk/blob/9584dbda9ed5fc91b1837f35f401659239fdaff1/polkadot/node/network/statement-distribution/src/v2/mod.rs#L3446
Contributor guide
Assessment
This issue has not been assessed yet.