Fix/chainlight 006 Unused Gas Penalty #26
Merged
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.
Fix this.
-SponsorshipPaymaster now charges
maxPenalty = (mUserOp.callGasLimit + mUserOp.paymasterPostOpGasLimit) * 10 / 100 * maxFeePerGas
at_validatePaymasterUserOp
.let's define the
EP.actualGasCost
emitted here asEPAGC
.Then
EPAGC = A + P + actualPenalty
, whereA
is actualGasCost passed to Paymaster.postOp here.P
is component brought bypreGas - gasleft()
from here , which you reference above as postOpCost I believe.actualPenalty
is the component added hereThe amount deducted by Paymaster (leaving Paymaster premium coming from
priceMarkup
aside) isPC = A + U + MaxPenalty
.Where
U
is(unaccountedGasCatched * actualUserOpFeePerGas)
from hereAnd
maxPenalty
is as discussed above.Assuming
MaxPenalty >= actualPenalty && U >= P
istrue
for all maxPenalty, actualPenalty, U, Pon backend we do
amountToRefund = PC - EPAGC = (U - P) + (MaxPenalty - actualPenalty)
which will reflect the exact amount overcharged by Paymaster.Q = priceMarkup / _PRICE_DENOMINATOR
when calculating the refund.EP emits AGC w/o Q, Paymaster also emits it's gas cost (A+U) before applying Q.