Skip to content

Commit

Permalink
vm -> spuriousDragon: added dedicated Byzantium HF list to getOpcodes…
Browse files Browse the repository at this point in the history
…ForHF functionality
  • Loading branch information
holgerd77 committed Jun 25, 2020
1 parent cefbc00 commit 3129859
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/vm/lib/evm/opcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ const opcodes: OpcodeList = createOpcodes({
0x3a: { name: 'GASPRICE', fee: 2, isAsync: false },
0x3b: { name: 'EXTCODESIZE', fee: 700, isAsync: true },
0x3c: { name: 'EXTCODECOPY', fee: 700, isAsync: true },
0x3d: { name: 'RETURNDATASIZE', fee: 2, isAsync: true },
0x3e: { name: 'RETURNDATACOPY', fee: 3, isAsync: true },
0x3f: { name: 'EXTCODEHASH', fee: 400, isAsync: true },

// '0x40' range - block operations
Expand Down Expand Up @@ -191,14 +189,19 @@ const opcodes: OpcodeList = createOpcodes({
0xf3: { name: 'RETURN', fee: 0, isAsync: false },
0xf4: { name: 'DELEGATECALL', fee: 700, isAsync: true },
0xf5: { name: 'CREATE2', fee: 32000, isAsync: true },
0xfa: { name: 'STATICCALL', fee: 700, isAsync: true },
0xfd: { name: 'REVERT', fee: 0, isAsync: false },

// '0x70', range - other
0xfe: { name: 'INVALID', fee: 0, isAsync: false },
0xff: { name: 'SELFDESTRUCT', fee: 5000, isAsync: true },
})

const byzantiumOpcodes: OpcodeList = createOpcodes({
0x3d: { name: 'RETURNDATASIZE', fee: 2, isAsync: true },
0x3e: { name: 'RETURNDATACOPY', fee: 3, isAsync: true },
0xfa: { name: 'STATICCALL', fee: 700, isAsync: true },
0xfd: { name: 'REVERT', fee: 0, isAsync: false },
})

const istanbulOpcodes: OpcodeList = createOpcodes({
0x31: { name: 'BALANCE', fee: 700, isAsync: true },
0x3f: { name: 'EXTCODEHASH', fee: 700, isAsync: true },
Expand Down Expand Up @@ -260,9 +263,12 @@ function getFullname(code: number, name: string): string {
* @returns {OpcodeList} Opcodes dictionary object.
*/
export function getOpcodesForHF(common: Common): OpcodeList {
let hfOpcodes = opcodes
if (common.gteHardfork('byzantium')) {
hfOpcodes = { ...hfOpcodes, ...byzantiumOpcodes }
}
if (common.gteHardfork('istanbul')) {
return { ...opcodes, ...istanbulOpcodes }
} else {
return { ...opcodes }
hfOpcodes = { ...hfOpcodes, ...istanbulOpcodes }
}
return hfOpcodes
}

0 comments on commit 3129859

Please sign in to comment.