Skip to content

Commit

Permalink
Merge pull request #2617 from OffchainLabs/spurious-refund-error
Browse files Browse the repository at this point in the history
Fix spurious refund error log to just be debug
  • Loading branch information
tsahee authored Sep 28, 2024
2 parents ce4342e + 8d2324d commit 4a93769
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,34 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
refund := func(refundFrom common.Address, amount *big.Int) {
const errLog = "fee address doesn't have enough funds to give user refund"

logMissingRefund := func(err error) {
if !errors.Is(err, vm.ErrInsufficientBalance) {
log.Error("unexpected error refunding balance", "err", err, "feeAddress", refundFrom)
return
}
logLevel := log.Error
isContract := p.evm.StateDB.GetCodeSize(refundFrom) > 0
if isContract {
// It's expected that the balance might not still be in this address if it's a contract.
logLevel = log.Debug
}
logLevel(errLog, "err", err, "feeAddress", refundFrom)
}

// Refund funds to the fee refund address without overdrafting the L1 deposit.
toRefundAddr := takeFunds(maxRefund, amount)
err = util.TransferBalance(&refundFrom, &inner.RefundTo, toRefundAddr, p.evm, scenario, "refund")
if err != nil {
// Normally the network fee address should be holding any collected fees.
// However, in theory, they could've been transferred out during the redeem attempt.
// If the network fee address doesn't have the necessary balance, log an error and don't give a refund.
log.Error(errLog, "err", err, "feeAddress", refundFrom)
logMissingRefund(err)
}
// Any extra refund can't be given to the fee refund address if it didn't come from the L1 deposit.
// Instead, give the refund to the retryable from address.
err = util.TransferBalance(&refundFrom, &inner.From, arbmath.BigSub(amount, toRefundAddr), p.evm, scenario, "refund")
if err != nil {
log.Error(errLog, "err", err, "feeAddress", refundFrom)
logMissingRefund(err)
}
}

Expand Down

0 comments on commit 4a93769

Please sign in to comment.