Skip to content

Commit

Permalink
Merge pull request #1101 from ethereumjs/fix-vm-client-hf-switching
Browse files Browse the repository at this point in the history
VM/Client: fix HF switching. Fix TangerineWhistle update bug.
  • Loading branch information
holgerd77 committed Feb 12, 2021
2 parents 97c30f1 + dc96a80 commit 139d90e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/client/lib/sync/execution/vmexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class VMExecution extends Execution {
const blockNumber = headBlock.header.number.toNumber()
this.config.execCommon.setHardforkByBlockNumber(blockNumber)
this.hardfork = this.config.execCommon.hardfork()
this.vm._updateOpcodes()
this.config.logger.info(`Initializing VM execution hardfork=${this.hardfork}`)
}

Expand Down Expand Up @@ -112,6 +113,7 @@ export class VMExecution extends Execution {
`Execution hardfork switch on block number=${blockNumber} hash=${hash} old=${this.hardfork} new=${hardfork}`
)
this.hardfork = this.config.execCommon.setHardforkByBlockNumber(blockNumber)
this.vm._updateOpcodes()
}
await this.vm.runBlock({ block, root: parentState })
txCounter += block.transactions.length
Expand Down
16 changes: 16 additions & 0 deletions packages/vm/lib/evm/opcodes/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,29 @@ const opcodes = {

// Array of hard forks in order. These changes are repeatedly applied to `opcodes` until the hard fork is in the future based upon the common
// TODO: All gas price changes should be moved to common
// If the base gas cost of any of the operations change, then these should also be added to this list.
// If there are context variables changed (such as "warm slot reads") which are not the base gas fees,
// Then this does not have to be added.
const hardforkOpcodes = [
{
hardforkName: 'homestead',
opcodes: {
0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7
},
},
{
hardforkName: 'tangerineWhistle',
opcodes: {
0x54: { name: 'SLOAD', isAsync: true },
0xf1: { name: 'CALL', isAsync: true },
0xf2: { name: 'CALLCODE', isAsync: true },
0x3b: { name: 'EXTCODESIZE', isAsync: true },
0x3c: { name: 'EXTCODECOPY', isAsync: true },
0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7
0xff: { name: 'SELFDESTRUCT', isAsync: true },
0x31: { name: 'BALANCE', isAsync: true },
},
},
{
hardforkName: 'byzantium',
opcodes: {
Expand Down

0 comments on commit 139d90e

Please sign in to comment.