diff --git a/core/blockchain.go b/core/blockchain.go index 88308a795..12639a34d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2540,49 +2540,49 @@ func (bc *BlockChain) ValidatePayload(block *types.Block, feeRecipient common.Ad } log.Warn("proposer payment not enough, trying last tx payment validation", "expected", expectedProfit, "actual", feeRecipientBalanceDelta) } + } - if len(receipts) == 0 { - return errors.New("no proposer payment receipt") - } + if len(receipts) == 0 { + return errors.New("no proposer payment receipt") + } - lastReceipt := receipts[len(receipts)-1] - if lastReceipt.Status != types.ReceiptStatusSuccessful { - return errors.New("proposer payment not successful") - } - txIndex := lastReceipt.TransactionIndex - if txIndex+1 != uint(len(block.Transactions())) { - return fmt.Errorf("proposer payment index not last transaction in the block (%d of %d)", txIndex, len(block.Transactions())-1) - } + lastReceipt := receipts[len(receipts)-1] + if lastReceipt.Status != types.ReceiptStatusSuccessful { + return errors.New("proposer payment not successful") + } + txIndex := lastReceipt.TransactionIndex + if txIndex+1 != uint(len(block.Transactions())) { + return fmt.Errorf("proposer payment index not last transaction in the block (%d of %d)", txIndex, len(block.Transactions())-1) + } - paymentTx := block.Transaction(lastReceipt.TxHash) - if paymentTx == nil { - return errors.New("payment tx not in the block") - } + paymentTx := block.Transaction(lastReceipt.TxHash) + if paymentTx == nil { + return errors.New("payment tx not in the block") + } - paymentTo := paymentTx.To() - if paymentTo == nil || *paymentTo != feeRecipient { - return fmt.Errorf("payment tx not to the proposers fee recipient (%v)", paymentTo) - } + paymentTo := paymentTx.To() + if paymentTo == nil || *paymentTo != feeRecipient { + return fmt.Errorf("payment tx not to the proposers fee recipient (%v)", paymentTo) + } - if paymentTx.Value().Cmp(expectedProfit) != 0 { - return fmt.Errorf("inaccurate payment %s, expected %s", paymentTx.Value().String(), expectedProfit.String()) - } + if paymentTx.Value().Cmp(expectedProfit) != 0 { + return fmt.Errorf("inaccurate payment %s, expected %s", paymentTx.Value().String(), expectedProfit.String()) + } - if len(paymentTx.Data()) != 0 { - return fmt.Errorf("malformed proposer payment, contains calldata") - } + if len(paymentTx.Data()) != 0 { + return fmt.Errorf("malformed proposer payment, contains calldata") + } - if paymentTx.GasPrice().Cmp(block.BaseFee()) != 0 { - return fmt.Errorf("malformed proposer payment, gas price not equal to base fee") - } + if paymentTx.GasPrice().Cmp(block.BaseFee()) != 0 { + return fmt.Errorf("malformed proposer payment, gas price not equal to base fee") + } - if paymentTx.GasTipCap().Cmp(block.BaseFee()) != 0 && paymentTx.GasTipCap().Sign() != 0 { - return fmt.Errorf("malformed proposer payment, unexpected gas tip cap") - } + if paymentTx.GasTipCap().Cmp(block.BaseFee()) != 0 && paymentTx.GasTipCap().Sign() != 0 { + return fmt.Errorf("malformed proposer payment, unexpected gas tip cap") + } - if paymentTx.GasFeeCap().Cmp(block.BaseFee()) != 0 { - return fmt.Errorf("malformed proposer payment, unexpected gas fee cap") - } + if paymentTx.GasFeeCap().Cmp(block.BaseFee()) != 0 { + return fmt.Errorf("malformed proposer payment, unexpected gas fee cap") } return nil