Skip to content

Commit 139d90e

Browse files
authored
Merge pull request #1101 from ethereumjs/fix-vm-client-hf-switching
VM/Client: fix HF switching. Fix TangerineWhistle update bug.
2 parents 97c30f1 + dc96a80 commit 139d90e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/client/lib/sync/execution/vmexecution.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class VMExecution extends Execution {
4949
const blockNumber = headBlock.header.number.toNumber()
5050
this.config.execCommon.setHardforkByBlockNumber(blockNumber)
5151
this.hardfork = this.config.execCommon.hardfork()
52+
this.vm._updateOpcodes()
5253
this.config.logger.info(`Initializing VM execution hardfork=${this.hardfork}`)
5354
}
5455

@@ -112,6 +113,7 @@ export class VMExecution extends Execution {
112113
`Execution hardfork switch on block number=${blockNumber} hash=${hash} old=${this.hardfork} new=${hardfork}`
113114
)
114115
this.hardfork = this.config.execCommon.setHardforkByBlockNumber(blockNumber)
116+
this.vm._updateOpcodes()
115117
}
116118
await this.vm.runBlock({ block, root: parentState })
117119
txCounter += block.transactions.length

packages/vm/lib/evm/opcodes/codes.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,29 @@ const opcodes = {
191191

192192
// 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
193193
// TODO: All gas price changes should be moved to common
194+
// If the base gas cost of any of the operations change, then these should also be added to this list.
195+
// If there are context variables changed (such as "warm slot reads") which are not the base gas fees,
196+
// Then this does not have to be added.
194197
const hardforkOpcodes = [
195198
{
196199
hardforkName: 'homestead',
197200
opcodes: {
198201
0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7
199202
},
200203
},
204+
{
205+
hardforkName: 'tangerineWhistle',
206+
opcodes: {
207+
0x54: { name: 'SLOAD', isAsync: true },
208+
0xf1: { name: 'CALL', isAsync: true },
209+
0xf2: { name: 'CALLCODE', isAsync: true },
210+
0x3b: { name: 'EXTCODESIZE', isAsync: true },
211+
0x3c: { name: 'EXTCODECOPY', isAsync: true },
212+
0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7
213+
0xff: { name: 'SELFDESTRUCT', isAsync: true },
214+
0x31: { name: 'BALANCE', isAsync: true },
215+
},
216+
},
201217
{
202218
hardforkName: 'byzantium',
203219
opcodes: {

0 commit comments

Comments
 (0)