Skip to content

Commit

Permalink
Discard reverting megabundle blocks and head change interrupted blocks (
Browse files Browse the repository at this point in the history
flashbots#123)

* Discard reverting megabundle blocks and head change interrupted blocks

* Discard all blocks with incomplete bundles

* Run reverting megabundles regression test separately from bundle tests
  • Loading branch information
Ruteri authored and avalonche committed Mar 22, 2023
1 parent 58e2357 commit ed0d05b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,31 @@ jobs:
path: e2e

- run: cd e2e && yarn install
- run: |
- name: Run single node e2e
run: |
cd e2e
GETH=`pwd`/../build/bin/geth ./run.sh &
sleep 15
yarn run demo-simple
yarn run e2e-reverting-bundles
yarn run demo-contract
pkill -9 geth || true
- name: Run private tx with two nodes
run: |
cd e2e
GETH=`pwd`/../build/bin/geth ./run.sh &
# Second node, not mining
P2P_PORT=30302 DATADIR=datadir2 HTTP_PORT=8546 MINER_ARGS='--nodiscover' GETH=`pwd`/../build/bin/geth ./run.sh &
sleep 15
DATADIR1=datadir DATADIR2=datadir2 GETH=`pwd`/../build/bin/geth ./peer_nodes.sh
sleep 15
yarn run demo-private-tx
pkill -9 geth || true
- name: Run megabundle-only node checking for reverts
run: |
cd e2e
# Disable bundle workers
MINER_ARGS='--miner.etherbase=0xd912aecb07e9f4e1ea8e6b4779e7fb6aa1c3e4d8 --miner.trustedrelays=0xfb11e78C4DaFec86237c2862441817701fdf197F --mine --miner.threads=2 --miner.maxmergedbundles=0' GETH=`pwd`/../build/bin/geth ./run.sh &
sleep 15
yarn run e2e-reverting-megabundle
pkill -9 geth || true
12 changes: 6 additions & 6 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,7 @@ func (w *worker) commitBundle(env *environment, txs types.Transactions, interrup
// (1) new head block event arrival, the interrupt signal is 1
// (2) worker start or restart, the interrupt signal is 1
// (3) worker recreate the sealing block with any newly arrived transactions, the interrupt signal is 2.
// For the first two cases, the semi-finished work will be discarded.
// For the third case, the semi-finished work will be submitted to the consensus engine.
// Discard the interrupted work, since it is incomplete and contains partial bundles
if interrupt != nil && atomic.LoadInt32(interrupt) != commitInterruptNone {
// Notify resubmit loop to increase resubmitting interval due to too frequent commits.
if atomic.LoadInt32(interrupt) == commitInterruptResubmit {
Expand All @@ -1018,10 +1017,11 @@ func (w *worker) commitBundle(env *environment, txs types.Transactions, interrup
}
return errBundleInterrupted
}
// If we don't have enough gas for any further transactions then we're done
// If we don't have enough gas for any further transactions discard the block
// since not all bundles of the were applied
if env.gasPool.Gas() < params.TxGas {
log.Trace("Not enough gas for further transactions", "have", env.gasPool, "want", params.TxGas)
break
return errCouldNotApplyTransaction
}

// Error may be ignored here. The error has already been checked
Expand Down Expand Up @@ -1661,11 +1661,11 @@ func (w *worker) simulateBundles(env *environment, bundles []types.MevBundle, pe
simulatedBundles := []simulatedBundle{}

for _, bundle := range bundles {
state := env.state.Copy()
gasPool := new(core.GasPool).AddGas(env.header.GasLimit)
if len(bundle.Txs) == 0 {
continue
}
state := env.state.Copy()
gasPool := new(core.GasPool).AddGas(env.header.GasLimit)
simmed, err := w.computeBundleGas(env, bundle, state, gasPool, pendingTxs, 0)

if err != nil {
Expand Down

0 comments on commit ed0d05b

Please sign in to comment.