nimbus-eth1/tests/test_block_fixture.nim

35 lines
146 KiB
Nim
Raw Normal View History

Core db and aristo updates for destructor and tx logic (#1894) * Disable `TransactionID` related functions from `state_db.nim` why: Functions `getCommittedStorage()` and `updateOriginalRoot()` from the `state_db` module are nowhere used. The emulation of a legacy `TransactionID` type functionality is administratively expensive to provide by `Aristo` (the legacy DB version is only partially implemented, anyway). As there is no other place where `TransactionID`s are used, they will not be provided by the `Aristo` variant of the `CoreDb`. For the legacy DB API, nothing will change. * Fix copyright headers in source code * Get rid of compiler warning * Update Aristo code, remove unused `merge()` variant, export `hashify()` why: Adapt to upcoming `CoreDb` wrapper * Remove synced tx feature from `Aristo` why: + This feature allowed to synchronise transaction methods like begin, commit, and rollback for a group of descriptors. + The feature is over engineered and not needed for `CoreDb`, neither is it complete (some convergence features missing.) * Add debugging helpers to `Kvt` also: Update database iterator, add count variable yield argument similar to `Aristo`. * Provide optional destructors for `CoreDb` API why; For the upcoming Aristo wrapper, this allows to control when certain smart destruction and update can take place. The auto destructor works fine in general when the storage/cache strategy is known and acceptable when creating descriptors. * Add update option for `CoreDb` API function `hash()` why; The hash function is typically used to get the state root of the MPT. Due to lazy hashing, this might be not available on the `Aristo` DB. So the `update` function asks for re-hashing the gurrent state changes if needed. * Update API tracking log mode: `info` => `debug * Use shared `Kvt` descriptor in new Ledger API why: No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
# Copyright (c) 2022-2023 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
# at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.
import
eth/[common/eth_types_rlp]
# mainnet block 4514995, chosen as it has a lot of logs
const rlpData = "0xfa0121bbf9020da0af98f51d16296bd876fd6501ad22aba82a6c565c2a54869d6fec83f5dcf5a0e5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493479452bc44d5378309ee2abf1539bf71de1b7d7be3b5a07328a3b55ab6f24171f21f03ecb4d99af033f345e7e5aff7071cc1dbea2c95f5a03249ff092f69ccd88036779c62cbb5e5cee44a07889da546a3b0a4929561da62a087e982cf38cd96a702c77374cc988333e69dcd876d590ec756a8088dcd8c008fb90100080000800440000000810044200100010000820100040080008c04020160010808000000000400900000004080100003408000400008008204100008090450081008004408a0240080000008000000800000010000040000010103040a0022000000842802a00028c00061402000182000020c0034064800100401300010600000100400100004008000009480440c001200410020804000000002c10400450000008000000000000000008040000104080005001000800000010080000c08080010400201040000000a210040000d010800c00481080004204002048000708900100000000210008200100680002420600000800000000030c0100000004080870538acf5d43b3a8344e4b3836685dd834f40dd845a033f378c6e616e6f706f6f6c2e6f7267a088b197a971ed9e4edf422865f55c2ac4acea9345d434dd4d86ffdc1b1ea56f0588c97f406002c6e481f9596bf95967f86d8337907b84ee6b280082c35094650bcfafc30252515661baa5c8d2bcef8f57d8bc87ddc1610e4b86108025a0ee753fd56130848b3358b733212b5d414e1c70e75d891c263348334d4edd48bca076492d4b66632967369496645b089e33e3cba5d1bf562400fe2a985eb96fa1f9f86d8337907c84ee6b280082c350941ede20f488273e42ef0f64d127ab4356a8902ffc87d8d0afcd78ddd88025a0ac36bd849ed84d4133934ef9e0f7b312544c06d998561c02a4ab7fef5ddb1f2ea03727b78800703f069b75d15fe0694040376f1cdde01954e5fa5a58bea9a4fd4bf86e8337907d84ee6b280082c35094ebd457f1432c5f00484d56cdd8a97a1c07d332418802d38e5d2ce9e4e08026a04fae468e7ac41ffa3931ec48f466a4f0115452e8355fc4c2fe2d24701c38d8f1a0691b6c903569ac887946c7077db98d77630604c976fdf29955b61f3269b8dcfbf86f830238728506fc23ac0082520894c1a41678c80e0b157376de27a1266198f6c7e95b8805360b42b128c0008026a0d8635bcbb3868743890d8ac3a5a96d8533b9790b5eb605eb228bb4fab8ef2eb1a0663af3157334ee3b0e5d77f492d1499cd82a12ee73ba8f7e473d603977a1bc64f86c098504e3b29200825208942abdc23017e0d0b88bd54676d9f377348beb0f0988016345785d8a00008025a0b6c056e7644456442f6d1beb8e566fd262d94c51d83965a42ed6bcc5edacbff1a07bcaa26df4f0e616c3b0e3b59046f9947a26e009eedbe9a9da6e884b173e24e6f86c278504e3b292008252089459930b2d086a78d1f22ad9bb1401293978df816d886f05b59d3b2000008025a083ba0ff8a856c908f35352531ceb1fb829bcdbafe42adfd97aa10664a1abe28fa0376db3a8eda5cf39f8d92262af783ec340dc4c89ae39fd565bb085792d45b3d5f869028504e3b2920082520894eb31acbf35b4e48ae39c8c62bb5674cf9d7c4fbe85e8d4a510008026a05167e12712c8e8f8dc4990aa9d1c34aeb6c38d13339e5fd01ce19956fc6dfd63a051d4c6d37625730a243b17eb9ef8b7e73dddecccd9fcf6e550bc0bd272ab5b21f86c258504e3b2920082520894201a1a1d32cfaab59bcefd2712cfe0ba809a795d8820cff53a44901000801ca0fa2c076dc150a36c32d3b75be66ba3a230c0efcee0507cbf84f23314e8fc3377a0709d806074bc2c771af6d33a4769f121e592d9af5e8880f78f455cb8bf4ef51af86b808504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce87046f0ce44f12ab8025a08a4af2a637f6834c49e91e30d12f4ccb7eaefcfd9166a389fca2e5e43cd872bea078e2090941321b03ac4ade0d38c205b9391bc882a7c991b024c8e748a081f2e1f86b278504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce87b04fdd7c7189008026a0eedcf12df2af223be62de99565aeca89be2c9d7b2ef1a318f1f00d853752f2baa00a3b33176368a2da75197afeb57935a7589191517888a336fa823223cef3107ff86b808504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce872208f590f2c0008025a0f5213e205bbe0436c084b367b26e1a96fe42c082e2e36c22c1fbf4be7c53a2c8a01725291ea1e2b758d7d47a7fe763b35690786d1e91003c9ad3c3f29d52dbfba6f86c81ad8504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce87b0fc46714106b88025a089081d05fe53dbae713e5a7d16e2342f7687dd11951cf8b9a219a70ebdb85fdba05d57a46fa172fed96ce15034b9653c1c2be15ecb9fb5e4b427eda47dc710abfdf86b808504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce875c101999ec30008026a02d4096d1f4cb5392ce9bfff072c5c6fbb0c598912692e80b053bd9b393b3b01ca0668e6152c9d2cc95633c9f3f5937c9813c0332aaac55d119312e2903394b51f5f86c808504a817c8008252089409f68ec56def1d3035d402a8321ec68f05273fce880161c77b7ebbc0008026a0234c2d6a55f248da823af59d01ec2ef92e602c6ca3b0594d22
const rlpb = rlpFromHex(rlpData)
var headerRlp = rlpb.listElem(0)
var bodyRlp = rlpb.listElem(1)
var receitsRlp = rlpb.listElem(2)
let blockHeader4514995* = headerRlp.read(BlockHeader)
let blockBody4514995* = bodyRlp.read(BlockBody)
let receipts4514995* = receitsRlp.read(seq[Receipt])
proc getBlockHeader4514995*(): BlockHeader {.gcsafe.} =
var headerRlp = rlpb.listElem(0)
return headerRlp.read(BlockHeader)
proc getBlockBody4514995*(): BlockBody {.gcsafe.} =
var bodyRlp = rlpb.listElem(1)
return bodyRlp.read(BlockBody)
proc getReceipts4514995*(): seq[Receipt] {.gcsafe.} =
var receitsRlp = rlpb.listElem(2)
return receitsRlp.read(seq[Receipt])