From 2cab6beb7faefacf15a12d2646ff800096d7d78c Mon Sep 17 00:00:00 2001 From: raina Date: Wed, 28 Feb 2024 16:54:02 +0800 Subject: [PATCH] fix: check gasFee and payBidTx in API layer --- internal/ethapi/api_mev.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api_mev.go b/internal/ethapi/api_mev.go index 6e2d0f55f0..3dac65a1ff 100644 --- a/internal/ethapi/api_mev.go +++ b/internal/ethapi/api_mev.go @@ -54,6 +54,10 @@ func (m *MevAPI) SendBid(ctx context.Context, args types.BidArgs) (common.Hash, fmt.Sprintf("non-aligned parent hash: %v", currentHeader.Hash())) } + if rawBid.GasFee == nil || rawBid.GasFee.Cmp(common.Big0) == 0 || rawBid.GasUsed == 0 { + return common.Hash{}, types.NewInvalidBidError("empty gasFee or empty gasUsed") + } + if rawBid.BuilderFee != nil { builderFee := rawBid.BuilderFee if builderFee.Cmp(common.Big0) < 0 { @@ -71,9 +75,16 @@ func (m *MevAPI) SendBid(ctx context.Context, args types.BidArgs) (common.Hash, } if builderFee.Cmp(common.Big0) > 0 { - if args.PayBidTxGasUsed >= TransferTxGasLimit { + // payBidTx can be nil when validator and builder take some other settlement + + if args.PayBidTxGasUsed > TransferTxGasLimit { return common.Hash{}, types.NewInvalidBidError( - fmt.Sprintf("transfer tx gas used must be less than %v", TransferTxGasLimit)) + fmt.Sprintf("transfer tx gas used must be no more than %v", TransferTxGasLimit)) + } + + if (len(args.PayBidTx) == 0 && args.PayBidTxGasUsed != 0) || + (len(args.PayBidTx) != 0 && args.PayBidTxGasUsed == 0) { + return common.Hash{}, types.NewInvalidPayBidTxError("non-aligned payBidTx and payBidTxGasUsed") } } } else {