Remove obsolete select_backend and fix simulators CI (#2007)

* Remove obsolete select_backend

* Fix copyright year
This commit is contained in:
andri lim 2024-02-04 21:28:20 +07:00 committed by GitHub
parent 9c53c73173
commit a441ec3cb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 228 additions and 348 deletions

View File

@ -27,7 +27,7 @@ jobs:
id: versions id: versions
run: | run: |
sudo apt-get -q update sudo apt-get -q update
sudo apt-get install -y libpcre3-dev sudo apt-get install -y librocksdb-dev libpcre3-dev
getHash() { getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1 git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
} }
@ -66,6 +66,20 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Restore rocksdb from cache
id: rocksdb-cache
uses: actions/cache@v4
with:
path: rocks-db-cache
key: 'rocksdb-v2'
- name: Build and install rocksdb
run: |
HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ccache
echo "/usr/local/opt/ccache/libexec" >> ${GITHUB_PATH}
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_rocksdb.sh
bash build_rocksdb.sh rocks-db-cache
- name: Get latest nimbus-build-system commit hash - name: Get latest nimbus-build-system commit hash
id: versions id: versions
run: | run: |
@ -110,18 +124,37 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Restore llvm-mingw (Windows) from cache - name: Restore Nim DLLs dependencies from cache
if: runner.os == 'Windows' id: windows-dlls-cache
uses: actions/cache@v4
with:
path: external/dlls
# according to docu, idle caches are kept for up to 7 days
# so change dlls# to force new cache contents (for some number #)
key: dlls0
- name: Install DLLs dependencies
if: steps.windows-dlls-cache.outputs.cache-hit != 'true'
run: |
ROCKSDBSUB=x64
DLLPATH=external/dlls
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -o"$DLLPATH"
# ROCKSDB
curl -L "https://github.com/status-im/nimbus-deps/releases/download/nimbus-deps/nimbus-deps.zip" -o external/nimbus-deps.zip
7z x -y external/nimbus-deps.zip
cp "./$ROCKSDBSUB/librocksdb.dll" "$DLLPATH/librocksdb.dll"
- name: Restore llvm-mingw from cache
id: windows-mingw-cache id: windows-mingw-cache
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: external/mingw-amd64 path: external/mingw-amd64
key: 'mingw-llvm-17-sim' key: 'mingw-llvm-17-sim'
- name: Install llvm-mingw dependency (Windows) - name: Install llvm-mingw dependency
if: > if: steps.windows-mingw-cache.outputs.cache-hit != 'true'
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: | run: |
mkdir -p external mkdir -p external
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905" MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
@ -130,11 +163,10 @@ jobs:
7z x -y "external/mingw-amd64.zip" -oexternal/mingw-amd64/ 7z x -y "external/mingw-amd64.zip" -oexternal/mingw-amd64/
mv external/mingw-amd64/**/* ./external/mingw-amd64 mv external/mingw-amd64/**/* ./external/mingw-amd64
- name: Path to cached dependencies (Windows) - name: Path to cached dependencies
if: >
runner.os == 'Windows'
run: | run: |
echo '${{ github.workspace }}'"/external/mingw-amd64/bin" >> $GITHUB_PATH echo '${{ github.workspace }}'"/external/mingw-amd64/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
- name: Get latest nimbus-build-system commit hash - name: Get latest nimbus-build-system commit hash
id: versions id: versions

View File

@ -17,7 +17,7 @@ USE_SYSTEM_NIM=1
ENV_SCRIPT="vendor/nimbus-build-system/scripts/env.sh" ENV_SCRIPT="vendor/nimbus-build-system/scripts/env.sh"
# nimbus_db_backend:none -> we only use memory db in simulators # nimbus_db_backend:none -> we only use memory db in simulators
NIM_FLAGS="c -d:release -d:nimbus_db_backend:none" NIM_FLAGS="c -d:release"
${ENV_SCRIPT} nim ${NIM_FLAGS} ${SIM_DIR}/engine/engine_sim ${ENV_SCRIPT} nim ${NIM_FLAGS} ${SIM_DIR}/engine/engine_sim
${ENV_SCRIPT} nim ${NIM_FLAGS} ${SIM_DIR}/consensus/consensus_sim ${ENV_SCRIPT} nim ${NIM_FLAGS} ${SIM_DIR}/consensus/consensus_sim

View File

@ -25,9 +25,7 @@ import
confutils/std/net confutils/std/net
], ],
eth/[common, net/utils, net/nat, p2p/bootnodes, p2p/enode, p2p/discoveryv5/enr], eth/[common, net/utils, net/nat, p2p/bootnodes, p2p/enode, p2p/discoveryv5/enr],
"."/[db/select_backend, "."/[constants, vm_compile_info, version],
constants, vm_compile_info, version
],
common/chain_config common/chain_config
export net export net
@ -35,12 +33,11 @@ export net
const const
# TODO: fix this agent-string format to match other # TODO: fix this agent-string format to match other
# eth clients format # eth clients format
NimbusIdent* = "$# v$# [$#: $#, $#, $#, $#]" % [ NimbusIdent* = "$# v$# [$#: $#, $#, $#]" % [
NimbusName, NimbusName,
NimbusVersion, NimbusVersion,
hostOS, hostOS,
hostCPU, hostCPU,
nimbus_db_backend,
VmName, VmName,
GitRevision GitRevision
] ]

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2021 Status Research & Development GmbH # Copyright (c) 2021-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT)) # * MIT license ([LICENSE-MIT](LICENSE-MIT))
@ -11,7 +11,6 @@ import
chronicles, chronicles,
eth/rlp, stew/io2, eth/rlp, stew/io2,
./chain, ./chain,
../db/select_backend,
../common/common, ../common/common,
../utils/utils ../utils/utils

View File

@ -12,39 +12,51 @@
import import
eth/trie/db, eth/trie/db,
eth/db/kvstore,
rocksdb, rocksdb,
"../.."/select_backend,
../base, ../base,
./legacy_db ./legacy_db,
../../kvstore_rocksdb
type type
LegaPersDbRef = ref object of LegacyDbRef LegaPersDbRef = ref object of LegacyDbRef
rdb: RocksStoreRef # for backend access with legacy mode rdb: RocksStoreRef # for backend access with legacy mode
# No other backend supported ChainDB = ref object of RootObj
doAssert nimbus_db_backend == "rocksdb" kv: KvStoreRef
rdb: RocksStoreRef
# TODO KvStore is a virtual interface and TrieDB is a virtual interface - one
# will be enough eventually - unless the TrieDB interface gains operations
# that are not typical to KvStores
proc get(db: ChainDB, key: openArray[byte]): seq[byte] =
var res: seq[byte]
proc onData(data: openArray[byte]) = res = @data
if db.kv.get(key, onData).expect("working database"):
return res
proc put(db: ChainDB, key, value: openArray[byte]) =
db.kv.put(key, value).expect("working database")
proc contains(db: ChainDB, key: openArray[byte]): bool =
db.kv.contains(key).expect("working database")
proc del(db: ChainDB, key: openArray[byte]): bool =
db.kv.del(key).expect("working database")
proc newChainDB(path: string): KvResult[ChainDB] =
let rdb = RocksStoreRef.init(path, "nimbus").valueOr:
return err(error)
ok(ChainDB(kv: kvStore rdb, rdb: rdb))
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Public constructor and low level data retrieval, storage & transation frame # Public constructor and low level data retrieval, storage & transation frame
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
proc newLegacyPersistentCoreDbRef*(path: string): CoreDbRef = proc newLegacyPersistentCoreDbRef*(path: string): CoreDbRef =
# Kludge: Compiler bails out on `results.tryGet()` with # when running `newChainDB(path)`. converted to a `Defect`.
# :: let backend = newChainDB(path).valueOr:
# fatal.nim(54) sysFatal let msg = "DB initialisation : " & error
# Error: unhandled exception: types.nim(1251, 10) \
# `b.kind in {tyObject} + skipPtrs` [AssertionDefect]
#
# when running `select_backend.newChainDB(path)`. The culprit seems to be
# the `ResultError` exception (or any other `CatchableError`). So this is
# converted to a `Defect`.
var backend: ChainDB
try:
{.push warning[Deprecated]: off.}
backend = newChainDB path
{.pop.}
except CatchableError as e:
let msg = "DB initialisation error(" & $e.name & "): " & e.msg
raise (ref ResultDefect)(msg: msg) raise (ref ResultDefect)(msg: msg)
proc done() = proc done() =

View File

@ -24,30 +24,14 @@
import import
../aristo, ../aristo,
./memory_only, ./memory_only,
../select_backend
export
memory_only
# This file is currently inconsistent due to the `dbBackend == rocksdb` hack
# which will be removed, soon (must go to the test base where such a compile
# time flag induced mechanism might be useful.)
#
# The `Aristo` backend has no business with `dbBackend` and will be extended
# in future.
{.warning: "Inconsistent API file needs to be de-uglified".}
# Allow hive sim to compile with dbBackend == none
when dbBackend == rocksdb:
import
base_iterators_persistent, base_iterators_persistent,
./backend/[aristo_rocksdb, legacy_rocksdb] ./backend/[aristo_rocksdb, legacy_rocksdb]
export export
memory_only,
base_iterators_persistent, base_iterators_persistent,
toRocksStoreRef toRocksStoreRef
proc newCoreDbRef*( proc newCoreDbRef*(
dbType: static[CoreDbType]; # Database type symbol dbType: static[CoreDbType]; # Database type symbol
path: string; # Storage path for database path: string; # Storage path for database
@ -56,7 +40,6 @@ proc newCoreDbRef*(
## ##
## Note: Using legacy notation `newCoreDbRef()` rather than ## Note: Using legacy notation `newCoreDbRef()` rather than
## `CoreDbRef.init()` because of compiler coughing. ## `CoreDbRef.init()` because of compiler coughing.
when dbBackend == rocksdb:
when dbType == LegacyDbPersistent: when dbType == LegacyDbPersistent:
newLegacyPersistentCoreDbRef path newLegacyPersistentCoreDbRef path
@ -65,8 +48,6 @@ proc newCoreDbRef*(
else: else:
{.error: "Unsupported dbType for persistent newCoreDbRef()".} {.error: "Unsupported dbType for persistent newCoreDbRef()".}
else:
{.error: "Unsupported dbBackend setting for persistent newCoreDbRef()".}
proc newCoreDbRef*( proc newCoreDbRef*(
dbType: static[CoreDbType]; # Database type symbol dbType: static[CoreDbType]; # Database type symbol
@ -77,15 +58,11 @@ proc newCoreDbRef*(
## ##
## Note: Using legacy notation `newCoreDbRef()` rather than ## Note: Using legacy notation `newCoreDbRef()` rather than
## `CoreDbRef.init()` because of compiler coughing. ## `CoreDbRef.init()` because of compiler coughing.
when dbBackend == rocksdb:
when dbType == AristoDbRocks: when dbType == AristoDbRocks:
newAristoRocksDbCoreDbRef(path, qlr) newAristoRocksDbCoreDbRef(path, qlr)
else: else:
{.error: "Unsupported dbType for persistent newCoreDbRef()" & {.error: "Unsupported dbType for persistent newCoreDbRef()" &
" with qidLayout argument".} " with qidLayout argument".}
else:
{.error: "Unsupported dbBackend setting for persistent newCoreDbRef()" &
" with qidLayout argument".}
# End # End

View File

@ -1,80 +0,0 @@
# Nimbus
# Copyright (c) 2019-2023 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
import strutils, eth/db/kvstore
export kvstore
# Database access layer that turns errors in the database into Defects as the
# code that uses it isn't equipped to handle errors of that kind - this should
# be reconsidered when making more changes here.
type DbBackend* = enum
none,
sqlite,
rocksdb,
lmdb
const
nimbus_db_backend* {.strdefine.} = "rocksdb"
dbBackend* = parseEnum[DbBackend](nimbus_db_backend)
when dbBackend == sqlite:
import eth/db/kvstore_sqlite3 as database_backend
elif dbBackend == rocksdb:
import ./kvstore_rocksdb as database_backend
type
ChainDB* = ref object of RootObj
kv*: KvStoreRef
when dbBackend == rocksdb:
rdb*: RocksStoreRef
# TODO KvStore is a virtual interface and TrieDB is a virtual interface - one
# will be enough eventually - unless the TrieDB interface gains operations
# that are not typical to KvStores
proc get*(db: ChainDB, key: openArray[byte]): seq[byte] =
var res: seq[byte]
proc onData(data: openArray[byte]) = res = @data
if db.kv.get(key, onData).expect("working database"):
return res
proc put*(db: ChainDB, key, value: openArray[byte]) =
db.kv.put(key, value).expect("working database")
proc contains*(db: ChainDB, key: openArray[byte]): bool =
db.kv.contains(key).expect("working database")
proc del*(db: ChainDB, key: openArray[byte]): bool =
db.kv.del(key).expect("working database")
when dbBackend == sqlite:
proc newChainDB*(path: string): ChainDB =
let db = SqStoreRef.init(path, "nimbus").expect("working database")
ChainDB(kv: kvStore db.openKvStore().expect("working database"))
elif dbBackend == rocksdb:
proc newChainDB*(path: string): ChainDB
{.gcsafe, deprecated: "use newCoreDbRef(LegacyDbPersistent,<path>)".} =
let rdb = RocksStoreRef.init(path, "nimbus").tryGet()
ChainDB(kv: kvStore rdb, rdb: rdb)
elif dbBackend == lmdb:
# TODO This implementation has several issues on restricted platforms, possibly
# due to mmap restrictions - see:
# https://github.com/status-im/nim-beacon-chain/issues/732
# https://github.com/status-im/nim-beacon-chain/issues/688
# It also has other issues, including exception safety:
# https://github.com/status-im/nim-beacon-chain/pull/809
{.error: "lmdb deprecated, needs reimplementing".}
elif dbBackend == none:
discard
when dbBackend != none:
export database_backend

View File

@ -24,7 +24,6 @@ import
./nimbus_desc, ./nimbus_desc,
./core/eip4844, ./core/eip4844,
./core/block_import, ./core/block_import,
./db/select_backend,
./db/core_db/persistent, ./db/core_db/persistent,
./core/clique/clique_desc, ./core/clique/clique_desc,
./core/clique/clique_sealer, ./core/clique/clique_sealer,

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2023 Status Research & Development GmbH # Copyright (c) 2023-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -18,7 +18,7 @@ import
eth/[common/eth_types, p2p], eth/[common/eth_types, p2p],
./core/chain/chain_desc, ./core/chain/chain_desc,
./core/executor/process_block, ./core/executor/process_block,
./db/[core_db, select_backend, ledger], ./db/[core_db, ledger],
./evm/async/[data_sources, operations, data_sources/json_rpc_data_source], ./evm/async/[data_sources, operations, data_sources/json_rpc_data_source],
"."/[vm_state, vm_types] "."/[vm_state, vm_types]

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -9,18 +9,12 @@
# except according to those terms. # except according to those terms.
import import
../db/select_backend,
./handlers/eth as handlers_eth, ./handlers/eth as handlers_eth,
./handlers/setup as handlers_setup ./handlers/setup as handlers_setup,
export
handlers_eth, handlers_setup
when dbBackend != select_backend.none:
import
./handlers/snap as handlers_snap ./handlers/snap as handlers_snap
export export
handlers_eth, handlers_setup,
handlers_snap handlers_snap
static: static:

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -12,7 +12,6 @@
import import
eth/p2p, eth/p2p,
../../db/select_backend,
../../core/[chain, tx_pool], ../../core/[chain, tx_pool],
../protocol, ../protocol,
./eth as handlers_eth ./eth as handlers_eth
@ -47,7 +46,6 @@ proc addEthHandlerCapability*(
# Public functions: convenience mappings for `snap` # Public functions: convenience mappings for `snap`
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
when dbBackend != select_backend.none:
import import
./snap as handlers_snap ./snap as handlers_snap

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)

View File

@ -14,7 +14,6 @@ import
chronicles, chronicles,
chronos, chronos,
eth/p2p, eth/p2p,
../db/select_backend,
../core/chain, ../core/chain,
./snap/[worker, worker_desc], ./snap/[worker, worker_desc],
"."/[protocol, sync_sched] "."/[protocol, sync_sched]

View File

@ -1,5 +1,5 @@
# nimbus-eth1 # nimbus-eth1
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -14,13 +14,12 @@ import
std/os, # std/[sequtils, strutils], std/os, # std/[sequtils, strutils],
eth/common/eth_types, eth/common/eth_types,
rocksdb, rocksdb,
../../../../db/[kvstore_rocksdb, select_backend] ../../../../db/kvstore_rocksdb
{.push raises: [].} {.push raises: [].}
type type
RockyBulkLoadRef* = ref object of RootObj RockyBulkLoadRef* = ref object of RootObj
when select_backend.dbBackend == select_backend.rocksdb:
db: RocksStoreRef db: RocksStoreRef
envOption: rocksdb_envoptions_t envOption: rocksdb_envoptions_t
importOption: rocksdb_ingestexternalfileoptions_t importOption: rocksdb_ingestexternalfileoptions_t
@ -38,7 +37,6 @@ proc init*(
envOption: rocksdb_envoptions_t envOption: rocksdb_envoptions_t
): T = ): T =
## Create a new bulk load descriptor. ## Create a new bulk load descriptor.
when select_backend.dbBackend == select_backend.rocksdb:
result = T( result = T(
db: db, db: db,
envOption: envOption, envOption: envOption,
@ -46,8 +44,6 @@ proc init*(
doAssert not result.importOption.isNil doAssert not result.importOption.isNil
doAssert not envOption.isNil doAssert not envOption.isNil
else:
T(csError: "rocksdb is unsupported")
proc init*(T: type RockyBulkLoadRef; db: RocksStoreRef): T = proc init*(T: type RockyBulkLoadRef; db: RocksStoreRef): T =
## Variant of `init()` ## Variant of `init()`
@ -57,8 +53,6 @@ proc clearCacheFile*(db: RocksStoreRef; fileName: string): bool
{.gcsafe, raises: [OSError].} = {.gcsafe, raises: [OSError].} =
## Remove left-over cache file from an imcomplete previous session. The ## Remove left-over cache file from an imcomplete previous session. The
## return value `true` indicated that a cache file was detected. ## return value `true` indicated that a cache file was detected.
discard
when select_backend.dbBackend == select_backend.rocksdb:
let filePath = db.tmpDir / fileName let filePath = db.tmpDir / fileName
if filePath.fileExists: if filePath.fileExists:
filePath.removeFile filePath.removeFile
@ -73,8 +67,6 @@ proc destroy*(rbl: RockyBulkLoadRef) {.gcsafe, raises: [OSError].} =
## reset and must not be used anymore with any function (different from ## reset and must not be used anymore with any function (different from
## `destroy()`.) ## `destroy()`.)
## ##
discard
when select_backend.dbBackend == select_backend.rocksdb:
if not rbl.writer.isNil: if not rbl.writer.isNil:
rbl.writer.rocksdb_sstfilewriter_destroy() rbl.writer.rocksdb_sstfilewriter_destroy()
if not rbl.envOption.isNil: if not rbl.envOption.isNil:
@ -95,18 +87,8 @@ proc lastError*(rbl: RockyBulkLoadRef): string =
proc store*(rbl: RockyBulkLoadRef): RocksDBInstance = proc store*(rbl: RockyBulkLoadRef): RocksDBInstance =
## Provide the diecriptor for backend functions as defined in `rocksdb`. ## Provide the diecriptor for backend functions as defined in `rocksdb`.
discard
when select_backend.dbBackend == select_backend.rocksdb:
rbl.db.store rbl.db.store
proc rocksStoreRef*(db: ChainDb): RocksStoreRef =
## Pull out underlying rocksdb backend descripto (if any)
# Current architecture allows only one globally defined persistent type
discard
when select_backend.dbBackend == select_backend.rocksdb:
if not db.isNil:
return db.rdb
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Public functions # Public functions
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -115,8 +97,6 @@ proc begin*(rbl: RockyBulkLoadRef; fileName: string): bool =
## Begin a new bulk load session storing data into a temporary cache file ## Begin a new bulk load session storing data into a temporary cache file
## `fileName`. When finished, this file will bi direcly imported into the ## `fileName`. When finished, this file will bi direcly imported into the
## database. ## database.
discard
when select_backend.dbBackend == select_backend.rocksdb:
rbl.writer = rocksdb_sstfilewriter_create( rbl.writer = rocksdb_sstfilewriter_create(
rbl.envOption, rbl.db.store.options) rbl.envOption, rbl.db.store.options)
if rbl.writer.isNil: if rbl.writer.isNil:
@ -145,8 +125,6 @@ proc add*(
## This function is a wrapper around `rocksdb_sstfilewriter_add()` or ## This function is a wrapper around `rocksdb_sstfilewriter_add()` or
## `rocksdb_sstfilewriter_put()` (stragely enough, there are two functions ## `rocksdb_sstfilewriter_put()` (stragely enough, there are two functions
## with exactly the same impementation code.) ## with exactly the same impementation code.)
discard
when select_backend.dbBackend == select_backend.rocksdb:
var csError: cstring var csError: cstring
rbl.writer.rocksdb_sstfilewriter_add( rbl.writer.rocksdb_sstfilewriter_add(
cast[cstring](unsafeAddr key[0]), csize_t(key.len), cast[cstring](unsafeAddr key[0]), csize_t(key.len),
@ -166,7 +144,6 @@ proc finish*(
## ##
## If successful, the return value is the size of the SST file used if ## If successful, the return value is the size of the SST file used if
## that value is available. Otherwise, `0` is returned. ## that value is available. Otherwise, `0` is returned.
when select_backend.dbBackend == select_backend.rocksdb:
var csError: cstring var csError: cstring
rbl.writer.rocksdb_sstfilewriter_finish(addr csError) rbl.writer.rocksdb_sstfilewriter_finish(addr csError)
@ -188,8 +165,6 @@ proc finish*(
rbl.csError = $csError rbl.csError = $csError
err()
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -20,9 +20,6 @@ import
hexary_interpolate, hexary_inspect, hexary_paths, snapdb_desc, hexary_interpolate, hexary_inspect, hexary_paths, snapdb_desc,
snapdb_persistent] snapdb_persistent]
import
../../../../db/select_backend
logScope: logScope:
topics = "snap-db" topics = "snap-db"
@ -66,7 +63,6 @@ proc persistentAccounts(
): Result[void,HexaryError] ): Result[void,HexaryError]
{.gcsafe, raises: [OSError,IOError,KeyError].} = {.gcsafe, raises: [OSError,IOError,KeyError].} =
## Store accounts trie table on databse ## Store accounts trie table on databse
when dbBackend == rocksdb:
if ps.rockDb.isNil: if ps.rockDb.isNil:
let rc = db.persistentAccountsPut(ps.kvDb) let rc = db.persistentAccountsPut(ps.kvDb)
if rc.isErr: return rc if rc.isErr: return rc

View File

@ -16,9 +16,6 @@ import
../../range_desc, ../../range_desc,
"."/[hexary_desc, hexary_error, snapdb_desc, snapdb_persistent] "."/[hexary_desc, hexary_error, snapdb_desc, snapdb_persistent]
import
../../../../db/select_backend
logScope: logScope:
topics = "snap-db" topics = "snap-db"
@ -49,7 +46,6 @@ proc persistentContracts(
): Result[void,HexaryError] ): Result[void,HexaryError]
{.gcsafe, raises: [OSError,IOError,KeyError].} = {.gcsafe, raises: [OSError,IOError,KeyError].} =
## Store contract codes onto permanent database ## Store contract codes onto permanent database
when dbBackend == rocksdb:
if ps.rockDb.isNil: if ps.rockDb.isNil:
let rc = data.persistentContractPut ps.kvDb let rc = data.persistentContractPut ps.kvDb
if rc.isErr: if rc.isErr:

View File

@ -15,7 +15,7 @@ import
chronicles, chronicles,
eth/[common, p2p, trie/nibbles], eth/[common, p2p, trie/nibbles],
../../../../db/core_db/persistent, ../../../../db/core_db/persistent,
../../../../db/[core_db, select_backend, storage_types], ../../../../db/[core_db, storage_types, kvstore_rocksdb],
../../../protocol, ../../../protocol,
../../range_desc, ../../range_desc,
"."/[hexary_desc, hexary_error, hexary_import, hexary_nearby, hexary_paths, "."/[hexary_desc, hexary_error, hexary_import, hexary_nearby, hexary_paths,
@ -35,8 +35,6 @@ type
## Global, re-usable descriptor ## Global, re-usable descriptor
keyMap: Table[RepairKey,uint] ## For debugging only (will go away) keyMap: Table[RepairKey,uint] ## For debugging only (will go away)
db: CoreDbRef ## General database db: CoreDbRef ## General database
# Allow hive sim to compile with dbBackend == none
when dbBackend == rocksdb:
rocky: RocksStoreRef ## Set if rocksdb is available rocky: RocksStoreRef ## Set if rocksdb is available
SnapDbBaseRef* = ref object of RootRef SnapDbBaseRef* = ref object of RootRef
@ -71,7 +69,6 @@ proc keyPp(a: RepairKey; pv: SnapDbRef): string =
# Private helper # Private helper
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
when dbBackend == rocksdb:
proc clearRockyCacheFile(rocky: RocksStoreRef): bool = proc clearRockyCacheFile(rocky: RocksStoreRef): bool =
if not rocky.isNil: if not rocky.isNil:
# A cache file might hang about from a previous crash # A cache file might hang about from a previous crash
@ -90,7 +87,6 @@ proc init*(
db: CoreDbRef db: CoreDbRef
): T = ): T =
## Main object constructor ## Main object constructor
when dbBackend == rocksdb:
T(db: db, rocky: db.backend.toRocksStoreRef) T(db: db, rocky: db.backend.toRocksStoreRef)
proc init*( proc init*(
@ -138,7 +134,6 @@ proc hexaDb*(ps: SnapDbBaseRef): HexaryTreeDbRef =
## Getter, low level access to underlying session DB ## Getter, low level access to underlying session DB
ps.xDb ps.xDb
when dbBackend == rocksdb:
proc rockDb*(ps: SnapDbBaseRef): RocksStoreRef = proc rockDb*(ps: SnapDbBaseRef): RocksStoreRef =
## Getter, low level access to underlying persistent rock DB interface ## Getter, low level access to underlying persistent rock DB interface
ps.base.rocky ps.base.rocky
@ -198,12 +193,10 @@ template toOpenArray*(k: ByteArray33): openArray[byte] =
proc dbBackendRocksDb*(pv: SnapDbRef): bool = proc dbBackendRocksDb*(pv: SnapDbRef): bool =
## Returns `true` if rocksdb features are available ## Returns `true` if rocksdb features are available
when dbBackend == rocksdb:
not pv.rocky.isNil not pv.rocky.isNil
proc dbBackendRocksDb*(ps: SnapDbBaseRef): bool = proc dbBackendRocksDb*(ps: SnapDbBaseRef): bool =
## Returns `true` if rocksdb features are available ## Returns `true` if rocksdb features are available
when dbBackend == rocksdb:
not ps.base.rocky.isNil not ps.base.rocky.isNil
proc mergeProofs*( proc mergeProofs*(

View File

@ -21,9 +21,6 @@ import
hexary_inspect, hexary_interpolate, hexary_paths, snapdb_desc, hexary_inspect, hexary_interpolate, hexary_paths, snapdb_desc,
snapdb_persistent] snapdb_persistent]
import
../../../../db/select_backend
logScope: logScope:
topics = "snap-db" topics = "snap-db"
@ -63,7 +60,6 @@ proc persistentStorageSlots(
): Result[void,HexaryError] ): Result[void,HexaryError]
{.gcsafe, raises: [OSError,IOError,KeyError].} = {.gcsafe, raises: [OSError,IOError,KeyError].} =
## Store accounts trie table on databse ## Store accounts trie table on databse
when dbBackend == rocksdb:
if ps.rockDb.isNil: if ps.rockDb.isNil:
let rc = db.persistentStorageSlotsPut(ps.kvDb) let rc = db.persistentStorageSlotsPut(ps.kvDb)
if rc.isErr: return rc if rc.isErr: return rc

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2021 Status Research & Development GmbH # Copyright (c) 2021-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -12,7 +12,6 @@
import import
eth/[common, p2p], eth/[common, p2p],
../../db/select_backend,
../misc/ticker, ../misc/ticker,
../sync_desc, ../sync_desc,
./worker/get/get_error, ./worker/get/get_error,

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2022-2023 Status Research & Development GmbH # Copyright (c) 2022-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -60,7 +60,6 @@ import
std/algorithm, std/algorithm,
eth/[common, p2p], eth/[common, p2p],
unittest2, unittest2,
../../nimbus/db/select_backend,
../../nimbus/sync/protocol, ../../nimbus/sync/protocol,
../../nimbus/sync/snap/range_desc, ../../nimbus/sync/snap/range_desc,
../../nimbus/sync/snap/worker/db/[ ../../nimbus/sync/snap/worker/db/[

View File

@ -1,5 +1,5 @@
# Nimbus # Nimbus
# Copyright (c) 2022-2023 Status Research & Development GmbH # Copyright (c) 2022-2024 Status Research & Development GmbH
# Licensed under either of # Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0) # http://www.apache.org/licenses/LICENSE-2.0)
@ -14,7 +14,6 @@ import
std/[sequtils, tables], std/[sequtils, tables],
eth/[common, p2p], eth/[common, p2p],
unittest2, unittest2,
../../nimbus/db/select_backend,
../../nimbus/sync/snap/range_desc, ../../nimbus/sync/snap/range_desc,
../../nimbus/sync/snap/worker/db/[ ../../nimbus/sync/snap/worker/db/[
hexary_desc, hexary_error, hexary_inspect, hexary_desc, hexary_error, hexary_inspect,