Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mattac21
Copy link
Contributor

@mattac21 mattac21 commented Dec 16, 2025

Description

This adds the ability for proposals to be created out of txs in the pending pool while the pool is resetting via a new block. Previously, this resetting would hold the lock on the pool for the entire duration of the reset, which would need to call recheck on every tx in the pending pool. This may take multiple seconds, which will block a call to Pending and therefore block PrepareProposal.

This PR addresses this by pushing txs into a txCollector as they are validated via demoteUnexecutables. Creating a 'snapshot' of the pending txs that have been validated for a height at any given time. This snapshot no longer shares the same global legacypool lock, thus unblocking PrepareProposal's call to Pending.

This PR also adds functionality where the reorg loop will be cancelled if it is still processing a reset (new block seen), and a new block arrives. This is to prevent the case where demoteUnexecutables takes such a long time to process txs that processing the previous height, always takes longer than the timeout the caller is willing to wait in Pending, thus preventing any txs from ever making it into a proposal.

This PR also addresses an issue existing in feat/krakatoa where the chain would essentially slow down heavily once tx load increased. This was due to tx gossip directly calling legacypool.Add which needed to acquire a lock shared with the reorg loop, which may take 5-10s at peak load in order to be released. This would cause a backup of other critical p2p messages, typically resulting in high prevote times. To fix this, a insertQueue has been added in order to decouple legacypool.Add from the hot path of p2p message processing.

Closes: STACK-2008


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@linear
Copy link

linear bot commented Dec 19, 2025

@mattac21 mattac21 force-pushed the ma/incremental-recheck branch 2 times, most recently from e87dacf to 9134baf Compare December 20, 2025 05:13
dirtyAccounts: dirtyAccounts,
events: queuedEvents,
}
go pool.runReorg(input)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
func (iq *insertQueue) addTx(tx *ethtypes.Transaction) {
defer func(t0 time.Time) {
telemetry.MeasureSince(t0, "expmempool_inserter_add") //nolint:staticcheck // TODO: switch to OpenTelemetry
}(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
@@ -417,16 +413,16 @@

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

return NewEVMMempoolIterator(
evmIterator,
cosmosIterator,

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
func (c *txCollector) Collect(ctx context.Context, height *big.Int, filter txpool.PendingFilter) map[common.Address][]*txpool.LazyTransaction {
genesis := big.NewInt(0)

start := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
done: make(chan struct{}),
}

go iq.loop()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
@mattac21 mattac21 merged commit c5e66b9 into feat/krakatoa Jan 8, 2026
17 of 19 checks passed
@mattac21 mattac21 deleted the ma/incremental-recheck branch January 8, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants