EstimateGas to handle private transaction gas cost differences #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compare intrinsic gas of public transaction versus the private version that contains the PTM hash instead. If there is a difference, add it on to the execution cost.
Consider the
SimpleStorage
contract:Calling the
set
function with the value1989
produces thedata
field60fe47b100000000000000000000000000000000000000000000000000000000000007c5
.This is 36 bytes long, and consists of a lot of
0
's (which have a lower gas cost). The intrinsic gas value of the transaction is21528
.If this were to be sent as a private transaction, this
data
field would be replaced by the hash the Private Transaction Manager produces, which is 64 bytes long, potentially with no0
's. Assuming the worst case hash with no0
's, the intrinsic gas cost of the transaction becomes25352
.If we were to use the original gas estimate and send it as a private transaction, it would fail with a
not enough gas
error.Since the execution cost of the transaction would not change whether it becomes a public or private transaction, the only difference in gas required comes from the intrinsic gas cost.
This PR adds on the difference between the intrinsic gas costs if the private cost is higher than the public cost. This changes the semantics of the call somewhat from "this is the exact gas cost right now" to "this is the maximum gas cost right now".