diff --git a/packages/vm/src/runBlock.ts b/packages/vm/src/runBlock.ts index 7fbfa4e862..8a25046710 100644 --- a/packages/vm/src/runBlock.ts +++ b/packages/vm/src/runBlock.ts @@ -2,7 +2,7 @@ import { debug as createDebugLogger } from 'debug' import { encode } from 'rlp' import { BaseTrie as Trie } from 'merkle-patricia-tree' import { Account, Address, BN, intToBuffer, generateAddress } from 'ethereumjs-util' -import { Block } from '@gxchain2-ethereumjs/block' +import { Block, BlockHeader } from '@gxchain2-ethereumjs/block' import VM from './index' import Bloom from './bloom' import { StateManager } from './state' @@ -67,6 +67,10 @@ export interface RunBlockOpts { * Clique signer for generating new block */ cliqueSigner?: Buffer + /** + * Get block reward address callback + */ + getBlockRewardAddress?: (header: BlockHeader) => Promise
} /** @@ -309,7 +313,7 @@ async function applyBlock(this: VM, block: Block, opts: RunBlockOpts) { const blockResults = await applyTransactions.bind(this)(block, opts) // Pay ommers and miners if (this._common.consensusType() === 'pow') { - await assignBlockRewards.bind(this)(block) + await assignBlockRewards.bind(this)(block, opts) } return blockResults } @@ -446,7 +450,7 @@ async function applyTransactions(this: VM, block: Block, opts: RunBlockOpts) { * Calculates block rewards for miner and ommers and puts * the updated balances of their accounts to state. */ -async function assignBlockRewards(this: VM, block: Block): Promise { +async function assignBlockRewards(this: VM, block: Block, opts: RunBlockOpts): Promise { if (this.DEBUG) { debug(`Assign block rewards`) } @@ -463,7 +467,13 @@ async function assignBlockRewards(this: VM, block: Block): Promise { } // Reward miner const reward = calculateMinerReward(minerReward, ommers.length) - const account = await rewardAccount(state, block.header.coinbase, reward) + const account = await rewardAccount( + state, + opts.getBlockRewardAddress + ? await opts.getBlockRewardAddress(block.header) + : block.header.coinbase, + reward + ) if (this.DEBUG) { debug(`Add miner reward ${reward} to account ${block.header.coinbase} (-> ${account.balance})`) } diff --git a/packages/vm/tests/tester.ts b/packages/vm/tests/tester.ts index e1d4260820..82ebb8aedd 100755 --- a/packages/vm/tests/tester.ts +++ b/packages/vm/tests/tester.ts @@ -159,7 +159,7 @@ async function runTests() { const dirs = config.getTestDirs(FORK_CONFIG_VM, name) for (const dir of dirs) { - await new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { testLoader .getTestsFromArgs( dir,