-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
op-supervisor: Add log db #10902
op-supervisor: Add log db #10902
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality is good, thank you! I have some suggestions to introduce more fine typing and separate the file-read/write layer from the entry-read/write layer, to make things more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some quick notes. I'll take a closer look later.
…s at a search checkpoint boundary (other than at the start of the file)
… rather than a 1 byte increment amount.
… kept up to date.
…fixed size array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Description
Introduces an append only database to record logs for a single chain. Reorgs can be handled by rewinding the chain back to a specific block then adding the new canonical logs.
This implements the basic log storage and search functionality but has two key pieces not yet implemented:
These items will be added in a follow up PR.
Also note that this doesn't attempt to track different levels of safety. Ideally an outer wrapper can track that based on block number. Storing those head levels to disk may require them being handled inside this struct though ideally I'd like them to just be a prefix and manage to keep this struct completely focussed on storing the log data.
A simple RWMutex is used to provide thread safety, it may be better to remove that again in the future and have thread safety be handled by the wrapper. Or if we want to maximise performance it may be possible to have more fine-grained locking so that checking if logs exist can be safely done in parallel with adding blocks, with only rewinds needing exclusive access. Going to avoid adding that complexity until we know it's needed.
Tests
Added unit tests. Each test is run first by writing and reading from the same DB instance, then writes and performs the reads from a separate instance to confirm it can be reread purely from the information on disk. Also implemented a set of invariant checks that are run after each test to verify key properties of the database format.
Metadata