Skip to content

offchain-worker: Do not intialize the entire System again#10235

Merged
bkchr merged 3 commits intomasterfrom
bkchr-fix-offchain-worker
Nov 10, 2025
Merged

offchain-worker: Do not intialize the entire System again#10235
bkchr merged 3 commits intomasterfrom
bkchr-fix-offchain-worker

Conversation

@bkchr
Copy link
Copy Markdown
Member

@bkchr bkchr commented Nov 6, 2025

When calling offchain-worker we were initializing the entire System again with the same block we are running on top of. However, with the change to require strictly increasing block numbers the offchain-worker was failing. This is now solved by just registering the missing digests. The rest of the changes done by initialize are not important for offchain workers.

The pull request ensures that we are actually testing this behavior of the offchain worker now.

When calling `offchain-worker` we were initializing the entire `System` again with the same block we are running on top of. However, with [the change to require strictly increasing block numbers](#10180) the
offchain-worker was failing. This is now solved by just registering the missing digests. The rest of the changes done by `initialize` are not important for offchain workers.

The pull request ensures that we are actually testing this behavior of the offchain worker now.
@bkchr bkchr requested a review from a team as a code owner November 6, 2025 21:24
@bkchr bkchr added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Nov 6, 2025
Copy link
Copy Markdown
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be backported to the same releases that source PR was going too.

let existing_digest = frame_system::Pallet::<System>::digest();
for digest in digests.logs().iter().filter(|d| !existing_digest.logs.contains(d)) {
frame_system::Pallet::<System>::deposit_log(digest.clone());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about well_known_keys::INTRABLOCK_ENTROPY it gets removed in finalize, maybe we should bring it back, some offchain worker could read into it.

@bkchr bkchr added A4-backport-stable2506 Pull request must be backported to the stable2506 release branch A4-backport-stable2509 Pull request must be backported to the stable2509 release branch labels Nov 7, 2025
@bkchr
Copy link
Copy Markdown
Member Author

bkchr commented Nov 7, 2025

/cmd prdoc --audience runtime_dev --bump patch

@bkchr bkchr enabled auto-merge November 7, 2025 10:59
@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/19166121427
Failed job name: test-linux-stable-no-try-runtime

@bkchr bkchr added A4-backport-stable2506 Pull request must be backported to the stable2506 release branch and removed A4-backport-stable2506 Pull request must be backported to the stable2506 release branch A4-backport-stable2509 Pull request must be backported to the stable2509 release branch labels Nov 8, 2025
@bkchr bkchr added this pull request to the merge queue Nov 10, 2025
auto-merge was automatically disabled November 10, 2025 14:04

Pull Request is not mergeable

Merged via the queue into master with commit 405e0bd Nov 10, 2025
321 of 423 checks passed
@bkchr bkchr deleted the bkchr-fix-offchain-worker branch November 10, 2025 14:14
@paritytech-release-backport-bot
Copy link
Copy Markdown

Successfully created backport PR for stable2506:

paritytech-release-backport-bot bot pushed a commit that referenced this pull request Nov 10, 2025
When calling `offchain-worker` we were initializing the entire `System`
again with the same block we are running on top of. However, with [the
change to require strictly increasing block
numbers](#10180) the
offchain-worker was failing. This is now solved by just registering the
missing digests. The rest of the changes done by `initialize` are not
important for offchain workers.

The pull request ensures that we are actually testing this behavior of
the offchain worker now.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 405e0bd)
@bkchr bkchr added the A4-backport-stable2509 Pull request must be backported to the stable2509 release branch label Nov 10, 2025
paritytech-release-backport-bot bot pushed a commit that referenced this pull request Nov 10, 2025
When calling `offchain-worker` we were initializing the entire `System`
again with the same block we are running on top of. However, with [the
change to require strictly increasing block
numbers](#10180) the
offchain-worker was failing. This is now solved by just registering the
missing digests. The rest of the changes done by `initialize` are not
important for offchain workers.

The pull request ensures that we are actually testing this behavior of
the offchain worker now.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 405e0bd)
@paritytech-release-backport-bot
Copy link
Copy Markdown

Successfully created backport PR for stable2509:

EgrPrty pushed a commit that referenced this pull request Nov 10, 2025
Backport #10235 into `stable2506` from bkchr.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
EgrPrty pushed a commit that referenced this pull request Nov 11, 2025
Backport #10235 into `stable2509` from bkchr.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Egor_P <egor@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A4-backport-stable2506 Pull request must be backported to the stable2506 release branch A4-backport-stable2509 Pull request must be backported to the stable2509 release branch T1-FRAME This PR/Issue is related to core FRAME, the framework.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants