This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Deferred Service Builder #4587
Copy link
Copy link
Closed
Labels
J0-enhancementAn additional feature request.An additional feature request.
Milestone
Description
Right now, the ServiceBuilder creates the client, backend and all else right at the beginning and executes the configured functions directly. This has some implicatations, we do not want:
- you can out the ServiceBuilder into an unexpected/unrecommended State by calling a service method multiple times with different callbacks. As these callbacks typically have side-effects, this can lead to inconsistent and unreliable cases–even to race conditions if, for example, an authoring mechanism was initiated.
- some of these functions actually conflict and shouldn''t both be called. However right now, we have no way of preventing that.
- It is up to the user to call the functions in the right order, which is unreliable and an unnecessary foodgun – especially if we had to change that order.
- We can't provide sane defaults – like the longest chain selector or the light client transaction pool, both are the same for all known usages of our node-template – without requiring to the do 1 and cause unexpected side effects.
- Certain aspects, like the transaction pool or externality extensions, are actually created during client creation and thus have a hacky API so we can change them after the fact, see Allow node to add externalities extensions #4583.
Instead the pattern should only keep the references to the fns and execute all in one go on .build only. This would allow us to provide defaults, enforce the order in which set up takes place and would ensure any fn is only called once.
Further more this might allow us to clean up the api, so you can have one global builder and then call build_light and build_full on them rather than having to specify two builder...
Metadata
Metadata
Assignees
Labels
J0-enhancementAn additional feature request.An additional feature request.