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

Add BoundedVec to Treasury Pallet #8665

Merged
5 commits merged into from
Apr 26, 2021
Merged

Add BoundedVec to Treasury Pallet #8665

5 commits merged into from
Apr 26, 2021

Conversation

shawntabrizi
Copy link
Member

@shawntabrizi shawntabrizi commented Apr 26, 2021

Helps with paritytech/polkadot-sdk#323

This adds an upper bound to the number of treasury proposals that can be in the queue for spending.

This will be used for benchmarking the PoV size.

polkadot companion: paritytech/polkadot#2932

@shawntabrizi shawntabrizi added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. B0-silent Changes should not be mentioned in any release notes D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. and removed B7-runtimenoteworthy labels Apr 26, 2021
@shawntabrizi shawntabrizi requested a review from kianenigma April 26, 2021 04:14
use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error, PalletId};
use frame_support::{
decl_module, decl_storage, decl_event, ensure, print, decl_error,
PalletId, BoundedVec, bounded_vec::TryAppendValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PalletId, BoundedVec, bounded_vec::TryAppendValue,
PalletId, BoundedVec,

Hmm are you sure we need this? We implemented it directly for storage::types so we won't need to import again.

Copy link
Member Author

Choose a reason for hiding this comment

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

did get a compiler issue. let me see

Copy link
Member Author

Choose a reason for hiding this comment

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

error[E0599]: no function or associated item named `try_append` found for struct `Approvals<T, I>` in the current scope
   --> frame/treasury/src/lib.rs:329:23
    |
178 | decl_storage! {
    | ------------- function or associated item `try_append` not found for this
...
329 |             Approvals::<T, I>::try_append(proposal_id).map_err(|_| Error::<T, I>::TooManyApprovals)?;
    |                                ^^^^^^^^^^ function or associated item not found in `Approvals<T, I>`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
66  | use crate::sp_api_hidden_includes_decl_storage::hidden_include::bounded_vec::TryAppendValue;

If you know a better fix, happy to accept a follow up pr

@shawntabrizi
Copy link
Member Author

/benchmark runtime pallet pallet_treasury

@parity-benchapp
Copy link

parity-benchapp bot commented Apr 26, 2021

Finished benchmark for branch: shawntabrizi-treasury-bounded

Benchmark: Benchmark Runtime Pallet

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

Results

Pallet: "pallet_treasury", Extrinsic: "propose_spend", Lowest values: [], Highest values: [], Steps: [50], Repeat: 20
Median Slopes Analysis

-- Extrinsic Time --

Model:
Time ~= 45.39
µs

Reads = 1
Writes = 2
Min Squares Analysis

-- Extrinsic Time --

Model:
Time ~= 45.39
µs

Reads = 1
Writes = 2
Pallet: "pallet_treasury", Extrinsic: "reject_proposal", Lowest values: [], Highest values: [], Steps: [50], Repeat: 20
Median Slopes Analysis

-- Extrinsic Time --

Model:
Time ~= 42.79
µs

Reads = 2
Writes = 2
Min Squares Analysis

-- Extrinsic Time --

Model:
Time ~= 42.79
µs

Reads = 2
Writes = 2
Pallet: "pallet_treasury", Extrinsic: "approve_proposal", Lowest values: [], Highest values: [], Steps: [50], Repeat: 20
Median Slopes Analysis

-- Extrinsic Time --

Model:
Time ~= 14.03
+ p 0.093
µs

Reads = 2 + (0 * p)
Writes = 1 + (0 * p)
Min Squares Analysis

-- Extrinsic Time --

Data points distribution:
p mean µs sigma µs %
0 11.92 0.079 0.6%
1 12.65 0.064 0.5%
2 12.92 0.052 0.4%
3 13.33 0.043 0.3%
4 13.4 0.078 0.5%
5 13.7 0.056 0.4%
6 14.47 0.049 0.3%
7 14.17 0.083 0.5%
8 14.52 0.05 0.3%
9 15.02 0.053 0.3%
10 14.68 0.08 0.5%
11 15.43 0.055 0.3%
12 15.08 0.142 0.9%
13 15.27 0.168 1.0%
14 15.41 0.148 0.9%
15 15.19 0.143 0.9%
16 15.81 0.192 1.2%
17 15.61 0.124 0.7%
18 16.42 0.086 0.5%
19 16.37 0.062 0.3%
20 16.25 0.1 0.6%
21 16.42 0.179 1.0%
22 16.98 0.107 0.6%
23 16.99 0.098 0.5%
24 16.66 0.106 0.6%
25 17.42 0.05 0.2%
26 17.29 0.118 0.6%
27 17.1 0.197 1.1%
28 16.84 0.152 0.9%
29 17.63 0.08 0.4%
30 17.77 0.102 0.5%
31 17.45 0.461 2.6%
32 18.23 0.108 0.5%
33 18.34 0.065 0.3%
34 18.61 0.065 0.3%
35 18.54 0.032 0.1%
36 18.5 0.285 1.5%
37 18.41 0.473 2.5%
38 17.52 0.137 0.7%
39 17.8 0.08 0.4%
40 17.77 0.119 0.6%
41 18.32 0.08 0.4%
42 18.33 0.112 0.6%
43 18.57 0.119 0.6%
44 18.14 0.066 0.3%
45 18.28 0.089 0.4%
46 18.26 0.071 0.3%
47 18.27 0.127 0.6%
48 16.92 0.082 0.4%
49 17.04 0.091 0.5%
50 17.61 0.451 2.5%
51 17.71 0.887 5.0%
52 16.95 0.157 0.9%
53 17.77 0.7 3.9%
54 18.48 1.278 6.9%
55 19.64 1.107 5.6%
56 19.02 0.086 0.4%
57 19.1 0.103 0.5%
58 18.91 0.163 0.8%
59 19.47 0.111 0.5%
60 19.24 0.111 0.5%
61 19.44 0.125 0.6%
62 21.34 0.612 2.8%
63 19.83 0.103 0.5%
64 19.6 0.147 0.7%
65 22.28 0.054 0.2%
66 21.91 1.025 4.6%
67 22.43 0.079 0.3%
68 22.48 0.142 0.6%
69 22.72 0.102 0.4%
70 22.8 0.065 0.2%
71 23.28 0.112 0.4%
72 23.3 0.111 0.4%
73 22.97 0.136 0.5%
74 23.3 0.836 3.5%
75 22.04 1.462 6.6%
76 20.38 0.094 0.4%
77 20.72 0.789 3.8%
78 21.54 1.228 5.6%
79 21.15 1.094 5.1%
80 23.3 1.343 5.7%
81 23.36 1.359 5.8%
82 24.33 0.111 0.4%
83 21.91 1.367 6.2%
84 22.59 1.47 6.5%
85 21.5 0.931 4.3%
86 21.67 0.082 0.3%
87 21.19 0.091 0.4%
88 21.8 0.881 4.0%
89 21.46 0.201 0.9%
90 21.39 0.058 0.2%
91 21.43 0.15 0.6%
92 21.46 0.166 0.7%
93 21.66 0.135 0.6%
94 21.5 0.145 0.6%
95 21.47 0.104 0.4%
96 21.88 0.116 0.5%
97 21.76 0.125 0.5%
98 22.08 0.08 0.3%
99 21.74 0.07 0.3%

Quality and confidence:
param error
p 0.001

Model:
Time ~= 14.15
+ p 0.094
µs

Reads = 2 + (0 * p)
Writes = 1 + (0 * p)
Pallet: "pallet_treasury", Extrinsic: "on_initialize_proposals", Lowest values: [], Highest values: [], Steps: [50], Repeat: 20
Median Slopes Analysis

-- Extrinsic Time --

Model:
Time ~= 59.96
+ p 65.48
µs

Reads = 2 + (3 * p)
Writes = 2 + (3 * p)
Min Squares Analysis

-- Extrinsic Time --

Data points distribution:
p mean µs sigma µs %
0 67.32 0.224 0.3%
2 201.1 0.225 0.1%
4 327.9 0.276 0.0%
6 457.5 0.319 0.0%
8 588.3 0.813 0.1%
10 717.3 0.898 0.1%
12 845.6 1.269 0.1%
14 977.9 1.134 0.1%
16 1105 1.217 0.1%
18 1236 1.749 0.1%
20 1363 1.596 0.1%
22 1502 1.441 0.0%
24 1621 1.216 0.0%
26 1757 1.687 0.0%
28 1881 2.722 0.1%
30 2008 2.199 0.1%
32 2154 5.985 0.2%
34 2280 1.585 0.0%
36 2405 2.087 0.0%
38 2549 2.259 0.0%
40 2664 3.294 0.1%
42 2811 7.178 0.2%
44 2942 8.648 0.2%
46 3068 7.331 0.2%
48 3200 2.979 0.0%
50 3315 4.379 0.1%
52 3450 3.544 0.1%
54 3583 3.863 0.1%
56 3720 6.289 0.1%
58 3841 8.783 0.2%
60 3977 6.655 0.1%
62 4090 8.063 0.1%
64 4221 4.062 0.0%
66 4358 7.997 0.1%
68 4491 10.54 0.2%
70 4605 4.144 0.0%
72 4774 9.604 0.2%
74 5003 5.515 0.1%
76 5135 3.869 0.0%
78 5277 2.952 0.0%
80 5295 11.6 0.2%
82 5423 5.191 0.0%
84 5574 8.189 0.1%
86 5709 12.17 0.2%
88 5833 7.156 0.1%
90 5967 4.39 0.0%
92 6111 7.617 0.1%
94 6228 7.613 0.1%
96 6374 13.48 0.2%
98 6489 3.116 0.0%
100 6590 7.136 0.1%

Quality and confidence:
param error
p 0.042

Model:
Time ~= 51.63
+ p 65.7
µs

Reads = 2 + (3 * p)
Writes = 2 + (3 * p)

…/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs
@shawntabrizi
Copy link
Member Author

bot merge

@ghost
Copy link

ghost commented Apr 26, 2021

Waiting for commit status.

@ghost
Copy link

ghost commented Apr 26, 2021

Merge aborted: Checks failed for 5728fa8

@shawntabrizi
Copy link
Member Author

bot merge

@ghost
Copy link

ghost commented Apr 26, 2021

Trying merge.

@ghost ghost merged commit 4cbeeca into master Apr 26, 2021
@ghost ghost deleted the shawntabrizi-treasury-bounded branch April 26, 2021 14:42
@jakoblell jakoblell added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 31, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. 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. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants