feat: Simplified asynchronous block writers #516
Labels
Alpha-0
Issues related to features designated for the Alpha-0 release
Block Node
Issues/PR related to the Block Node.
New Feature
A new feature, service, or documentation. Major changes that are not backwards compatible.
P1
High priority issue. Required to be completed in the assigned milestone.
Milestone
Story:
AS A Block Node Operator
I WANT the Block Node to be as correct and performant as possible
SO THAT I can minimize errors and operating costs.
This task aims to improve the architecture and correctness of of the local persistence handler. As a side benefit we also expect to gain performance improvements.
DEPENDS ON: #309
Tech Notes:
Currently, the local block writer abstraction is neither async, nor stateless. It makes a lot of complex decisions about writing and storage based on a stateful design that is highly susceptible to several forms of race condition and state-status mismatch.
To address these concerns, we need to detach the writer from having any other logic than simply writing a batch of data to the appropriate place(s). The writer must not be bothered with checking any state, making calculations or decisions "should or shouldn't I write some data to some place". The block writer must simply be supplied some data to persist and once it is flagged that it has received everything, it should then complete it's work and be gone once it is done.
One important note is that we are constantly receiving the block stream. It is guaranteed that we have a batch of block items. Batches can start with a block header and can end with block proof. Batches absolutely cannot start with a block proof, and cannot end with a block header. Also, a batch absolutely cannot have a block header or proof somewhere in the middle. This allows us to very easily denote and distinguish where a block starts (we check that a received batch starts with a block header) and where it ends (we check that a received batch ends with a block proof), all batches of items (if any) received in between such "start"/"end" batches are always of items for that delimited block.
All that being said, In order to achieve correct and asynchronous writing of the block files, we need to do the following:
The text was updated successfully, but these errors were encountered: