Skip to content

Commit e9213ca

Browse files
committed
Fix getOpcodesForHF for hf > istanbul
1 parent d5475fa commit e9213ca

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/evm/opcodes.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Common from 'ethereumjs-common'
2+
13
export interface Opcode {
24
name: string
35
fee: number
@@ -180,8 +182,8 @@ const istanbulOpcodes: OpcodeList = {
180182
0x54: { name: 'SLOAD', fee: 800, isAsync: true },
181183
}
182184

183-
export function getOpcodesForHF(hf: string) {
184-
if (hf === 'istanbul') {
185+
export function getOpcodesForHF(common: Common) {
186+
if (common.gteHardfork('istanbul')) {
185187
return { ...opcodes, ...istanbulOpcodes }
186188
} else {
187189
return { ...opcodes }

lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default class VM extends AsyncEventEmitter {
110110
}
111111

112112
// Set list of opcodes based on HF
113-
this._opcodes = getOpcodesForHF(this._common.hardfork()!)
113+
this._opcodes = getOpcodesForHF(this._common)
114114

115115
if (opts.stateManager) {
116116
this.stateManager = opts.stateManager

tests/api/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tape('VM with default blockchain', (t) => {
4343
})
4444

4545
t.test('should accept a common object as option', (st) => {
46-
const common = new Common('mainnet')
46+
const common = new Common('mainnet', 'istanbul')
4747

4848
const vm = new VM({ common })
4949
st.equal(vm._common, common)

0 commit comments

Comments
 (0)