Skip to content

✨ Prepare pallets for async backing#471

Merged
lrazovic merged 1 commit intomainfrom
03-14-prepare_pallets_for_async_backing
May 2, 2025
Merged

✨ Prepare pallets for async backing#471
lrazovic merged 1 commit intomainfrom
03-14-prepare_pallets_for_async_backing

Conversation

@dastansam
Copy link
Copy Markdown
Contributor

@dastansam dastansam commented Mar 14, 2025

What?

Introduces BlockNumberProvider type for pallets

Why?

So that we can use a more reliable, consistent notion of block number, since with async backing system block number becomes nondeterministic

How?

Relay chain's block number is used where possible, i.e funding, linear-release, and we rely on system block number in other cases

Testing?

Changes were made to Instantiator so that it works for both integration and unit tests, since now integration tests Runtime uses relay chain's block number instead of chain's

Screenshots (optional)

Anything Else?

#469

Copy link
Copy Markdown
Contributor Author

dastansam commented Mar 14, 2025

@dastansam dastansam marked this pull request as ready for review March 14, 2025 08:13
@dastansam dastansam self-assigned this Mar 14, 2025
@dastansam dastansam requested a review from lrazovic March 14, 2025 08:13
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Mar 14, 2025

Graphite Automations

"Auto-assign PRs to author" took an action on this PR • (03/14/25)

1 assignee was added to this PR based on Juan Ignacio Rios's automation.

@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from a021c92 to e07c1a9 Compare March 14, 2025 08:40
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from e07c1a9 to cbc803c Compare March 17, 2025 09:14
@dastansam dastansam force-pushed the 03-14-upgrade_to_stable2412-2 branch from 0ca5002 to 891799a Compare March 19, 2025 14:37
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from cbc803c to 4317213 Compare March 19, 2025 14:37
@dastansam dastansam force-pushed the 03-14-upgrade_to_stable2412-2 branch from 891799a to d116e92 Compare March 19, 2025 15:17
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from 4317213 to 8c9017b Compare March 19, 2025 15:17
@dastansam dastansam force-pushed the 03-14-upgrade_to_stable2412-2 branch from d116e92 to 2828880 Compare March 19, 2025 15:18
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from 8c9017b to d1e02ed Compare March 19, 2025 15:18
Copy link
Copy Markdown
Member

@lrazovic lrazovic left a comment

Choose a reason for hiding this comment

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

Just 2 nits, but the approach seems straightforward!


#[frame_support::pallet]
pub mod pallet {
use super::BlockNumberFor;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this also part of the use super::*; two lines below?

Copy link
Copy Markdown
Contributor Author

@dastansam dastansam Mar 27, 2025

Choose a reason for hiding this comment

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

ah, that's because the type is ambiguous here. there is BlockNumberFor in the frame_system::pallet_prelude::* as well

@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from d1e02ed to 699d4da Compare April 2, 2025 06:10
@lrazovic lrazovic requested a review from Copilot April 3, 2025 09:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates several pallets and related tests to use a unified notion of block number via the new BlockNumberProvider type, enabling more reliable async backing.

  • Replaces direct calls to frame_system’s block_number with BlockNumberProvider::current_block_number.
  • Adds BlockNumberProvider implementations and configurations in TestRuntime, mocks, and integration tests.
  • Updates Cargo.toml dependencies to include necessary cumulus pallets to support asynchronous backing.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pallets/funding/src/mock.rs Updated system config and added ParachainSystem configuration.
pallets/funding/src/lib.rs Replaced frame_system block_number calls with BlockNumberProvider calls.
pallets/funding/src/instantiator/* Updated type bounds and block number calls to incorporate BlockNumberProvider.
pallets/funding/src/functions/* Uniformly replaced block_number retrieval methods.
pallets/democracy/* Switched to using BlockNumberProvider in multiple block number checks.
integration-tests/* Adjusted integration tests to reference the relay chain’s block number provider.
Comments suppressed due to low confidence (2)

pallets/funding/src/instantiator/chain_interactions.rs:177

  • [nitpick] This workaround uses frame_system::Pallet's set_block_number instead of a corresponding method from BlockNumberProvider. Consider unifying block number setting under BlockNumberProvider if a proper method becomes available.
self.execute(|| { frame_system::Pallet::<T>::set_block_number(block - One::one()); });

integration-tests/src/tests/e2e.rs:586

  • [nitpick] The change from PolimecSystem to PolkadotSystem for retrieving the block number may lead to inconsistencies. Verify that using PolkadotSystem here is intentional and consistent with the overall use of BlockNumberProvider in production code.
let now = PolkadotSystem::block_number();

@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from 699d4da to f4e4f84 Compare April 8, 2025 17:47
@dastansam dastansam force-pushed the 03-14-upgrade_to_stable2412-2 branch 2 times, most recently from e205664 to fc38ace Compare April 9, 2025 07:28
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch from f4e4f84 to e8ccde4 Compare April 9, 2025 07:28
@dastansam dastansam force-pushed the 03-14-upgrade_to_stable2412-2 branch from fc38ace to 51c4399 Compare April 9, 2025 08:36
@dastansam dastansam force-pushed the 03-14-prepare_pallets_for_async_backing branch 2 times, most recently from 6ab4ec1 to e087f8f Compare April 9, 2025 08:39
@lrazovic lrazovic mentioned this pull request Apr 25, 2025
@lrazovic lrazovic changed the title Prepare pallets for async backing ✨Prepare pallets for async backing May 1, 2025
@lrazovic lrazovic changed the title ✨Prepare pallets for async backing ✨ Prepare pallets for async backing May 1, 2025
Copy link
Copy Markdown
Member

lrazovic commented May 2, 2025

Merge activity

  • May 2, 7:23 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • May 2, 7:24 AM EDT: Graphite rebased this pull request as part of a merge.
  • May 2, 7:25 AM EDT: @lrazovic merged this pull request with Graphite.

@lrazovic lrazovic changed the base branch from 03-14-upgrade_to_stable2412-2 to graphite-base/471 May 2, 2025 11:23
@lrazovic lrazovic changed the base branch from graphite-base/471 to main May 2, 2025 11:23
@lrazovic lrazovic force-pushed the 03-14-prepare_pallets_for_async_backing branch from e087f8f to b207098 Compare May 2, 2025 11:24
@lrazovic lrazovic merged commit a386d80 into main May 2, 2025
1 check passed
@lrazovic lrazovic deleted the 03-14-prepare_pallets_for_async_backing branch May 2, 2025 11:25
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.

3 participants