From 268a07a5d2bec5a57b7f5d2e34a6839f3e26cfdc Mon Sep 17 00:00:00 2001 From: avalonche Date: Sat, 26 Aug 2023 13:47:54 +1000 Subject: [PATCH] Add flashbots block validation endpoint v3 --- beacon/engine/types.go | 154 +++++++++++++++++++------------ builder/builder.go | 18 ++-- builder/builder_test.go | 4 +- builder/local_relay.go | 42 ++++----- builder/local_relay_test.go | 28 +++--- builder/relay.go | 8 +- builder/relay_aggregator.go | 8 +- builder/relay_aggregator_test.go | 28 +++--- builder/validator.go | 14 +-- core/state/metrics.go | 2 +- core/state/statedb.go | 2 +- core/txpool/subpool.go | 3 +- eth/block-validation/api.go | 151 ++++++++++++++++-------------- eth/block-validation/api_test.go | 20 ++-- eth/handler_eth_test.go | 2 +- flashbotsextra/database.go | 10 +- flashbotsextra/database_test.go | 4 +- go.mod | 22 ++--- go.sum | 48 +++++----- miner/algo_common.go | 4 +- miner/algo_common_test.go | 8 +- miner/algo_test.go | 2 +- miner/ordering.go | 26 +++--- miner/worker.go | 10 +- 24 files changed, 331 insertions(+), 287 deletions(-) diff --git a/beacon/engine/types.go b/beacon/engine/types.go index 4c6cb7a1ad..ab396c7a30 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -17,15 +17,19 @@ package engine import ( + "crypto/sha256" "fmt" "math/big" + denebapi "github.com/attestantio/go-builder-client/api/deneb" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" ) @@ -279,17 +283,39 @@ type ExecutionPayloadBodyV1 struct { Withdrawals []*types.Withdrawal `json:"withdrawals"` } -func ExecutionPayloadToBlock(payload *bellatrix.ExecutionPayload) (*types.Block, error) { - // TODO: consolidate this into one function that handles all forks - transactionBytes := make([][]byte, len(payload.Transactions)) +func ExecutionPayloadV1ToBlock(payload *bellatrix.ExecutionPayload) (*types.Block, error) { + // base fee per gas is stored little-endian but we need it + // big-endian for big.Int. + var baseFeePerGasBytes [32]byte + for i := 0; i < 32; i++ { + baseFeePerGasBytes[i] = payload.BaseFeePerGas[32-1-i] + } + baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBytes[:]) + + txs := make([][]byte, len(payload.Transactions)) for i, txHexBytes := range payload.Transactions { - transactionBytes[i] = txHexBytes[:] + txs[i] = txHexBytes } - txs, err := decodeTransactions(transactionBytes) - if err != nil { - return nil, err + executableData := ExecutableData{ + ParentHash: common.Hash(payload.ParentHash), + FeeRecipient: common.Address(payload.FeeRecipient), + StateRoot: common.Hash(payload.StateRoot), + ReceiptsRoot: common.Hash(payload.ReceiptsRoot), + LogsBloom: payload.LogsBloom[:], + Random: common.Hash(payload.PrevRandao), + Number: payload.BlockNumber, + GasLimit: payload.GasLimit, + GasUsed: payload.GasUsed, + Timestamp: payload.Timestamp, + ExtraData: payload.ExtraData, + BaseFeePerGas: baseFeePerGas, + BlockHash: common.Hash(payload.BlockHash), + Transactions: txs, } + return ExecutableDataToBlock(executableData, nil) +} +func ExecutionPayloadV2ToBlock(payload *capella.ExecutionPayload) (*types.Block, error) { // base fee per gas is stored little-endian but we need it // big-endian for big.Int. var baseFeePerGasBytes [32]byte @@ -298,36 +324,44 @@ func ExecutionPayloadToBlock(payload *bellatrix.ExecutionPayload) (*types.Block, } baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBytes[:]) - header := &types.Header{ - ParentHash: common.Hash(payload.ParentHash), - UncleHash: types.EmptyUncleHash, - Coinbase: common.Address(payload.FeeRecipient), - Root: common.Hash(payload.StateRoot), - TxHash: types.DeriveSha(types.Transactions(txs), trie.NewStackTrie(nil)), - ReceiptHash: common.Hash(payload.ReceiptsRoot), - Bloom: types.BytesToBloom(payload.LogsBloom[:]), - Difficulty: common.Big0, - Number: new(big.Int).SetUint64(payload.BlockNumber), - GasLimit: payload.GasLimit, - GasUsed: payload.GasUsed, - Time: payload.Timestamp, - BaseFee: baseFeePerGas, - Extra: payload.ExtraData, - MixDigest: common.Hash(payload.PrevRandao), + txs := make([][]byte, len(payload.Transactions)) + for i, txHexBytes := range payload.Transactions { + txs[i] = txHexBytes } - block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */) - return block, nil + + withdrawals := make([]*types.Withdrawal, len(payload.Withdrawals)) + for i, withdrawal := range payload.Withdrawals { + withdrawals[i] = &types.Withdrawal{ + Index: uint64(withdrawal.Index), + Validator: uint64(withdrawal.ValidatorIndex), + Address: common.Address(withdrawal.Address), + Amount: uint64(withdrawal.Amount), + } + } + executableData := ExecutableData{ + ParentHash: common.Hash(payload.ParentHash), + FeeRecipient: common.Address(payload.FeeRecipient), + StateRoot: common.Hash(payload.StateRoot), + ReceiptsRoot: common.Hash(payload.ReceiptsRoot), + LogsBloom: payload.LogsBloom[:], + Random: common.Hash(payload.PrevRandao), + Number: payload.BlockNumber, + GasLimit: payload.GasLimit, + GasUsed: payload.GasUsed, + Timestamp: payload.Timestamp, + ExtraData: payload.ExtraData, + BaseFeePerGas: baseFeePerGas, + BlockHash: common.Hash(payload.BlockHash), + Transactions: txs, + Withdrawals: withdrawals, + } + return ExecutableDataToBlock(executableData, nil) } -func ExecutionPayloadV2ToBlock(payload *capella.ExecutionPayload) (*types.Block, error) { - // TODO: separate decode function to avoid allocating twice - transactionBytes := make([][]byte, len(payload.Transactions)) +func ExecutionPayloadV3ToBlock(payload *deneb.ExecutionPayload, blobsBundle *denebapi.BlobsBundle) (*types.Block, error) { + txs := make([][]byte, len(payload.Transactions)) for i, txHexBytes := range payload.Transactions { - transactionBytes[i] = txHexBytes[:] - } - txs, err := decodeTransactions(transactionBytes) - if err != nil { - return nil, err + txs[i] = txHexBytes } withdrawals := make([]*types.Withdrawal, len(payload.Withdrawals)) @@ -339,34 +373,36 @@ func ExecutionPayloadV2ToBlock(payload *capella.ExecutionPayload) (*types.Block, Amount: uint64(withdrawal.Amount), } } - withdrawalsHash := types.DeriveSha(types.Withdrawals(withdrawals), trie.NewStackTrie(nil)) - // base fee per gas is stored little-endian but we need it - // big-endian for big.Int. - var baseFeePerGasBytes [32]byte - for i := 0; i < 32; i++ { - baseFeePerGasBytes[i] = payload.BaseFeePerGas[32-1-i] + hasher := sha256.New() + versionedHashes := make([]common.Hash, len(blobsBundle.Commitments)) + for i, commitment := range blobsBundle.Commitments { + hasher.Write(commitment[:]) + hash := hasher.Sum(nil) + hasher.Reset() + + var vhash common.Hash + vhash[0] = params.BlobTxHashVersion + copy(vhash[1:], hash[1:]) + versionedHashes[i] = vhash } - baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBytes[:]) - header := &types.Header{ - ParentHash: common.Hash(payload.ParentHash), - UncleHash: types.EmptyUncleHash, - Coinbase: common.Address(payload.FeeRecipient), - Root: common.Hash(payload.StateRoot), - TxHash: types.DeriveSha(types.Transactions(txs), trie.NewStackTrie(nil)), - ReceiptHash: common.Hash(payload.ReceiptsRoot), - Bloom: types.BytesToBloom(payload.LogsBloom[:]), - Difficulty: common.Big0, - Number: new(big.Int).SetUint64(payload.BlockNumber), - GasLimit: payload.GasLimit, - GasUsed: payload.GasUsed, - Time: payload.Timestamp, - BaseFee: baseFeePerGas, - Extra: payload.ExtraData, - MixDigest: common.Hash(payload.PrevRandao), - WithdrawalsHash: &withdrawalsHash, + executableData := ExecutableData{ + ParentHash: common.Hash(payload.ParentHash), + FeeRecipient: common.Address(payload.FeeRecipient), + StateRoot: common.Hash(payload.StateRoot), + ReceiptsRoot: common.Hash(payload.ReceiptsRoot), + LogsBloom: payload.LogsBloom[:], + Random: common.Hash(payload.PrevRandao), + Number: payload.BlockNumber, + GasLimit: payload.GasLimit, + GasUsed: payload.GasUsed, + Timestamp: payload.Timestamp, + ExtraData: payload.ExtraData, + BaseFeePerGas: payload.BaseFeePerGas.ToBig(), + BlockHash: common.Hash(payload.BlockHash), + Transactions: txs, + Withdrawals: withdrawals, } - block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(withdrawals) - return block, nil + return ExecutableDataToBlock(executableData, versionedHashes) } diff --git a/builder/builder.go b/builder/builder.go index 1cb61a7a2a..b7dfe33d04 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -9,9 +9,9 @@ import ( "sync" "time" - bellatrixapi "github.com/attestantio/go-builder-client/api/bellatrix" - capellaapi "github.com/attestantio/go-builder-client/api/capella" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -46,8 +46,8 @@ type ValidatorData struct { } type IRelay interface { - SubmitBlock(msg *bellatrixapi.SubmitBlockRequest, vd ValidatorData) error - SubmitBlockCapella(msg *capellaapi.SubmitBlockRequest, vd ValidatorData) error + SubmitBlock(msg *builderApiBellatrix.SubmitBlockRequest, vd ValidatorData) error + SubmitBlockCapella(msg *builderApiCapella.SubmitBlockRequest, vd ValidatorData) error GetValidatorForSlot(nextSlot uint64) (ValidatorData, error) Config() RelayConfig Start() error @@ -235,7 +235,7 @@ func (b *Builder) submitBellatrixBlock(block *types.Block, blockValue *big.Int, return err } - blockBidMsg := apiv1.BidTrace{ + blockBidMsg := builderApiV1.BidTrace{ Slot: attrs.Slot, ParentHash: payload.ParentHash, BlockHash: payload.BlockHash, @@ -253,7 +253,7 @@ func (b *Builder) submitBellatrixBlock(block *types.Block, blockValue *big.Int, return err } - blockSubmitReq := bellatrixapi.SubmitBlockRequest{ + blockSubmitReq := builderApiBellatrix.SubmitBlockRequest{ Signature: signature, Message: &blockBidMsg, ExecutionPayload: payload, @@ -294,7 +294,7 @@ func (b *Builder) submitCapellaBlock(block *types.Block, blockValue *big.Int, or return err } - blockBidMsg := apiv1.BidTrace{ + blockBidMsg := builderApiV1.BidTrace{ Slot: attrs.Slot, ParentHash: payload.ParentHash, BlockHash: payload.BlockHash, @@ -312,7 +312,7 @@ func (b *Builder) submitCapellaBlock(block *types.Block, blockValue *big.Int, or return err } - blockSubmitReq := capellaapi.SubmitBlockRequest{ + blockSubmitReq := builderApiCapella.SubmitBlockRequest{ Signature: signature, Message: &blockBidMsg, ExecutionPayload: payload, diff --git a/builder/builder_test.go b/builder/builder_test.go index 3d3793f49f..ba38d15a35 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/ethereum/go-ethereum/beacon/engine" @@ -102,7 +102,7 @@ func TestOnPayloadAttributes(t *testing.T) { expectedProposerPubkey, err := utils.HexToPubkey(testBeacon.validator.Pk.String()) require.NoError(t, err) - expectedMessage := apiv1.BidTrace{ + expectedMessage := builderApiV1.BidTrace{ Slot: uint64(25), ParentHash: phase0.Hash32{0x02, 0x03}, BuilderPubkey: builder.builderPublicKey, diff --git a/builder/local_relay.go b/builder/local_relay.go index 9c2abef78c..479bdbe632 100644 --- a/builder/local_relay.go +++ b/builder/local_relay.go @@ -12,16 +12,16 @@ import ( "sync" "time" - "github.com/attestantio/go-builder-client/api" - bellatrixapi "github.com/attestantio/go-builder-client/api/bellatrix" - capellaapi "github.com/attestantio/go-builder-client/api/capella" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-builder-client/spec" - apiv1bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix" - consensusspec "github.com/attestantio/go-eth2-client/spec" + builderApi "github.com/attestantio/go-builder-client/api" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderCapellaApi "github.com/attestantio/go-builder-client/api/capella" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" + builderSpec "github.com/attestantio/go-builder-client/spec" + eth2ApiV1Bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix" + "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/phase0" - bellatrixutil "github.com/attestantio/go-eth2-client/util/bellatrix" + eth2UtilBellatrix "github.com/attestantio/go-eth2-client/util/bellatrix" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/flashbots/go-boost-utils/bls" @@ -110,12 +110,12 @@ func (r *LocalRelay) Stop() { r.beaconClient.Stop() } -func (r *LocalRelay) SubmitBlock(msg *bellatrixapi.SubmitBlockRequest, _ ValidatorData) error { +func (r *LocalRelay) SubmitBlock(msg *builderApiBellatrix.SubmitBlockRequest, _ ValidatorData) error { log.Info("submitting block to local relay", "block", msg.ExecutionPayload.BlockHash.String()) return r.submitBlock(msg) } -func (r *LocalRelay) SubmitBlockCapella(msg *capellaapi.SubmitBlockRequest, _ ValidatorData) error { +func (r *LocalRelay) SubmitBlockCapella(msg *builderCapellaApi.SubmitBlockRequest, _ ValidatorData) error { log.Info("submitting block to local relay", "block", msg.ExecutionPayload.BlockHash.String()) return r.submitBlockCapella(msg) @@ -127,11 +127,11 @@ func (r *LocalRelay) Config() RelayConfig { } // TODO: local relay support for capella -func (r *LocalRelay) submitBlockCapella(msg *capellaapi.SubmitBlockRequest) error { +func (r *LocalRelay) submitBlockCapella(msg *builderCapellaApi.SubmitBlockRequest) error { return nil } -func (r *LocalRelay) submitBlock(msg *bellatrixapi.SubmitBlockRequest) error { +func (r *LocalRelay) submitBlock(msg *builderApiBellatrix.SubmitBlockRequest) error { header, err := PayloadToPayloadHeader(msg.ExecutionPayload) if err != nil { log.Error("could not convert payload to header", "err", err) @@ -148,7 +148,7 @@ func (r *LocalRelay) submitBlock(msg *bellatrixapi.SubmitBlockRequest) error { } func (r *LocalRelay) handleRegisterValidator(w http.ResponseWriter, req *http.Request) { - payload := []apiv1.SignedValidatorRegistration{} + payload := []builderApiV1.SignedValidatorRegistration{} if err := json.NewDecoder(req.Body).Decode(&payload); err != nil { log.Error("could not decode payload", "err", err) respondError(w, http.StatusBadRequest, "invalid payload") @@ -278,7 +278,7 @@ func (r *LocalRelay) handleGetHeader(w http.ResponseWriter, req *http.Request) { return } - bid := bellatrixapi.BuilderBid{ + bid := builderApiBellatrix.BuilderBid{ Header: bestHeader, Value: profit, Pubkey: r.relayPublicKey, @@ -289,9 +289,9 @@ func (r *LocalRelay) handleGetHeader(w http.ResponseWriter, req *http.Request) { return } - response := &spec.VersionedSignedBuilderBid{ - Version: consensusspec.DataVersionBellatrix, - Bellatrix: &bellatrixapi.SignedBuilderBid{Message: &bid, Signature: signature}, + response := &builderSpec.VersionedSignedBuilderBid{ + Version: spec.DataVersionBellatrix, + Bellatrix: &builderApiBellatrix.SignedBuilderBid{Message: &bid, Signature: signature}, } w.Header().Set("Content-Type", "application/json") @@ -303,7 +303,7 @@ func (r *LocalRelay) handleGetHeader(w http.ResponseWriter, req *http.Request) { } func (r *LocalRelay) handleGetPayload(w http.ResponseWriter, req *http.Request) { - payload := new(apiv1bellatrix.SignedBlindedBeaconBlock) + payload := new(eth2ApiV1Bellatrix.SignedBlindedBeaconBlock) if err := json.NewDecoder(req.Body).Decode(&payload); err != nil { log.Error("failed to decode payload", "error", err) respondError(w, http.StatusBadRequest, "invalid payload") @@ -356,8 +356,8 @@ func (r *LocalRelay) handleGetPayload(w http.ResponseWriter, req *http.Request) return } - response := &api.VersionedExecutionPayload{ - Version: consensusspec.DataVersionBellatrix, + response := &builderApi.VersionedExecutionPayload{ + Version: spec.DataVersionBellatrix, Bellatrix: bestPayload, } @@ -442,7 +442,7 @@ func PayloadToPayloadHeader(p *bellatrix.ExecutionPayload) (*bellatrix.Execution var txs []bellatrix.Transaction txs = append(txs, p.Transactions...) - transactions := bellatrixutil.ExecutionPayloadTransactions{Transactions: txs} + transactions := eth2UtilBellatrix.ExecutionPayloadTransactions{Transactions: txs} txroot, err := transactions.HashTreeRoot() if err != nil { return nil, err diff --git a/builder/local_relay_test.go b/builder/local_relay_test.go index 29943b1ac8..bc92656b5c 100644 --- a/builder/local_relay_test.go +++ b/builder/local_relay_test.go @@ -11,10 +11,10 @@ import ( "time" "github.com/attestantio/go-builder-client/api" - bellatrixapi "github.com/attestantio/go-builder-client/api/bellatrix" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-builder-client/spec" - consensusapiv1bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" + builderSpec "github.com/attestantio/go-builder-client/spec" + eth2ApiV1Bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix" "github.com/attestantio/go-eth2-client/spec/altair" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -102,12 +102,12 @@ func TestValidatorRegistration(t *testing.T) { // TODO: cover all errors } -func prepareRegistrationMessage(t *testing.T, domain phase0.Domain, v *ValidatorPrivateData) ([]apiv1.SignedValidatorRegistration, error) { +func prepareRegistrationMessage(t *testing.T, domain phase0.Domain, v *ValidatorPrivateData) ([]builderApiV1.SignedValidatorRegistration, error) { var pubkey phase0.BLSPubKey copy(pubkey[:], v.Pk) require.Equal(t, []byte(v.Pk), pubkey[:]) - msg := apiv1.ValidatorRegistration{ + msg := builderApiV1.ValidatorRegistration{ FeeRecipient: bellatrix.ExecutionAddress{0x42}, GasLimit: 15_000_000, Timestamp: time.Now(), @@ -117,7 +117,7 @@ func prepareRegistrationMessage(t *testing.T, domain phase0.Domain, v *Validator signature, err := v.Sign(&msg, domain) require.NoError(t, err) - return []apiv1.SignedValidatorRegistration{{ + return []builderApiV1.SignedValidatorRegistration{{ Message: &msg, Signature: signature, }}, nil @@ -172,7 +172,7 @@ func TestGetHeader(t *testing.T) { rr = testRequest(t, relay, "GET", path, nil) require.Equal(t, http.StatusOK, rr.Code) - bid := new(spec.VersionedSignedBuilderBid) + bid := new(builderSpec.VersionedSignedBuilderBid) err = json.Unmarshal(rr.Body.Bytes(), bid) require.NoError(t, err) @@ -182,7 +182,7 @@ func TestGetHeader(t *testing.T) { require.NoError(t, err) expectedValue, ok := uint256.FromBig(forkchoiceBlockProfit) require.False(t, ok) - require.EqualValues(t, &bellatrixapi.BuilderBid{ + require.EqualValues(t, &builderApiBellatrix.BuilderBid{ Header: expectedHeader, Value: expectedValue, Pubkey: backend.builderPublicKey, @@ -220,7 +220,7 @@ func TestGetPayload(t *testing.T) { rr := testRequest(t, relay, "GET", path, nil) require.Equal(t, http.StatusOK, rr.Code) - bid := new(spec.VersionedSignedBuilderBid) + bid := new(builderSpec.VersionedSignedBuilderBid) err = json.Unmarshal(rr.Body.Bytes(), bid) require.NoError(t, err) @@ -228,12 +228,12 @@ func TestGetPayload(t *testing.T) { syncCommitteeBits := [64]byte{0x07} // Create request payload - msg := &consensusapiv1bellatrix.BlindedBeaconBlock{ + msg := ð2ApiV1Bellatrix.BlindedBeaconBlock{ Slot: 1, ProposerIndex: 2, ParentRoot: phase0.Root{0x03}, StateRoot: phase0.Root{0x04}, - Body: &consensusapiv1bellatrix.BlindedBeaconBlockBody{ + Body: ð2ApiV1Bellatrix.BlindedBeaconBlockBody{ ETH1Data: &phase0.ETH1Data{ DepositRoot: phase0.Root{0x05}, DepositCount: 5, @@ -257,7 +257,7 @@ func TestGetPayload(t *testing.T) { require.NoError(t, err) // Call getPayload with invalid signature - rr = testRequest(t, relay, "POST", "/eth/v1/builder/blinded_blocks", &consensusapiv1bellatrix.SignedBlindedBeaconBlock{ + rr = testRequest(t, relay, "POST", "/eth/v1/builder/blinded_blocks", ð2ApiV1Bellatrix.SignedBlindedBeaconBlock{ Message: msg, Signature: phase0.BLSSignature{0x09}, }) @@ -265,7 +265,7 @@ func TestGetPayload(t *testing.T) { require.Equal(t, `{"code":400,"message":"invalid signature"}`+"\n", rr.Body.String()) // Call getPayload with correct signature - rr = testRequest(t, relay, "POST", "/eth/v1/builder/blinded_blocks", &consensusapiv1bellatrix.SignedBlindedBeaconBlock{ + rr = testRequest(t, relay, "POST", "/eth/v1/builder/blinded_blocks", ð2ApiV1Bellatrix.SignedBlindedBeaconBlock{ Message: msg, Signature: signature, }) diff --git a/builder/relay.go b/builder/relay.go index a28fe1e71c..2088fbf29b 100644 --- a/builder/relay.go +++ b/builder/relay.go @@ -9,8 +9,8 @@ import ( "sync" "time" - "github.com/attestantio/go-builder-client/api/bellatrix" - "github.com/attestantio/go-builder-client/api/capella" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" "github.com/ethereum/go-ethereum/log" "github.com/flashbots/go-boost-utils/utils" ) @@ -134,7 +134,7 @@ func (r *RemoteRelay) Start() error { func (r *RemoteRelay) Stop() {} -func (r *RemoteRelay) SubmitBlock(msg *bellatrix.SubmitBlockRequest, _ ValidatorData) error { +func (r *RemoteRelay) SubmitBlock(msg *builderApiBellatrix.SubmitBlockRequest, _ ValidatorData) error { log.Info("submitting block to remote relay", "endpoint", r.config.Endpoint) endpoint := r.config.Endpoint + "/relay/v1/builder/blocks" if r.cancellationsEnabled { @@ -155,7 +155,7 @@ func (r *RemoteRelay) SubmitBlock(msg *bellatrix.SubmitBlockRequest, _ Validator return nil } -func (r *RemoteRelay) SubmitBlockCapella(msg *capella.SubmitBlockRequest, _ ValidatorData) error { +func (r *RemoteRelay) SubmitBlockCapella(msg *builderApiCapella.SubmitBlockRequest, _ ValidatorData) error { log.Info("submitting block to remote relay", "endpoint", r.config.Endpoint) endpoint := r.config.Endpoint + "/relay/v1/builder/blocks" diff --git a/builder/relay_aggregator.go b/builder/relay_aggregator.go index 12f6f62c13..8ecfb15cb8 100644 --- a/builder/relay_aggregator.go +++ b/builder/relay_aggregator.go @@ -5,8 +5,8 @@ import ( "fmt" "sync" - "github.com/attestantio/go-builder-client/api/bellatrix" - "github.com/attestantio/go-builder-client/api/capella" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" "github.com/ethereum/go-ethereum/log" ) @@ -41,7 +41,7 @@ func (r *RemoteRelayAggregator) Stop() { } } -func (r *RemoteRelayAggregator) SubmitBlock(msg *bellatrix.SubmitBlockRequest, registration ValidatorData) error { +func (r *RemoteRelayAggregator) SubmitBlock(msg *builderApiBellatrix.SubmitBlockRequest, registration ValidatorData) error { r.registrationsCacheLock.RLock() defer r.registrationsCacheLock.RUnlock() @@ -61,7 +61,7 @@ func (r *RemoteRelayAggregator) SubmitBlock(msg *bellatrix.SubmitBlockRequest, r return nil } -func (r *RemoteRelayAggregator) SubmitBlockCapella(msg *capella.SubmitBlockRequest, registration ValidatorData) error { +func (r *RemoteRelayAggregator) SubmitBlockCapella(msg *builderApiCapella.SubmitBlockRequest, registration ValidatorData) error { r.registrationsCacheLock.RLock() defer r.registrationsCacheLock.RUnlock() diff --git a/builder/relay_aggregator_test.go b/builder/relay_aggregator_test.go index d46533e49a..15d840ac57 100644 --- a/builder/relay_aggregator_test.go +++ b/builder/relay_aggregator_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/attestantio/go-builder-client/api/bellatrix" - "github.com/attestantio/go-builder-client/api/capella" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" "github.com/stretchr/testify/require" ) @@ -22,10 +22,10 @@ type testRelay struct { gvsErr error requestedSlot uint64 - submittedMsg *bellatrix.SubmitBlockRequest - submittedMsgCh chan *bellatrix.SubmitBlockRequest - submittedMsgCapella *capella.SubmitBlockRequest - submittedMsgChCapella chan *capella.SubmitBlockRequest + submittedMsg *builderApiBellatrix.SubmitBlockRequest + submittedMsgCh chan *builderApiBellatrix.SubmitBlockRequest + submittedMsgCapella *builderApiCapella.SubmitBlockRequest + submittedMsgChCapella chan *builderApiCapella.SubmitBlockRequest } type testRelayAggBackend struct { @@ -46,7 +46,7 @@ func newTestRelayAggBackend(numRelay int) *testRelayAggBackend { return &testRelayAggBackend{testRelays, ragg} } -func (r *testRelay) SubmitBlock(msg *bellatrix.SubmitBlockRequest, registration ValidatorData) error { +func (r *testRelay) SubmitBlock(msg *builderApiBellatrix.SubmitBlockRequest, registration ValidatorData) error { if r.submittedMsgCh != nil { select { case r.submittedMsgCh <- msg: @@ -57,7 +57,7 @@ func (r *testRelay) SubmitBlock(msg *bellatrix.SubmitBlockRequest, registration return r.sbError } -func (r *testRelay) SubmitBlockCapella(msg *capella.SubmitBlockRequest, registration ValidatorData) error { +func (r *testRelay) SubmitBlockCapella(msg *builderApiCapella.SubmitBlockRequest, registration ValidatorData) error { if r.submittedMsgCh != nil { select { case r.submittedMsgChCapella <- msg: @@ -145,7 +145,7 @@ func TestRemoteRelayAggregator(t *testing.T) { time.Sleep(10 * time.Millisecond) // if submitting for unseen VD should error out - msg := &bellatrix.SubmitBlockRequest{} + msg := &builderApiBellatrix.SubmitBlockRequest{} err = backend.ragg.SubmitBlock(msg, ValidatorData{GasLimit: 40}) require.Error(t, err) }) @@ -166,12 +166,12 @@ func TestRemoteRelayAggregator(t *testing.T) { time.Sleep(10 * time.Millisecond) // if submitting for unseen VD should error out - msg := &bellatrix.SubmitBlockRequest{} + msg := &builderApiBellatrix.SubmitBlockRequest{} err = backend.ragg.SubmitBlock(msg, ValidatorData{GasLimit: 40}) require.Error(t, err) // should submit to the single pirmary if its the only one matching - backend.relays[0].submittedMsgCh = make(chan *bellatrix.SubmitBlockRequest, 1) + backend.relays[0].submittedMsgCh = make(chan *builderApiBellatrix.SubmitBlockRequest, 1) err = backend.ragg.SubmitBlock(msg, ValidatorData{GasLimit: 10}) require.NoError(t, err) select { @@ -212,9 +212,9 @@ func TestRemoteRelayAggregator(t *testing.T) { time.Sleep(10 * time.Millisecond) // should submit to multiple matching relays - backend.relays[0].submittedMsgCh = make(chan *bellatrix.SubmitBlockRequest, 1) - backend.relays[2].submittedMsgCh = make(chan *bellatrix.SubmitBlockRequest, 1) - msg := &bellatrix.SubmitBlockRequest{} + backend.relays[0].submittedMsgCh = make(chan *builderApiBellatrix.SubmitBlockRequest, 1) + backend.relays[2].submittedMsgCh = make(chan *builderApiBellatrix.SubmitBlockRequest, 1) + msg := &builderApiBellatrix.SubmitBlockRequest{} err = backend.ragg.SubmitBlock(msg, ValidatorData{GasLimit: 10}) require.Error(t, err) diff --git a/builder/validator.go b/builder/validator.go index 9adcc51493..66aa4da5cd 100644 --- a/builder/validator.go +++ b/builder/validator.go @@ -4,7 +4,7 @@ import ( "errors" "time" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/flashbots/go-boost-utils/bls" @@ -29,19 +29,19 @@ func (v *ValidatorPrivateData) Sign(msg ssz.ObjWithHashTreeRoot, d phase0.Domain return ssz.SignMessage(msg, d, v.sk) } -func (v *ValidatorPrivateData) PrepareRegistrationMessage(feeRecipientHex string) (apiv1.SignedValidatorRegistration, error) { +func (v *ValidatorPrivateData) PrepareRegistrationMessage(feeRecipientHex string) (builderApiV1.SignedValidatorRegistration, error) { address, err := utils.HexToAddress(feeRecipientHex) if err != nil { - return apiv1.SignedValidatorRegistration{}, err + return builderApiV1.SignedValidatorRegistration{}, err } if len(v.Pk) != 48 { - return apiv1.SignedValidatorRegistration{}, errors.New("invalid public key") + return builderApiV1.SignedValidatorRegistration{}, errors.New("invalid public key") } pubkey := phase0.BLSPubKey{} copy(pubkey[:], v.Pk) - msg := &apiv1.ValidatorRegistration{ + msg := &builderApiV1.ValidatorRegistration{ FeeRecipient: address, GasLimit: 1000, Timestamp: time.Now(), @@ -49,7 +49,7 @@ func (v *ValidatorPrivateData) PrepareRegistrationMessage(feeRecipientHex string } signature, err := v.Sign(msg, ssz.DomainBuilder) if err != nil { - return apiv1.SignedValidatorRegistration{}, err + return builderApiV1.SignedValidatorRegistration{}, err } - return apiv1.SignedValidatorRegistration{Message: msg, Signature: signature}, nil + return builderApiV1.SignedValidatorRegistration{Message: msg, Signature: signature}, nil } diff --git a/core/state/metrics.go b/core/state/metrics.go index ac5f70d4e7..d487356fc8 100644 --- a/core/state/metrics.go +++ b/core/state/metrics.go @@ -30,7 +30,7 @@ var ( stateCopyMeter = metrics.NewRegisteredMeter("state/copy", nil) stateSnapshotMeter = metrics.NewRegisteredMeter("state/snapshot", nil) - + slotDeletionMaxCount = metrics.NewRegisteredGauge("state/delete/storage/max/slot", nil) slotDeletionMaxSize = metrics.NewRegisteredGauge("state/delete/storage/max/size", nil) slotDeletionTimer = metrics.NewRegisteredResettingTimer("state/delete/storage/timer", nil) diff --git a/core/state/statedb.go b/core/state/statedb.go index fee64c19ec..69b087f01e 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -864,7 +864,7 @@ func (s *StateDB) Copy() *StateDB { if metrics.EnabledBuilder { stateCopyMeter.Mark(1) } - + return state } diff --git a/core/txpool/subpool.go b/core/txpool/subpool.go index 8276725adf..a629ec9d58 100644 --- a/core/txpool/subpool.go +++ b/core/txpool/subpool.go @@ -107,7 +107,7 @@ type SubPool interface { Add(txs []*Transaction, local bool, sync bool, private bool) []error // AddMevBundle adds a mev bundle to the pool. - AddMevBundle(bundle types.MevBundle) error + AddMevBundle(bundle types.MevBundle) error AddMevBundles(bundles []types.MevBundle) error @@ -127,7 +127,6 @@ type SubPool interface { RegisterBundleFetcher(fetcher IFetcher) - // Pending retrieves all currently processable transactions, grouped by origin // account and sorted by nonce. Pending(enforceTips bool) map[common.Address][]*LazyTransaction diff --git a/eth/block-validation/api.go b/eth/block-validation/api.go index 47b96f846d..de8d0b79bc 100644 --- a/eth/block-validation/api.go +++ b/eth/block-validation/api.go @@ -7,13 +7,16 @@ import ( "math/big" "os" - bellatrixapi "github.com/attestantio/go-builder-client/api/bellatrix" - capellaapi "github.com/attestantio/go-builder-client/api/capella" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" + builderApiDeneb "github.com/attestantio/go-builder-client/api/deneb" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/ethereum/go-ethereum/beacon/engine" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/log" @@ -130,7 +133,7 @@ func NewBlockValidationAPI(eth *eth.Ethereum, accessVerifier *AccessVerifier, fo } type BuilderBlockValidationRequest struct { - bellatrixapi.SubmitBlockRequest + builderApiBellatrix.SubmitBlockRequest RegisteredGasLimit uint64 `json:"registered_gas_limit,string"` } @@ -142,67 +145,16 @@ func (api *BlockValidationAPI) ValidateBuilderSubmissionV1(params *BuilderBlockV return errors.New("nil execution payload") } payload := params.ExecutionPayload - block, err := engine.ExecutionPayloadToBlock(payload) + block, err := engine.ExecutionPayloadV1ToBlock(payload) if err != nil { return err } - if params.Message.ParentHash != phase0.Hash32(block.ParentHash()) { - return fmt.Errorf("incorrect ParentHash %s, expected %s", params.Message.ParentHash.String(), block.ParentHash().String()) - } - - if params.Message.BlockHash != phase0.Hash32(block.Hash()) { - return fmt.Errorf("incorrect BlockHash %s, expected %s", params.Message.BlockHash.String(), block.Hash().String()) - } - - if params.Message.GasLimit != block.GasLimit() { - return fmt.Errorf("incorrect GasLimit %d, expected %d", params.Message.GasLimit, block.GasLimit()) - } - - if params.Message.GasUsed != block.GasUsed() { - return fmt.Errorf("incorrect GasUsed %d, expected %d", params.Message.GasUsed, block.GasUsed()) - } - - feeRecipient := common.BytesToAddress(params.Message.ProposerFeeRecipient[:]) - expectedProfit := params.Message.Value.ToBig() - - var vmconfig vm.Config - var tracer *logger.AccessListTracer = nil - if api.accessVerifier != nil { - if err := api.accessVerifier.isBlacklisted(block.Coinbase()); err != nil { - return err - } - if err := api.accessVerifier.isBlacklisted(feeRecipient); err != nil { - return err - } - if err := api.accessVerifier.verifyTransactions(types.LatestSigner(api.eth.BlockChain().Config()), block.Transactions()); err != nil { - return err - } - isPostMerge := true // the call is PoS-native - timestamp := params.SubmitBlockRequest.ExecutionPayload.Timestamp - precompiles := vm.ActivePrecompiles(api.eth.APIBackend.ChainConfig().Rules(new(big.Int).SetUint64(params.ExecutionPayload.BlockNumber), isPostMerge, timestamp)) - tracer = logger.NewAccessListTracer(nil, common.Address{}, common.Address{}, precompiles) - vmconfig = vm.Config{Tracer: tracer} - } - - err = api.eth.BlockChain().ValidatePayload(block, feeRecipient, expectedProfit, params.RegisteredGasLimit, vmconfig, api.forceLastTxPayment) - if err != nil { - log.Error("invalid payload", "hash", payload.BlockHash.String(), "number", payload.BlockNumber, "parentHash", payload.ParentHash.String(), "err", err) - return err - } - - if api.accessVerifier != nil && tracer != nil { - if err := api.accessVerifier.verifyTraces(tracer); err != nil { - return err - } - } - - log.Info("validated block", "hash", block.Hash(), "number", block.NumberU64(), "parentHash", block.ParentHash()) - return nil + return api.validateBlock(block, params.Message, params.RegisteredGasLimit) } type BuilderBlockValidationRequestV2 struct { - capellaapi.SubmitBlockRequest + builderApiCapella.SubmitBlockRequest RegisteredGasLimit uint64 `json:"registered_gas_limit,string"` WithdrawalsRoot common.Hash `json:"withdrawals_root"` } @@ -219,7 +171,7 @@ func (r *BuilderBlockValidationRequestV2) UnmarshalJSON(data []byte) error { r.RegisteredGasLimit = params.RegisteredGasLimit r.WithdrawalsRoot = params.WithdrawalsRoot - blockRequest := new(capellaapi.SubmitBlockRequest) + blockRequest := new(builderApiCapella.SubmitBlockRequest) err = json.Unmarshal(data, &blockRequest) if err != nil { return err @@ -240,24 +192,53 @@ func (api *BlockValidationAPI) ValidateBuilderSubmissionV2(params *BuilderBlockV return err } - if params.Message.ParentHash != phase0.Hash32(block.ParentHash()) { - return fmt.Errorf("incorrect ParentHash %s, expected %s", params.Message.ParentHash.String(), block.ParentHash().String()) + return api.validateBlock(block, params.Message, params.RegisteredGasLimit) +} + +type BuilderBlockValidationRequestV3 struct { + builderApiDeneb.SubmitBlockRequest + RegisteredGasLimit uint64 `json:"registered_gas_limit,string"` +} + +func (api *BlockValidationAPI) ValidateBuilderSubmissionV3(params *BuilderBlockValidationRequestV3) error { + // TODO: fuzztest, make sure the validation is sound + payload := params.ExecutionPayload + blobsBundle := params.BlobsBundle + block, err := engine.ExecutionPayloadV3ToBlock(payload, blobsBundle) + if err != nil { + return err } - if params.Message.BlockHash != phase0.Hash32(block.Hash()) { - return fmt.Errorf("incorrect BlockHash %s, expected %s", params.Message.BlockHash.String(), block.Hash().String()) + err = api.validateBlock(block, params.Message, params.RegisteredGasLimit) + if err != nil { + return err } + err = validateBlobsBundle(block.Transactions(), blobsBundle) + if err != nil { + return err + } + return nil +} - if params.Message.GasLimit != block.GasLimit() { - return fmt.Errorf("incorrect GasLimit %d, expected %d", params.Message.GasLimit, block.GasLimit()) +func (api *BlockValidationAPI) validateBlock(block *types.Block, msg *builderApiV1.BidTrace, registeredGasLimit uint64) error { + if msg.ParentHash != phase0.Hash32(block.ParentHash()) { + return fmt.Errorf("incorrect ParentHash %s, expected %s", msg.ParentHash.String(), block.ParentHash().String()) } - if params.Message.GasUsed != block.GasUsed() { - return fmt.Errorf("incorrect GasUsed %d, expected %d", params.Message.GasUsed, block.GasUsed()) + if msg.BlockHash != phase0.Hash32(block.Hash()) { + return fmt.Errorf("incorrect BlockHash %s, expected %s", msg.BlockHash.String(), block.Hash().String()) } - feeRecipient := common.BytesToAddress(params.Message.ProposerFeeRecipient[:]) - expectedProfit := params.Message.Value.ToBig() + if msg.GasLimit != block.GasLimit() { + return fmt.Errorf("incorrect GasLimit %d, expected %d", msg.GasLimit, block.GasLimit()) + } + + if msg.GasUsed != block.GasUsed() { + return fmt.Errorf("incorrect GasUsed %d, expected %d", msg.GasUsed, block.GasUsed()) + } + + feeRecipient := common.BytesToAddress(msg.ProposerFeeRecipient[:]) + expectedProfit := msg.Value.ToBig() var vmconfig vm.Config var tracer *logger.AccessListTracer = nil @@ -272,14 +253,14 @@ func (api *BlockValidationAPI) ValidateBuilderSubmissionV2(params *BuilderBlockV return err } isPostMerge := true // the call is PoS-native - precompiles := vm.ActivePrecompiles(api.eth.APIBackend.ChainConfig().Rules(new(big.Int).SetUint64(params.ExecutionPayload.BlockNumber), isPostMerge, params.ExecutionPayload.Timestamp)) + precompiles := vm.ActivePrecompiles(api.eth.APIBackend.ChainConfig().Rules(new(big.Int).SetUint64(block.NumberU64()), isPostMerge, block.Time())) tracer = logger.NewAccessListTracer(nil, common.Address{}, common.Address{}, precompiles) vmconfig = vm.Config{Tracer: tracer} } - err = api.eth.BlockChain().ValidatePayload(block, feeRecipient, expectedProfit, params.RegisteredGasLimit, vmconfig, api.forceLastTxPayment) + err := api.eth.BlockChain().ValidatePayload(block, feeRecipient, expectedProfit, registeredGasLimit, vmconfig, api.forceLastTxPayment) if err != nil { - log.Error("invalid payload", "hash", payload.BlockHash.String(), "number", payload.BlockNumber, "parentHash", payload.ParentHash.String(), "err", err) + log.Error("invalid payload", "hash", msg.BlockHash.String(), "number", block.NumberU64(), "parentHash", msg.ParentHash.String(), "err", err) return err } @@ -292,3 +273,31 @@ func (api *BlockValidationAPI) ValidateBuilderSubmissionV2(params *BuilderBlockV log.Info("validated block", "hash", block.Hash(), "number", block.NumberU64(), "parentHash", block.ParentHash()) return nil } + +func validateBlobsBundle(txs types.Transactions, blobsBundle *builderApiDeneb.BlobsBundle) error { + var hashes []common.Hash + for _, tx := range txs { + hashes = append(hashes, tx.BlobHashes()...) + + } + blobs := blobsBundle.Blobs + commits := blobsBundle.Commitments + proofs := blobsBundle.Proofs + + if len(blobs) != len(hashes) { + return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(blobs), len(hashes)) + } + if len(commits) != len(hashes) { + return fmt.Errorf("invalid number of %d blob commitments compared to %d blob hashes", len(commits), len(hashes)) + } + if len(proofs) != len(hashes) { + return fmt.Errorf("invalid number of %d blob proofs compared to %d blob hashes", len(proofs), len(hashes)) + } + + for i := range blobs { + if err := kzg4844.VerifyBlobProof(kzg4844.Blob(blobs[i]), kzg4844.Commitment(commits[i]), kzg4844.Proof(proofs[i])); err != nil { + return fmt.Errorf("invalid blob %d: %v", i, err) + } + } + return nil +} diff --git a/eth/block-validation/api_test.go b/eth/block-validation/api_test.go index acc142172d..55550e58e2 100644 --- a/eth/block-validation/api_test.go +++ b/eth/block-validation/api_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - bellatrixapi "github.com/attestantio/go-builder-client/api/bellatrix" - capellaapi "github.com/attestantio/go-builder-client/api/capella" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiBellatrix "github.com/attestantio/go-builder-client/api/bellatrix" + builderApiCapella "github.com/attestantio/go-builder-client/api/capella" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -102,9 +102,9 @@ func TestValidateBuilderSubmissionV1(t *testing.T) { copy(proposerAddr[:], testValidatorAddr[:]) blockRequest := &BuilderBlockValidationRequest{ - SubmitBlockRequest: bellatrixapi.SubmitBlockRequest{ + SubmitBlockRequest: builderApiBellatrix.SubmitBlockRequest{ Signature: phase0.BLSSignature{}, - Message: &apiv1.BidTrace{ + Message: &builderApiV1.BidTrace{ ParentHash: phase0.Hash32(execData.ParentHash), BlockHash: phase0.Hash32(execData.BlockHash), ProposerFeeRecipient: proposerAddr, @@ -230,9 +230,9 @@ func TestValidateBuilderSubmissionV2(t *testing.T) { copy(proposerAddr[:], testValidatorAddr.Bytes()) blockRequest := &BuilderBlockValidationRequestV2{ - SubmitBlockRequest: capellaapi.SubmitBlockRequest{ + SubmitBlockRequest: builderApiCapella.SubmitBlockRequest{ Signature: phase0.BLSSignature{}, - Message: &apiv1.BidTrace{ + Message: &builderApiV1.BidTrace{ ParentHash: phase0.Hash32(execData.ParentHash), BlockHash: phase0.Hash32(execData.BlockHash), ProposerFeeRecipient: proposerAddr, @@ -302,7 +302,7 @@ func TestValidateBuilderSubmissionV2(t *testing.T) { } func updatePayloadHash(t *testing.T, blockRequest *BuilderBlockValidationRequest) { - updatedBlock, err := engine.ExecutionPayloadToBlock(blockRequest.ExecutionPayload) + updatedBlock, err := engine.ExecutionPayloadV1ToBlock(blockRequest.ExecutionPayload) require.NoError(t, err) copy(blockRequest.Message.BlockHash[:], updatedBlock.Hash().Bytes()[:32]) } @@ -596,9 +596,9 @@ func executableDataToBlockValidationRequest(execData *engine.ExecutableData, pro return nil, errors.New("could not convert value to uint256") } blockRequest := &BuilderBlockValidationRequestV2{ - SubmitBlockRequest: capellaapi.SubmitBlockRequest{ + SubmitBlockRequest: builderApiCapella.SubmitBlockRequest{ Signature: phase0.BLSSignature{}, - Message: &apiv1.BidTrace{ + Message: &builderApiV1.BidTrace{ ParentHash: phase0.Hash32(execData.ParentHash), BlockHash: phase0.Hash32(execData.BlockHash), ProposerFeeRecipient: proposerAddr, diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 1db9477f0d..e135fc6ef5 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -316,7 +316,7 @@ func testSendTransactions(t *testing.T, protocol uint) { insert[nonce] = &txpool.Transaction{Tx: tx} } go handler.txpool.Add(insert, false, false, false) // Need goroutine to not block on feed - time.Sleep(250 * time.Millisecond) // Wait until tx events get out of the system (can't use events, tx broadcaster races with peer join) + time.Sleep(250 * time.Millisecond) // Wait until tx events get out of the system (can't use events, tx broadcaster races with peer join) // Create a source handler to send messages through and a sink peer to receive them p2pSrc, p2pSink := p2p.MsgPipe() diff --git a/flashbotsextra/database.go b/flashbotsextra/database.go index d39274e974..7b2b983b9c 100644 --- a/flashbotsextra/database.go +++ b/flashbotsextra/database.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" @@ -23,14 +23,14 @@ type IDatabaseService interface { ConsumeBuiltBlock(block *types.Block, blockValue *big.Int, OrdersClosedAt time.Time, sealedAt time.Time, commitedBundles []types.SimulatedBundle, allBundles []types.SimulatedBundle, usedSbundles []types.UsedSBundle, - bidTrace *apiv1.BidTrace) + bidTrace *builderApiV1.BidTrace) GetPriorityBundles(ctx context.Context, blockNum int64, isHighPrio bool) ([]DbBundle, error) GetLatestUuidBundles(ctx context.Context, blockNum int64) ([]types.LatestUuidBundle, error) } type NilDbService struct{} -func (NilDbService) ConsumeBuiltBlock(block *types.Block, _ *big.Int, _ time.Time, _ time.Time, _ []types.SimulatedBundle, _ []types.SimulatedBundle, _ []types.UsedSBundle, _ *apiv1.BidTrace) { +func (NilDbService) ConsumeBuiltBlock(block *types.Block, _ *big.Int, _ time.Time, _ time.Time, _ []types.SimulatedBundle, _ []types.SimulatedBundle, _ []types.UsedSBundle, _ *builderApiV1.BidTrace) { } func (NilDbService) GetPriorityBundles(ctx context.Context, blockNum int64, isHighPrio bool) ([]DbBundle, error) { @@ -172,7 +172,7 @@ func (ds *DatabaseService) getBundleIdsAndInsertMissingBundles(ctx context.Conte return bundleIdsMap, nil } -func (ds *DatabaseService) insertBuildBlock(tx *sqlx.Tx, ctx context.Context, block *types.Block, blockValue *big.Int, bidTrace *apiv1.BidTrace, ordersClosedAt time.Time, sealedAt time.Time) (uint64, error) { +func (ds *DatabaseService) insertBuildBlock(tx *sqlx.Tx, ctx context.Context, block *types.Block, blockValue *big.Int, bidTrace *builderApiV1.BidTrace, ordersClosedAt time.Time, sealedAt time.Time) (uint64, error) { blockData := BuiltBlock{ BlockNumber: block.NumberU64(), Profit: new(big.Rat).SetFrac(blockValue, big.NewInt(1e18)).FloatString(18), @@ -247,7 +247,7 @@ func (ds *DatabaseService) insertUsedSBundleIds(tx *sqlx.Tx, ctx context.Context func (ds *DatabaseService) ConsumeBuiltBlock(block *types.Block, blockValue *big.Int, ordersClosedAt time.Time, sealedAt time.Time, commitedBundles []types.SimulatedBundle, allBundles []types.SimulatedBundle, usedSbundles []types.UsedSBundle, - bidTrace *apiv1.BidTrace) { + bidTrace *builderApiV1.BidTrace) { ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second) defer cancel() diff --git a/flashbotsextra/database_test.go b/flashbotsextra/database_test.go index 232ab4c3b1..fa463d99f6 100644 --- a/flashbotsextra/database_test.go +++ b/flashbotsextra/database_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + builderApiV1 "github.com/attestantio/go-builder-client/api/v1" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" @@ -120,7 +120,7 @@ func TestDatabaseBlockInsertion(t *testing.T) { Success: true, } - bidTrace := &apiv1.BidTrace{} + bidTrace := &builderApiV1.BidTrace{} ocAt := time.Now().Add(-time.Hour).UTC() sealedAt := time.Now().Add(-30 * time.Minute).UTC() diff --git a/go.mod b/go.mod index 5a097fa201..6c82db4274 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.19 require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 github.com/VictoriaMetrics/fastcache v1.6.0 - github.com/attestantio/go-builder-client v0.3.0 - github.com/attestantio/go-eth2-client v0.16.3 + github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1 + github.com/attestantio/go-eth2-client v0.18.0 github.com/aws/aws-sdk-go-v2 v1.2.0 github.com/aws/aws-sdk-go-v2/config v1.1.1 github.com/aws/aws-sdk-go-v2/credentials v1.1.1 @@ -33,7 +33,7 @@ require ( github.com/go-stack/stack v1.8.1 github.com/gofrs/flock v0.8.1 github.com/golang-jwt/jwt/v4 v4.3.0 - github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf v1.5.3 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa github.com/google/uuid v1.3.0 @@ -63,17 +63,17 @@ require ( github.com/rs/cors v1.7.0 github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible github.com/status-im/keycard-go v0.2.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 github.com/supranational/blst v0.3.11 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tyler-smith/go-bip39 v1.1.0 github.com/urfave/cli/v2 v2.24.1 go.uber.org/automaxprocs v1.5.2 - golang.org/x/crypto v0.9.0 + golang.org/x/crypto v0.10.0 golang.org/x/exp v0.0.0-20230810033253-352e893a4cad golang.org/x/sync v0.3.0 golang.org/x/sys v0.9.0 - golang.org/x/text v0.9.0 + golang.org/x/text v0.10.0 golang.org/x/time v0.3.0 golang.org/x/tools v0.9.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 @@ -135,13 +135,13 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/common v0.42.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc - github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect @@ -150,7 +150,7 @@ require ( golang.org/x/mod v0.11.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index e9b1f43a35..29a9310eb0 100644 --- a/go.sum +++ b/go.sum @@ -22,10 +22,10 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/attestantio/go-builder-client v0.3.0 h1:NY7pUNT070T3tx/N8hCaO5KpExvaVQhH//9zsgRh43M= -github.com/attestantio/go-builder-client v0.3.0/go.mod h1:DwesMTOqnCp4u+n3uZ+fWL8wwnSBZVD9VMIVPDR+AZE= -github.com/attestantio/go-eth2-client v0.16.3 h1:D6LLwswDlHbUwsAqfBKaKXjWdBzRlNQRXUoC+5vFsDw= -github.com/attestantio/go-eth2-client v0.16.3/go.mod h1:Om16oH+H34E2JHoOY8hLWg+64twlO+AjAE7kkK3f1Xc= +github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1 h1:c6Jmkd6mryaFuWv2/Pa4aLqi+2QOv3gEN+Krj0Nmiq4= +github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1/go.mod h1:8NZx9L/rC7nLhSMbbVR6PXr37tC28wTE4u65n+Pa3BQ= +github.com/attestantio/go-eth2-client v0.18.0 h1:W8/d6Fa0SvgwO6ybcEwBiRZP1yaUCq7JlvMHHAx3O6Q= +github.com/attestantio/go-eth2-client v0.18.0/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0= github.com/aws/aws-sdk-go-v2 v1.2.0 h1:BS+UYpbsElC82gB+2E2jiCBg36i8HlubTB/dO/moQ9c= github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2/config v1.1.1 h1:ZAoq32boMzcaTW9bcUacBswAmHTbvlvDJICgHFZuECo= @@ -218,8 +218,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= @@ -264,6 +265,8 @@ github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iU github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc= +github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= @@ -417,15 +420,15 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7 h1:cZC+usqsYgHtlBaGulVnZ1hfKAi8iWtujBnRLQE698c= github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7/go.mod h1:IToEjHuttnUzwZI5KBSM/LOOW3qLbbrHOEfp3SbECGY= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw= @@ -434,8 +437,9 @@ github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc h1:zAsgcP8MhzAbhMnB1QQ2 github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc/go.mod h1:S8xSOnV3CgpNrWd0GQ/OoQfMtlg2uPRSuTzcSGrzwK8= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -461,17 +465,13 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -532,8 +532,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU= golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= @@ -645,8 +645,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= @@ -698,8 +698,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/miner/algo_common.go b/miner/algo_common.go index 0fc9e49a9c..ac54ba371a 100644 --- a/miner/algo_common.go +++ b/miner/algo_common.go @@ -586,8 +586,8 @@ func (envDiff *environmentDiff) commitSBundleInner( var ( totalProfit *big.Int = new(big.Int) refundableProfit *big.Int = new(big.Int) - coinbaseDelta = new(big.Int) - coinbaseBefore *big.Int + coinbaseDelta = new(big.Int) + coinbaseBefore *big.Int ) // insert body and check it for i, el := range b.Body { diff --git a/miner/algo_common_test.go b/miner/algo_common_test.go index 233b017e1a..289a76904f 100644 --- a/miner/algo_common_test.go +++ b/miner/algo_common_test.go @@ -213,10 +213,10 @@ func newEnvironment(data chainData, state *state.StateDB, coinbase common.Addres currentBlock := data.chain.CurrentBlock() // Note the passed coinbase may be different with header.Coinbase. return &environment{ - signer: types.MakeSigner(data.chainConfig, currentBlock.Number, currentBlock.Time), - state: state, - gasPool: new(core.GasPool).AddGas(gasLimit), - coinbase: coinbase, + signer: types.MakeSigner(data.chainConfig, currentBlock.Number, currentBlock.Time), + state: state, + gasPool: new(core.GasPool).AddGas(gasLimit), + coinbase: coinbase, header: &types.Header{ Coinbase: coinbase, ParentHash: currentBlock.Hash(), diff --git a/miner/algo_test.go b/miner/algo_test.go index fbaa8726e7..dbbdb4fa10 100644 --- a/miner/algo_test.go +++ b/miner/algo_test.go @@ -265,7 +265,7 @@ func BenchmarkAlgo(b *testing.B) { for addr, txs := range txPool { for _, tx := range txs { txPoolCopy[addr] = append(txPoolCopy[addr], &txpool.LazyTransaction{ - Pool: tx.Pool, + Pool: tx.Pool, Hash: tx.Hash, Tx: tx.Tx, Time: tx.Time, diff --git a/miner/ordering.go b/miner/ordering.go index e123ba5345..eaa4201f19 100644 --- a/miner/ordering.go +++ b/miner/ordering.go @@ -36,7 +36,7 @@ type _TxOrder struct { tx *txpool.LazyTransaction } -func (o _TxOrder) AsTx() *txpool.LazyTransaction { return o.tx } +func (o _TxOrder) AsTx() *txpool.LazyTransaction { return o.tx } func (o _TxOrder) AsBundle() *types.SimulatedBundle { return nil } func (o _TxOrder) AsSBundle() *types.SimSBundle { return nil } @@ -44,7 +44,7 @@ type _BundleOrder struct { bundle *types.SimulatedBundle } -func (o _BundleOrder) AsTx() *txpool.LazyTransaction { return nil } +func (o _BundleOrder) AsTx() *txpool.LazyTransaction { return nil } func (o _BundleOrder) AsBundle() *types.SimulatedBundle { return o.bundle } func (o _BundleOrder) AsSBundle() *types.SimSBundle { return nil } @@ -52,15 +52,15 @@ type _SBundleOrder struct { sbundle *types.SimSBundle } -func (o _SBundleOrder) AsTx() *txpool.LazyTransaction { return nil } +func (o _SBundleOrder) AsTx() *txpool.LazyTransaction { return nil } func (o _SBundleOrder) AsBundle() *types.SimulatedBundle { return nil } func (o _SBundleOrder) AsSBundle() *types.SimSBundle { return o.sbundle } // txWithMinerFee wraps a transaction with its gas price or effective miner gasTipCap type txWithMinerFee struct { - order _Order - from common.Address - fees *big.Int + order _Order + from common.Address + fees *big.Int } func (t *txWithMinerFee) Tx() *txpool.LazyTransaction { @@ -117,8 +117,8 @@ func (t *txWithMinerFee) SetProfit(profit *big.Int) { func newBundleWithMinerFee(bundle *types.SimulatedBundle) (*txWithMinerFee, error) { minerFee := bundle.MevGasPrice return &txWithMinerFee{ - order: _BundleOrder{bundle}, - fees: minerFee, + order: _BundleOrder{bundle}, + fees: minerFee, }, nil } @@ -126,8 +126,8 @@ func newBundleWithMinerFee(bundle *types.SimulatedBundle) (*txWithMinerFee, erro func newSBundleWithMinerFee(sbundle *types.SimSBundle) (*txWithMinerFee, error) { minerFee := sbundle.MevGasPrice return &txWithMinerFee{ - order: _SBundleOrder{sbundle}, - fees: minerFee, + order: _SBundleOrder{sbundle}, + fees: minerFee, }, nil } @@ -144,8 +144,8 @@ func newTxWithMinerFee(tx *txpool.LazyTransaction, from common.Address, baseFee } return &txWithMinerFee{ order: _TxOrder{tx}, - from: from, - fees: tip, + from: from, + fees: tip, }, nil } @@ -196,7 +196,7 @@ type transactionsByPriceAndNonce struct { func newTransactionsByPriceAndNonce(signer types.Signer, txs map[common.Address][]*txpool.LazyTransaction, bundles []types.SimulatedBundle, sbundles []*types.SimSBundle, baseFee *big.Int) *transactionsByPriceAndNonce { // Initialize a price and received time based heap with the head transactions heads := make(txByPriceAndTime, 0, len(txs)) - + for i := range sbundles { wrapped, err := newSBundleWithMinerFee(sbundles[i]) if err != nil { diff --git a/miner/worker.go b/miner/worker.go index 7d94e79b65..d8e2f0fb6f 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -93,7 +93,7 @@ type environment struct { gasPool *core.GasPool // available gas used to pack transactions coinbase common.Address - profit *big.Int + profit *big.Int header *types.Header txs []*types.Transaction @@ -109,7 +109,7 @@ func (env *environment) copy() *environment { coinbase: env.coinbase, header: types.CopyHeader(env.header), receipts: copyReceipts(env.receipts), - profit: new(big.Int).Set(env.profit), + profit: new(big.Int).Set(env.profit), } if env.gasPool != nil { gasPool := *env.gasPool @@ -805,8 +805,8 @@ func (w *worker) makeEnv(parent *types.Header, header *types.Header, coinbase co state: state, coinbase: coinbase, header: header, - profit: new(big.Int), - } + profit: new(big.Int), + } // Keep track of transactions which return errors so they can be removed env.tcount = 0 env.gasPool = new(core.GasPool).AddGas(header.GasLimit) @@ -912,7 +912,7 @@ func (w *worker) commitBundle(env *environment, txs []*txpool.Transaction, inter // It's important to copy then .SetTxContext() - don't reorder. env.state.SetTxContext(tx.Tx.Hash(), env.tcount) - + logs, err := w.commitTransaction(env, tx) switch { case errors.Is(err, core.ErrGasLimitReached):