Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: return exact result when send bundle" #41

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions core/types/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type SimulatedBundle struct {
BundleGasPrice *big.Int
BundleGasUsed uint64
EthSentToSystem *big.Int

Err error
}

func (bundle *Bundle) Size() uint64 {
Expand Down
2 changes: 1 addition & 1 deletion miner/bundle_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (c *BundleCacheEntry) UpdateSimulatedBundles(result map[common.Hash]*types.

bundleHash := bundle.Hash()

if result[bundleHash] != nil && result[bundleHash].Err == nil {
if result[bundleHash] != nil {
c.successfulBundles[bundleHash] = result[bundleHash]
} else {
c.failedBundles[bundleHash] = struct{}{}
Expand Down
4 changes: 0 additions & 4 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,5 @@ 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
}
15 changes: 4 additions & 11 deletions miner/worker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,22 +265,15 @@ 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(noErrBundles, func(i, j int) bool {
priceI, priceJ := noErrBundles[i].BundleGasPrice, noErrBundles[j].BundleGasPrice
sort.SliceStable(simulatedBundles, func(i, j int) bool {
priceI, priceJ := simulatedBundles[i].BundleGasPrice, simulatedBundles[j].BundleGasPrice

return priceI.Cmp(priceJ) >= 0
})

// merge bundles based on iterative state
includedTxs, mergedBundle, err := w.mergeBundles(env, noErrBundles)
includedTxs, mergedBundle, err := w.mergeBundles(env, simulatedBundles)
if err != nil {
log.Error("fail to merge bundles", "err", err)
return nil, nil, err
Expand Down Expand Up @@ -311,8 +304,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()
Expand Down
Loading