upstream verkle to ledger backend

This commit is contained in:
advaita-saha 2024-05-06 23:18:09 +05:30
parent 49a7f2c9c6
commit d1ab073aad
No known key found for this signature in database
GPG Key ID: 33CFA1C66B77807C
3 changed files with 19 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import
eth/common,
../../../../stateless/multi_keys,
"../.."/[core_db, distinct_tries],
../accounts_cache as impl,
../verkle_accounts_cache as impl,
".."/[base, base/base_desc],
./accounts_cache_desc as wrp
@ -51,7 +51,7 @@ proc ledgerMethods(lc: impl.AccountsCache): LedgerFns =
lc.addLogEntry(log),
beginSavepointFn: proc(): LedgerSpRef =
wrp.SavePoint(sp: lc.beginSavepoint()),
wrp.SavePoint(sp: lc.beginSavePoint()),
clearStorageFn: proc(eAddr: EthAddress) =
lc.clearStorage(eAddr),
@ -184,7 +184,7 @@ proc ledgerMethods(lc: impl.AccountsCache): LedgerFns =
proc ledgerExtras(lc: impl.AccountsCache): LedgerExtras =
LedgerExtras(
getMptFn: proc(): CoreDbMptRef =
lc.rawTrie.mpt,
lc.rawTrie.mpt, # -----------> needs to be fixed, MPT doesn't exist anymore
rawRootHashFn: proc(): Hash256 =
lc.rawTrie.rootHash())
@ -195,7 +195,7 @@ proc newLegacyAccountsCache(
root: Hash256;
pruneTrie: bool): LedgerRef =
## Constructor
let lc = impl.AccountsCache.init(db, root, pruneTrie)
let lc = impl.AccountsCache.init()
wrp.AccountsCache(
ldgType: LegacyAccountsCache,
ac: lc,
@ -231,7 +231,7 @@ iterator storageIt*(
): (UInt256,UInt256)
{.gcsafe, raises: [CoreDbApiError].} =
noRlpException "storage()":
for w in lc.ac.storage(eAddr):
for w in lc.ac.storage(eAddr): # -----------> needs to be fixed, storage() doesn't exist yet
yield w
# ------------------------------------------------------------------------------

View File

@ -9,7 +9,7 @@
# according to those terms.
import
../accounts_cache as impl,
../verkle_accounts_cache as impl,
../base/base_desc
type

View File

@ -119,7 +119,7 @@ proc rawTrie*(ac: AccountsCache): VerkleTrie {.inline.} = ac.trie
proc init*(x: typedesc[AccountsCache]): AccountsCache =
new result
result.trie = initVerkleTrie()
result.witnessCache = initTable[EthAddress, WitnessData]
result.witnessCache = initTable[EthAddress, WitnessData]()
discard result.beginSavePoint
proc rootHash*(ac: AccountsCache): KeccakHash =
@ -261,6 +261,18 @@ proc storageValue(acc: RefAccount, address: EthAddress, slot: UInt256, db: Verkl
do:
result = acc.originalStorageValue(address, slot, db)
proc getCommittedStorage*(ac: AccountsCache, address: EthAddress, slot: UInt256): UInt256 {.inline.} =
let acc = ac.getAccount(address, false)
if acc.isNil:
return
acc.originalStorageValue(address, slot, ac.trie)
proc getStorage*(ac: AccountsCache, address: EthAddress, slot: UInt256): UInt256 {.inline.} =
let acc = ac.getAccount(address, false)
if acc.isNil:
return
acc.storageValue(address, slot, ac.trie)
proc kill(acc: RefAccount) =
acc.flags.excl Alive
acc.overlayStorage.clear()