diff --git a/core/types/bundle.go b/core/types/bundle.go index 45cbb797d4..b388d45c5f 100644 --- a/core/types/bundle.go +++ b/core/types/bundle.go @@ -46,6 +46,8 @@ type SimulatedBundle struct { BundleGasPrice *big.Int BundleGasUsed uint64 EthSentToSystem *big.Int + + Err error } func (bundle *Bundle) Size() uint64 { diff --git a/miner/bundle_cache.go b/miner/bundle_cache.go index 54609682c5..73aacf529d 100644 --- a/miner/bundle_cache.go +++ b/miner/bundle_cache.go @@ -79,7 +79,7 @@ func (c *BundleCacheEntry) UpdateSimulatedBundles(result map[common.Hash]*types. bundleHash := bundle.Hash() - if result[bundleHash] != nil { + if result[bundleHash] != nil && result[bundleHash].Err == nil { c.successfulBundles[bundleHash] = result[bundleHash] } else { c.failedBundles[bundleHash] = struct{}{} diff --git a/miner/miner.go b/miner/miner.go index 25dab62171..f0e4a413e3 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -377,5 +377,9 @@ func (miner *Miner) SimulateBundle(bundle *types.Bundle) (*big.Int, error) { return nil, errors.New("no valid sim result") } + if s[0].Err != nil { + return nil, s[0].Err + } + return s[0].BundleGasPrice, nil } diff --git a/miner/worker_builder.go b/miner/worker_builder.go index b264180303..2e5cba3ae6 100644 --- a/miner/worker_builder.go +++ b/miner/worker_builder.go @@ -265,15 +265,22 @@ func (w *worker) generateOrderedBundles( return nil, nil, err } + noErrBundles := make([]*types.SimulatedBundle, 0) + for _, v := range simulatedBundles { + if v.Err == nil { + noErrBundles = append(noErrBundles, v) + } + } + // sort bundles according to fresh gas price - sort.SliceStable(simulatedBundles, func(i, j int) bool { - priceI, priceJ := simulatedBundles[i].BundleGasPrice, simulatedBundles[j].BundleGasPrice + sort.SliceStable(noErrBundles, func(i, j int) bool { + priceI, priceJ := noErrBundles[i].BundleGasPrice, noErrBundles[j].BundleGasPrice return priceI.Cmp(priceJ) >= 0 }) // merge bundles based on iterative state - includedTxs, mergedBundle, err := w.mergeBundles(env, simulatedBundles) + includedTxs, mergedBundle, err := w.mergeBundles(env, noErrBundles) if err != nil { log.Error("fail to merge bundles", "err", err) return nil, nil, err @@ -304,8 +311,8 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]* gasPool := prepareGasPool(env.header.GasLimit) simmed, err := w.simulateBundle(env, bundle, state, gasPool, 0, true, true) if err != nil { + simmed = &types.SimulatedBundle{Err: err} log.Trace("Error computing gas for a simulateBundle", "error", err) - return } mu.Lock()