In Mailbox, function requestL2Transaction, the isFree parameter of the call to _requestL2Transaction is hard-coded to false:
So the calculation of the L2 gas price:
Mailbox, lines 303 to 307
Defaults to:
Taking into account that its value can never be zero because:
This returns at least FAIR_L2_GAS_PRICE. If we go to bootloader, function processL1Tx, the refundGas the user will receive is the sum of:
Note: please see calculation in wardens original submission.
reservedGas is the excess of gas between what the user provided and what the operator is willing to use, and refundGas (not the final one) is the remaining gas that is left after preparing and executing the requested transaction. It is expected then that _refundRecipient will receive refundGas * gasPrice as a compensation for providing more gas than the needed for the execution of the L1L2 transaction.
However, we see in:
Mailbox, lines 929 to 932
It is never used, as it assumes that L1L2 transactions are free, which is not true. If the transaction does not revert, then _refundRecipient will receive:
bootloader, line 950
This equals to msg.value - (l2Value + payToOperator). I kindly suggest changing the code to:
bootloader, lines 929 to 952
If both equations are equal, that is, refundGas * gasPrice = msg.value - (l2Value + payToOperator), then this is more explicit and saves gas by not doing safeSubs nor safeAdds (QA). If they are NOT, then this code is the correct one, as you are giving the refund recipient exactly the calculated refundGas, no more, no less.
