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

core, trie/triedb/pathdb: adjust pathdb for verkle #28297

Closed
wants to merge 1 commit into from

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Oct 10, 2023

This pull request is a prerequisite for landing verkle.

Specifically, verkle and merkle are two independent trees which may be existent at the same time. In order to store tree data separately, we need to explicitly make the isolation in database level, for both key-value store and state freezer.

Besides, verkle uses a slim format which doesn't store the node hash in the parent node. This slim format can significantly reduce the read and write amplification, but in the same time loses some robustness. However, we think it's still worthwhile to at least experiment it to see the performance difference. In order to support it, pathdb will no longer maintain the node hash which is also beneficial by maintaining less stuff in memory.

But one thing is noteworthy, pathdb will return the node blindly where ever it's found without hash comparison(clean cache, dirty cache, diff layer, disk). Originally we have this tiny trick to compare the hash if the node is found in clean cache, and fallback to disk if it's not matched, just in case the clean cache is not properly maintained, but this mechanism is lost in this pull request.

Update: this pull request can snap/full sync the mainnet, we have more confidence that the clean cache is properly maintained and safe to have this change.

@rjl493456442
Copy link
Member Author

From the metrics, fortunately we don't have any clean cache false which is expected.

截屏2023-10-10 上午11 57 44

Copy link
Member

@gballet gballet left a comment

Choose a reason for hiding this comment

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

LGTM. Left minor comments. I still do not see an easy upgrade path for the overlay transition, but that's a problem for later.

core/rawdb/accessors_trie.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
@rjl493456442
Copy link
Member Author

I think this pull request is ready for review, please take a look @holiman @karalabe

@holiman
Copy link
Contributor

holiman commented Nov 24, 2023

I agree that we need to get this in, however, later rather than sooner. The type of error that we encountered here: #28595 , we would not have been able to detect that error if this PR had been already merged.
At some point, a consensus-error would have occurred, but it would have been hard to pinpoint the exact cause. So IMO let's keep the hash-check around a bit longer

@rjl493456442
Copy link
Member Author

Replaced with #29084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants