polkadot-sdk icon indicating copy to clipboard operation
polkadot-sdk copied to clipboard

NoOp Impl Polling Trait

Open Doordashcon opened this issue 1 year ago • 9 comments

Adds NoOp implementation for the Polling trait and updates benchmarks in pallet-ranked-collective.

Doordashcon avatar Aug 10 '24 16:08 Doordashcon

@Doordashcon do you have any reasoning for this?

bkchr avatar Sep 03 '24 20:09 bkchr

@bkchr just a follow up on this? https://github.com/polkadot-fellows/runtimes/pull/347#discussion_r1709679890

Doordashcon avatar Sep 03 '24 23:09 Doordashcon

@bkchr just a follow up on this? polkadot-fellows/runtimes#347 (comment)

The comment is saying that this no-op should be implemented on () or some special NoOp struct.

bkchr avatar Sep 10 '24 06:09 bkchr

Implemented Polling for () and updated the tests where we have methods unimplemented!().

Doordashcon avatar Sep 10 '24 14:09 Doordashcon

Added Default bound.

please review @muharem @bkchr

Doordashcon avatar Sep 13 '24 20:09 Doordashcon

@Doordashcon can you please fix it as done in this pr https://github.com/paritytech/polkadot-sdk/pull/3049?

bkchr avatar Sep 14 '24 22:09 bkchr

frame-omni-bencher results on the Secretary Collective.

Pallet: "pallet_ranked_collective", Extrinsic: "vote", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: `SecretaryCollective::Members` (r:1 w:0)
Proof: `SecretaryCollective::Members` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`)

....

Pallet: "pallet_ranked_collective", Extrinsic: "cleanup_poll", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: `SecretaryCollective::VotingCleanup` (r:1 w:0)
Proof: `SecretaryCollective::VotingCleanup` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`)

Doordashcon avatar Sep 23 '24 14:09 Doordashcon

@bkchr @muharem please review

Doordashcon avatar Sep 25 '24 16:09 Doordashcon

It is known that both extrinsics each involve a single read operation. This can be manually accounted for, rather than relying on the default value for a non existent class. Would you agree with this approach @bkchr?

let class_exists = T::Polls::classes().into_iter().next().is_some();
        let class = if class_exists {
            T::Polls::classes().into_iter().next().unwrap() // Assuming there's at least one class here
        } else {
            return Err(BenchmarkError::Override(BenchmarkResult::from_weight(
                T::DbWeight::get().reads(1),
            )));
      };

Doordashcon avatar Oct 05 '24 19:10 Doordashcon

See this.

bkchr avatar Oct 07 '24 21:10 bkchr

please review @bkchr

I saw no other way to create an invalid poll for a NoOp Poll than adding From<u8> bound to the Index type

Doordashcon avatar Oct 13 '24 08:10 Doordashcon

Hopefully we get to backport the Secretary Collective after this is merged @bkchr @muharem

Doordashcon avatar Nov 07 '24 17:11 Doordashcon

Thanks for the benchmarking tip @ggwpez should be ready to merge now!

Doordashcon avatar Nov 11 '24 21:11 Doordashcon

@bkchr wondering if there is anything more I can do here?

Doordashcon avatar Dec 04 '24 01:12 Doordashcon

Successfully created backport PR for stable2407:

  • #6804

Successfully created backport PR for stable2409:

  • #6805

Successfully created backport PR for stable2412:

  • #6806