feat: add mev helper params and func (#2512)
This commit is contained in:
parent
aab4b8812a
commit
f467c6018b
@ -193,5 +193,7 @@ type MevParams struct {
|
||||
ValidatorCommission uint64 // 100 means 1%
|
||||
BidSimulationLeftOver time.Duration
|
||||
GasCeil uint64
|
||||
GasPrice *big.Int // Minimum avg gas price for bid block
|
||||
BuilderFeeCeil *big.Int
|
||||
Version string
|
||||
}
|
||||
|
@ -484,6 +484,10 @@ func (b *EthAPIBackend) RemoveBuilder(builder common.Address) error {
|
||||
return b.Miner().RemoveBuilder(builder)
|
||||
}
|
||||
|
||||
func (b *EthAPIBackend) HasBuilder(builder common.Address) bool {
|
||||
return b.Miner().HasBuilder(builder)
|
||||
}
|
||||
|
||||
func (b *EthAPIBackend) SendBid(ctx context.Context, bid *types.BidArgs) (common.Hash, error) {
|
||||
return b.Miner().SendBid(ctx, bid)
|
||||
}
|
||||
|
@ -752,6 +752,13 @@ func (ec *Client) MevRunning(ctx context.Context) (bool, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
// HasBuilder returns whether the builder is registered
|
||||
func (ec *Client) HasBuilder(ctx context.Context, address common.Address) (bool, error) {
|
||||
var result bool
|
||||
err := ec.c.CallContext(ctx, &result, "mev_hasBuilder", address)
|
||||
return result, err
|
||||
}
|
||||
|
||||
// SendBid sends a bid
|
||||
func (ec *Client) SendBid(ctx context.Context, args types.BidArgs) (common.Hash, error) {
|
||||
var hash common.Hash
|
||||
|
@ -87,6 +87,10 @@ func (m *MevAPI) Params() *types.MevParams {
|
||||
return m.b.MevParams()
|
||||
}
|
||||
|
||||
func (m *MevAPI) HasBuilder(builder common.Address) bool {
|
||||
return m.b.HasBuilder(builder)
|
||||
}
|
||||
|
||||
// Running returns true if mev is running
|
||||
func (m *MevAPI) Running() bool {
|
||||
return m.b.MevRunning()
|
||||
|
@ -650,7 +650,8 @@ func (b testBackend) ServiceFilter(ctx context.Context, session *bloombits.Match
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *testBackend) MevRunning() bool { return false }
|
||||
func (b *testBackend) MevRunning() bool { return false }
|
||||
func (b *testBackend) HasBuilder(builder common.Address) bool { return false }
|
||||
func (b *testBackend) MevParams() *types.MevParams {
|
||||
return &types.MevParams{}
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ type Backend interface {
|
||||
AddBuilder(builder common.Address, builderUrl string) error
|
||||
// RemoveBuilder removes a builder from the bid simulator.
|
||||
RemoveBuilder(builder common.Address) error
|
||||
// HasBuilder returns true if the builder is in the builder list.
|
||||
HasBuilder(builder common.Address) bool
|
||||
// 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.
|
||||
|
@ -416,7 +416,8 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
|
||||
|
||||
func (b *backendMock) Engine() consensus.Engine { return nil }
|
||||
|
||||
func (b *backendMock) MevRunning() bool { return false }
|
||||
func (b *backendMock) MevRunning() bool { return false }
|
||||
func (b *backendMock) HasBuilder(builder common.Address) bool { return false }
|
||||
func (b *backendMock) MevParams() *types.MevParams {
|
||||
return &types.MevParams{}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
type BuilderConfig struct {
|
||||
@ -59,6 +60,11 @@ func (miner *Miner) RemoveBuilder(builderAddr common.Address) error {
|
||||
return miner.bidSimulator.RemoveBuilder(builderAddr)
|
||||
}
|
||||
|
||||
// HasBuilder returns true if the builder is in the builder list.
|
||||
func (miner *Miner) HasBuilder(builder common.Address) bool {
|
||||
return miner.bidSimulator.ExistBuilder(builder)
|
||||
}
|
||||
|
||||
func (miner *Miner) SendBid(ctx context.Context, bidArgs *types.BidArgs) (common.Hash, error) {
|
||||
builder, err := bidArgs.EcrecoverSender()
|
||||
if err != nil {
|
||||
@ -117,6 +123,8 @@ func (miner *Miner) MevParams() *types.MevParams {
|
||||
ValidatorCommission: miner.worker.config.Mev.ValidatorCommission,
|
||||
BidSimulationLeftOver: miner.worker.config.Mev.BidSimulationLeftOver,
|
||||
GasCeil: miner.worker.config.GasCeil,
|
||||
GasPrice: miner.worker.config.GasPrice,
|
||||
BuilderFeeCeil: builderFeeCeil,
|
||||
Version: params.Version,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user