Description
In this specific test I noticed that I had to specifically pass on the Common object which is used by the VM in order to get the right results. I would assume that any package which is used downstream (tx/block) would use the Common of the VM in case it is ran. But this is not the case. One can create a VM which points to Istanbul
, and then instantiate a block which uses Chainstart
. This leads to the very weird situation where the EVM executes rules according to Istanbul
(e.g. gas calculations), but the block will validate the rules against Chainstart
. This sounds like a very bug-prone feature and it seems very inconsistent to me.
I'd say a way to fix this is to call setHardfork
on the tx/block before we run it and thus set the common to the same hardfork as the one the VM is using. But this would be a breaking change as now suddenly the Common of tx/block can switch forks when you run it. We could also explicitly communicate that if you want to ensure "correctness", then you need to always pass on the common of the VM in case you create a tx/block.
One other nasty problem here is that in the constructor of block/tx there are some validations/calculations which explicitly depend upon the fork. In block
it checks DAO extra data, and if calcDifficultyFromHeader
is set to true
then it also calculates difficulty (which could thus change if you are on a different fork due to the difficulty bomb). In tx
it also verifies that the v
value of the signature is correct.