Skip to content

Commit

Permalink
vm -> PoA clique: do no update miner account on PoA chains
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Feb 9, 2021
1 parent 010c04d commit 749b93f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/vm/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export default class VM extends AsyncEventEmitter {

/**
* Processes the `block` running all of the transactions it contains and updating the miner's account
* on PoW chains.
*
* This method modifies the state. If `generate` is `true`, the state modifications will be
* reverted if an exception is raised. If it's `false`, it won't revert if the block's header is
Expand Down
24 changes: 13 additions & 11 deletions packages/vm/lib/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,20 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise<RunTxResult> {
)

// Update miner's balance
const miner = block.header.coinbase
const minerAccount = await state.getAccount(miner)
// add the amount spent on gas to the miner's account
minerAccount.balance.iadd(results.amountSpent)
if (this._common.consensusType() === 'pow') {
const miner = block.header.coinbase
const minerAccount = await state.getAccount(miner)
// add the amount spent on gas to the miner's account
minerAccount.balance.iadd(results.amountSpent)

// 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(miner, minerAccount)
debug(
`tx update miner account (${miner.toString()}) balance (-> ${minerAccount.balance.toString()})`
)
// 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(miner, minerAccount)
debug(
`tx update miner account (${miner.toString()}) balance (-> ${minerAccount.balance.toString()})`
)
}

/*
* Cleanup accounts
Expand Down

0 comments on commit 749b93f

Please sign in to comment.