mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-11 11:37:01 +00:00
cleanups, import fixes (#2964)
* more generic-path removal * tighter imports
This commit is contained in:
parent
80f8b3c2b1
commit
036dd23e9b
@ -9,9 +9,7 @@
|
||||
# according to those terms.
|
||||
|
||||
import
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
stint,
|
||||
eth/common/[base, hashes],
|
||||
kzg4844/kzg,
|
||||
kzg4844/kzg_abi,
|
||||
stew/endians2,
|
||||
@ -19,6 +17,7 @@ import
|
||||
results,
|
||||
../../../../nimbus/core/eip4844
|
||||
|
||||
export base, hashes
|
||||
type
|
||||
BlobID* = uint64
|
||||
BlobIDs* = seq[BlobID]
|
||||
|
@ -105,12 +105,6 @@ type
|
||||
taskpool*: Taskpool
|
||||
## Shared task pool for offloading computation to other threads
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Forward declarations
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc proofOfStake*(com: CommonRef, header: Header): bool {.gcsafe.}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Private helper functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -14,6 +14,8 @@ import
|
||||
eth/common/[addresses, transactions],
|
||||
../utils/mergeutils
|
||||
|
||||
export addresses
|
||||
|
||||
type
|
||||
SlotSet = HashSet[UInt256]
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import
|
||||
std/times,
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_desc/desc_backend,
|
||||
./aristo_init/memory_db,
|
||||
@ -230,32 +230,6 @@ type
|
||||
## Variant of `partAccountTwig()`. Note that the function always returns
|
||||
## an error unless the `accPath` is valid.
|
||||
|
||||
AristoApiPartUntwigGeneric* =
|
||||
proc(chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
): Result[Opt[seq[byte]],AristoError]
|
||||
{.noRaise.}
|
||||
## Follow and verify the argument `chain` up unlil the last entry which
|
||||
## must be a leaf node. Extract the payload and pass it on as return
|
||||
## code. If a `Opt.none()` result is returned then the `path` argument
|
||||
## does provably not exist relative to `chain`.
|
||||
|
||||
AristoApiPartUntwigGenericOk* =
|
||||
proc(chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
payload: Opt[seq[byte]];
|
||||
): Result[void,AristoError]
|
||||
{.noRaise.}
|
||||
## Variant of `partUntwigGeneric()`. The function verifies the argument
|
||||
## `chain` of rlp-encoded nodes against the `path` and `payload`
|
||||
## arguments. If `payload` is passed `Opt.none()`, then the function is
|
||||
## subject to proving that the `path` does not exist relaive to `chain`.
|
||||
##
|
||||
## Note: This function provides a functionality comparable to the
|
||||
## `isValidBranch()` function from `hexary.nim`.
|
||||
|
||||
AristoApiPartUntwigPath* =
|
||||
proc(chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
@ -359,8 +333,6 @@ type
|
||||
|
||||
partAccountTwig*: AristoApiPartAccountTwig
|
||||
partStorageTwig*: AristoApiPartStorageTwig
|
||||
partUntwigGeneric*: AristoApiPartUntwigGeneric
|
||||
partUntwigGenericOk*: AristoApiPartUntwigGenericOk
|
||||
partUntwigPath*: AristoApiPartUntwigPath
|
||||
partUntwigPathOk*: AristoApiPartUntwigPathOk
|
||||
|
||||
@ -429,45 +401,12 @@ type
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
when AutoValidateApiHooks:
|
||||
proc validate(api: AristoApiObj|AristoApiRef) =
|
||||
doAssert not api.commit.isNil
|
||||
|
||||
doAssert not api.deleteAccountRecord.isNil
|
||||
doAssert not api.deleteStorageData.isNil
|
||||
doAssert not api.deleteStorageTree.isNil
|
||||
|
||||
doAssert not api.fetchLastSavedState.isNil
|
||||
|
||||
doAssert not api.fetchAccountRecord.isNil
|
||||
doAssert not api.fetchStateRoot.isNil
|
||||
doAssert not api.fetchStorageData.isNil
|
||||
doAssert not api.fetchStorageRoot.isNil
|
||||
|
||||
doAssert not api.finish.isNil
|
||||
|
||||
doAssert not api.hasPathAccount.isNil
|
||||
doAssert not api.hasPathStorage.isNil
|
||||
doAssert not api.hasStorageData.isNil
|
||||
|
||||
doAssert not api.isTop.isNil
|
||||
doAssert not api.txFrameLevel.isNil
|
||||
|
||||
doAssert not api.mergeAccountRecord.isNil
|
||||
doAssert not api.mergeStorageData.isNil
|
||||
|
||||
doAssert not api.partAccountTwig.isNil
|
||||
doAssert not api.partStorageTwig.isNil
|
||||
doAssert not api.partUntwigPath.isNil
|
||||
doAssert not api.partUntwigPathOk.isNil
|
||||
|
||||
doAssert not api.pathAsBlob.isNil
|
||||
doAssert not api.persist.isNil
|
||||
doAssert not api.rollback.isNil
|
||||
doAssert not api.txFrameBegin.isNil
|
||||
doAssert not api.txFrameTop.isNil
|
||||
proc validate(api: AristoApiObj) =
|
||||
for _, field in api.fieldPairs():
|
||||
doAssert not field.isNil
|
||||
|
||||
proc validate(prf: AristoApiProfRef) =
|
||||
prf.AristoApiRef.validate
|
||||
prf.AristoApiRef[].validate
|
||||
doAssert not prf.data.isNil
|
||||
|
||||
proc dup(be: BackendRef): BackendRef =
|
||||
@ -534,43 +473,10 @@ func init*(T: type AristoApiRef): T =
|
||||
result[].init()
|
||||
|
||||
func dup*(api: AristoApiRef): AristoApiRef =
|
||||
result = AristoApiRef(
|
||||
commit: api.commit,
|
||||
|
||||
deleteAccountRecord: api.deleteAccountRecord,
|
||||
deleteStorageData: api.deleteStorageData,
|
||||
deleteStorageTree: api.deleteStorageTree,
|
||||
|
||||
fetchLastSavedState: api.fetchLastSavedState,
|
||||
fetchAccountRecord: api.fetchAccountRecord,
|
||||
fetchStateRoot: api.fetchStateRoot,
|
||||
fetchStorageData: api.fetchStorageData,
|
||||
fetchStorageRoot: api.fetchStorageRoot,
|
||||
|
||||
finish: api.finish,
|
||||
|
||||
hasPathAccount: api.hasPathAccount,
|
||||
hasPathStorage: api.hasPathStorage,
|
||||
hasStorageData: api.hasStorageData,
|
||||
|
||||
isTop: api.isTop,
|
||||
txFrameLevel: api.txFrameLevel,
|
||||
|
||||
mergeAccountRecord: api.mergeAccountRecord,
|
||||
mergeStorageData: api.mergeStorageData,
|
||||
|
||||
partAccountTwig: api.partAccountTwig,
|
||||
partStorageTwig: api.partStorageTwig,
|
||||
partUntwigPath: api.partUntwigPath,
|
||||
partUntwigPathOk: api.partUntwigPathOk,
|
||||
|
||||
pathAsBlob: api.pathAsBlob,
|
||||
persist: api.persist,
|
||||
rollback: api.rollback,
|
||||
txFrameBegin: api.txFrameBegin,
|
||||
txFrameTop: api.txFrameTop)
|
||||
result = AristoApiRef()
|
||||
result[] = api[]
|
||||
when AutoValidateApiHooks:
|
||||
result.validate
|
||||
result[].validate
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public profile API constuctor
|
||||
|
@ -14,9 +14,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[algorithm, sequtils, tables],
|
||||
eth/common,
|
||||
stew/interval_set,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_walk/persistent,
|
||||
"."/[aristo_desc, aristo_get, aristo_init],
|
||||
@ -88,18 +86,6 @@ proc check*(
|
||||
? db.checkBE()
|
||||
ok()
|
||||
|
||||
proc check*(
|
||||
db: AristoDbRef; # Database
|
||||
root: VertexID; # Start node
|
||||
path: openArray[byte]; # Data path
|
||||
): Result[void,AristoError] =
|
||||
## Check generic path `path` against portal proof generation and
|
||||
## verification.
|
||||
##
|
||||
## Note that this check might have side effects in that it might compile
|
||||
## the hash keys on the `root` sub-tree.
|
||||
db.checkTwig(root, path)
|
||||
|
||||
proc check*(
|
||||
db: AristoDbRef; # Database
|
||||
accPath: Hash32; # Account key
|
||||
@ -109,7 +95,7 @@ proc check*(
|
||||
##
|
||||
## Note that this check might have side effects in that it might compile
|
||||
## the hash keys on the accounts sub-tree.
|
||||
db.checkTwig(VertexID(1), accPath.data)
|
||||
db.checkTwig(accPath)
|
||||
|
||||
proc check*(
|
||||
db: AristoDbRef; # Database
|
||||
|
@ -11,7 +11,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
".."/[aristo_compute, aristo_desc, aristo_fetch, aristo_part]
|
||||
|
||||
@ -21,13 +21,12 @@ import
|
||||
|
||||
proc checkTwig*(
|
||||
db: AristoDbRef; # Database
|
||||
root: VertexID; # Start node
|
||||
path: openArray[byte]; # Data path
|
||||
accPath: Hash32; # Data path
|
||||
): Result[void,AristoError] =
|
||||
let
|
||||
proof = ? db.partGenericTwig(root, path)
|
||||
key = ? db.computeKey (root,root)
|
||||
discard ? proof[0].partUntwigGeneric(key.to(Hash32), path)
|
||||
proof = ? db.partAccountTwig(accPath)
|
||||
key = ? db.computeKey (VertexID(1),VertexID(1))
|
||||
discard ? proof[0].partUntwigPath(key.to(Hash32), accPath)
|
||||
|
||||
ok()
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
import
|
||||
std/strformat,
|
||||
chronicles,
|
||||
eth/common,
|
||||
eth/common/[accounts_rlp, base_rlp, hashes_rlp],
|
||||
results,
|
||||
"."/[aristo_desc, aristo_get, aristo_walk/persistent],
|
||||
./aristo_desc/desc_backend
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import
|
||||
std/typetraits,
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_delete/delete_subtree,
|
||||
"."/[aristo_desc, aristo_fetch, aristo_get, aristo_hike, aristo_layers]
|
||||
|
@ -11,7 +11,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
".."/[aristo_desc, aristo_get, aristo_layers]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -14,10 +14,9 @@
|
||||
|
||||
import
|
||||
std/tables,
|
||||
eth/common,
|
||||
results,
|
||||
./aristo_desc/desc_backend,
|
||||
"."/[aristo_desc]
|
||||
./aristo_desc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public functions, save to backend
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
import
|
||||
std/[hashes, sets, tables],
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_constants,
|
||||
./aristo_desc/[desc_error, desc_identifiers, desc_nibbles, desc_structural],
|
||||
@ -36,7 +36,7 @@ from ./aristo_desc/desc_backend
|
||||
# Not auto-exporting backend
|
||||
export
|
||||
tables, aristo_constants, desc_error, desc_identifiers, desc_nibbles,
|
||||
desc_structural, minilru, common
|
||||
desc_structural, minilru, hashes
|
||||
|
||||
type
|
||||
AristoTxRef* = ref object
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
import
|
||||
std/[algorithm, sequtils, sets, strutils, hashes],
|
||||
eth/common,
|
||||
eth/common/[base, hashes],
|
||||
eth/rlp,
|
||||
stew/byteutils,
|
||||
chronicles,
|
||||
results,
|
||||
@ -24,7 +25,7 @@ import
|
||||
./desc_nibbles
|
||||
|
||||
export
|
||||
desc_nibbles
|
||||
desc_nibbles, base, hashes, rlp
|
||||
|
||||
type
|
||||
VertexID* = distinct uint64
|
||||
@ -311,12 +312,12 @@ func to*(lid: HashKey; T: type Hash32): T =
|
||||
elif 0 < lid.len:
|
||||
lid.data.keccak256
|
||||
else:
|
||||
EMPTY_ROOT_HASH
|
||||
emptyRoot
|
||||
|
||||
func to*(key: Hash32; T: type HashKey): T =
|
||||
## This is an efficient version of `HashKey.fromBytes(key.data).value`, not
|
||||
## to be confused with `digestTo(HashKey)`.
|
||||
if key == EMPTY_ROOT_HASH:
|
||||
if key == emptyRoot:
|
||||
T()
|
||||
else:
|
||||
T(len: 32, buf: key.data)
|
||||
|
@ -15,12 +15,12 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[hashes, tables],
|
||||
std/[hashes as std_hashes, tables],
|
||||
stint,
|
||||
eth/common,
|
||||
eth/common/[accounts, base, hashes],
|
||||
./desc_identifiers
|
||||
|
||||
export stint
|
||||
export stint, tables, accounts, base, hashes
|
||||
|
||||
type
|
||||
LeafTiePayload* = object
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import
|
||||
std/typetraits,
|
||||
eth/common,
|
||||
eth/common/[base, hashes],
|
||||
results,
|
||||
"."/[aristo_compute, aristo_desc, aristo_get, aristo_layers, aristo_hike]
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/tables,
|
||||
results,
|
||||
"."/[aristo_desc, aristo_layers]
|
||||
|
||||
|
@ -11,9 +11,8 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
stew/arraybuf,
|
||||
"."/[aristo_desc, aristo_get]
|
||||
|
||||
const
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
import
|
||||
std/[algorithm, options, sequtils, tables],
|
||||
eth/common,
|
||||
results,
|
||||
../aristo_constants,
|
||||
../aristo_desc,
|
||||
|
@ -27,7 +27,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
rocksdb,
|
||||
results,
|
||||
../aristo_desc,
|
||||
|
@ -16,7 +16,6 @@
|
||||
import
|
||||
std/os,
|
||||
std/concurrency/atomics,
|
||||
eth/common,
|
||||
rocksdb,
|
||||
stew/endians2,
|
||||
../../aristo_desc,
|
||||
|
@ -14,7 +14,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
rocksdb,
|
||||
results,
|
||||
../../[aristo_blobify, aristo_desc],
|
||||
|
@ -14,7 +14,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
rocksdb,
|
||||
results,
|
||||
../../[aristo_blobify, aristo_desc],
|
||||
|
@ -14,7 +14,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
stew/endians2,
|
||||
rocksdb,
|
||||
./rdb_desc,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import
|
||||
std/[enumerate, sequtils, sets, tables],
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_desc
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
import
|
||||
std/typetraits,
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
"."/[aristo_desc, aristo_fetch, aristo_get, aristo_layers, aristo_vid]
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import
|
||||
std/[sets, sequtils],
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
"."/[aristo_desc, aristo_fetch, aristo_get, aristo_merge, aristo_layers,
|
||||
aristo_utils],
|
||||
@ -66,7 +66,7 @@ iterator vkPairs*(ps: PartStateRef): (RootedVertexID, HashKey) =
|
||||
# Public functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc partGenericTwig*(
|
||||
proc partTwig(
|
||||
db: AristoDbRef;
|
||||
root: VertexID;
|
||||
path: NibblesBuf;
|
||||
@ -87,51 +87,38 @@ proc partGenericTwig*(
|
||||
else:
|
||||
err(rc.error)
|
||||
|
||||
proc partGenericTwig*(
|
||||
db: AristoDbRef;
|
||||
root: VertexID;
|
||||
path: openArray[byte];
|
||||
): Result[(seq[seq[byte]],bool), AristoError] =
|
||||
## Variant of `partGenericTwig()`.
|
||||
##
|
||||
## Note: This function provides a functionality comparable to the
|
||||
## `getBranch()` function from `hexary.nim`
|
||||
##
|
||||
db.partGenericTwig(root, NibblesBuf.fromBytes path)
|
||||
|
||||
proc partAccountTwig*(
|
||||
db: AristoDbRef;
|
||||
accPath: Hash32;
|
||||
): Result[(seq[seq[byte]],bool), AristoError] =
|
||||
## Variant of `partGenericTwig()`.
|
||||
db.partGenericTwig(VertexID(1), NibblesBuf.fromBytes accPath.data)
|
||||
db.partTwig(VertexID(1), NibblesBuf.fromBytes accPath.data)
|
||||
|
||||
proc partStorageTwig*(
|
||||
db: AristoDbRef;
|
||||
accPath: Hash32;
|
||||
stoPath: Hash32;
|
||||
): Result[(seq[seq[byte]],bool), AristoError] =
|
||||
## Variant of `partGenericTwig()`. Note that the function returns an error unless
|
||||
## Note that the function returns an error unless
|
||||
## the argument `accPath` is valid.
|
||||
let vid = db.fetchStorageID(accPath).valueOr:
|
||||
if error == FetchPathStoRootMissing:
|
||||
return ok((@[],false))
|
||||
return err(error)
|
||||
db.partGenericTwig(vid, NibblesBuf.fromBytes stoPath.data)
|
||||
db.partTwig(vid, NibblesBuf.fromBytes stoPath.data)
|
||||
|
||||
# ----------
|
||||
|
||||
proc partUntwigGeneric*(
|
||||
proc partUntwigPath*(
|
||||
chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
path: Hash32;
|
||||
): Result[Opt[seq[byte]],AristoError] =
|
||||
## Verify the chain of rlp-encoded nodes and return the payload. If a
|
||||
## `Opt.none()` result is returned then the `path` argument does provably
|
||||
## not exist relative to `chain`.
|
||||
try:
|
||||
let
|
||||
nibbles = NibblesBuf.fromBytes path
|
||||
nibbles = NibblesBuf.fromBytes path.data
|
||||
rc = chain.trackRlpNodes(root.to(HashKey), nibbles, start=true)
|
||||
if rc.isOk:
|
||||
return ok(Opt.some rc.value)
|
||||
@ -141,32 +128,6 @@ proc partUntwigGeneric*(
|
||||
except RlpError:
|
||||
return err(PartTrkRlpError)
|
||||
|
||||
proc partUntwigPath*(
|
||||
chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: Hash32;
|
||||
): Result[Opt[seq[byte]],AristoError] =
|
||||
## Variant of `partUntwigGeneric()`.
|
||||
chain.partUntwigGeneric(root, path.data)
|
||||
|
||||
|
||||
proc partUntwigGenericOk*(
|
||||
chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
payload: Opt[seq[byte]];
|
||||
): Result[void,AristoError] =
|
||||
## Verify the argument `chain` of rlp-encoded nodes against the `path`
|
||||
## and `payload` arguments.
|
||||
##
|
||||
## Note: This function provides a functionality comparable to the
|
||||
## `isValidBranch()` function from `hexary.nim`.
|
||||
##
|
||||
if payload == ? chain.partUntwigGeneric(root, path):
|
||||
ok()
|
||||
else:
|
||||
err(PartTrkPayloadMismatch)
|
||||
|
||||
proc partUntwigPathOk*(
|
||||
chain: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
@ -174,7 +135,10 @@ proc partUntwigPathOk*(
|
||||
payload: Opt[seq[byte]];
|
||||
): Result[void,AristoError] =
|
||||
## Variant of `partUntwigGenericOk()`.
|
||||
chain.partUntwigGenericOk(root, path.data, payload)
|
||||
if payload == ? chain.partUntwigPath(root, path):
|
||||
ok()
|
||||
else:
|
||||
err(PartTrkPayloadMismatch)
|
||||
|
||||
# ----------------
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import
|
||||
std/sequtils,
|
||||
eth/common,
|
||||
eth/common/hashes,
|
||||
results,
|
||||
./aristo_desc
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
results,
|
||||
"."/[aristo_desc, aristo_compute]
|
||||
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
import
|
||||
std/typetraits,
|
||||
eth/common,
|
||||
"../.."/[constants],
|
||||
".."/[kvt, aristo],
|
||||
eth/common/[accounts, base, hashes],
|
||||
../../constants,
|
||||
../[kvt, aristo],
|
||||
./base/[api_tracking, base_config, base_desc, base_helpers]
|
||||
|
||||
export
|
||||
@ -134,61 +134,6 @@ proc stateBlockNumber*(db: CoreDbRef): BlockNumber =
|
||||
0u64
|
||||
db.ifTrackNewApi: debug logTxt, api, elapsed, result
|
||||
|
||||
proc verify*(
|
||||
db: CoreDbRef | CoreDbAccRef;
|
||||
proof: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
): CoreDbRc[Opt[seq[byte]]] =
|
||||
## This function os the counterpart of any of the `proof()` functions. Given
|
||||
## the argument chain of rlp-encoded nodes `proof`, this function verifies
|
||||
## that the chain represents a partial MPT starting with a root node state
|
||||
## `root` followig the path `key` leading to leaf node encapsulating a
|
||||
## payload which is passed back as return code.
|
||||
##
|
||||
## Note: The `mpt` argument is used for administative purposes (e.g. logging)
|
||||
## only. The functionality is provided by the `Aristo` database
|
||||
## function `aristo_part.partUntwigGeneric()` with the same prototype
|
||||
## arguments except the `db`.
|
||||
##
|
||||
template mpt: untyped =
|
||||
when db is CoreDbRef:
|
||||
CoreDbAccRef(db.defCtx)
|
||||
else:
|
||||
db
|
||||
mpt.setTrackNewApi BaseVerifyFn
|
||||
result = block:
|
||||
let rc = mpt.call(partUntwigGeneric, proof, root, path)
|
||||
if rc.isOk:
|
||||
ok(rc.value)
|
||||
else:
|
||||
err(rc.error.toError($api, ProofVerify))
|
||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed, result
|
||||
|
||||
proc verifyOk*(
|
||||
db: CoreDbRef | CoreDbAccRef;
|
||||
proof: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: openArray[byte];
|
||||
payload: Opt[seq[byte]];
|
||||
): CoreDbRc[void] =
|
||||
## Variant of `verify()` which directly checks the argument `payload`
|
||||
## against what would be the return code in `verify()`.
|
||||
##
|
||||
template mpt: untyped =
|
||||
when db is CoreDbRef:
|
||||
CoreDbAccRef(db.defCtx)
|
||||
else:
|
||||
db
|
||||
mpt.setTrackNewApi BaseVerifyOkFn
|
||||
result = block:
|
||||
let rc = mpt.call(partUntwigGenericOk, proof, root, path, payload)
|
||||
if rc.isOk:
|
||||
ok()
|
||||
else:
|
||||
err(rc.error.toError($api, ProofVerify))
|
||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed, result
|
||||
|
||||
proc verify*(
|
||||
db: CoreDbRef | CoreDbAccRef;
|
||||
proof: openArray[seq[byte]];
|
||||
@ -210,28 +155,6 @@ proc verify*(
|
||||
err(rc.error.toError($api, ProofVerify))
|
||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed, result
|
||||
|
||||
proc verifyOk*(
|
||||
db: CoreDbRef | CoreDbAccRef;
|
||||
proof: openArray[seq[byte]];
|
||||
root: Hash32;
|
||||
path: Hash32;
|
||||
payload: Opt[seq[byte]];
|
||||
): CoreDbRc[void] =
|
||||
## Variant of `verifyOk()`.
|
||||
template mpt: untyped =
|
||||
when db is CoreDbRef:
|
||||
CoreDbAccRef(db.defCtx)
|
||||
else:
|
||||
db
|
||||
mpt.setTrackNewApi BaseVerifyOkFn
|
||||
result = block:
|
||||
let rc = mpt.call(partUntwigPathOk, proof, root, path, payload)
|
||||
if rc.isOk:
|
||||
ok()
|
||||
else:
|
||||
err(rc.error.toError($api, ProofVerify))
|
||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed, result
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public key-value table methods
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import
|
||||
std/[sequtils, strutils, times, typetraits],
|
||||
eth/common,
|
||||
eth/common/[accounts, base, hashes],
|
||||
results,
|
||||
stew/byteutils,
|
||||
../../aristo/aristo_profile,
|
||||
@ -56,7 +56,6 @@ type
|
||||
BasePersistentFn = "persistent"
|
||||
BaseStateBlockNumberFn = "stateBlockNumber"
|
||||
BaseVerifyFn = "verify"
|
||||
BaseVerifyOkFn = "verifyOk"
|
||||
|
||||
CptKvtLogFn = "kvtLog"
|
||||
CptLevelFn = "level"
|
||||
|
@ -116,23 +116,12 @@ type
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
when AutoValidateApiHooks:
|
||||
proc validate(api: KvtApiObj|KvtApiRef) =
|
||||
doAssert not api.commit.isNil
|
||||
doAssert not api.del.isNil
|
||||
doAssert not api.finish.isNil
|
||||
doAssert not api.get.isNil
|
||||
doAssert not api.hasKeyRc.isNil
|
||||
doAssert not api.isTop.isNil
|
||||
doAssert not api.txFrameLevel.isNil
|
||||
doAssert not api.put.isNil
|
||||
doAssert not api.rollback.isNil
|
||||
doAssert not api.persist.isNil
|
||||
doAssert not api.toKvtDbRef.isNil
|
||||
doAssert not api.txFrameBegin.isNil
|
||||
doAssert not api.txFrameTop.isNil
|
||||
proc validate(api: KvtApiObj) =
|
||||
for _, field in api.fieldPairs:
|
||||
doAssert not field.isNil
|
||||
|
||||
proc validate(prf: KvtApiProfRef) =
|
||||
prf.KvtApiRef.validate
|
||||
prf.KvtApiRef[].validate
|
||||
doAssert not prf.data.isNil
|
||||
|
||||
proc dup(be: BackendRef): BackendRef =
|
||||
@ -176,23 +165,10 @@ func init*(T: type KvtApiRef): T =
|
||||
result[].init()
|
||||
|
||||
func dup*(api: KvtApiRef): KvtApiRef =
|
||||
result = KvtApiRef(
|
||||
commit: api.commit,
|
||||
del: api.del,
|
||||
finish: api.finish,
|
||||
get: api.get,
|
||||
len: api.len,
|
||||
hasKeyRc: api.hasKeyRc,
|
||||
isTop: api.isTop,
|
||||
txFrameLevel: api.txFrameLevel,
|
||||
put: api.put,
|
||||
rollback: api.rollback,
|
||||
persist: api.persist,
|
||||
toKvtDbRef: api.toKvtDbRef,
|
||||
txFrameBegin: api.txFrameBegin,
|
||||
txFrameTop: api.txFrameTop)
|
||||
result = KvtApiRef()
|
||||
result[] = api[]
|
||||
when AutoValidateApiHooks:
|
||||
result.validate
|
||||
result[].validate
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public profile API constuctor
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -23,7 +23,7 @@ from ./kvt_desc/desc_backend
|
||||
|
||||
# Not auto-exporting backend
|
||||
export
|
||||
tables, kvt_constants, desc_error, desc_structural
|
||||
hashes, tables, kvt_constants, desc_error, desc_structural
|
||||
|
||||
type
|
||||
KvtTxRef* = ref object
|
||||
|
@ -29,7 +29,6 @@
|
||||
import
|
||||
std/tables,
|
||||
chronicles,
|
||||
eth/common,
|
||||
results,
|
||||
stew/byteutils,
|
||||
../kvt_desc,
|
||||
|
@ -884,7 +884,7 @@ proc clearTransientStorage*(ac: LedgerRef) =
|
||||
doAssert(ac.savePoint.parentSavepoint.isNil)
|
||||
ac.savePoint.transientStorage.clear()
|
||||
|
||||
func getAccessList*(ac: LedgerRef): common.AccessList =
|
||||
func getAccessList*(ac: LedgerRef): transactions.AccessList =
|
||||
# make sure all savepoint already committed
|
||||
doAssert(ac.savePoint.parentSavepoint.isNil)
|
||||
ac.savePoint.accessList.getAccessList()
|
||||
|
@ -9,7 +9,9 @@
|
||||
# according to those terms.
|
||||
|
||||
import
|
||||
eth/common
|
||||
eth/common/[base, hashes]
|
||||
|
||||
export base, hashes
|
||||
|
||||
type
|
||||
DBKeyKind* = enum
|
||||
@ -61,7 +63,7 @@ func canonicalHeadHashKey*(): DbKey {.inline.} =
|
||||
func dataDirIdKey*(): DbKey {.inline.} =
|
||||
result.data[0] = byte ord(dataDirId)
|
||||
result.dataEndPos = 1
|
||||
|
||||
|
||||
func slotHashToSlotKey*(h: openArray[byte]): DbKey {.inline.} =
|
||||
doAssert(h.len == 32)
|
||||
result.data[0] = byte ord(slotHashToSlot)
|
||||
|
@ -5,7 +5,7 @@
|
||||
# * 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 chronicles, eth/common, stew/byteutils, ./interpreter/op_codes, ./code_bytes
|
||||
import chronicles, stint, stew/byteutils, ./interpreter/op_codes, ./code_bytes
|
||||
|
||||
export code_bytes
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common, # GasInt
|
||||
eth/common/base,
|
||||
../evm_errors,
|
||||
../types
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
eth/common,
|
||||
../../computation,
|
||||
../../stack,
|
||||
../../evm_errors,
|
||||
|
@ -30,8 +30,7 @@ import
|
||||
./oph_defs,
|
||||
./oph_helpers,
|
||||
chronicles,
|
||||
eth/common,
|
||||
eth/common/eth_types,
|
||||
eth/common/addresses,
|
||||
stew/assign2,
|
||||
stint
|
||||
|
||||
|
@ -28,10 +28,7 @@ import
|
||||
../op_codes,
|
||||
./oph_defs,
|
||||
./oph_helpers,
|
||||
chronicles,
|
||||
eth/common,
|
||||
eth/common/eth_types,
|
||||
stint
|
||||
chronicles
|
||||
|
||||
when not defined(evmc_enabled):
|
||||
import
|
||||
|
@ -24,9 +24,7 @@ import
|
||||
../op_codes,
|
||||
./oph_defs,
|
||||
./oph_helpers,
|
||||
eth/common,
|
||||
stew/assign2,
|
||||
stint
|
||||
stew/assign2
|
||||
|
||||
when not defined(evmc_enabled):
|
||||
import ../../state
|
||||
|
@ -19,9 +19,7 @@ import
|
||||
../../evm_errors,
|
||||
../../types,
|
||||
../gas_costs,
|
||||
eth/common,
|
||||
eth/common/eth_types,
|
||||
stint
|
||||
eth/common/[addresses, base, hashes]
|
||||
|
||||
when defined(evmc_enabled):
|
||||
import
|
||||
|
@ -15,6 +15,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/sequtils,
|
||||
stew/assign2,
|
||||
../../../constants,
|
||||
../../evm_errors,
|
||||
@ -26,10 +27,7 @@ import
|
||||
../op_codes,
|
||||
./oph_defs,
|
||||
./oph_gen_handlers,
|
||||
./oph_helpers,
|
||||
eth/common,
|
||||
sequtils,
|
||||
stint
|
||||
./oph_helpers
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Private, names & settings
|
||||
|
@ -25,9 +25,7 @@ import
|
||||
../gas_costs,
|
||||
../op_codes,
|
||||
./oph_defs,
|
||||
./oph_helpers,
|
||||
eth/common,
|
||||
stint
|
||||
./oph_helpers
|
||||
|
||||
when not defined(evmc_enabled):
|
||||
import
|
||||
|
@ -24,9 +24,7 @@ import
|
||||
../gas_costs,
|
||||
../op_codes,
|
||||
./oph_defs,
|
||||
./oph_helpers,
|
||||
eth/common,
|
||||
stint
|
||||
./oph_helpers
|
||||
|
||||
when not defined(evmc_enabled):
|
||||
import
|
||||
|
Loading…
x
Reference in New Issue
Block a user