Repository navigation
Conversation
…st-reactor-no-block-response
…st-reactor-no-block-response
…st-reactor-no-block-response
…st-reactor-no-block-response
…st-reactor-no-block-response
| @@ -0,0 +1,56 @@ | |||
| package types | |||
There was a problem hiding this comment.
we have "factory"package that contains similar code
There was a problem hiding this comment.
opinionated: the package factory (the same as util) doesn't have a certain purpose of usage, it is like a package for everything, which violates the design of the app, in my opinion. I would rather use a more specific package, based on the domain for example.
There was a problem hiding this comment.
We should not have two different approaches. Either we use factory and you move your code there, or we get rid of it, and move that code to correct places.
I see factory as a 'test helper' package, so maybe just renaming is a solution.
If you decide to get rid of factory, it deserves separate PR.
…st-reactor-no-block-response
Co-authored-by: lklimek <[email protected]>
…pes.MockValidatorSet
…-block-response' into td-143-fix-flaky-test-reactor-no-block-response
| @@ -0,0 +1,56 @@ | |||
| package types | |||
There was a problem hiding this comment.
We should not have two different approaches. Either we use factory and you move your code there, or we get rid of it, and move that code to correct places.
I see factory as a 'test helper' package, so maybe just renaming is a solution.
If you decide to get rid of factory, it deserves separate PR.
Co-authored-by: lklimek <[email protected]>
…-block-response' into td-143-fix-flaky-test-reactor-no-block-response
…st-reactor-no-block-response
Co-authored-by: lklimek <[email protected]>
…-block-response' into td-143-fix-flaky-test-reactor-no-block-response
shotonoff
left a comment
There was a problem hiding this comment.
PR is ready for review again
…st-reactor-no-block-response
| err = s.applyBlock(ctx) | ||
| if err != nil { | ||
| s.logger.Error("cannot apply a block", "height", resp.Block.Height, "error", err.Error()) | ||
| s.RemovePeer(resp.PeerID) |
There was a problem hiding this comment.
When peer responds, we increase its score by 1. Otherwise, we decrease its score by 1 (or whatever "punishment" we want to make). See PeerManager.processPeerEvent().
We select peer to use based on the highest score, descending. See peerStore.ranked().
As a result, best peers (= the ones who responded to most queries) are most likely to get requests.
We can optimize to use latency info when increasing the score, and/or add some weighted random mechanism when selecting peer to use.
| t.Run(fmt.Sprintf("test-case %d", i), func(t *testing.T) { | ||
| p := New(tc.exec) | ||
| res, err := p.Await() | ||
| if tc.wantErr != "" { |
There was a problem hiding this comment.
let's go with pkg (separate PR)
Issue being fixed or feature implemented
Motivation for this refactoring is
bpRequestimplementation on worker-pool approach. Worker pool simplifies the implementation of the requirements, like limit for simultaneous requests for the blocks etc. Not needed to worry how much requests are performed, we just produce a job if a worker is free otherwise wait for worker or peer will be ready for the request.blocksynccodebase, to make the module easier to maintain and develop.What was done?
Keys design changes
The job itself must implement the
workerpool.Jobinterface, and the job instance must be passed into the worker-pool.Communication between worker-pool and workers is carried out over the job channel.
When the execution is complete, the worker sends
workerpool.Resultover the result channel to the worker pool to report the result of the execution.BlockClientinterfaceThe GetBlock method requests a block from a peer and returns promise.Promise which resolve the result if response received in time otherwise reject
How Has This Been Tested?
Breaking Changes
N/A
Checklist:
For repository code-owners and collaborators only