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(provider): consistent database view #6896

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

rkrasiuk
Copy link
Member

Description

Extracted from #6576 and modified.

This PR adds an ability to create a consistent view of the database. Each attempt to create a provider will be followed by tip consistency checks.

Intended Usage

This view is useful when attempting to perform parallel reads of the state across multiple threads while preserving the guarantee that the state remains unchanged.

@rkrasiuk rkrasiuk added C-enhancement New feature or request A-db Related to the database labels Feb 29, 2024
@gakonst
Copy link
Member

gakonst commented Feb 29, 2024

@mattsse ptal

Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had some time to review, simple enough. I think the mevoors like Snoopy may want this too

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense,
but this is really enforces consistent Tip, so view sounds a bit too general to me

wdyt @shekhirin

@rkrasiuk
Copy link
Member Author

rkrasiuk commented Mar 1, 2024

imo it's fine to call it a view as it gets invalidated on chain advancement

Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do I understand correctly that this is just a precautionary measure in an already consistent scenario (trie update), when we're already sure there are no other write transactions happening during that time? Not fully understand what will happen if this doesn't hold, do we just crash?

@shekhirin
Copy link
Collaborator

shekhirin commented Mar 1, 2024

I think this makes sense, but this is really enforces consistent Tip, so view sounds a bit too general to me

wdyt @shekhirin

agreed it's fine to call it a view, although can add it to comments why so: because all updates are atomic, and the tip changes at the same time as other parts of the database.

@rkrasiuk
Copy link
Member Author

rkrasiuk commented Mar 1, 2024

@shekhirin this is a pre-cautionary measure against the misuse of the parallel/async API. if we misuse it internally, ye we should crash because our logic is flawed. for external use it's handy to catch that error and decide what to do next

@rkrasiuk rkrasiuk added this pull request to the merge queue Mar 1, 2024
Merged via the queue into main with commit 02111c4 Mar 1, 2024
29 checks passed
@rkrasiuk rkrasiuk deleted the rkrasiuk/feat-consistent-view branch March 1, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants