Skip to content

Commit 2e855b3

Browse files
committed
Discard reverting megabundle blocks and head change interrupted blocks (#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
1 parent 5c4037b commit 2e855b3

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

.github/workflows/go.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,31 @@ jobs:
5656
path: e2e
5757

5858
- run: cd e2e && yarn install
59-
- run: |
59+
- name: Run single node e2e
60+
run: |
6061
cd e2e
6162
GETH=`pwd`/../build/bin/geth ./run.sh &
6263
sleep 15
6364
yarn run demo-simple
65+
yarn run e2e-reverting-bundles
6466
yarn run demo-contract
67+
pkill -9 geth || true
68+
- name: Run private tx with two nodes
69+
run: |
70+
cd e2e
71+
GETH=`pwd`/../build/bin/geth ./run.sh &
72+
# Second node, not mining
73+
P2P_PORT=30302 DATADIR=datadir2 HTTP_PORT=8546 MINER_ARGS='--nodiscover' GETH=`pwd`/../build/bin/geth ./run.sh &
74+
sleep 15
75+
DATADIR1=datadir DATADIR2=datadir2 GETH=`pwd`/../build/bin/geth ./peer_nodes.sh
76+
sleep 15
6577
yarn run demo-private-tx
78+
pkill -9 geth || true
79+
- name: Run megabundle-only node checking for reverts
80+
run: |
81+
cd e2e
82+
# Disable bundle workers
83+
MINER_ARGS='--miner.etherbase=0xd912aecb07e9f4e1ea8e6b4779e7fb6aa1c3e4d8 --miner.trustedrelays=0xfb11e78C4DaFec86237c2862441817701fdf197F --mine --miner.threads=2 --miner.maxmergedbundles=0' GETH=`pwd`/../build/bin/geth ./run.sh &
84+
sleep 15
85+
yarn run e2e-reverting-megabundle
86+
pkill -9 geth || true

miner/worker.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,7 @@ func (w *worker) commitBundle(env *environment, txs types.Transactions, interrup
945945
// (1) new head block event arrival, the interrupt signal is 1
946946
// (2) worker start or restart, the interrupt signal is 1
947947
// (3) worker recreate the sealing block with any newly arrived transactions, the interrupt signal is 2.
948-
// For the first two cases, the semi-finished work will be discarded.
949-
// For the third case, the semi-finished work will be submitted to the consensus engine.
948+
// Discard the interrupted work, since it is incomplete and contains partial bundles
950949
if interrupt != nil && atomic.LoadInt32(interrupt) != commitInterruptNone {
951950
// Notify resubmit loop to increase resubmitting interval due to too frequent commits.
952951
if atomic.LoadInt32(interrupt) == commitInterruptResubmit {
@@ -961,10 +960,11 @@ func (w *worker) commitBundle(env *environment, txs types.Transactions, interrup
961960
}
962961
return errBundleInterrupted
963962
}
964-
// If we don't have enough gas for any further transactions then we're done
963+
// If we don't have enough gas for any further transactions discard the block
964+
// since not all bundles of the were applied
965965
if env.gasPool.Gas() < params.TxGas {
966966
log.Trace("Not enough gas for further transactions", "have", env.gasPool, "want", params.TxGas)
967-
break
967+
return errCouldNotApplyTransaction
968968
}
969969

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

15471547
for _, bundle := range bundles {
1548-
state := env.state.Copy()
1549-
gasPool := new(core.GasPool).AddGas(env.header.GasLimit)
15501548
if len(bundle.Txs) == 0 {
15511549
continue
15521550
}
1551+
state := env.state.Copy()
1552+
gasPool := new(core.GasPool).AddGas(env.header.GasLimit)
15531553
simmed, err := w.computeBundleGas(env, bundle, state, gasPool, pendingTxs, 0)
15541554

15551555
if err != nil {

0 commit comments

Comments
 (0)