Skip to content

Fix duplicate task generation (frontport of #5431)#5459

Merged
ndr-ds merged 1 commit intomainfrom
ndr-ds/frontport-5431
Feb 17, 2026
Merged

Fix duplicate task generation (frontport of #5431)#5459
ndr-ds merged 1 commit intomainfrom
ndr-ds/frontport-5431

Conversation

@ndr-ds
Copy link
Copy Markdown
Contributor

@ndr-ds ndr-ds commented Feb 17, 2026

Motivation

Frontport of #5431 from testnet_conway to main.

Proposal

Cherry-pick of #5431 with conflict resolution (adapted cursors field name used on main).

Test Plan

CI.

The task processor can call `process_actions` multiple times while a
previous batch's tasks are still in-flight.
When there's a backlog (`schedule.start` far in the past), the deadline
timer fires
immediately because the next event is also in the past. The
`last_requested_callbacks` guard passes, and
`next_actions` reads stale on-chain state (schedule.start hasn't
advanced yet), generating overlapping timestamps.
When both batches are eventually submitted as blocks, batch 2's stale
timestamps don't
match the now-advanced `schedule.start`, causing:

```
contract.rs:115: assert_eq!(timed_data.timestamp, next_timestamp, "unexpected timestamp in posted data")
```

Introduce an `in_flight_apps: BTreeSet<ApplicationId>` guard in the task
processor. When a batch of tasks is spawned
for an application, the app is marked as in-flight and subsequent
`process_actions` calls skip it. A new
`TaskMessage` enum replaces the raw `(ApplicationId, TaskOutcome)`
channel, adding a `BatchComplete` variant that the
spawned task sends after all outcomes. On `BatchComplete`, the guard is
cleared and `process_actions` is
re-triggered for that app so it reads freshly-updated on-chain state.

- CI
- I had a stuck worker with a big backlog. After rebuilding pm-app with
this fix and restarting the worker with the new package version, I see
no more panics, and it seems that the worker is actually making progress
through the backlog:

![Screenshot 2026-02-12 at
13.44.18.png](https://app.graphite.com/user-attachments/assets/be611bf2-3b7a-4bbd-bda2-45b1e5049108.png)
Copy link
Copy Markdown
Contributor Author

ndr-ds commented Feb 17, 2026

@ndr-ds ndr-ds added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit c14107b Feb 17, 2026
35 checks passed
@ndr-ds ndr-ds deleted the ndr-ds/frontport-5431 branch February 17, 2026 23:10
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.

2 participants