Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 78be0a7

Browse files
Ruteriavalonche
authored andcommitted
Improvements from greedy improve algo (#41)
* Backport improvements to the builder from incremental improvements * Make linter happy
1 parent e4dfa84 commit 78be0a7

20 files changed

+276
-96
lines changed

builder/builder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package builder
33
import (
44
"context"
55
"errors"
6-
blockvalidation "github.com/ethereum/go-ethereum/eth/block-validation"
7-
"golang.org/x/time/rate"
86
"math/big"
97
_ "os"
108
"sync"
119
"time"
1210

11+
blockvalidation "github.com/ethereum/go-ethereum/eth/block-validation"
12+
"golang.org/x/time/rate"
13+
1314
"github.com/ethereum/go-ethereum/common/hexutil"
1415
"github.com/ethereum/go-ethereum/core/beacon"
1516
"github.com/ethereum/go-ethereum/core/types"

builder/local_relay_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"golang.org/x/time/rate"
87
"math/big"
98
"net/http"
109
"net/http/httptest"
1110
"testing"
1211
"time"
1312

13+
"golang.org/x/time/rate"
14+
1415
"github.com/ethereum/go-ethereum/common"
1516
"github.com/ethereum/go-ethereum/common/hexutil"
1617
"github.com/ethereum/go-ethereum/core/beacon"

builder/relay.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ func (r *testRelay) GetValidatorForSlot(nextSlot uint64) (ValidatorData, error)
2929
r.requestedSlot = nextSlot
3030
return r.validator, nil
3131
}
32-
func (r *testRelay) handleRegisterValidator(w http.ResponseWriter, req *http.Request) {
33-
}
3432

3533
type RemoteRelay struct {
3634
endpoint string

builder/resubmit_utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package builder
22

33
import (
44
"context"
5+
"time"
6+
57
"github.com/ethereum/go-ethereum/log"
68
"golang.org/x/time/rate"
7-
"time"
89
)
910

1011
// runResubmitLoop checks for update signal and calls submit respecting provided rate limiter and context

builder/resubmit_utils_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package builder
22

33
import (
44
"context"
5-
"golang.org/x/time/rate"
65
"math/rand"
76
"sort"
87
"sync"
98
"testing"
109
"time"
10+
11+
"golang.org/x/time/rate"
1112
)
1213

1314
type submission struct {

builder/service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package builder
33
import (
44
"errors"
55
"fmt"
6-
blockvalidation "github.com/ethereum/go-ethereum/eth/block-validation"
76
"net/http"
87
"os"
98

9+
blockvalidation "github.com/ethereum/go-ethereum/eth/block-validation"
10+
1011
"github.com/ethereum/go-ethereum/common"
1112
"github.com/ethereum/go-ethereum/common/hexutil"
1213
"github.com/ethereum/go-ethereum/core/types"

cmd/utils/flags.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,14 +1740,11 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
17401740
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
17411741
}
17421742
if ctx.IsSet(MinerAlgoTypeFlag.Name) {
1743-
switch ctx.String(MinerAlgoTypeFlag.Name) {
1744-
case "greedy":
1745-
cfg.AlgoType = miner.ALGO_GREEDY
1746-
case "mev-geth":
1747-
cfg.AlgoType = miner.ALGO_MEV_GETH
1748-
default:
1743+
algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(MinerAlgoTypeFlag.Name))
1744+
if err != nil {
17491745
Fatalf("Invalid algo in --miner.algotype: %s", ctx.String(MinerAlgoTypeFlag.Name))
17501746
}
1747+
cfg.AlgoType = algoType
17511748
}
17521749
if ctx.IsSet(MinerRecommitIntervalFlag.Name) {
17531750
cfg.Recommit = ctx.Duration(MinerRecommitIntervalFlag.Name)

core/types/transaction.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,19 @@ func NewTransactionsByPriceAndNonce(signer Signer, txs map[common.Address]Transa
585585
}
586586
}
587587

588+
func (t *TransactionsByPriceAndNonce) DeepCopy() *TransactionsByPriceAndNonce {
589+
newT := &TransactionsByPriceAndNonce{
590+
txs: make(map[common.Address]Transactions),
591+
heads: append(TxByPriceAndTime{}, t.heads...),
592+
signer: t.signer,
593+
baseFee: new(big.Int).Set(t.baseFee),
594+
}
595+
for k, v := range t.txs {
596+
newT.txs[k] = v
597+
}
598+
return newT
599+
}
600+
588601
// Peek returns the next transaction by price.
589602
func (t *TransactionsByPriceAndNonce) Peek() *TxWithMinerFee {
590603
if len(t.heads) == 0 {

eth/block-validation/api_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ var (
4141
testValidatorKey, _ = crypto.HexToECDSA("28c3cd61b687fdd03488e167a5d84f50269df2a4c29a2cfb1390903aa775c5d0")
4242
testValidatorAddr = crypto.PubkeyToAddress(testValidatorKey.PublicKey)
4343

44-
testMinerKey, _ = crypto.HexToECDSA("28c3cd61b687fdd03488e167a5d84f50269df2a4c29a2cfb1390903aa775c5d0")
45-
testMinerAddr = crypto.PubkeyToAddress(testValidatorKey.PublicKey)
46-
4744
testBalance = big.NewInt(2e18)
4845
)
4946

@@ -57,7 +54,7 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
5754
api := NewBlockValidationAPI(ethservice, nil)
5855
parent := preMergeBlocks[len(preMergeBlocks)-1]
5956

60-
api.eth.APIBackend.Miner().SetEtherbase(testMinerAddr)
57+
api.eth.APIBackend.Miner().SetEtherbase(testValidatorAddr)
6158

6259
// This EVM code generates a log when the contract is created.
6360
logCode := common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00")
@@ -142,7 +139,7 @@ func TestValidateBuilderSubmissionV1(t *testing.T) {
142139
invalidPayload.LogsBloom = boostTypes.Bloom{}
143140
copy(invalidPayload.ReceiptsRoot[:], hexutil.MustDecode("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")[:32])
144141
blockRequest.ExecutionPayload = invalidPayload
145-
copy(blockRequest.Message.BlockHash[:], hexutil.MustDecode("0x272872d14b2a8a0454e747ed472d82d8d5ce342cfafd65fa7b77aa6de1c061d4")[:32])
142+
copy(blockRequest.Message.BlockHash[:], hexutil.MustDecode("0x2ff468dee2e05f1f58744d5496f3ab22fdc23c8141f86f907b4b0f2c8e22afc4")[:32])
146143
require.ErrorContains(t, api.ValidateBuilderSubmissionV1(blockRequest), "could not apply tx 3", "insufficient funds for gas * price + value")
147144
}
148145

eth/tracers/logger/account_touch_tracer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
package logger
1818

1919
import (
20-
"github.com/ethereum/go-ethereum/common"
21-
"github.com/ethereum/go-ethereum/core/vm"
2220
"math/big"
2321
"time"
22+
23+
"github.com/ethereum/go-ethereum/common"
24+
"github.com/ethereum/go-ethereum/core/vm"
2425
)
2526

2627
type AccountTouchTracer struct {

0 commit comments

Comments
 (0)