-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from cerc-io/roy/v5-dev
* Rewrite trie_by_cid package to be read-write * add CI workflows
- Loading branch information
Showing
48 changed files
with
7,305 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: PR actions | ||
on: | ||
- pull_request | ||
|
||
jobs: | ||
run-tests: | ||
uses: ./.github/workflows/test.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Run tests | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
unit-tests: | ||
name: Run unit tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
- name: "Run DB container" | ||
working-directory: ./test | ||
run: | | ||
docker compose up -d --quiet-pull | ||
- name: "Build and run tests" | ||
run: | | ||
until [[ "$(docker inspect test-ipld-eth-db | jq -r '.[0].State.Status')" = 'running' ]] | ||
do sleep 1; done & | ||
go build ./... | ||
wait $! | ||
go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
# ipld-eth-statedb | ||
|
||
Implementation of the geth [vm.StateDB](https://github.com/ethereum/go-ethereum/blob/master/core/vm/interface.go#L28) on top of | ||
[ipld-eth-db](https://github.com/cerc-io/ipld-eth-db), to allow us to plug into existing EVM functionality. Analogous to | ||
[ipfs-ethdb](https://github.com/cerc-io/ipfs-ethdb) but at one database abstraction level higher. This allows us to | ||
bypass the trie-traversal access pattern normally used by the EVM (and which ipfs-ethdb allows us to replicate ontop of our | ||
Postgres IPLD blockstore in the "public.blocks" table) and access state and storage directly in the "state_cids" and | ||
"storage_cids" tables. | ||
This contains multiple implementations of the geth [vm.StateDB](https://github.com/ethereum/go-ethereum/blob/master/core/vm/interface.go#L28) and supporting types for different use cases. | ||
|
||
## Package `direct_by_leaf` | ||
|
||
Note: "IPFS" is chosen in the name of "ipfs-ethdb" as it can function through an IPFS BlockService abstraction or directly ontop of an IPLD blockstore, whereas this repository | ||
is very tightly coupled to the schema in ipld-eth-db. | ||
A read-only implementation which uses the schema defined in [ipld-eth-db](https://github.com/cerc-io/ipld-eth-db), to allow direct querying by state and storage node leaf key, bypassing the trie-traversal access pattern normally used by the EVM. | ||
This operates at one abstraction level higher than [ipfs-ethdb](https://github.com/cerc-io/ipfs-ethdb), and is suitable for providing fast state reads. | ||
|
||
The top-level package contains the implementation of the `vm.StateDB` interface that accesses state directly using the | ||
`state_cids` and `storage_cids` tables in ipld-eth-db. The `trie_by_cid` package contains an alternative implementation | ||
which accesses state in `ipld.blocks` through the typical trie traversal access pattern (using CIDs instead of raw | ||
keccak256 hashes), it is used for benchmarking and for functionality which requires performing a trie traversal | ||
(things which must collect intermediate nodes, e.g. `eth_getProof` and `eth_getSlice`). | ||
## Package `trie_by_cid` | ||
|
||
A read-write implementation which uses a Postgres IPLD v0 Blockstore as the backing `ethdb.Database`. Specifically this passes v1 CIDs of Keccak-256 hashes to the database in place of plain hashes, and can be used in combination with a [ipfs-ethdb/postgres/v0](https://github.com/cerc-io/ipfs-ethdb/tree/v5/postgres/v0) `Database` instance, or an IPLD BlockService providing a v0 Blockstore. | ||
|
||
This implementation uses trie traversal to access state, and is capable of computing state root hashes and performing full EVM operations. It's also suitable for scenarios requiring trie traversal and access to intermediate state nodes (e.g. `eth_getProof` and `eth_getSlice` on [ipld-eth-server](https://github.com/cerc-io/ipld-eth-server)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Containers to run backing DB for unit testing | ||
|
||
services: | ||
migrations: | ||
restart: on-failure | ||
depends_on: | ||
- ipld-eth-db | ||
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v5.0.2-alpha | ||
environment: | ||
DATABASE_USER: "vdbm" | ||
DATABASE_NAME: "cerc_testing" | ||
DATABASE_PASSWORD: "password" | ||
DATABASE_HOSTNAME: "ipld-eth-db" | ||
DATABASE_PORT: 5432 | ||
|
||
ipld-eth-db: | ||
container_name: test-ipld-eth-db | ||
image: timescale/timescaledb:latest-pg14 | ||
restart: always | ||
command: ["postgres", "-c", "log_statement=all"] | ||
environment: | ||
POSTGRES_USER: "vdbm" | ||
POSTGRES_DB: "cerc_testing" | ||
POSTGRES_PASSWORD: "password" | ||
ports: | ||
- "127.0.0.1:8077:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This package is a near complete copy of go-ethereum/trie and go-ethereum/core/state, modified to use | ||
// a v0 IPFS blockstore as the backing DB, i.e. DB values are indexed by CID rather than hash. | ||
package trie_by_cid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.