go-ethereum/triedb
Arran Schlosberg 594abd9f42
feat: triedb.Config support for arbitrary backend implementations (#70)
## 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.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-11-14 16:55:07 +00:00
..
database [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
hashdb [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
pathdb [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00
database.go feat: triedb.Config support for arbitrary backend implementations (#70) 2024-11-14 16:55:07 +00:00
database.libevm.go feat: triedb.Config support for arbitrary backend implementations (#70) 2024-11-14 16:55:07 +00:00
database.libevm_test.go feat: triedb.Config support for arbitrary backend implementations (#70) 2024-11-14 16:55:07 +00:00
preimages.go [AUTO] rename Go module + update internal import paths 2024-10-17 01:49:47 +00:00