Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simplified asynchronous block writers #516

Open
Tracked by #515
ata-nas opened this issue Jan 21, 2025 · 0 comments · May be fixed by #545
Open
Tracked by #515

feat: Simplified asynchronous block writers #516

ata-nas opened this issue Jan 21, 2025 · 0 comments · May be fixed by #545
Assignees
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

Comments

@ata-nas
Copy link
Contributor

ata-nas commented Jan 21, 2025

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:

  • simplify the block writer:
    • the block writer only knows where to write data that it is being supplied & how to write it
    • the block writer makes no decisions as to wether it must/must not write some data
    • each distinct block (collection of block items from a Header to a Proof) must be supplied to a separate block writer, which then knows how to handle that specific block
  • persistence handler is now the decision maker
    • block writers are now managed by the block persistence
    • shift the responsibility of deciding wether to persist a block or continue to accept items from the block writer (current implementation) to the persistence handler, which is receiving the stream, so it can make such decisions and is able to supply a block writer with the correct collection(s) of items
    • each block writer has a transfer queue, where we will be pushing items from the persistence handler as they are received until we denote that a block has ended
    • after a block has ended, we flag the writer that it has received everything and it can continue, asynchronously, to proceed with writing all the items to the appropriate place
    • in the meantime, we are now pushing the following items for the next block in a new writer, managed by the persistence handler
@ata-nas ata-nas added 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. Block Node Issues/PR related to the Block Node. labels Jan 21, 2025
@jsync-swirlds jsync-swirlds changed the title feat: async block writers feat: Simplified asynchronous block writers Jan 22, 2025
@ata-nas ata-nas self-assigned this Jan 23, 2025
@ata-nas ata-nas added this to the 0.4.0 milestone Jan 23, 2025
@ata-nas ata-nas linked a pull request Jan 27, 2025 that will close this issue
2 tasks
@ata-nas ata-nas linked a pull request Jan 27, 2025 that will close this issue
2 tasks
@jsync-swirlds jsync-swirlds added the Alpha-0 Issues related to features designated for the Alpha-0 release label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants