Skip to content

Commit

Permalink
[VM] fix case where miner account gets 0 gas fees
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Jul 13, 2020
1 parent e2f5371 commit 46d9cd6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/vm/lib/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise<RunTxResult> {
const minerAccount = await state.getAccount(block.header.coinbase)
// add the amount spent on gas to the miner's account
minerAccount.balance = toBuffer(new BN(minerAccount.balance).add(results.amountSpent))
if (!new BN(minerAccount.balance).isZero()) {
await state.putAccount(block.header.coinbase, minerAccount)
}

// Put the miner account into the state. If the balance of the miner account remains zero, note that
// 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

0 comments on commit 46d9cd6

Please sign in to comment.