File tree Expand file tree Collapse file tree 4 files changed +14
-16
lines changed Expand file tree Collapse file tree 4 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -680,12 +680,9 @@ export const handlers: { [k: string]: OpHandler } = {
680
680
runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callNewAccount' ) ) )
681
681
}
682
682
} else if ( ! ( await runState . stateManager . accountExists ( toAddressBuf ) ) ) {
683
- // We are before Spurious Dragon
683
+ // We are before Spurious Dragon and the account does not exist.
684
684
// Call new account gas: account does not exist (it is not in the state trie, not even as an "empty" account)
685
- const accountDoesNotExist = ! ( await runState . stateManager . accountExists ( toAddressBuf ) )
686
- if ( accountDoesNotExist ) {
687
- runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callNewAccount' ) ) )
688
- }
685
+ runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callNewAccount' ) ) )
689
686
}
690
687
691
688
if ( ! value . isZero ( ) ) {
Original file line number Diff line number Diff line change @@ -54,27 +54,23 @@ export default class Cache {
54
54
/**
55
55
* Looks up address in underlying trie.
56
56
* @param address - Address of account
57
- * @param create - Create emtpy account if non-existent
58
57
*/
59
- async _lookupAccount ( address : Buffer , create : boolean = true ) : Promise < Account | undefined > {
58
+ async _lookupAccount ( address : Buffer ) : Promise < Account > {
60
59
const raw = await this . _trie . get ( address )
61
- if ( raw || create ) {
62
- const account = new Account ( raw )
63
- return account
64
- }
60
+ const account = new Account ( raw )
61
+ return account
65
62
}
66
63
67
64
/**
68
65
* Looks up address in cache, if not found, looks it up
69
66
* in the underlying trie.
70
67
* @param key - Address of account
71
- * @param create - Create emtpy account if non-existent
72
68
*/
73
- async getOrLoad ( key : Buffer , create : boolean = true ) : Promise < Account | undefined > {
69
+ async getOrLoad ( key : Buffer ) : Promise < Account > {
74
70
let account = this . lookup ( key )
75
71
76
72
if ( ! account ) {
77
- account = await this . _lookupAccount ( key , create )
73
+ account = await this . _lookupAccount ( key )
78
74
if ( account ) {
79
75
this . _update ( key , account as Account , false , false )
80
76
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export interface StorageDump {
10
10
export interface StateManager {
11
11
copy ( ) : StateManager
12
12
getAccount ( address : Buffer ) : Promise < Account >
13
- putAccount ( address : Buffer , account : Account | null ) : Promise < void >
13
+ putAccount ( address : Buffer , account : Account ) : Promise < void >
14
14
deleteAccount ( address : Buffer ) : Promise < void >
15
15
touchAccount ( address : Buffer ) : void
16
16
putContractCode ( address : Buffer , value : Buffer ) : Promise < void >
Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ export default class DefaultStateManager implements StateManager {
89
89
this . touchAccount ( address )
90
90
}
91
91
92
+ /**
93
+ * Deletes an [`@ethereumjs/account`](https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/account)
94
+ * from state under the provided `address`. The account will also be removed from the state trie.
95
+ * @param address - Address of the account which should be deleted
96
+ */
92
97
async deleteAccount ( address : Buffer ) {
93
98
this . _cache . del ( address )
94
99
this . touchAccount ( address )
@@ -115,7 +120,7 @@ export default class DefaultStateManager implements StateManager {
115
120
const codeHash = keccak256 ( value )
116
121
117
122
if ( codeHash . equals ( KECCAK256_NULL ) ) {
118
- // return
123
+ return
119
124
}
120
125
121
126
const account = await this . getAccount ( address )
You can’t perform that action at this time.
0 commit comments