Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
irrun committed Mar 6, 2024
1 parent 7877f70 commit f5bd475
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"math/big"
"time"

"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -485,7 +487,7 @@ func (b *EthAPIBackend) SendBid(ctx context.Context, bid *types.BidArgs) (common
return b.Miner().SendBid(ctx, bid)
}

func (b *EthAPIBackend) BestBidGasFee(parentHash common.Hash) *big.Int {
func (b *EthAPIBackend) BestBidGasFee(parentHash common.Hash) *uint256.Int {
return b.Miner().BestPackedBlockReward(parentHash)
}

Expand Down
13 changes: 7 additions & 6 deletions internal/ethapi/api_mev.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package ethapi
import (
"context"
"fmt"
"math/big"

"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -55,17 +56,17 @@ 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 {
if rawBid.GasFee == nil || rawBid.GasFee.Cmp(common.U2560) == 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 {
if builderFee.Cmp(common.U2560) < 0 {
return common.Hash{}, types.NewInvalidBidError("builder fee should not be less than 0")
}

if builderFee.Cmp(common.Big0) == 0 {
if builderFee.Cmp(common.U2560) == 0 {
if len(args.PayBidTx) != 0 || args.PayBidTxGasUsed != 0 {
return common.Hash{}, types.NewInvalidPayBidTxError("payBidTx should be nil when builder fee is 0")
}
Expand All @@ -75,7 +76,7 @@ func (m *MevAPI) SendBid(ctx context.Context, args types.BidArgs) (common.Hash,
return common.Hash{}, types.NewInvalidBidError("builder fee must be less than gas fee")
}

if builderFee.Cmp(common.Big0) > 0 {
if builderFee.Cmp(common.U2560) > 0 {
// payBidTx can be nil when validator and builder take some other settlement

if args.PayBidTxGasUsed > TransferTxGasLimit {
Expand All @@ -97,7 +98,7 @@ func (m *MevAPI) SendBid(ctx context.Context, args types.BidArgs) (common.Hash,
return m.b.SendBid(ctx, &args)
}

func (m *MevAPI) BestBidGasFee(_ context.Context, parentHash common.Hash) *big.Int {
func (m *MevAPI) BestBidGasFee(_ context.Context, parentHash common.Hash) *uint256.Int {
return m.b.BestBidGasFee(parentHash)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func (b *testBackend) SendBid(ctx context.Context, bid *types.BidArgs) (common.H
panic("implement me")
}
func (b *testBackend) MinerInTurn() bool { return false }
func (b *testBackend) BestBidGasFee(parentHash common.Hash) *big.Int {
func (b *testBackend) BestBidGasFee(parentHash common.Hash) *uint256.Int {
//TODO implement me
panic("implement me")
}
Expand Down
4 changes: 3 additions & 1 deletion internal/ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"math/big"
"time"

"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -117,7 +119,7 @@ type Backend interface {
// SendBid receives bid from the builders.
SendBid(ctx context.Context, bid *types.BidArgs) (common.Hash, error)
// BestBidGasFee returns the gas fee of the best bid for the given parent hash.
BestBidGasFee(parentHash common.Hash) *big.Int
BestBidGasFee(parentHash common.Hash) *uint256.Int
// MinerInTurn returns true if the validator is in turn to propose the block.
MinerInTurn() bool
}
Expand Down
4 changes: 3 additions & 1 deletion internal/ethapi/transaction_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -427,6 +429,6 @@ func (b *backendMock) SendBid(ctx context.Context, bid *types.BidArgs) (common.H
panic("implement me")
}
func (b *backendMock) MinerInTurn() bool { return false }
func (b *backendMock) BestBidGasFee(parentHash common.Hash) *big.Int {
func (b *backendMock) BestBidGasFee(parentHash common.Hash) *uint256.Int {
panic("implement me")
}

0 comments on commit f5bd475

Please sign in to comment.