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

Increase sync size to 1s to avoid hitting 429 too many requests issue #21

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
eb4d322
Implement geth-embedded builder API
Ruteri Apr 28, 2022
3c0d5f1
Adjust transactions root computation (#3)
Ruteri Jun 2, 2022
0211eab
Adjust logsBloom encoding (#4)
Ruteri Jun 2, 2022
6fbef37
Adjust base fee encoding (#5)
Ruteri Jun 3, 2022
b67d952
Allow resending of the same validator registration (#7)
Ruteri Jun 7, 2022
28fd947
Adjust value encoding (#9)
Ruteri Jun 10, 2022
3f12831
Adjust gas limit calculation (#8)
Ruteri Jun 10, 2022
0b356f2
Show builder pubkey on index page (#10)
Ruteri Jun 10, 2022
ab55c8c
Add remote relay connection for getting validator data (#11)
Ruteri Jul 21, 2022
69168ab
Run builder even if cannot connect to remote relay (#12)
Ruteri Jul 25, 2022
2cbfc71
Add GasUsed and GasLimit to bid trace (#13)
Ruteri Jul 29, 2022
1357e20
Upgrade github.com/btcsuite/btcd (#14)
Ruteri Aug 1, 2022
b06509e
Fix lint issues (#15)
Ruteri Aug 1, 2022
74375b1
Update README.md (#16)
thINKoor Aug 2, 2022
32a7206
Add block build trigger from beacon node api (#17)
avalonche Aug 11, 2022
7a6d33d
Addjust profit calculation and use the blocks channel directly
Ruteri Aug 11, 2022
262f18c
Add more explicit builder flags and other QoL improvements (#20)
Ruteri Aug 16, 2022
9d24d68
Resubmit block build job periodically (#22)
Ruteri Aug 25, 2022
f248ccb
Implement proposer payment via transaction (#23)
bhakiyakalimuthu Aug 11, 2022
b87888e
Base block profit on the proposer payment instead of balance differen…
Ruteri Aug 31, 2022
1633a5d
Flashbots change up to v0.3
jparyani Oct 27, 2021
7c424df
Flashbots changes v0.3 to v0.4
bogatyy Oct 27, 2021
4ea7e11
Flashbots changes v0.4 to v0.5
Ruteri Feb 21, 2022
70a26aa
Private Transaction API Sample (v1.10.13)
xcarlo Nov 29, 2021
a3d99c2
Remove private transactions that are confirmed in blocks
Jan 28, 2022
6fe1708
Run private transactions e2e tests in ci
Ruteri Feb 24, 2022
231448f
Discard reverting megabundle blocks and head change interrupted block…
Ruteri Mar 30, 2022
997e95b
Seal the best block available
Ruteri Jul 29, 2022
913a792
Implement block validation API
Ruteri Aug 17, 2022
e16c69e
Add timeout to e2e
Ruteri Aug 11, 2022
d55f648
Upgrade dependencies
Ruteri Aug 30, 2022
1bc67bd
Only submit blocks that improve profit (#19)
Ruteri Aug 31, 2022
6449811
Remove megabundles as they are no longer needed (#20)
Ruteri Aug 31, 2022
9b27c8a
Implement pushing blocks data to the DB (#18)
Ruteri Aug 31, 2022
74b7659
add miner blocklist (#21)
dvush Sep 1, 2022
624b2df
fix statedb copy (#22)
dvush Sep 2, 2022
a39100e
Rate limit blocks submitted to the relay and DB (#25)
Ruteri Sep 7, 2022
39d4fab
fix proposer payout bug with payout tx (#27)
dvush Sep 13, 2022
04d0def
add other state access to touch tracer (#26)
dvush Sep 13, 2022
ae3e497
init bundle fetcher (#24)
bhakiyakalimuthu Sep 13, 2022
47140e7
increase payment tx gas limit
dvush Sep 15, 2022
78b79f6
do not fetch bundle if empty block num during the starup (#29)
bhakiyakalimuthu Sep 19, 2022
4e08119
Update gas limit in api check (#30)
Ruteri Sep 20, 2022
f4fad7d
set proposer payment to 26k (#31)
dvush Sep 21, 2022
2b1d810
Adjust block number for bundle fetching (#32)
Ruteri Sep 21, 2022
97fa9c1
new greedy builder
dvush Sep 8, 2022
982e38f
sim bundles in parallel (new merger) (#33)
dvush Sep 23, 2022
570b42c
Merge new merger algo and mev-geth
Ruteri Sep 23, 2022
ba76641
Enable portable blst
Ruteri Sep 23, 2022
79c9121
Build on multiple tips (#35)
dvush Sep 28, 2022
fade0b7
better logs (#36)
dvush Sep 28, 2022
e5037ec
squash more annoying logs (#37)
dvush Sep 28, 2022
cee22fa
Logs pt 3 (#38)
dvush Sep 28, 2022
c5dae01
New payment tx (#40)
dvush Oct 5, 2022
dbe3dff
Improvements from greedy improve algo (#41)
Ruteri Oct 7, 2022
9a62829
Do not commit failing payment txs (#43)
Ruteri Oct 11, 2022
baf280f
More bundle visibility (#42)
Ruteri Oct 17, 2022
12041db
Cleanup and include old mev geth prs (#45)
Ruteri Oct 25, 2022
a4fd793
Increase submission rate to 2 blocks per second (#47)
Ruteri Oct 25, 2022
6152cfc
Add disable bundle fetcher flag (#48)
Ruteri Nov 3, 2022
5d7d714
update readme (#49)
dvush Nov 18, 2022
a10a730
Update README.md
metachris Nov 18, 2022
a02f4e0
Merge pull request #1 from flashbots/metachris-patch-1
bertmiller Nov 18, 2022
7379542
Merge changes from validation (#4)
Ruteri Nov 22, 2022
4d1b163
Use snapshots for blocklist revert (#5)
dvush Nov 22, 2022
f4d48be
added contributing.md (#8)
metachris Nov 23, 2022
9ca4d16
cleanup cla (#9)
metachris Nov 23, 2022
6cdb430
Add builder config toml support (#2)
refcell Nov 28, 2022
5d25e8b
Add submitting and requesting registrations from multiple relays
Ruteri Oct 18, 2022
2c80489
Refactor relay aggregator registrations and tests, add better logging
avalonche Nov 29, 2022
2456f57
Fix duplicate relay registrations in cache (#15)
avalonche Dec 5, 2022
c216aca
Improve performance of token compilation (#12)
estensen Dec 6, 2022
e7810b5
Increase submission delay from 0.5s to 1s
madjarevicn Dec 7, 2022
8033129
Merge branch 'main' of https://github.com/DcentraLab/builder
madjarevicn Dec 7, 2022
ff77df3
Set rate to 0.6 secs to avoid rate limit.
madjarevicn Dec 7, 2022
33935a5
Fix
madjarevicn Dec 8, 2022
6b30dbb
Update outdated parts of README (#22)
avalonche Dec 8, 2022
d2b1409
Add log for block.profit
madjarevicn Dec 14, 2022
e34a579
Merge branch 'flashbots:main' into main
madjarevicn Dec 14, 2022
78c823d
Create docker-image.yml
madjarevicn Dec 14, 2022
9d84d2d
Update Dockerfile
madjarevicn Dec 14, 2022
9d21297
updated dockerfile
madjarevicn Dec 14, 2022
2a85eb4
Update Dockerfile
madjarevicn Dec 19, 2022
c582dd0
Updated docker file COPY path.
Miljan9602 Dec 20, 2022
879010a
Merge pull request #1 from Miljan9602/patch-1
madjarevicn Dec 20, 2022
1c9a6a8
Updated dockerfile file
Miljan9602 Dec 21, 2022
0a0f211
Updated docker file with ./
Miljan9602 Dec 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Flashbots change up to v0.3
  • Loading branch information
jparyani authored and Ruteri committed Nov 18, 2022
commit 1633a5d443e867f1afed8a7c0c6739c5a028188d
64 changes: 64 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Go

on:
push:
pull_request:
branches: [ master ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Test
run: go test ./core ./miner/... ./internal/ethapi/... ./les/...

- name: Build
run: make geth

e2e:
name: End to End
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: make geth

- name: Check out the e2e code repo
uses: actions/checkout@v2
with:
repository: flashbots/mev-geth-demo
path: e2e

- run: cd e2e && yarn install
- run: |
cd e2e
GETH=`pwd`/../build/bin/geth ./run.sh &
sleep 15
yarn run demo-simple
yarn run demo-contract
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var (
utils.MinerExtraDataFlag,
utils.MinerRecommitIntervalFlag,
utils.MinerNoVerifyFlag,
utils.MinerMaxMergedBundles,
utils.NATFlag,
utils.NoDiscoverFlag,
utils.DiscoveryV5Flag,
Expand Down
8 changes: 8 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ var (
Usage: "Disable remote sealing verification",
Category: flags.MinerCategory,
}
MinerMaxMergedBundles = &cli.IntFlag{
Name: "miner.maxmergedbundles",
Usage: "flashbots - The maximum amount of bundles to merge. The miner will run this many workers in parallel to calculate if the full block is more profitable with these additional bundles.",
Value: 3,
Category: flags.MinerCategory,
}

// Account settings
UnlockedAccountFlag = &cli.StringFlag{
Expand Down Expand Up @@ -1714,6 +1720,8 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.IsSet(LegacyMinerGasTargetFlag.Name) {
log.Warn("The generic --miner.gastarget flag is deprecated and will be removed in the future!")
}

cfg.MaxMergedBundles = ctx.Int(MinerMaxMergedBundles.Name)
}

func setRequiredBlocks(ctx *cli.Context, cfg *ethconfig.Config) {
Expand Down
64 changes: 59 additions & 5 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,12 @@ type TxPool struct {
locals *accountSet // Set of local transaction to exempt from eviction rules
journal *txJournal // Journal of local transaction to back up to disk

pending map[common.Address]*txList // All currently processable transactions
queue map[common.Address]*txList // Queued but non-processable transactions
beats map[common.Address]time.Time // Last heartbeat from each known account
all *txLookup // All transactions to allow lookups
priced *txPricedList // All transactions sorted by price
pending map[common.Address]*txList // All currently processable transactions
queue map[common.Address]*txList // Queued but non-processable transactions
beats map[common.Address]time.Time // Last heartbeat from each known account
mevBundles []types.MevBundle
all *txLookup // All transactions to allow lookups
priced *txPricedList // All transactions sorted by price

chainHeadCh chan ChainHeadEvent
chainHeadSub event.Subscription
Expand Down Expand Up @@ -557,6 +558,59 @@ func (pool *TxPool) Pending(enforceTips bool) map[common.Address]types.Transacti
return pending
}

/// AllMevBundles returns all the MEV Bundles currently in the pool
func (pool *TxPool) AllMevBundles() []types.MevBundle {
return pool.mevBundles
}

// MevBundles returns a list of bundles valid for the given blockNumber/blockTimestamp
// also prunes bundles that are outdated
func (pool *TxPool) MevBundles(blockNumber *big.Int, blockTimestamp uint64) ([]types.MevBundle, error) {
pool.mu.Lock()
defer pool.mu.Unlock()

// returned values
var ret []types.MevBundle
// rolled over values
var bundles []types.MevBundle

for _, bundle := range pool.mevBundles {
// Prune outdated bundles
if (bundle.MaxTimestamp != 0 && blockTimestamp > bundle.MaxTimestamp) || blockNumber.Cmp(bundle.BlockNumber) > 0 {
continue
}

// Roll over future bundles
if (bundle.MinTimestamp != 0 && blockTimestamp < bundle.MinTimestamp) || blockNumber.Cmp(bundle.BlockNumber) < 0 {
bundles = append(bundles, bundle)
continue
}

// return the ones which are in time
ret = append(ret, bundle)
// keep the bundles around internally until they need to be pruned
bundles = append(bundles, bundle)
}

pool.mevBundles = bundles
return ret, nil
}

// AddMevBundle adds a mev bundle to the pool
func (pool *TxPool) AddMevBundle(txs types.Transactions, blockNumber *big.Int, minTimestamp, maxTimestamp uint64, revertingTxHashes []common.Hash) error {
pool.mu.Lock()
defer pool.mu.Unlock()

pool.mevBundles = append(pool.mevBundles, types.MevBundle{
Txs: txs,
BlockNumber: blockNumber,
MinTimestamp: minTimestamp,
MaxTimestamp: maxTimestamp,
RevertingTxHashes: revertingTxHashes,
})
return nil
}

// Locals retrieves the accounts currently considered local by the pool.
func (pool *TxPool) Locals() []common.Address {
pool.mu.Lock()
Expand Down
8 changes: 8 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,11 @@ func copyAddressPtr(a *common.Address) *common.Address {
cpy := *a
return &cpy
}

type MevBundle struct {
Txs Transactions
BlockNumber *big.Int
MinTimestamp uint64
MaxTimestamp uint64
RevertingTxHashes []common.Hash
}
4 changes: 4 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
return b.eth.txPool.AddLocal(signedTx)
}

func (b *EthAPIBackend) SendBundle(ctx context.Context, txs types.Transactions, blockNumber rpc.BlockNumber, minTimestamp uint64, maxTimestamp uint64, revertingTxHashes []common.Hash) error {
return b.eth.txPool.AddMevBundle(txs, big.NewInt(blockNumber.Int64()), minTimestamp, maxTimestamp, revertingTxHashes)
}

func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error) {
pending := b.eth.txPool.Pending(false)
var txs types.Transactions
Expand Down
23 changes: 23 additions & 0 deletions infra/Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Build Geth in a stock Go builder container
FROM golang:1.15-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

ADD . /go-ethereum
RUN cd /go-ethereum && make geth

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest

ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache groff less python3 curl jq ca-certificates && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools awscli

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

COPY ./infra/start-mev-geth-node.sh /root/start-mev-geth-node.sh
RUN chmod 755 /root/start-mev-geth-node.sh

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["/root/start-mev-geth-node.sh"]
23 changes: 23 additions & 0 deletions infra/Dockerfile.updater
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Build Geth in a stock Go builder container
FROM golang:1.15-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

ADD . /go-ethereum
RUN cd /go-ethereum && make geth

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest

ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache groff less python3 curl jq ca-certificates && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools awscli

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/

COPY ./infra/start-mev-geth-updater.sh /root/start-mev-geth-updater.sh
RUN chmod 755 /root/start-mev-geth-updater.sh

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["/root/start-mev-geth-updater.sh"]
96 changes: 96 additions & 0 deletions infra/start-mev-geth-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/sh -x
# Starts the Mev-Geth node client
# Written by Luke Youngblood, [email protected]

# network=mainnet # normally set by environment
# syncmode=fast # normally set by environment
# rpcport=8545 # normally set by environment
# wsport=8546 # normally set by environment
# netport=30303 # normally set by environment

init_node() {
# You can put any commands you would like to run to initialize the node here.
echo Initializing node...
}

start_node() {
if [ $network = "goerli" ]
then
geth \
--port $netport \
--http \
--http.addr 0.0.0.0 \
--http.port $rpcport \
--http.api eth,net,web3 \
--http.vhosts '*' \
--http.corsdomain '*' \
--graphql \
--graphql.corsdomain '*' \
--graphql.vhosts '*' \
--ws \
--ws.addr 0.0.0.0 \
--ws.port $wsport \
--ws.api eth,net,web3 \
--ws.origins '*' \
--syncmode $syncmode \
--cache 4096 \
--maxpeers $connections \
--goerli
if [ $? -ne 0 ]
then
echo "Node failed to start; exiting."
exit 1
fi
else
geth \
--port $netport \
--http \
--http.addr 0.0.0.0 \
--http.port $rpcport \
--http.api eth,net,web3 \
--http.vhosts '*' \
--http.corsdomain '*' \
--graphql \
--graphql.corsdomain '*' \
--graphql.vhosts '*' \
--ws \
--ws.addr 0.0.0.0 \
--ws.port $wsport \
--ws.api eth,net,web3 \
--ws.origins '*' \
--syncmode $syncmode \
--cache 4096 \
--maxpeers $connections
if [ $? -ne 0 ]
then
echo "Node failed to start; exiting."
exit 1
fi
fi
}

s3_sync() {
# Determine data directory
if [ $network = "goerli" ]
then
datadir=/root/.ethereum/goerli/geth/chaindata
else
datadir=/root/.ethereum/geth/chaindata
fi
# If the current1 key exists, node1 is the most current set of blockchain data
echo "A 404 error below is expected and nothing to be concerned with."
aws s3api head-object --request-payer requester --bucket $chainbucket --key current1
if [ $? -eq 0 ]
then
s3key=node1
else
s3key=node2
fi
aws s3 sync --only-show-errors --request-payer requester --region $region s3://$chainbucket/$s3key $datadir
}

# main

init_node
s3_sync
start_node
Loading