fix(payload): initialize prewarming state synchronously - #7227
Conversation
|
cyclops audit super-fast |
tempoxyz-bot
left a comment
There was a problem hiding this comment.
👁️ Cyclops Review
This change leaves a high-severity stale worker-state path because Rayon scope callers are not covered by the pool broadcasts.
Reviewer Callouts
- ⚡ External Rayon scope participation: Confirm initialization and cleanup semantics for both Rayon-owned workers and the calling thread; the updated test currently checks only pool threads via
broadcast.
| Provider: StateProviderFactory + Clone + 'static, | ||
| { | ||
| let pool = executor.prewarming_pool(); | ||
| let prewarm = ctx.prewarm.clone(); |
There was a problem hiding this comment.
🚨 [SECURITY] Coordinator-thread worker state survives across payload builds
WorkerPool::init and pool.clear() broadcast only to Rayon-owned pool threads, but in_place_scope allows the external calling thread to execute scoped jobs. A job on that caller lazily stores this build's EVM in the global worker TLS; cleanup does not clear it, so a later build on the same coordinator thread can reuse stale parent state/environment. Its replay may then be rejected as invalid, causing an otherwise valid payment transaction to be omitted from the payload.
Recommended Fix:
Initialize and explicitly clear the external scope caller's worker slot for every build, with a barrier before jobs begin, or avoid global worker TLS for external scope participants and pass build-scoped state directly. Add a two-build regression test on the same coordinator thread with distinct contexts and force a scoped task onto that thread.
Initializes per-worker EVM state before spawning scoped prewarming work, ensuring every worker is ready before transaction execution. Updates the lifecycle test to verify worker-local state is cleared after prewarming completes. Extracted while reviewing #4069.