-
Notifications
You must be signed in to change notification settings - Fork 828
Closed
Labels
Description
If you create a VM using istanbul
and then create a VM using petersburg
you will get in the petersburg
VM a VM which has (this is what I tested) set the SLOAD
gas cost 800 while it should be 200 (the original value). I suspect this also means that you can access SELFBALANCE
and CHAINID
in the petersburg VM and that the EXTCODEHASH
and BALANCE
opcodes are gas priced the wrong way.
The (clean) solution would be to give every VM their own codes
list instead of pointing it to the "global" variable codes
in lib/evm/opcodes.ts
.
I quickly fixed this myself by adding this to lib/evm/opcodes.ts
: (which is obviously a dirty solution)
const normalOpcodes: any = {
0x31: ['BALANCE', 400, true],
0x3f: ['EXTCODEHASH', 400, true],
0x54: ['SLOAD', 200, true],
}
export function setOpcodes(hf: string) {
if (hf === 'istanbul') {
codes = { ...codes, ...istanbulOpcodes }
} else {
codes = { ...codes, ...normalOpcodes }
codes[0x47] = undefined;
codes[0x46] = undefined;
}
}