Skip to content

Commit

Permalink
[VM] fix SpuriousDragon and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Jul 13, 2020
1 parent 46d9cd6 commit 04eaff3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/vm/lib/evm/opFns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,12 @@ export const handlers: { [k: string]: OpHandler } = {
}
subMemUsage(runState, inOffset, inLength)
subMemUsage(runState, outOffset, outLength)
if (!value.isZero()){

if (!value.isZero()) {
runState.eei.useGas(new BN(runState._common.param('gasPrices', 'callValueTransfer')))
}
gasLimit = maxCallGas(gasLimit, runState.eei.getGasLeft())

let data = Buffer.alloc(0)
if (!inLength.isZero()) {
data = runState.memory.read(inOffset.toNumber(), inLength.toNumber())
Expand All @@ -676,10 +676,10 @@ export const handlers: { [k: string]: OpHandler } = {
if (runState._common.gteHardfork('spuriousDragon')) {
// We are at or after Spurious Dragon
// Call new account gas: account is DEAD and we transfer nonzero value
if (runState.stateManager.accountIsEmpty(toAddressBuf) && !value.isZero()) {
if ((await runState.stateManager.accountIsEmpty(toAddressBuf)) && !value.isZero()) {
runState.eei.useGas(new BN(runState._common.param('gasPrices', 'callNewAccount')))
}
} else if ( !(await runState.stateManager.accountExists(toAddressBuf))){
} else if (!(await runState.stateManager.accountExists(toAddressBuf))) {
// We are before Spurious Dragon
// Call new account gas: account does not exist (it is not in the state trie, not even as an "empty" account)
const accountDoesNotExist = !(await runState.stateManager.accountExists(toAddressBuf))
Expand Down
1 change: 0 additions & 1 deletion packages/vm/lib/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise<RunTxResult> {
// the state.putAccount function puts this into the "touched" accounts. This will thus be removed when
// we clean the touched accounts below in case we are in a fork >= SpuriousDragon
await state.putAccount(block.header.coinbase, minerAccount)


/*
* Cleanup accounts
Expand Down
6 changes: 3 additions & 3 deletions packages/vm/lib/state/stateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class DefaultStateManager implements StateManager {
this._cache.put(address, account)
this.touchAccount(address)
}

async deleteAccount(address: Buffer) {
this._cache.del(address)
this.touchAccount(address)
Expand Down Expand Up @@ -490,10 +490,10 @@ export default class DefaultStateManager implements StateManager {
async accountExists(address: Buffer): Promise<boolean> {
const account = await this._cache.lookup(address)
if (account) {
return true;
return true
}
if (await this._cache._trie.get(address)) {
return true;
return true
}
return false
}
Expand Down

0 comments on commit 04eaff3

Please sign in to comment.