Jordan Hrycaj a84a2131cd
No ext update (#2494)
* Imported/rebase from `no-ext`, PR #2485

  Store extension nodes together with the branch

  Extension nodes must be followed by a branch - as such, it makes sense
  to store the two together both in the database and in memory:

  * fewer reads, writes and updates to traverse the tree
  * simpler logic for maintaining the node structure
  * less space used, both memory and storage, because there are fewer
    nodes overall

  There is also a downside: hashes can no longer be cached for an
  extension - instead, only the extension+branch hash can be cached - this
  seems like a fine tradeoff since computing it should be fast.

  TODO: fix commented code

* Fix merge functions and `toNode()`

* Update `merkleSignCommit()` prototype

why:
  Result is always a 32bit hash

* Update short Merkle hash key generation

details:
  Ethereum reference MPTs use Keccak hashes as node links if the size of
  an RLP encoded node is at least 32 bytes. Otherwise, the RLP encoded
  node value is used as a pseudo node link (rather than a hash.) This is
  specified in the yellow paper, appendix D.

  Different to the `Aristo` implementation, the reference MPT would not
  store such a node on the key-value database. Rather the RLP encoded node value is stored instead of a node link in a parent node
  is stored as a node link on the parent database.

  Only for the root hash, the top level node is always referred to by the
  hash.

* Fix/update `Extension` sections

why:
  Were commented out after removal of a dedicated `Extension` type which
  left the system disfunctional.

* Clean up unused error codes

* Update unit tests

* Update docu

---------

Co-authored-by: Jacek Sieka <jacek@status.im>
2024-07-16 19:47:59 +00:00

196 lines
4.3 KiB
Nim

# nimbus-eth1
# Copyright (c) 2023-2024 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.
type
AristoError* = enum
NothingSerious = 0
# Miscelaneous/unclassified handy helpers
GenericError
# Data record transcoders, `blobify()` from `blobify.nim`
BlobifyBranchMissingRefs
BlobifyExtMissingRefs
BlobifyExtPathOverflow
BlobifyLeafPathOverflow
BlobifyNilVertex
# Cache checker `checkCache()`
CheckAnyVidDeadStorageRoot
CheckAnyVidSharedStorageRoot
CheckAnyVtxEmptyKeyMissing
CheckAnyVtxEmptyKeyExpected
CheckAnyVtxEmptyKeyMismatch
CheckAnyVtxBranchLinksMissing
CheckAnyVtxLockWithoutKey
CheckAnyVTopUnset
CheckBeCacheGarbledVTop
CheckBeCacheKeyDangling
CheckBeCacheKeyNonEmpty
CheckBeGarbledVTop
CheckBeVtxBranchLinksMissing
CheckBeVtxInvalid
CheckBeVtxMissing
CheckStkKeyStrayZeroEntry
CheckStkVtxKeyMismatch
CheckRlxVtxIncomplete
CheckRlxVtxKeyMissing
CheckRlxVtxKeyMismatch
# De-serialiser from `blobify.nim`
Deblob256LenUnsupported
Deblob64LenUnsupported
DeblobBranchGotLeafPrefix
DeblobBranchTooShort
DeblobCodeLenUnsupported
DeblobExtSizeGarbled
DeblobLeafGotExtPrefix
DeblobLeafSizeGarbled
DeblobRVidLenUnsupported
DeblobUnknown
DeblobVtxTooShort
DeblobWrongSize
DeblobWrongType
# Deletion of vertex paths, `deleteXxx()`
DelAccRootNotAccepted
DelBranchExpexted
DelBranchWithoutRefs
DelDanglingStoTrie
DelLeafExpexted
DelPathNotFound
DelRootVidMissing
DelStoAccMissing
DelStoRootMissing
DelStoRootNotAccepted
DelVidStaleVtx
# Functions from `aristo_desc.nim`
DescMustBeOnCentre
DescNotAllowedOnCentre
DescStaleDescriptor
# Functions from `aristo_delta.nim`
FilBackendMissing
FilBackendRoMode
#FilNilFilterRejected
FilSiblingsCommitUnfinshed
#FilSrcTrgInconsistent
#FilStateRootMismatch
#FilTrgSrcMismatch
# Fetch functions from `aristo_fetch.nim`
FetchAccInaccessible
FetchAccPathWithoutLeaf
FetchAccRootNotAccepted
FetchLeafKeyInvalid
FetchPathInvalid
FetchPathNotFound
FetchRootVidMissing
FetchStoRootNotAccepted
# Get functions from `aristo_get.nim`
GetFilNotFound
GetFqsNotFound
GetKeyNotFound
GetKeyUpdateNeeded
GetLstNotFound
GetTuvNotFound
GetVtxNotFound
# Path function `hikeUp()`
HikeBranchMissingEdge
HikeBranchTailEmpty
HikeDanglingEdge
HikeEmptyPath
HikeLeafUnexpected
HikeNoLegs
HikeRootMissing
# Merge leaf `merge()`
MergeHikeFailed # Ooops, internal error
MergeAccRootNotAccepted
MergeStoRootNotAccepted
MergeLeafPathCachedAlready
MergeLeafPathOnBackendAlready
MergeRootVidMissing
MergeStoAccMissing
# Neighbour vertex, tree traversal `nearbyRight()` and `nearbyLeft()`
NearbyBeyondRange
NearbyBranchError
NearbyDanglingLink
NearbyEmptyHike
NearbyFailed
NearbyLeafExpected
NearbyNestingTooDeep
NearbyPathTailUnexpected
NearbyUnexpectedVtx
NearbyVidInvalid
# Path/nibble/key conversions in `aisto_path.nim`
PathExpected64Nibbles
PathAtMost64Nibbles
PathExpectedLeaf
# RocksDB backend
RdbBeCantCreateDataDir
RdbBeCantCreateTmpDir
RdbBeDriverDelAdmError
RdbBeDriverDelKeyError
RdbBeDriverDelVtxError
RdbBeDriverGetAdmError
RdbBeDriverGetKeyError
RdbBeDriverGetVtxError
RdbBeDriverGuestError
RdbBeDriverPutAdmError
RdbBeDriverPutKeyError
RdbBeDriverPutVtxError
RdbBeDriverWriteError
RdbBeTypeUnsupported
RdbBeWrSessionUnfinished
RdbBeWrTriggerActiveAlready
RdbBeWrTriggerNilFn
RdbGuestInstanceAborted
RdbHashKeyExpected
# Transaction wrappers
TxAccRootMissing
TxArgStaleTx
TxArgsUseless
TxBackendNotWritable
TxLevelTooDeep
TxLevelUseless
TxNoPendingTx
TxNotFound
TxNotTopTx
TxPendingTx
TxPrettyPointlessLayer
TxStackGarbled
TxStateRootMismatch
# End