Skip to content

Make NoOpPoll generic over Moment#8938

Merged
bkontur merged 14 commits intoparitytech:masterfrom
Doordashcon:GM
Jun 25, 2025
Merged

Make NoOpPoll generic over Moment#8938
bkontur merged 14 commits intoparitytech:masterfrom
Doordashcon:GM

Conversation

@Doordashcon
Copy link
Copy Markdown
Contributor

Description

This PR enhances the flexibility of the NoOpPoll implementation by introducing a generic Moment parameter. This change enables support for diverse clock configurations across different runtimes, allowing NoOpPoll to work seamlessly with various block number implementations (e.g., u32, u64, or custom block number types).

Integration

Downstream projects using NoOpPoll must make these adjustments:

  • Add generic parameter: Specify the Moment type when using NoOpPoll

  • Update type annotations: Modify existing references to include the generic parameter

Example Migration:

// Before
use frame_support::traits::NoOpPoll;

let _ = NoOpPoll;

// After
use frame_support::traits::NoOpPoll;
use frame_system::pallet_prelude::BlockNumberFor;

Generic struct update:

- pub struct NoOpPoll;
+ pub struct NoOpPoll<Moment>(core::marker::PhantomData<Moment>);

Polling trait implementation:

- impl<Tally> Polling<Tally> for NoOpPoll {
+ impl<Tally, Moment> Polling<Tally> for NoOpPoll<Moment> {
     type Index = u8;
     type Votes = u32;
     type Class = u16;
-    type Moment = u64;
+    type Moment = Moment;

@Doordashcon Doordashcon requested a review from a team as a code owner June 23, 2025 12:13
Copy link
Copy Markdown
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

Will this fix this: polkadot-fellows/runtimes#347 (comment), right?

Comment thread prdoc/pr_8938.prdoc Outdated
@bkchr bkchr added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Jun 24, 2025
@bkchr
Copy link
Copy Markdown
Member

bkchr commented Jun 24, 2025

@Doordashcon tests are still failing.

@Doordashcon
Copy link
Copy Markdown
Contributor Author

Please review @bkchr, @bkontur

@Doordashcon
Copy link
Copy Markdown
Contributor Author

Will this fix this: polkadot-fellows/runtimes#347 (comment), right?

Yes! ran the changes on the runtime repo as well.

Comment thread prdoc/pr_8938.prdoc
@bkontur
Copy link
Copy Markdown
Contributor

bkontur commented Jun 25, 2025

/cmd prdoc --audience runtime_dev

@github-actions
Copy link
Copy Markdown
Contributor

Command "prdoc --audience runtime_dev" has failed ❌! See logs here

@bkontur
Copy link
Copy Markdown
Contributor

bkontur commented Jun 25, 2025

/cmd prdoc --audience runtime_dev --force

Comment thread prdoc/pr_8938.prdoc Outdated
@bkontur bkontur enabled auto-merge June 25, 2025 08:07
@bkontur bkontur added this pull request to the merge queue Jun 25, 2025
auto-merge was automatically disabled June 25, 2025 09:02

Pull Request is not mergeable

Merged via the queue into paritytech:master with commit 45cc86a Jun 25, 2025
244 checks passed
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
# Description
This PR enhances the flexibility of the `NoOpPoll` implementation by
introducing a generic `Moment` parameter. This change enables support
for diverse clock configurations across different runtimes, allowing
`NoOpPoll` to work seamlessly with various block number implementations
(e.g., `u32`, `u64`, or custom block number types).

### Integration
Downstream projects using `NoOpPoll` must make these adjustments:

- Add generic parameter: Specify the Moment type when using `NoOpPoll`

- Update type annotations: Modify existing references to include the
generic parameter

### Example Migration:

```diff
// Before
use frame_support::traits::NoOpPoll;

let _ = NoOpPoll;

// After
use frame_support::traits::NoOpPoll;
use frame_system::pallet_prelude::BlockNumberFor;
```

### Generic struct update:

```diff
- pub struct NoOpPoll;
+ pub struct NoOpPoll<Moment>(core::marker::PhantomData<Moment>);
```
### Polling trait implementation:
```diff
- impl<Tally> Polling<Tally> for NoOpPoll {
+ impl<Tally, Moment> Polling<Tally> for NoOpPoll<Moment> {
     type Index = u8;
     type Votes = u32;
     type Class = u16;
-    type Moment = u64;
+    type Moment = Moment;
```

---------

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

Labels

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.

4 participants