IntersectMBO / IntersectMBO/ouroboros-consensus
Consensus test: run each node in a separate thread
- Dominant language
- Haskell
- Stars
- 67
- Forks
- 43
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 43
Description
While working on input-output-hk/ouroboros-network#1389, I noticed that all the nodes were sharing a single `ResourceRegistry`. Also, the ChainDBs were not opened in a bracketed fashion. This causes some issues with cleanly shutting down a node and accessing a registry from a different thread.
What we should do is:
* Spawn a thread for each node. In that thread:
* Create a `ResourceRegistry` (using `withRegistry`) that is used to allocate all the resources/threads that node needs.
* Create `BlockchainTime`. This means each node will have its own `BlockchainTime`, so to terminate the network simulation: call `testBlockchainTimeDone` on all `BlockchainTime`s.
* Open a ChainDB using `withDB`.
* How mini-protocol threads are started will have to change a bit: it will be more unidirectional than the current bidirectional approach.
* At the end of the simulation, each node is shut down by killing each node's main thread.
**Important:** this will more closely resemble how a real node is set up and torn down.
Maybe this will bring up some issues with proper termination, possibly the issue we're seeing in https://github.com/input-output-hk/ouroboros-network/issues/1350.
Contributor guide
Assessment
This issue has not been assessed yet.