Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

pallet-lottery: add generate_storage_info #10594

Merged
merged 14 commits into from
Jan 11, 2022

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Jan 5, 2022

Adds generate_storage_info to pallet-lottery.
Related paritytech/polkadot-sdk#323

@shawntabrizi shawntabrizi added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. labels Jan 5, 2022
@shawntabrizi
Copy link
Member

Lottery pallet is not deployed to any production runtimes, so it should be fine to merge this without any worries about migrations.

@@ -442,12 +455,12 @@ impl<T: Config> Pallet<T> {
Error::<T>::AlreadyParticipating
Copy link
Member Author

Choose a reason for hiding this comment

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

Using a BoundedSet here would make matters easier, but I'm not sure if it is worth the refactor rn.

@shawntabrizi
Copy link
Member

/benchmark runtime pallet pallet_lottery

@parity-benchapp
Copy link

parity-benchapp bot commented Jan 7, 2022

Benchmark Runtime Pallet for branch "lottery-bounded-len" with command cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_lottery --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/lottery/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Toolchain: stable-x86_64-unknown-linux-gnu (default)
rustc 1.57.0 (f1edd0429 2021-11-29)

Results
Pallet: "pallet_lottery", Extrinsic: "buy_ticket", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Lottery Lottery (r:1 w:0)
Storage: Lottery CallIndices (r:1 w:0)
Storage: Lottery TicketsCount (r:1 w:1)
Storage: Lottery Participants (r:1 w:1)
Storage: Lottery LotteryIndex (r:1 w:0)
Storage: System Account (r:1 w:1)
Storage: Lottery Tickets (r:0 w:1)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    53.06
              µs

Reads = 6
Writes = 4

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    53.06
              µs

Reads = 6
Writes = 4

Pallet: "pallet_lottery", Extrinsic: "set_calls", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Lottery CallIndices (r:0 w:1)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    13.32
    + n    0.387
              µs

Reads = 0 + (0 * n)
Writes = 1 + (0 * n)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    n   mean µs  sigma µs       %
    0     12.56      0.09    0.7%
    1     13.84     0.149    1.0%
    2     14.21     0.117    0.8%
    3     15.17     0.362    2.3%
    4     14.84     0.166    1.1%
    5     15.35     0.165    1.0%
    6     15.57     0.127    0.8%
    7     15.81     0.125    0.7%
    8     16.26     0.144    0.8%
    9     16.94     0.186    1.0%
   10     17.29     0.185    1.0%

Quality and confidence:
param     error
n         0.011

Model:
Time ~=    13.25
    + n    0.402
              µs

Reads = 0 + (0 * n)
Writes = 1 + (0 * n)

Pallet: "pallet_lottery", Extrinsic: "start_lottery", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Lottery Lottery (r:1 w:1)
Storage: Lottery LotteryIndex (r:1 w:1)
Storage: System Account (r:1 w:1)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    45.04
              µs

Reads = 3
Writes = 3

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    45.04
              µs

Reads = 3
Writes = 3

Pallet: "pallet_lottery", Extrinsic: "stop_repeat", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Lottery Lottery (r:1 w:1)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    5.732
              µs

Reads = 1
Writes = 1

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    5.732
              µs

Reads = 1
Writes = 1

Pallet: "pallet_lottery", Extrinsic: "on_initialize_end", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0)
Storage: Lottery Lottery (r:1 w:1)
Storage: System Account (r:2 w:2)
Storage: Lottery TicketsCount (r:1 w:1)
Storage: Lottery Tickets (r:1 w:0)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    73.89
              µs

Reads = 6
Writes = 4

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    73.89
              µs

Reads = 6
Writes = 4

Pallet: "pallet_lottery", Extrinsic: "on_initialize_repeat", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0)
Storage: Lottery Lottery (r:1 w:1)
Storage: System Account (r:2 w:2)
Storage: Lottery TicketsCount (r:1 w:1)
Storage: Lottery Tickets (r:1 w:0)
Storage: Lottery LotteryIndex (r:1 w:1)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    77.32
              µs

Reads = 7
Writes = 5

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    77.32
              µs

Reads = 7
Writes = 5


ERROR: Unable to push ./frame/lottery/src/weights.rs

Comment on lines +63 to +66
BoundedVec::<CallIndex, T::MaxCalls>::try_from(vec![
set_code_index;
T::MaxCalls::get().saturating_sub(1) as usize
],
]).unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I recently added a bounded_vec! macro for very basic usages. I think you can easily make it understand vec![_; _] syntax as well and then use it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't find the macro in the code-base, can you point me to it please?

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh it is in #10601, maybe you can review it ? :p

Copy link
Contributor

Choose a reason for hiding this comment

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

not a big deal, we can proceed without it.

Would be good if either of us remembers to come clean it up after the aforementioned PR is merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok thanks.

Copy link
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.

Some small suggestions, but overall looks good! welcome! 🎉

@ggwpez
Copy link
Member Author

ggwpez commented Jan 11, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit a6b7943 into paritytech:master Jan 11, 2022
paritytech-processbot bot pushed a commit that referenced this pull request Jan 11, 2022
* pallet-preimage: fix crate doc

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_lottery --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/lottery/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <[email protected]>
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
* pallet-lottery: add generate_storage_info

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test call_to_indices with TooManyCalls

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: move try_push above transfer

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test stop_repeat

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test do_buy_ticket as white-box

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: use BoundedVec in bechmarks

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: fix zero div panic

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: extend buy_ticket tests

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: test buy_ticket AlreadyParticipating

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* fmt

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: use /// comments on private functions

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: use with_bounded_capacity

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
)

* pallet-preimage: fix crate doc

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_lottery --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/lottery/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <[email protected]>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* pallet-lottery: add generate_storage_info

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test call_to_indices with TooManyCalls

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: move try_push above transfer

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test stop_repeat

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: test do_buy_ticket as white-box

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: use BoundedVec in bechmarks

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* pallet-lottery: fix zero div panic

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: extend buy_ticket tests

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: test buy_ticket AlreadyParticipating

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* fmt

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: use /// comments on private functions

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* review: use with_bounded_capacity

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
)

* pallet-preimage: fix crate doc

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_lottery --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/lottery/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants