core/rawdb: add QKC raw database support - #49
Conversation
1ce6469 to
74483ef
Compare
|
Quick question: will the old |
go test ./qkc/...
# github.com/ethereum/go-ethereum/qkc/rawdb [github.com/ethereum/go-ethereum/qkc/rawdb.test]
qkc/rawdb/accessors_chain_test.go:88:5: types.NewRootBlockWithHeader(&types.RootBlockHeader{…}).WithBody undefined (type *"github.com/ethereum/go-ethereum/qkc/types".RootBlock has no field or method WithBody)
ok github.com/ethereum/go-ethereum/qkc 0.381s
ok github.com/ethereum/go-ethereum/qkc/account 2.889s
ok github.com/ethereum/go-ethereum/qkc/cluster/conn 1.171s
ok github.com/ethereum/go-ethereum/qkc/cluster/wire 0.065s
ok github.com/ethereum/go-ethereum/qkc/common (cached)
ok github.com/ethereum/go-ethereum/qkc/common/hexutil (cached)
ok github.com/ethereum/go-ethereum/qkc/config (cached)
? github.com/ethereum/go-ethereum/qkc/params [no test files]
FAIL github.com/ethereum/go-ethereum/qkc/rawdb [build failed]
ok github.com/ethereum/go-ethereum/qkc/serialize (cached)
ok github.com/ethereum/go-ethereum/qkc/shard 6.430s
ok github.com/ethereum/go-ethereum/qkc/slave 4.688s
? github.com/ethereum/go-ethereum/qkc/state [no test files]
ok github.com/ethereum/go-ethereum/qkc/types 0.071s
FAIL |
|
I have a similar question to #49 (comment). The existing |
When QKC and geth have the same storage semantics, QKC directly uses the existing |
All related test passed now. go test -count=1 ./core/rawdb ./qkc/types ./qkc/...
ok github.com/ethereum/go-ethereum/core/rawdb 9.920s
ok github.com/ethereum/go-ethereum/qkc/types 0.012s
ok github.com/ethereum/go-ethereum/qkc 0.155s
ok github.com/ethereum/go-ethereum/qkc/account 0.556s
ok github.com/ethereum/go-ethereum/qkc/cluster/conn 1.112s
ok github.com/ethereum/go-ethereum/qkc/cluster/wire 0.022s
ok github.com/ethereum/go-ethereum/qkc/common 0.073s
ok github.com/ethereum/go-ethereum/qkc/common/hexutil 0.016s
ok github.com/ethereum/go-ethereum/qkc/config 0.154s
? github.com/ethereum/go-ethereum/qkc/params [no test files]
ok github.com/ethereum/go-ethereum/qkc/serialize 0.017s
ok github.com/ethereum/go-ethereum/qkc/shard 0.570s
ok github.com/ethereum/go-ethereum/qkc/slave 0.337s
? github.com/ethereum/go-ethereum/qkc/state [no test files] |
Summary
Integrate QuarkChain database support into
core/rawdbinstead of maintaining a separateqkc/rawdbimplementation.The storage architecture follows these rules:
core/rawdbfunctions and keys.*_qkc.gofiles undercore/rawdb.qkc_prefix:qkc_rb<hash>andqkc_mb<hash>.Moving the QKC accessors into
core/rawdbmakescore/rawdbdepend onqkc/types. The previousqkc/types -> triedependency would then form the cycle:To remove this cycle,
qkc/types.DeriveShano longer constructs or imports a trie directly. It accepts thecore/types.ListHasherinterface from its caller. This preserves the goquarkchain/pyquarkchain insertion order while leaving trie construction to the higher-level package.Changes
schema_qkc.goandaccessors_chain_qkc.go.accessors_metadata_qkc.go.accessors_indexes_qkc.go, reusing geth's existing lookup key where applicable.qkc/types.DeriveShato accept acore/types.ListHasher, removing thetriedependency and the resulting import cycle while preserving QKC hash behavior.Adding QKC RawDB Data
Future QKC-specific records should follow the same structure.
For example, to add storage for the latest minor headers:
schema_qkc.goand generate the completeqkc_-namespaced key throughqkcKey.*_qkc.gofile.If geth already provides an accessor with identical semantics and key layout, use it directly instead of adding a QKC wrapper.
Database Compatibility
QKC-specific keys intentionally use the new namespaced schema. Existing goquarkchain database contents are not migrated; nodes are expected to resync.
Testing