Polykey
Polykey copied to clipboard
Allow `NodeManager` to start lazily without network entry procedure
Specification
When starting the PolykeyAgent
the NodeManager
takes two steps to enter the network. When NodeManager
is started it calls this.setupRefreshBucketTasks()
and shortly after starting the PolykeyAgent calls
this.nodeManager.syncNodeGraph. The fact that these two steps happen by default when starting a
PolykeyAgent` can interfere with testing and adds a bunch of processing that doesn't need to be done.
We need to update this behaviour as specified in this comment https://github.com/MatrixAI/Polykey/pull/451#issuecomment-1261697179.
Additional context
- Related #451
- https://github.com/MatrixAI/Polykey/pull/451#issuecomment-1261697179
Tasks
- Add a
lazy
parameter toNodeManager.start
that when true, skips the creation ofrefreshBucket
tasks withsetupRefreshBucketTasks
and skips runningsyncNodeGraph
. - Add a method to
NodeManager
calledstartSync
that combines thesetupRefreshBucketTasks
andsyncNodeGraph
operations - rename
syncNodeGraph
tosyncSeedNodes
- Have the
PolykeyAgent
creation and start optionally skip thestartSync
process based on a parameter. - Update any
PolykeyAgent
usage in testing to skip the sync process where needed. - Remove any mocking of
refreshBucket
to stub it out and replace it with usage of 5.
Would this be something we should do as part of 6th testnet deployment?
Not strictly needed but is nice to have for testing and should be reasonably quick to implement. I'll add it in.
I think this is the case now. You can start the NodeManager
and then need to call syncNodeGraph
. I'd like to extend this to all background functionality in NodeGraph
. So we can disable all background operations for tests. They tend to add a bunch of noise when testing and can interfere in some cases.
I'd also like to add a option PolykeyAgent
to disable background tasks such as these.
I suggest we use the stealth mode #199 feature to side-step this problem. Essentially it would temporarily (togglable) disable all background network tasks (that includes social discovery, node discovery, mdns... etc) across the board, then we don't need to add special configuration just to disable certain things for testing.
To do such a thing, you can make use of the pattern used in the TaskManager with substart commands. Like startProcessing
stopProcessing
.
Any domain that has backgrounded network operations should have a substart/substop operations that can be called independently to switch its operating modes.