Skip to content

Commit

Permalink
fix: check gasFee and payBidTx in API layer
Browse files Browse the repository at this point in the history
  • Loading branch information
irrun committed Feb 28, 2024
1 parent 86f7079 commit 2cab6be
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/ethapi/api_mev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 2cab6be

Please sign in to comment.