Skip to content

Commit 02300d6

Browse files
[VM] move StateManager calls from opFns into the EEI
1 parent 868c4b3 commit 02300d6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/vm/lib/evm/eei.ts

+8
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,14 @@ export default class EEI {
583583
return this._state.accountIsEmpty(address)
584584
}
585585

586+
/**
587+
* Returns true if account exists in the state trie (it can be empty). Returns false if the account is `null`.
588+
* @param address - Address of account
589+
*/
590+
async accountExists(address: Buffer): Promise<boolean> {
591+
return this._state.accountExists(address)
592+
}
593+
586594
private _getReturnCode(results: EVMResult) {
587595
// This preserves the previous logic, but seems to contradict the EEI spec
588596
// https://github.com/ewasm/design/blob/38eeded28765f3e193e12881ea72a6ab807a3371/eth_interface.md

packages/vm/lib/evm/opFns.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,10 @@ export const handlers: { [k: string]: OpHandler } = {
676676
if (runState._common.gteHardfork('spuriousDragon')) {
677677
// We are at or after Spurious Dragon
678678
// Call new account gas: account is DEAD and we transfer nonzero value
679-
if ((await runState.stateManager.accountIsEmpty(toAddressBuf)) && !value.isZero()) {
679+
if ((await runState.eei.isAccountEmpty(toAddressBuf)) && !value.isZero()) {
680680
runState.eei.useGas(new BN(runState._common.param('gasPrices', 'callNewAccount')))
681681
}
682-
} else if (!(await runState.stateManager.accountExists(toAddressBuf))) {
682+
} else if (!(await runState.eei.accountExists(toAddressBuf))) {
683683
// We are before Spurious Dragon and the account does not exist.
684684
// Call new account gas: account does not exist (it is not in the state trie, not even as an "empty" account)
685685
runState.eei.useGas(new BN(runState._common.param('gasPrices', 'callNewAccount')))

0 commit comments

Comments
 (0)