From 55ec12d64183cc339396bf64890962c8b0eb69f5 Mon Sep 17 00:00:00 2001 From: Mars Date: Fri, 27 Dec 2024 22:12:13 -0500 Subject: [PATCH] feat: change bribe accept EOA to EOA list, rename to `ValidatorBribeEOAs` --- miner/bid_simulator.go | 20 +++++++++++++------- miner/miner_mev.go | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/miner/bid_simulator.go b/miner/bid_simulator.go index 7b7df5a3f..cd07d8abb 100644 --- a/miner/bid_simulator.go +++ b/miner/bid_simulator.go @@ -607,9 +607,7 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) { err = fmt.Errorf("invalid tx in bid, %v", err) return } - if b.config.ValidatorBribeEOA != (common.Address{}) { - bidRuntime.checkValidatorBribe(b.config.ValidatorBribeEOA, tx, receipt) - } + bidRuntime.checkValidatorBribe(b.config.ValidatorBribeEOAs, tx, receipt) } // check if bid reward is valid @@ -772,12 +770,20 @@ func (r *BidRuntime) isExpectedBetterThanBestBid(bestBid *BidRuntime) bool { return r.expectedRewardFromBuilder().Cmp(bestBid.totalRewardFromBuilder()) > 0 } -func (r *BidRuntime) checkValidatorBribe(selfBribe common.Address, tx *types.Transaction, receipt *types.Receipt) { - if to := tx.To(); to != nil && *to == selfBribe && - receipt.Status == types.ReceiptStatusSuccessful && +func (r *BidRuntime) checkValidatorBribe(acceptBribeEOAs []common.Address, tx *types.Transaction, receipt *types.Receipt) { + if len(acceptBribeEOAs) == 0 { + return + } + + if to := tx.To(); to != nil && receipt.Status == types.ReceiptStatusSuccessful && tx.Value() != nil && tx.Value().Cmp(common.Big0) > 0 { - r.directBribe.Add(r.directBribe, tx.Value()) + for _, acceptBribeEOA := range acceptBribeEOAs { + if acceptBribeEOA == *to { + r.directBribe.Add(r.directBribe, tx.Value()) + break + } + } } } diff --git a/miner/miner_mev.go b/miner/miner_mev.go index 12861a9ae..dd42dc4b0 100644 --- a/miner/miner_mev.go +++ b/miner/miner_mev.go @@ -25,7 +25,7 @@ type MevConfig struct { Builders []BuilderConfig // The list of builders ValidatorCommission uint64 // 100 means the validator claims 1% from block reward BidSimulationLeftOver time.Duration - ValidatorBribeEOA common.Address + ValidatorBribeEOAs []common.Address } var DefaultMevConfig = MevConfig{