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: triedb.Config support for arbitrary backend implementations #70

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Nov 13, 2024

Why this should be merged

Allow ava-labs/coreth to use arbitrary triedb database implementations.

How this works

Introduces HashBackend and PathBackend interfaces that triedb.Database type-asserts to instead of hashdb.Database and pathdb.Backend respectively. Other interfaces are introduced to avoid having to modify {hash,path}db.Database.Reader() return values.

The explicit DBOverride field means that we don't have to modify any of the triedb constructor beyond adding a single line immediately before the return. This leaves all modifications of original files entirely mechanistic. This is, however, at the expense of compile-time guarantees of the overriding database being either a HashBackend or a PathBackend.

How this was tested

Unit test demonstrating override + plumbing.

@ARR4N ARR4N marked this pull request as ready for review November 13, 2024 18:32
triedb/database.go Outdated Show resolved Hide resolved
triedb/database.go Outdated Show resolved Hide resolved
triedb/database.libevm.go Show resolved Hide resolved
@ARR4N ARR4N enabled auto-merge (squash) November 14, 2024 16:54
@ARR4N ARR4N merged commit 594abd9 into main Nov 14, 2024
3 checks passed
@ARR4N ARR4N deleted the arr4n/triedb-backend-override branch November 14, 2024 16:55
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.

2 participants