@@ -37,6 +37,7 @@ import (
3737 "github.com/ethereum/go-ethereum/core/state"
3838 "github.com/ethereum/go-ethereum/core/types"
3939 "github.com/ethereum/go-ethereum/crypto"
40+ "github.com/ethereum/go-ethereum/eth/tracers/logger"
4041 "github.com/ethereum/go-ethereum/event"
4142 "github.com/ethereum/go-ethereum/log"
4243 "github.com/ethereum/go-ethereum/params"
@@ -210,6 +211,7 @@ type worker struct {
210211 engine consensus.Engine
211212 eth Backend
212213 chain * core.BlockChain
214+ blockList map [common.Address ]struct {}
213215
214216 // Feeds
215217 pendingLogsFeed event.Feed
@@ -330,6 +332,11 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
330332 }()
331333 }
332334
335+ blockList := make (map [common.Address ]struct {})
336+ for _ , address := range config .Blocklist {
337+ blockList [address ] = struct {}{}
338+ }
339+
333340 worker := & worker {
334341 config : config ,
335342 chainConfig : chainConfig ,
@@ -957,18 +964,47 @@ func (w *worker) updateSnapshot(env *environment) {
957964}
958965
959966func (w * worker ) commitTransaction (env * environment , tx * types.Transaction ) ([]* types.Log , error ) {
960- snap := env .state .Snapshot ()
967+ gasPool := * env .gasPool
968+ envGasUsed := env .header .GasUsed
969+ var stateDB * state.StateDB
970+ if len (w .blockList ) != 0 {
971+ stateDB = env .state .Copy ()
972+ } else {
973+ stateDB = env .state
974+ }
975+
976+ snapshot := stateDB .Snapshot ()
961977
962978 gasPrice , err := tx .EffectiveGasTip (env .header .BaseFee )
963979 if err != nil {
964980 return nil , err
965981 }
966982
967- receipt , err := core .ApplyTransaction (w .chainConfig , w .chain , & env .coinbase , env .gasPool , env .state , env .header , tx , & env .header .GasUsed , * w .chain .GetVMConfig ())
983+ var tracer * logger.AccountTouchTracer
984+ config := * w .chain .GetVMConfig ()
985+ if len (w .blockList ) != 0 {
986+ tracer = logger .NewAccountTouchTracer ()
987+ config .Tracer = tracer
988+ config .Debug = true
989+ }
990+
991+ receipt , err := core .ApplyTransaction (w .chainConfig , w .chain , & env .coinbase , & gasPool , stateDB , env .header , tx , & envGasUsed , config )
968992 if err != nil {
969- env . state . RevertToSnapshot (snap )
993+ stateDB . RevertToSnapshot (snapshot )
970994 return nil , err
971995 }
996+ if len (w .blockList ) != 0 {
997+ for _ , address := range tracer .TouchedAddresses () {
998+ if _ , in := w .blockList [address ]; in {
999+ return nil , errBlocklistViolation
1000+ }
1001+ }
1002+ }
1003+
1004+ * env .gasPool = gasPool
1005+ env .header .GasUsed = envGasUsed
1006+ env .state = stateDB
1007+
9721008 env .txs = append (env .txs , tx )
9731009 env .receipts = append (env .receipts , receipt )
9741010
@@ -1390,6 +1426,7 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, *big.Int, e
13901426 log .Warn ("Block building is interrupted" , "allowance" , common .PrettyDuration (w .newpayloadTimeout ))
13911427 }
13921428 blockBundles = mergedBundles
1429+ log .Info ("Filled block with transactions" , "time" , time .Since (start ), "gas used" , work .header .GasUsed )
13931430 }
13941431 block , err := w .engine .FinalizeAndAssemble (w .chain , work .header , work .state , work .txs , work .unclelist (), work .receipts , params .withdrawals )
13951432 if err != nil {
@@ -1669,13 +1706,27 @@ func (w *worker) computeBundleGas(env *environment, bundle types.MevBundle, stat
16691706 state .Prepare (tx .Hash (), i + currentTxCount )
16701707 coinbaseBalanceBefore := state .GetBalance (env .coinbase )
16711708
1672- receipt , err := core .ApplyTransaction (w .chainConfig , w .chain , & env .coinbase , gasPool , state , env .header , tx , & tempGasUsed , * w .chain .GetVMConfig ())
1709+ config := * w .chain .GetVMConfig ()
1710+ var tracer * logger.AccountTouchTracer
1711+ if len (w .blockList ) != 0 {
1712+ tracer = logger .NewAccountTouchTracer ()
1713+ config .Tracer = tracer
1714+ config .Debug = true
1715+ }
1716+ receipt , err := core .ApplyTransaction (w .chainConfig , w .chain , & env .coinbase , gasPool , state , env .header , tx , & tempGasUsed , config )
16731717 if err != nil {
16741718 return simulatedBundle {}, err
16751719 }
16761720 if receipt .Status == types .ReceiptStatusFailed && ! containsHash (bundle .RevertingTxHashes , receipt .TxHash ) {
16771721 return simulatedBundle {}, errors .New ("failed tx" )
16781722 }
1723+ if len (w .blockList ) != 0 {
1724+ for _ , address := range tracer .TouchedAddresses () {
1725+ if _ , in := w .blockList [address ]; in {
1726+ return simulatedBundle {}, errBlocklistViolation
1727+ }
1728+ }
1729+ }
16791730
16801731 totalGasUsed += receipt .GasUsed
16811732
0 commit comments