2023-10-18 19:27:22 +00:00
|
|
|
# Nimbus
|
2024-02-21 16:04:59 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-10-18 19:27:22 +00:00
|
|
|
# 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.
|
|
|
|
|
2024-07-12 13:12:25 +00:00
|
|
|
## Ledger management APIs.
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/common,
|
2024-06-21 07:44:10 +00:00
|
|
|
../../evm/code_bytes,
|
2024-06-08 08:05:00 +00:00
|
|
|
../../stateless/multi_keys,
|
2023-10-25 14:03:09 +00:00
|
|
|
../core_db,
|
2024-07-12 13:12:25 +00:00
|
|
|
./backend/accounts_ledger,
|
|
|
|
./base/[api_tracking, base_config, base_desc]
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
ReadOnlyStateDB* = distinct LedgerRef
|
|
|
|
|
|
|
|
export
|
2024-06-21 07:44:10 +00:00
|
|
|
code_bytes,
|
2023-10-18 19:27:22 +00:00
|
|
|
LedgerRef,
|
2024-02-29 21:10:24 +00:00
|
|
|
LedgerSpRef
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2023-12-12 17:47:41 +00:00
|
|
|
# Logging/tracking helpers (some public)
|
2023-10-18 19:27:22 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-07-12 13:12:25 +00:00
|
|
|
when LedgerEnableApiTracking:
|
|
|
|
{.warning: "*** Provided API logging for Ledger (disabled by default)".}
|
2023-11-24 22:16:21 +00:00
|
|
|
import
|
|
|
|
std/times,
|
2023-12-12 17:47:41 +00:00
|
|
|
chronicles
|
2024-07-12 13:12:25 +00:00
|
|
|
logScope:
|
|
|
|
topics = "ledger"
|
|
|
|
const
|
|
|
|
apiTxt = "API"
|
2023-10-25 14:03:09 +00:00
|
|
|
|
2024-07-12 13:12:25 +00:00
|
|
|
when LedgerEnableApiProfiling:
|
|
|
|
{.warning: "*** Provided API profiling for Ledger (disabled by default)".}
|
|
|
|
export
|
|
|
|
LedgerFnInx,
|
|
|
|
LedgerProfListRef
|
2023-10-25 14:03:09 +00:00
|
|
|
|
2023-10-18 19:27:22 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public methods
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
proc accessList*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgAccessListFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.accessList(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc accessList*(ldg: LedgerRef, eAddr: EthAddress, slot: UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgAccessListFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.accessList(eAddr, slot)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc accountExists*(ldg: LedgerRef, eAddr: EthAddress): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgAccountExistsFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.accountExists(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc addBalance*(ldg: LedgerRef, eAddr: EthAddress, delta: UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgAddBalanceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.addBalance(eAddr, delta)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), delta
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc addLogEntry*(ldg: LedgerRef, log: Log) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgAddLogEntryFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.addLogEntry(log)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc beginSavepoint*(ldg: LedgerRef): LedgerSpRef =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgBeginSavepointFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.beginSavepoint()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc clearStorage*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgClearStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.clearStorage(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc clearTransientStorage*(ldg: LedgerRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgClearTransientStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.clearTransientStorage()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc collectWitnessData*(ldg: LedgerRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgCollectWitnessDataFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.collectWitnessData()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc commit*(ldg: LedgerRef, sp: LedgerSpRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgCommitFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.commit(sp)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc deleteAccount*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgDeleteAccountFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.deleteAccount(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc dispose*(ldg: LedgerRef, sp: LedgerSpRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgDisposeFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.dispose(sp)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getAndClearLogEntries*(ldg: LedgerRef): seq[Log] =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetAndClearLogEntriesFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getAndClearLogEntries()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getBalance*(ldg: LedgerRef, eAddr: EthAddress): UInt256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetBalanceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getBalance(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-06-21 07:44:10 +00:00
|
|
|
proc getCode*(ldg: LedgerRef, eAddr: EthAddress): CodeBytesRef =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetCodeFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getCode(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getCodeHash*(ldg: LedgerRef, eAddr: EthAddress): Hash256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetCodeHashFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getCodeHash(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result=($$result)
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getCodeSize*(ldg: LedgerRef, eAddr: EthAddress): int =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetCodeSizeFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getCodeSize(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-11-24 22:16:21 +00:00
|
|
|
|
|
|
|
proc getCommittedStorage*(
|
|
|
|
ldg: LedgerRef;
|
|
|
|
eAddr: EthAddress;
|
|
|
|
slot: UInt256;
|
|
|
|
): UInt256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetCommittedStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getCommittedStorage(eAddr, slot)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getNonce*(ldg: LedgerRef, eAddr: EthAddress): AccountNonce =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetNonceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getNonce(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getStorage*(ldg: LedgerRef, eAddr: EthAddress, slot: UInt256): UInt256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getStorage(eAddr, slot)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc getStorageRoot*(ldg: LedgerRef, eAddr: EthAddress): Hash256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetStorageRootFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getStorageRoot(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result=($$result)
|
2023-11-24 22:16:21 +00:00
|
|
|
|
|
|
|
proc getTransientStorage*(
|
|
|
|
ldg: LedgerRef;
|
|
|
|
eAddr: EthAddress;
|
|
|
|
slot: UInt256;
|
|
|
|
): UInt256 =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgGetTransientStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getTransientStorage(eAddr, slot)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-04-16 02:31:10 +00:00
|
|
|
proc contractCollision*(ldg: LedgerRef, eAddr: EthAddress): bool =
|
|
|
|
ldg.beginTrackApi LdgContractCollisionFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.contractCollision(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc inAccessList*(ldg: LedgerRef, eAddr: EthAddress): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgInAccessListFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.inAccessList(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc inAccessList*(ldg: LedgerRef, eAddr: EthAddress, slot: UInt256): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgInAccessListFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.inAccessList(eAddr, slot)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc incNonce*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgIncNonceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.incNonce(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc isDeadAccount*(ldg: LedgerRef, eAddr: EthAddress): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgIsDeadAccountFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.isDeadAccount(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc isEmptyAccount*(ldg: LedgerRef, eAddr: EthAddress): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgIsEmptyAccountFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.isEmptyAccount(eAddr)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc isTopLevelClean*(ldg: LedgerRef): bool =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgIsTopLevelCleanFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.isTopLevelClean()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc logEntries*(ldg: LedgerRef): seq[Log] =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgLogEntriesFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.logEntries()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-02-21 16:04:59 +00:00
|
|
|
proc makeMultiKeys*(ldg: LedgerRef): MultiKeysRef =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgMakeMultiKeysFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.makeMultiKeys()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-06-25 05:30:32 +00:00
|
|
|
proc persist*(ldg: LedgerRef, clearEmptyAccount = false, clearCache = false) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgPersistFn
|
2024-06-25 05:30:32 +00:00
|
|
|
ldg.ac.persist(clearEmptyAccount, clearCache)
|
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, clearEmptyAccount, clearCache
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc ripemdSpecial*(ldg: LedgerRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgRipemdSpecialFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.ripemdSpecial()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc rollback*(ldg: LedgerRef, sp: LedgerSpRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgRollbackFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.rollback(sp)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc safeDispose*(ldg: LedgerRef, sp: LedgerSpRef) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSafeDisposeFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.safeDispose(sp)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc selfDestruct*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSelfDestructFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.selfDestruct(eAddr)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc selfDestruct6780*(ldg: LedgerRef, eAddr: EthAddress) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSelfDestruct6780Fn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.selfDestruct6780(eAddr)
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc selfDestructLen*(ldg: LedgerRef): int =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSelfDestructLenFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.selfDestructLen()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, result
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc setBalance*(ldg: LedgerRef, eAddr: EthAddress, balance: UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSetBalanceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.setBalance(eAddr, balance)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), balance
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc setCode*(ldg: LedgerRef, eAddr: EthAddress, code: Blob) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSetCodeFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.setCode(eAddr, code)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), code
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc setNonce*(ldg: LedgerRef, eAddr: EthAddress, nonce: AccountNonce) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSetNonceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.setNonce(eAddr, nonce)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), nonce
|
2023-10-18 19:27:22 +00:00
|
|
|
|
|
|
|
proc setStorage*(ldg: LedgerRef, eAddr: EthAddress, slot, val: UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSetStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.setStorage(eAddr, slot, val)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, val
|
2023-11-24 22:16:21 +00:00
|
|
|
|
|
|
|
proc setTransientStorage*(
|
|
|
|
ldg: LedgerRef;
|
|
|
|
eAddr: EthAddress;
|
|
|
|
slot: UInt256;
|
|
|
|
val: UInt256;
|
|
|
|
) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSetTransientStorageFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.setTransientStorage(eAddr, slot, val)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), slot, val
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
proc state*(ldg: LedgerRef): Hash256 =
|
|
|
|
ldg.beginTrackApi LdgStateFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.state()
|
2024-04-19 18:37:27 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, result
|
|
|
|
|
2023-10-18 19:27:22 +00:00
|
|
|
proc subBalance*(ldg: LedgerRef, eAddr: EthAddress, delta: UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgSubBalanceFn
|
2024-05-29 11:06:49 +00:00
|
|
|
ldg.ac.subBalance(eAddr, delta)
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr), delta
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-02-29 11:16:47 +00:00
|
|
|
proc getAccessList*(ldg: LedgerRef): AccessList =
|
|
|
|
ldg.beginTrackApi LdgGetAccessListFn
|
2024-05-29 11:06:49 +00:00
|
|
|
result = ldg.ac.getAccessList()
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2024-02-29 11:16:47 +00:00
|
|
|
|
2024-05-29 11:06:49 +00:00
|
|
|
proc rootHash*(ldg: LedgerRef): KeccakHash =
|
|
|
|
ldg.state()
|
2024-04-19 18:37:27 +00:00
|
|
|
|
2024-06-16 03:21:02 +00:00
|
|
|
proc getEthAccount*(ldg: LedgerRef, eAddr: EthAddress): Account =
|
|
|
|
ldg.beginTrackApi LdgGetAthAccountFn
|
|
|
|
result = ldg.ac.getEthAccount(eAddr)
|
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, result
|
|
|
|
|
2023-10-18 19:27:22 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public virtual read-only methods
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-05-29 11:06:49 +00:00
|
|
|
proc rootHash*(db: ReadOnlyStateDB): KeccakHash = db.LedgerRef.state()
|
2023-10-18 19:27:22 +00:00
|
|
|
proc getCodeHash*(db: ReadOnlyStateDB, eAddr: EthAddress): Hash256 {.borrow.}
|
|
|
|
proc getStorageRoot*(db: ReadOnlyStateDB, eAddr: EthAddress): Hash256 {.borrow.}
|
|
|
|
proc getBalance*(db: ReadOnlyStateDB, eAddr: EthAddress): UInt256 {.borrow.}
|
|
|
|
proc getStorage*(db: ReadOnlyStateDB, eAddr: EthAddress, slot: UInt256): UInt256 {.borrow.}
|
|
|
|
proc getNonce*(db: ReadOnlyStateDB, eAddr: EthAddress): AccountNonce {.borrow.}
|
2024-06-21 07:44:10 +00:00
|
|
|
proc getCode*(db: ReadOnlyStateDB, eAddr: EthAddress): CodeBytesRef {.borrow.}
|
2023-10-18 19:27:22 +00:00
|
|
|
proc getCodeSize*(db: ReadOnlyStateDB, eAddr: EthAddress): int {.borrow.}
|
2024-04-16 02:31:10 +00:00
|
|
|
proc contractCollision*(db: ReadOnlyStateDB, eAddr: EthAddress): bool {.borrow.}
|
2023-10-18 19:27:22 +00:00
|
|
|
proc accountExists*(db: ReadOnlyStateDB, eAddr: EthAddress): bool {.borrow.}
|
|
|
|
proc isDeadAccount*(db: ReadOnlyStateDB, eAddr: EthAddress): bool {.borrow.}
|
|
|
|
proc isEmptyAccount*(db: ReadOnlyStateDB, eAddr: EthAddress): bool {.borrow.}
|
|
|
|
proc getCommittedStorage*(db: ReadOnlyStateDB, eAddr: EthAddress, slot: UInt256): UInt256 {.borrow.}
|
|
|
|
func inAccessList*(db: ReadOnlyStateDB, eAddr: EthAddress): bool {.borrow.}
|
|
|
|
func inAccessList*(db: ReadOnlyStateDB, eAddr: EthAddress, slot: UInt256): bool {.borrow.}
|
|
|
|
func getTransientStorage*(db: ReadOnlyStateDB, eAddr: EthAddress, slot: UInt256): UInt256 {.borrow.}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|