Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
nil pointer panic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Sep 15, 2023
1 parent 6047350 commit 3128174
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
10 changes: 9 additions & 1 deletion miner/ordering.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ func (s txByPriceAndTime) Less(i, j int) bool {
// deterministic sorting
cmp := s[i].fees.Cmp(s[j].fees)
if cmp == 0 {
return s[i].Tx().Time.Before(s[j].Tx().Time)
if s[i].Tx() != nil && s[j].Tx() != nil {
return s[i].Tx().Time.Before(s[j].Tx().Time)
} else if s[i].Bundle() != nil && s[j].Bundle() != nil {
return s[i].Bundle().TotalGasUsed <= s[j].Bundle().TotalGasUsed
} else if s[i].Bundle() != nil {
return false
}

return true
}
return cmp > 0
}
Expand Down
5 changes: 5 additions & 0 deletions miner/payload_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ func (payload *Payload) ResolveFull() *engine.ExecutionPayloadEnvelope {
default:
close(payload.stop)
}

if payload.full == nil {
return nil
}

return engine.BlockToExecutableData(payload.full, payload.fullFees, payload.sidecars)
}

Expand Down
18 changes: 16 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1836,15 +1836,29 @@ func (w *worker) simulateBundles(env *environment, bundles []types.MevBundle, sb
wg.Wait()

simCache.UpdateSimulatedBundles(simResult, bundles)
simulatedBundles := make([]simulatedBundle, 0, len(bundles))
simBundleCount := 0
for _, bundle := range simResult {
if bundle != nil {
simBundleCount += 1
}
}

simulatedBundles := make([]simulatedBundle, 0, simBundleCount)
for _, bundle := range simResult {
if bundle != nil {
simulatedBundles = append(simulatedBundles, *bundle)
}
}

simCache.UpdateSimSBundle(sbSimResult, sbundles)
simulatedSbundle := make([]*types.SimSBundle, 0, len(sbundles))
simSBundleCount := 0
for _, sbundle := range sbSimResult {
if sbundle != nil {
simSBundleCount += 1
}
}

simulatedSbundle := make([]*types.SimSBundle, 0, simSBundleCount)
for _, sbundle := range sbSimResult {
if sbundle != nil {
simulatedSbundle = append(simulatedSbundle, sbundle)
Expand Down

0 comments on commit 3128174

Please sign in to comment.