mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
ef1bab0802
* pre-allocate `blobify` data and remove redundant error handling (cannot fail on correct data) * use threadvar for temporary storage when decoding rdb, avoiding closure env * speed up database walkers by avoiding many temporaries ~5% perf improvement on block import, 100x on database iteration (useful for building analysis tooling)
73 lines
2.0 KiB
Nim
73 lines
2.0 KiB
Nim
# Nimbus
|
|
# Copyright (c) 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.
|
|
|
|
{.used.}
|
|
|
|
import unittest2, ../../nimbus/db/aristo/aristo_blobify
|
|
|
|
suite "Aristo blobify":
|
|
test "VertexRef roundtrip":
|
|
let
|
|
leafRawData = VertexRef(vType: Leaf, lData: LeafPayload(pType: RawData))
|
|
leafAccount = VertexRef(vType: Leaf, lData: LeafPayload(pType: AccountData))
|
|
leafStoData =
|
|
VertexRef(vType: Leaf, lData: LeafPayload(pType: StoData, stoData: 42.u256))
|
|
branch = VertexRef(
|
|
vType: Branch,
|
|
bVid: [
|
|
VertexID(0),
|
|
VertexID(1),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(4),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
],
|
|
)
|
|
|
|
extension = VertexRef(
|
|
vType: Branch,
|
|
ePfx: NibblesBuf.nibble(2),
|
|
bVid: [
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(2),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(5),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
],
|
|
)
|
|
|
|
check:
|
|
deblobify(blobify(leafRawData), VertexRef)[] == leafRawData
|
|
deblobify(blobify(leafAccount), VertexRef)[] == leafAccount
|
|
deblobify(blobify(leafStoData), VertexRef)[] == leafStoData
|
|
deblobify(blobify(branch), VertexRef)[] == branch
|
|
deblobify(blobify(extension), VertexRef)[] == extension
|