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

fix: index out of range #10

Merged
merged 1 commit into from
Mar 20, 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: 1 addition & 1 deletion miner/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (b *Bidder) bid(work *environment) {
}

b.deleteBestWork(work)
log.Info("Bidder: bidding success")
log.Info("Bidder: bidding success", "number", work.header.Number, "txs", len(work.txs))
}

// isBestWork returns the work is better than the current best work
Expand Down
15 changes: 10 additions & 5 deletions miner/bundle_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ func (c *BundleCacheEntry) GetSimulatedBundle(bundle common.Hash) (*types.Simula
return nil, false
}

func (c *BundleCacheEntry) UpdateSimulatedBundles(result []*types.SimulatedBundle, bundles []*types.Bundle) {
func (c *BundleCacheEntry) UpdateSimulatedBundles(result map[common.Hash]*types.SimulatedBundle, bundles []*types.Bundle) {
c.mu.Lock()
defer c.mu.Unlock()

for i, simBundle := range result {
bundleHash := bundles[i].Hash()
if simBundle != nil {
c.successfulBundles[bundleHash] = simBundle
for _, bundle := range bundles {
if bundle == nil {
continue
}

bundleHash := bundle.Hash()

if result[bundleHash] != nil {
c.successfulBundles[bundleHash] = result[bundleHash]
} else {
c.failedBundles[bundleHash] = struct{}{}
}
Expand Down
9 changes: 4 additions & 5 deletions miner/worker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var (
// into the given sealing block. The selection and ordering strategy can be extended in the future.
func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environment, stopTimer *time.Timer) error {
var (
pending map[common.Address][]*txpool.LazyTransaction
localPlainTxs map[common.Address][]*txpool.LazyTransaction
remotePlainTxs map[common.Address][]*txpool.LazyTransaction
localBlobTxs map[common.Address][]*txpool.LazyTransaction
Expand Down Expand Up @@ -75,7 +74,7 @@ func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environ

bundles = w.eth.TxPool().PendingBundles(env.header.Number.Uint64(), env.header.Time)

log.Info("fill bundles and transactions", "bundles_count", len(bundles), "tx_count", len(pending))
log.Info("fill bundles and transactions", "bundles_count", len(bundles), "tx_count", len(localPlainTxs)+len(remotePlainTxs))

// if no bundles, not necessary to fill transactions
if len(bundles) == 0 {
Expand Down Expand Up @@ -282,12 +281,12 @@ func (w *worker) generateOrderedBundles(
func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]*types.SimulatedBundle, error) {
headerHash := env.header.Hash()
simCache := w.bundleCache.GetBundleCache(headerHash)
simResult := make([]*types.SimulatedBundle, len(bundles))
simResult := make(map[common.Hash]*types.SimulatedBundle)

var wg sync.WaitGroup
for i, bundle := range bundles {
if simmed, ok := simCache.GetSimulatedBundle(bundle.Hash()); ok {
simResult = append(simResult, simmed)
simResult[bundle.Hash()] = simmed
continue
}

Expand All @@ -302,7 +301,7 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]*
return
}

simResult[idx] = simmed
simResult[bundle.Hash()] = simmed
}(i, bundle, env.state.Copy())
}

Expand Down
Loading