Closed jsign closed 3 weeks ago
This PR served us well to generate the latest v0.0.6 fixtures, and planting a flag for stable fixtures.
Now closing this since we'll end up using https://github.com/gballet/go-ethereum/pull/502 which that all bugs were fixed to pass the fixtures.
This PR does changes to satisfy a new requirement when adding elements to the execution witness.
The new requirement involves only adding elements to the witness if there's sufficient gas for it.
Examples:
TouchCodeChunksRangeAndChargeGas(...)
would add the code chunk to the witness and return the cost to be charged. If we had, say, 100 gas available, this would mean that the user didn't have enough funds to pay for that (i.e: 100<200). But it's too late, and it was already added to the witness.BASIC_DATA
andCODEHASH
of this address. Before this PR, we always addedBASIC_DATA
andCODEHASH
and returned the cost. If the user only had gas to pay forBASIC_DATA
but notCODEHASH
, it would be too late since we have already added both.More generally, if you have
X
of available gas and include something in the witness costY
, withY>X
, then we must not include it in the witness. This is made more apparent when we try to include a wide range of code chunks and only have gas for one but are asked to include 15. Before this PR, we were including 15, not only one.From a stateless client perspective, being this strict is fine. Knowing if you have enough gas to include something in the witness doesn't depend on what you received from the witness (i.e: this PR including less things in the witness doesn't affect it). This is because everything you need to know to be sure that you can add something new to the witness is the access witness state of which branches and code chunks were added.