Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statemanager: cache and other refactors #3569

Merged
merged 27 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fa3c2ec
Revert "statemanager: refactor logic into capabilities (#3554)"
gabrocheleau Aug 7, 2024
bd1f237
statemanager: refactor modifyAccountFields
gabrocheleau Aug 7, 2024
d5aaf30
statemanager: adjust return statements
gabrocheleau Aug 7, 2024
533fa8c
statemanager: refactor separate caches into caches class
gabrocheleau Aug 9, 2024
31c94af
chore: merge with master
gabrocheleau Aug 9, 2024
bba928b
statemanager: fix shallow copy logic
gabrocheleau Aug 9, 2024
a04158d
client: fix vmexecution statemanager cache opts
gabrocheleau Aug 9, 2024
2431594
statemanager: refactor some capabilities to caches methods
gabrocheleau Aug 9, 2024
814b9f7
statemanager: fix tests
gabrocheleau Aug 9, 2024
2439219
statemanager: refactor caches into optional opt passed in directly to…
gabrocheleau Aug 9, 2024
4c6240f
statemanager: adjust tests with refactored caches
gabrocheleau Aug 9, 2024
5e1666d
client: adjust vm execution with update cache
gabrocheleau Aug 9, 2024
c754eac
vm: fix vm tests
gabrocheleau Aug 9, 2024
5d4895c
vm: adjust test runners with non-default caches
gabrocheleau Aug 9, 2024
888b20e
statemanager: simplify handling of deactivate
gabrocheleau Aug 9, 2024
905a52e
statemanager: remove redundant checks
gabrocheleau Aug 9, 2024
f30288a
statemanager: remove non null asesertion
gabrocheleau Aug 9, 2024
ba00837
statemanager: remove cache opt from key naming
gabrocheleau Aug 10, 2024
c037ae2
statemanager: refactor rpc state manager to use caches
gabrocheleau Aug 11, 2024
fdcdb36
statemanager: fix rpc state manager tests
gabrocheleau Aug 11, 2024
3d93587
client: vmexecution cache stats refactor
gabrocheleau Aug 11, 2024
48baee3
Merge remote-tracking branch 'origin/master' into statemanager/capabi…
acolytec3 Aug 12, 2024
f0b66bf
Merge branch 'master' into statemanager/capabilities-refactor
acolytec3 Aug 12, 2024
5f4c253
statemanageR: updategetproof json-rpc call format
gabrocheleau Aug 12, 2024
7fe21fd
statemanager: remove deactivate from caches
gabrocheleau Aug 12, 2024
4864383
client: remove deactivate from vm execution instantiation
gabrocheleau Aug 12, 2024
b6ee97b
Merge branch 'statemanager/capabilities-refactor' of https://github.c…
gabrocheleau Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
client: adjust vm execution with update cache
gabrocheleau committed Aug 9, 2024
commit 5e1666d97d424be8c9bf27b2793dcd269098c90c
5 changes: 3 additions & 2 deletions packages/client/src/execution/vmexecution.ts
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import { MCLBLS, RustBN254 } from '@ethereumjs/evm'
import { getGenesis } from '@ethereumjs/genesis'
import {
CacheType,
Caches,
DefaultStateManager,
StatelessVerkleStateManager,
} from '@ethereumjs/statemanager'
@@ -164,7 +165,7 @@ export class VMExecution extends Execution {
const stateManager = new DefaultStateManager({
trie,
prefixStorageTrieKeys: this.config.prefixStorageTrieKeys,
cachesOpts: {
caches: new Caches({
accountCacheOpts: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can fully drop the CacheOpts from this key, makes it nicer to digest/read and remains fully expressive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same for others of course)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

deactivate: false,
type: CacheType.LRU,
@@ -180,7 +181,7 @@ export class VMExecution extends Execution {
type: CacheType.LRU,
size: this.config.codeCache,
},
},
}),
common: this.config.chainCommon,
})


Unchanged files with check annotations Beta

)
const vmCopy = await vm.shallowCopy()
assert.isUndefined(

Check failure on line 22 in packages/vm/test/api/copy.spec.ts

GitHub Actions / vm-api

test/api/copy.spec.ts > VM Copy Test > should pass copy of state manager

AssertionError: non-committed checkpoints will not be copied: expected Account{ _nonce: 5n, …(5) } to equal undefined - Expected: undefined + Received: Account { "_balance": 100n, "_codeHash": Uint8Array [ 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112, ], "_codeSize": 0, "_nonce": 5n, "_storageRoot": Uint8Array [ 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, ], "_version": 0, } ❯ test/api/copy.spec.ts:22:12

Check failure on line 22 in packages/vm/test/api/copy.spec.ts

GitHub Actions / test-all-browser (20)

test/api/copy.spec.ts > VM Copy Test > should pass copy of state manager

AssertionError: non-committed checkpoints will not be copied: expected Account{ _nonce: 5n, …(5) } to equal undefined - Expected: undefined + Received: Account { "_balance": 100n, "_codeHash": Uint8Array [ 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112, ], "_codeSize": 0, "_nonce": 5n, "_storageRoot": Uint8Array [ 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, ], "_version": 0, } ❯ test/api/copy.spec.ts:22:11
await vmCopy.stateManager.getAccount(address),
'non-committed checkpoints will not be copied',
)
const storage = genesisState[contractAddress][2]
// Returned value should be 4, because we are trying to trigger the method `retrieve`
// in the contract, which returns the variable stored in slot 0x00..00
assert.equal(bytesToHex(callResult.execResult.returnValue), storage[0][1])

Check failure on line 116 in packages/vm/test/api/customChain.spec.ts

GitHub Actions / vm-api

test/api/customChain.spec.ts > VM initialized with custom state > should retrieve value from storage

AssertionError: expected '0x' to equal '0x00000000000000000000000000000000000…' - Expected + Received - 0x0000000000000000000000000000000000000000000000000000000000000004 + 0x ❯ test/api/customChain.spec.ts:116:12

Check failure on line 116 in packages/vm/test/api/customChain.spec.ts

GitHub Actions / test-all-browser (20)

test/api/customChain.spec.ts > VM initialized with custom state > should retrieve value from storage

AssertionError: expected '0x' to equal '0x00000000000000000000000000000000000…' - Expected + Received - 0x0000000000000000000000000000000000000000000000000000000000000004 + 0x ❯ test/api/customChain.spec.ts:116:11
})
it('setHardfork', async () => {
resultNotActivated.execResult.executionGasUsed - resultActivated.execResult.executionGasUsed
const expected = common.param('callNewAccountGas')
assert.equal(diff, expected, 'precompiles are activated')

Check failure on line 335 in packages/vm/test/api/index.spec.ts

GitHub Actions / vm-api

test/api/index.spec.ts > VM -> setHardfork, state (deprecated), blockchain > Ensure that precompile activation creates non-empty accounts > should work

AssertionError: precompiles are activated: expected 0n to equal 25000n - Expected + Received - 25000n + 0n ❯ test/api/index.spec.ts:335:14

Check failure on line 335 in packages/vm/test/api/index.spec.ts

GitHub Actions / test-all-browser (20)

test/api/index.spec.ts > VM -> setHardfork, state (deprecated), blockchain > Ensure that precompile activation creates non-empty accounts > should work

AssertionError: precompiles are activated: expected 0n to equal 25000n - Expected + Received - 25000n + 0n ❯ test/api/index.spec.ts:335:13
})
})
})
await runBlock(vm, { block, skipBlockValidation: true, generate: true })
const storage = await vm.stateManager.getStorage(defaultAuthAddr, zeros(32))
assert.ok(equalsBytes(storage, new Uint8Array([2])))

Check failure on line 677 in packages/vm/test/api/runBlock.spec.ts

GitHub Actions / vm-api

test/api/runBlock.spec.ts > runBlock() -> tx types > eip7702 txs

AssertionError: expected false to be truthy ❯ test/api/runBlock.spec.ts:677:12

Check failure on line 677 in packages/vm/test/api/runBlock.spec.ts

GitHub Actions / test-all-browser (20)

test/api/runBlock.spec.ts > runBlock() -> tx types > eip7702 txs

AssertionError: expected false to be truthy ❯ test/api/runBlock.spec.ts:677:11
})
})
await runTx(vm, { tx, skipHardForkValidation: true })
const hash = await vm.stateManager.getStorage(codeAddr, zeros(32))
assert.deepEqual(hash, KECCAK256_NULL, 'hash ok')

Check failure on line 790 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / vm-api

test/api/runTx.spec.ts > Validate EXTCODEHASH puts KECCAK256_NULL on stack if calling account has no balance and zero nonce (but it did exist)

AssertionError: hash ok: expected Uint8Array[] to deeply equal Uint8Array[ 197, 210, 70, 1, 134, …(-214) ] - Expected + Received - Uint8Array [ - 197, - 210, - 70, - 1, - 134, - 247, - 35, - 60, - 146, - 126, - 125, - 178, - 220, - 199, - 3, - 192, - 229, - 0, - 182, - 83, - 202, - 130, - 39, - 59, - 123, - 250, - 216, - 4, - 93, - 133, - 164, - 112, - ] + Uint8Array [] ❯ test/api/runTx.spec.ts:790:10

Check failure on line 790 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / test-all-browser (20)

test/api/runTx.spec.ts > Validate EXTCODEHASH puts KECCAK256_NULL on stack if calling account has no balance and zero nonce (but it did exist)

AssertionError: hash ok: expected Uint8Array[] to deeply equal Uint8Array[ 197, 210, 70, 1, 134, …(-214) ] - Expected + Received - Uint8Array [ - 197, - 210, - 70, - 1, - 134, - 247, - 35, - 60, - 146, - 126, - 125, - 178, - 220, - 199, - 3, - 192, - 229, - 0, - 182, - 83, - 202, - 130, - 39, - 59, - 123, - 250, - 216, - 4, - 93, - 133, - 164, - 112, - ] + Uint8Array [] ❯ test/api/runTx.spec.ts:790:9
})
it('Validate CALL does not charge new account gas when calling CALLER and caller is non-empty', async () => {
const acc = await vm.stateManager.getAccount(addr)
acc!.balance = BigInt(tx.gasLimit * tx.gasPrice + tx.value)
await vm.stateManager.putAccount(addr, acc!)
assert.equal(

Check failure on line 821 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / vm-api

test/api/runTx.spec.ts > Validate CALL does not charge new account gas when calling CALLER and caller is non-empty

AssertionError: did not charge callNewAccount: expected 21000n to equal 27818n - Expected + Received - 27818n + 21000n ❯ test/api/runTx.spec.ts:821:10

Check failure on line 821 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / test-all-browser (20)

test/api/runTx.spec.ts > Validate CALL does not charge new account gas when calling CALLER and caller is non-empty

AssertionError: did not charge callNewAccount: expected 21000n to equal 27818n - Expected + Received - 27818n + 21000n ❯ test/api/runTx.spec.ts:821:9
(await runTx(vm, { tx, skipHardForkValidation: true })).totalGasSpent,
BigInt(27818),
'did not charge callNewAccount',
const acc = await vm.stateManager.getAccount(addr)
acc!.balance = BigInt(tx.gasLimit * tx.gasPrice + tx.value)
await vm.stateManager.putAccount(addr, acc!)
assert.equal(

Check failure on line 852 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / vm-api

test/api/runTx.spec.ts > Validate SELFDESTRUCT does not charge new account gas when calling CALLER and caller is non-empty

AssertionError: did not charge callNewAccount: expected 21000n to equal 13001n - Expected + Received - 13001n + 21000n ❯ test/api/runTx.spec.ts:852:10

Check failure on line 852 in packages/vm/test/api/runTx.spec.ts

GitHub Actions / test-all-browser (20)

test/api/runTx.spec.ts > Validate SELFDESTRUCT does not charge new account gas when calling CALLER and caller is non-empty

AssertionError: did not charge callNewAccount: expected 21000n to equal 13001n - Expected + Received - 13001n + 21000n ❯ test/api/runTx.spec.ts:852:9
(await runTx(vm, { tx, skipHardForkValidation: true })).totalGasSpent,
BigInt(13001),
'did not charge callNewAccount',
}
const result = await runTest(test)
assert.deepEqual(returndata, result[0].execResult.returnValue)

Check failure on line 101 in packages/vm/test/api/EIPs/eip-1153.spec.ts

GitHub Actions / vm-api

test/api/EIPs/eip-1153.spec.ts > EIP 1153: transient storage > should tload and tstore

AssertionError: expected Uint8Array[ 0, 0, 0, 0, 0, 0, 0, …(33) ] to deeply equal Uint8Array[] - Expected + Received - Uint8Array [] + Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + ] ❯ test/api/EIPs/eip-1153.spec.ts:101:12

Check failure on line 101 in packages/vm/test/api/EIPs/eip-1153.spec.ts

GitHub Actions / test-all-browser (20)

test/api/EIPs/eip-1153.spec.ts > EIP 1153: transient storage > should tload and tstore

AssertionError: expected Uint8Array[ 0, 0, 0, 0, 0, 0, 0, …(33) ] to deeply equal Uint8Array[] - Expected + Received - Uint8Array [] + Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + ] ❯ test/api/EIPs/eip-1153.spec.ts:101:11
assert.equal(undefined, result[0].execResult.exceptionError)
})
}
const [result] = await runTest(test)
assert.equal(bytesToInt(result.execResult.returnValue), 0xaa)

Check failure on line 661 in packages/vm/test/api/EIPs/eip-1153.spec.ts

GitHub Actions / vm-api

test/api/EIPs/eip-1153.spec.ts > EIP 1153: transient storage > tload should not keep reverted changes

AssertionError: expected +0 to equal 170 - Expected + Received - 170 + 0 ❯ test/api/EIPs/eip-1153.spec.ts:661:12

Check failure on line 661 in packages/vm/test/api/EIPs/eip-1153.spec.ts

GitHub Actions / test-all-browser (20)

test/api/EIPs/eip-1153.spec.ts > EIP 1153: transient storage > tload should not keep reverted changes

AssertionError: expected +0 to equal 170 - Expected + Received - 170 + 0 ❯ test/api/EIPs/eip-1153.spec.ts:661:11
})
})
assert.equal(res.execResult.executionGasUsed, BigInt(testCase.used))
assert.equal(res.execResult.gasRefund, BigInt(testCase.refund))
} catch (e: any) {
assert.fail(e.message)

Check failure on line 62 in packages/vm/test/api/EIPs/eip-1283-net-gas-metering.spec.ts

GitHub Actions / vm-api

test/api/EIPs/eip-1283-net-gas-metering.spec.ts > Constantinople: EIP-1283 > net-metering SSTORE

AssertionError: expected 0n to equal 412n ❯ test/api/EIPs/eip-1283-net-gas-metering.spec.ts:62:16

Check failure on line 62 in packages/vm/test/api/EIPs/eip-1283-net-gas-metering.spec.ts

GitHub Actions / test-all-browser (20)

test/api/EIPs/eip-1283-net-gas-metering.spec.ts > Constantinople: EIP-1283 > net-metering SSTORE

AssertionError: expected 0n to equal 412n ❯ test/api/EIPs/eip-1283-net-gas-metering.spec.ts:62:15
}
}
})
if (account !== undefined) {
this._caches.account!.put(address, account)
} else {
this._caches.account!.del(address)

Check warning on line 168 in packages/statemanager/src/stateManager.ts

Codecov / codecov/patch

packages/statemanager/src/stateManager.ts#L168

Added line #L168 was not covered by tests
}
}
}
this._debug(`Delete account ${address}`)
}
this._caches?.deleteAccount(address)

Check warning on line 193 in packages/statemanager/src/stateManager.ts

Codecov / codecov/patch

packages/statemanager/src/stateManager.ts#L193

Added line #L193 was not covered by tests
if (this._caches === undefined || this._caches.settings.account.deactivate === true) {

Check warning on line 195 in packages/statemanager/src/stateManager.ts

Codecov / codecov/patch

packages/statemanager/src/stateManager.ts#L195

Added line #L195 was not covered by tests
await this._trie.del(address.bytes)
}
}
debug(`putCode address=${address.toString()} value=${short(value)}`)
}
this._caches?.code?.put(address, value)

Check warning on line 228 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L228

Added line #L228 was not covered by tests
const codeHash = keccak256(value)
if (KECCAK256_NULL === codeHash) {
// If the code hash is the null hash, no code has to be stored
debug(`getCode address=${address.toString()}`)
}
if (this._caches !== undefined && !this._caches.settings.code.deactivate) {
const elem = this._caches.code?.get(address)

Check warning on line 253 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L252-L253

Added lines #L252 - L253 were not covered by tests
if (elem !== undefined) {
return elem.code ?? new Uint8Array(0)
}
// Return accessedCode where only accessed code has been copied
const contactCode = accessedCode.slice(0, codeSize)
if (this._caches !== undefined && !this._caches.settings.code.deactivate) {
this._caches.code?.put(address, contactCode)

Check warning on line 300 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L299-L300

Added lines #L299 - L300 were not covered by tests
}
return contactCode
}
async getCodeSize(address: Address): Promise<number> {
if (this._caches !== undefined && !this._caches.settings.account.deactivate) {
const elem = this._caches.account!.get(address)

Check warning on line 308 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L307-L308

Added lines #L307 - L308 were not covered by tests
if (elem !== undefined) {
const account =
elem.accountRLP !== undefined ? createPartialAccountFromRLP(elem.accountRLP) : undefined
* If this does not exist an empty `Uint8Array` is returned.
*/
async getStorage(address: Address, key: Uint8Array): Promise<Uint8Array> {
if (this._caches !== undefined && !this._caches.settings.storage.deactivate) {
const value = this._caches.storage!.get(address, key)

Check warning on line 340 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L339-L340

Added lines #L339 - L340 were not covered by tests
if (value !== undefined) {
return value
}
)
const storageValue = toBytes(this._state[bytesToHex(storageKey)])
if (this._caches !== undefined && !this._caches.settings.storage.deactivate) {
this._caches.storage?.put(address, key, storageValue ?? hexToBytes('0x80'))

Check warning on line 354 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L353-L354

Added lines #L353 - L354 were not covered by tests
}
return storageValue
* @param value - Value to set at `key` for account corresponding to `address`. Cannot be more than 32 bytes. Leading zeros are stripped. If it is a empty or filled with zeros, deletes the value.
*/
async putStorage(address: Address, key: Uint8Array, value: Uint8Array): Promise<void> {
if (this._caches !== undefined && !this._caches.settings.storage.deactivate) {
this._caches.storage!.put(address, key, value)

Check warning on line 369 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L368-L369

Added lines #L368 - L369 were not covered by tests
} else {
// TODO: Consider refactoring this in a writeContractStorage function? Like in stateManager.ts
const storageKey = await getVerkleTreeKeyForStorageSlot(
async clearStorage(address: Address): Promise<void> {
const stem = getVerkleStem(this.verkleCrypto, address, 0)
const codeHashKey = getVerkleKey(stem, VerkleLeafType.CodeHash)
this._caches?.storage?.clearStorage(address)

Check warning on line 390 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L390

Added line #L390 was not covered by tests
// Update codeHash to `c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`
this._state[bytesToHex(codeHashKey)] = KECCAK256_NULL_S
}
}
if (this._caches !== undefined && !this._caches.settings.account.deactivate) {
this._caches.account?.put(address, account, true)

Check warning on line 480 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L480

Added line #L480 was not covered by tests
}
return account
if (account !== undefined) {
this._caches?.account?.put(address, account, true)
} else {
this._caches?.account?.del(address)

Check warning on line 507 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L507

Added line #L507 was not covered by tests
}
}
}
const { address, type } = accessedState
switch (type) {
case AccessedStateType.Version: {
const encodedAccount = this._caches?.account?.get(address)?.accountRLP

Check warning on line 635 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L635

Added line #L635 was not covered by tests
if (encodedAccount === undefined) {
return null
}
return ZEROVALUE
}
case AccessedStateType.Balance: {
const encodedAccount = this._caches?.account?.get(address)?.accountRLP

Check warning on line 644 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L644

Added line #L644 was not covered by tests
if (encodedAccount === undefined) {
return null
}
}
case AccessedStateType.Nonce: {
const encodedAccount = this._caches?.account?.get(address)?.accountRLP

Check warning on line 654 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L654

Added line #L654 was not covered by tests
if (encodedAccount === undefined) {
return null
}
}
case AccessedStateType.CodeHash: {
const encodedAccount = this._caches?.account?.get(address)?.accountRLP

Check warning on line 663 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L663

Added line #L663 was not covered by tests
if (encodedAccount === undefined) {
return null
}
}
case AccessedStateType.CodeSize: {
const codeSize = this._caches?.code?.get(address)?.code?.length

Check warning on line 671 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L671

Added line #L671 was not covered by tests
if (codeSize === undefined) {
// it could be an EOA lets check for that
const encodedAccount = this._caches?.account?.get(address)?.accountRLP

Check warning on line 674 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L674

Added line #L674 was not covered by tests
if (encodedAccount === undefined) {
return null
}
case AccessedStateType.Code: {
const { codeOffset } = accessedState
const code = this._caches?.code?.get(address)?.code

Check warning on line 694 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L694

Added line #L694 was not covered by tests
if (code === undefined) {
return null
}
const { slot } = accessedState
const key = setLengthLeft(bigIntToBytes(slot), 32)
const storage = this._caches?.storage?.get(address, key)

Check warning on line 710 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L710

Added line #L710 was not covered by tests
if (storage === undefined) {
return null
}
*/
async checkpoint(): Promise<void> {
this._checkpoints.push(this._state)
this._caches?.checkpoint()

Check warning on line 726 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L726

Added line #L726 was not covered by tests
}
/**
*/
async commit(): Promise<void> {
this._checkpoints.pop()
this._caches?.commit()

Check warning on line 735 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L735

Added line #L735 was not covered by tests
}
// TODO
async revert(): Promise<void> {
// setup trie checkpointing
this._checkpoints.pop()
this._caches?.revert()

Check warning on line 750 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L750

Added line #L750 was not covered by tests
}
/**
* Clears all underlying caches
*/
clearCaches() {
this._caches?.clear()

Check warning on line 784 in packages/statemanager/src/statelessVerkleStateManager.ts

Codecov / codecov/patch

packages/statemanager/src/statelessVerkleStateManager.ts#L784

Added line #L784 was not covered by tests
}
// TODO: Removing this causes a Kaustinen6 test in client to fail