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

Adds remove_approval feature to treasury pallet #11243

Merged

Conversation

guzzit
Copy link
Contributor

@guzzit guzzit commented Apr 19, 2022

This PR adds a feature to remove previously approved proposals from the approval queue.

Resolves Force Remove Approved Extrinsic in Treasury #10952

polkadot companion: paritytech/polkadot#5352

supercedes: #10989

polkadot address: 13dUB1KQNcbCGAxbEpzFBsnbvkwVAjmHtBj41E6oPfmfpaAX

Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

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

nice, looks good

@shawntabrizi
Copy link
Member

/tip small

@substrate-tip-bot
Copy link

Please fix the following problems before calling the tip bot again:

  • Contributor did not properly post their Polkadot or Kusama address.

Make sure the pull request description has: "{network} address: {address}".

@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. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Apr 23, 2022
@shawntabrizi
Copy link
Member

/benchmark runtime pallet pallet_treasury

@parity-benchapp
Copy link

parity-benchapp bot commented Apr 23, 2022

Benchmark Runtime Pallet for branch "remove-approval-treasury-pallet" with command cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --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

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

Results
Pallet: "pallet_treasury", Extrinsic: "propose_spend", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Treasury ProposalCount (r:1 w:1)
Storage: Treasury Proposals (r:0 w:1)

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

Model:
Time ~=    22.06
              µs

Reads = 1
Writes = 2

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

Model:
Time ~=    22.06
              µs

Reads = 1
Writes = 2

Pallet: "pallet_treasury", Extrinsic: "reject_proposal", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Treasury Proposals (r:1 w:1)
Storage: System Account (r:1 w:1)

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

Model:
Time ~=    25.96
              µs

Reads = 2
Writes = 2

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

Model:
Time ~=    25.96
              µs

Reads = 2
Writes = 2

Pallet: "pallet_treasury", Extrinsic: "approve_proposal", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Treasury Proposals (r:1 w:0)
Storage: Treasury Approvals (r:1 w:1)

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

Model:
Time ~=    7.407
    + p    0.101
              µs

Reads = 2 + (0 * p)
Writes = 1 + (0 * p)

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

Data points distribution:
    p   mean µs  sigma µs       %
    0     5.836     0.046    0.7%
    1     6.573      0.05    0.7%
    2     6.556     0.076    1.1%
    3     7.112      0.05    0.7%
    4     6.986     0.063    0.9%
    5     7.307     0.044    0.6%
    6     7.876      0.07    0.8%
    7     7.633     0.198    2.5%
    8     7.867     0.059    0.7%
    9     8.261     0.076    0.9%
   10     8.263     0.062    0.7%
   11     8.532     0.065    0.7%
   12     8.307     0.107    1.2%
   13     8.954     0.102    1.1%
   14     8.767     0.071    0.8%
   15     8.684     0.057    0.6%
   16     9.228     0.074    0.8%
   17     8.975     0.055    0.6%
   18     9.365     0.086    0.9%
   19      9.31     0.086    0.9%
   20     9.094      0.09    0.9%
   21     9.806     0.081    0.8%
   22       9.8     0.048    0.4%
   23     9.825      0.08    0.8%
   24     9.642     0.065    0.6%
   25     10.03     0.039    0.3%
   26     10.35     0.081    0.7%
   27     10.49     0.095    0.9%
   28     10.66     0.096    0.9%
   29     10.63     0.086    0.8%
   30     10.49      0.06    0.5%
   31     10.57     0.123    1.1%
   32     10.86     0.056    0.5%
   33      10.9     0.073    0.6%
   34     10.89     0.049    0.4%
   35     10.84     0.067    0.6%
   36     10.77     0.093    0.8%
   37      11.5      0.08    0.6%
   38     11.42      0.12    1.0%
   39     11.83     0.062    0.5%
   40     12.01     0.095    0.7%
   41     12.03     0.088    0.7%
   42     11.81     0.095    0.8%
   43     12.37     0.069    0.5%
   44     12.07     0.052    0.4%
   45      12.1     0.081    0.6%
   46     12.19     0.076    0.6%
   47     12.36     0.079    0.6%
   48     12.31     0.101    0.8%
   49     12.48     0.109    0.8%
   50     12.63     0.072    0.5%
   51     12.98     0.052    0.4%
   52     12.62     0.111    0.8%
   53     12.94     0.082    0.6%
   54     12.88     0.067    0.5%
   55     13.06     0.102    0.7%
   56     13.04     0.052    0.3%
   57     13.18     0.099    0.7%
   58     13.26     0.076    0.5%
   59     13.71     0.024    0.1%
   60     13.26      0.07    0.5%
   61     13.58      0.11    0.8%
   62     13.39     0.059    0.4%
   63     13.97      0.09    0.6%
   64     13.91     0.152    1.0%
   65     14.46     0.111    0.7%
   66     14.42     0.101    0.7%
   67     14.16       0.1    0.7%
   68     14.17     0.101    0.7%
   69     14.24     0.056    0.3%
   70     14.38     0.084    0.5%
   71     14.63     0.118    0.8%
   72     15.04     0.129    0.8%
   73     14.68     0.145    0.9%
   74     15.14     0.195    1.2%
   75     15.15     0.099    0.6%
   76     15.15     0.148    0.9%
   77     15.08     0.067    0.4%
   78      15.3     0.144    0.9%
   79     15.06      0.08    0.5%
   80      15.6     0.139    0.8%
   81     15.89     0.073    0.4%
   82     15.93     0.129    0.8%
   83      15.7     0.079    0.5%
   84     15.76     0.063    0.3%
   85     15.66     0.081    0.5%
   86     16.71       0.2    1.1%
   87     16.07     0.054    0.3%
   88      16.3     0.127    0.7%
   89     16.06     0.114    0.7%
   90     16.35     0.113    0.6%
   91     16.38     0.129    0.7%
   92     16.34     0.097    0.5%
   93     16.61     0.057    0.3%
   94     16.56     0.131    0.7%
   95     16.65      0.08    0.4%
   96     16.93     0.135    0.7%
   97     16.75     0.153    0.9%
   98      17.2     0.079    0.4%
   99     16.81     0.095    0.5%

Quality and confidence:
param     error
p             0

Model:
Time ~=    7.299
    + p    0.103
              µs

Reads = 2 + (0 * p)
Writes = 1 + (0 * p)

Pallet: "pallet_treasury", Extrinsic: "remove_approval", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Treasury Approvals (r:1 w:1)

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

Model:
Time ~=    3.867
              µs

Reads = 1
Writes = 1

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

Model:
Time ~=    3.867
              µs

Reads = 1
Writes = 1

Pallet: "pallet_treasury", Extrinsic: "on_initialize_proposals", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========
Storage: Treasury Approvals (r:1 w:1)
Storage: Bounties BountyApprovals (r:1 w:1)
Storage: Treasury Proposals (r:2 w:2)
Storage: System Account (r:4 w:4)

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

Model:
Time ~=     31.3
    + p    28.07
              µs

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

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

Data points distribution:
    p   mean µs  sigma µs       %
    0      34.2     0.121    0.3%
    2     93.84      0.17    0.1%
    4     145.8     0.192    0.1%
    6     200.5     0.332    0.1%
    8     257.9      0.44    0.1%
   10     310.5      0.74    0.2%
   12     367.8     0.998    0.2%
   14     421.8     0.711    0.1%
   16     477.8     8.346    1.7%
   18     530.6     0.762    0.1%
   20     587.8     1.726    0.2%
   22     641.6     2.189    0.3%
   24     698.5     6.663    0.9%
   26     751.3     5.035    0.6%
   28     802.4     1.454    0.1%
   30     864.1     12.42    1.4%
   32     913.9     10.54    1.1%
   34       969     1.731    0.1%
   36      1038     11.37    1.0%
   38      1090     14.27    1.3%
   40      1156     13.16    1.1%
   42      1200     11.27    0.9%
   44      1271     14.64    1.1%
   46      1318     13.55    1.0%
   48      1373     11.77    0.8%
   50      1443     10.94    0.7%
   52      1502      8.22    0.5%
   54      1536     14.89    0.9%
   56      1600     14.51    0.9%
   58      1660      10.4    0.6%
   60      1684     2.905    0.1%
   62      1755     12.39    0.7%
   64      1816     11.58    0.6%
   66      1879       8.4    0.4%
   68      1933     11.84    0.6%
   70      2000     12.89    0.6%
   72      2052     7.284    0.3%
   74      2102     16.03    0.7%
   76      2185     15.28    0.6%
   78      2235     7.197    0.3%
   80      2268     10.39    0.4%
   82      2330     11.09    0.4%
   84      2398     16.77    0.6%
   86      2458     12.54    0.5%
   88      2494     16.69    0.6%
   90      2554     12.36    0.4%
   92      2639     4.823    0.1%
   94      2686     15.68    0.5%
   96      2759     14.52    0.5%
   98      2785     23.34    0.8%
  100      2845     7.143    0.2%

Quality and confidence:
param     error
p         0.022

Model:
Time ~=    24.02
    + p    28.19
              µs

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


…--manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --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
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
@paritytech paritytech deleted a comment Apr 23, 2022
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.

Have some minor complains before approving.

/// # </weight>
///
/// Errors:
/// - `ProposalNotApproved`: Proposal has not been approved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, but this isn't quite informative. You need to think about what this means when someone reads this. Which proposal wasn't approved? What are the causes for this error? These are questions that someone who encountered the ProposalNotApproved error would really want to know about, and attempt to fix it themselves.

There are two reasons why this can happen -- either the proposal exists but was not approved, or that a proposal with the specified proposal_id doesn't exist altogether. These two bits of information are very helpful for users who encounter this error and are trying to look for the next steps in resolving it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this work:

The `proposal_id` supplied was not found in the approval queue, i.e., the proposal has not been approved. 
This could also mean the proposal with the supplied `proposal_id` does not exist altogether, 
thus there is no way it would have been approved in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @KiChjang, I've modified the description.

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.

LGTM

@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot
Copy link

Error: "Check reviews" status is not passing for paritytech/polkadot#5352

@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot
Copy link

Error: "Check reviews" status is not passing for paritytech/polkadot#5352

@ggwpez
Copy link
Member

ggwpez commented Apr 27, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 3a02a69 into paritytech:master Apr 27, 2022
godcodehunter pushed a commit to sensoriumxr/substrate that referenced this pull request Jun 22, 2022
* added remove_approval feature to treasury pallet

* Update frame/treasury/src/lib.rs

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* treasury pallet refactoring: removed proposalId check in remove_approval call and trailing new line in tests file

* fmt

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --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

* Update frame/treasury/src/lib.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* remove_approval extrinsic in treasury pallet:added extra checks in test and extra documentation

* refactored error logging on remove_approval extrinsic in treasury pallet

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
* added remove_approval feature to treasury pallet

* Update frame/treasury/src/lib.rs

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* treasury pallet refactoring: removed proposalId check in remove_approval call and trailing new line in tests file

* fmt

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --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

* Update frame/treasury/src/lib.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* remove_approval extrinsic in treasury pallet:added extra checks in test and extra documentation

* refactored error logging on remove_approval extrinsic in treasury pallet

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* added remove_approval feature to treasury pallet

* Update frame/treasury/src/lib.rs

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* treasury pallet refactoring: removed proposalId check in remove_approval call and trailing new line in tests file

* fmt

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --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

* Update frame/treasury/src/lib.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* remove_approval extrinsic in treasury pallet:added extra checks in test and extra documentation

* refactored error logging on remove_approval extrinsic in treasury pallet

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
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. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force Remove Approved Extrinsic in Treasury
6 participants