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

implement dispatch_as #9934

Merged
merged 11 commits into from
Nov 4, 2021
Merged

implement dispatch_as #9934

merged 11 commits into from
Nov 4, 2021

Conversation

xlc
Copy link
Contributor

@xlc xlc commented Oct 5, 2021

Closes #6428

I am not going to add any additional types to frame-system until paritytech/polkadot-sdk#367 is addressed.

I am go for the most generalized approach so root can not only dispatch as signed origin, but also all other kinds of origin including collectives etc, which may or may not be useful.

Let me know if you think I should just have a dispatch_as_signed instead of this generalized approach.

polkadot address: 14DsLzVyTUTDMm2eP3czwPbH53KgqnQRp3CJJZS9GR7yxGDP

skip check-dependent-cumulus

polkadot companion: paritytech/polkadot#4075
cumulus companion: paritytech/cumulus#715

@xlc xlc requested a review from athei as a code owner October 5, 2021 08:26
frame/utility/src/lib.rs Outdated Show resolved Hide resolved
frame/utility/src/lib.rs Outdated Show resolved Hide resolved
frame/utility/src/lib.rs Outdated Show resolved Hide resolved
frame/utility/src/lib.rs Outdated Show resolved Hide resolved
@xlc
Copy link
Contributor Author

xlc commented Oct 5, 2021

Let me know if this makes sense and then I can do the polkadot companion.

@athei
Copy link
Member

athei commented Oct 6, 2021

Let me know if this makes sense and then I can do the polkadot companion.

To me it looks fine. But I don't feel comfortable signing off on this. I requested reviews from the FRAME experts.

@emostov
Copy link
Contributor

emostov commented Oct 13, 2021

On the surface this seems reasonable but I think it makes more sense to have this in its own minimal pallet.

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.

I see no issues with this.

@shawntabrizi shawntabrizi added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Oct 13, 2021
Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

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

shouldn't we have the new call have a proper benchmark ?
I think even if it straightforward it a better practice than having some hardcoded weight in the pallet.

EDIT: otherwise code is good to me

frame/utility/src/lib.rs Outdated Show resolved Hide resolved
@xlc
Copy link
Contributor Author

xlc commented Oct 30, 2021

/benchmark runtime pallet pallet_utility

@parity-benchapp
Copy link

parity-benchapp bot commented Oct 30, 2021

Benchmark Runtime Pallet for branch "dispatch-as" 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_utility --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/utility/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Results
Pallet: "pallet_utility", Extrinsic: "batch", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

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

Model:
Time ~=    17.98
    + c    5.525
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)

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

Data points distribution:
    c   mean µs  sigma µs       %
    0     13.08      0.12    0.9%
   20     128.8     0.554    0.4%
   40     240.7     1.572    0.6%
   60       345     2.352    0.6%
   80     455.7     1.523    0.3%
  100     568.4     9.892    1.7%
  120     670.8     3.679    0.5%
  140       787     10.59    1.3%
  160     914.5     12.84    1.4%
  180      1003     9.558    0.9%
  200      1136     8.234    0.7%
  220      1245     13.13    1.0%
  240      1336     10.54    0.7%
  260      1465     15.89    1.0%
  280      1565     13.05    0.8%
  300      1673     12.14    0.7%
  320      1776     6.616    0.3%
  340      1909     7.749    0.4%
  360      2012     3.416    0.1%
  380      2120     11.47    0.5%
  400      2232     7.756    0.3%
  420      2323     10.12    0.4%
  440      2451     18.16    0.7%
  460      2549     14.27    0.5%
  480      2653     16.85    0.6%
  500      2780     23.15    0.8%
  520      2880     14.59    0.5%
  540      3033     11.88    0.3%
  560      3120     12.84    0.4%
  580      3244     7.704    0.2%
  600      3360     10.26    0.3%
  620      3473      5.49    0.1%
  640      3568     16.31    0.4%
  660      3740     14.45    0.3%
  680      3758     15.83    0.4%
  700      3858     10.55    0.2%
  720      3972     14.02    0.3%
  740      4110     12.46    0.3%
  760      4218     14.74    0.3%
  780      4316     20.17    0.4%
  800      4466     22.39    0.5%
  820      4568     17.36    0.3%
  840      4653     11.05    0.2%
  860      4758     27.05    0.5%
  880      4871     18.92    0.3%
  900      4999     12.78    0.2%
  920      5054     13.02    0.2%
  940      5222     27.29    0.5%
  960      5315     18.36    0.3%
  980      5451     18.81    0.3%
 1000      5558     11.82    0.2%

Quality and confidence:
param     error
c         0.003

Model:
Time ~=    18.29
    + c     5.53
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)

Pallet: "pallet_utility", Extrinsic: "as_derivative", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

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

Model:
Time ~=    3.387
              µs

Reads = 0
Writes = 0

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

Model:
Time ~=    3.387
              µs

Reads = 0
Writes = 0

Pallet: "pallet_utility", Extrinsic: "batch_all", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

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

Model:
Time ~=    21.14
    + c    5.989
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)

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

Data points distribution:
    c   mean µs  sigma µs       %
    0     13.91      0.06    0.4%
   20     139.7     0.435    0.3%
   40     260.9     1.563    0.5%
   60     376.9     3.471    0.9%
   80     498.2     2.046    0.4%
  100     619.9     4.076    0.6%
  120     737.9     3.743    0.5%
  140     859.1     4.176    0.4%
  160     975.9      11.7    1.1%
  180      1098     15.95    1.4%
  200      1237     12.05    0.9%
  220      1358     11.24    0.8%
  240      1469     13.99    0.9%
  260      1607     8.548    0.5%
  280      1694     14.04    0.8%
  300      1823     5.823    0.3%
  320      1939      8.34    0.4%
  340      2069     11.12    0.5%
  360      2179     11.63    0.5%
  380      2295     11.85    0.5%
  400      2415     16.02    0.6%
  420      2549      8.38    0.3%
  440      2658     15.01    0.5%
  460      2770     11.18    0.4%
  480      2905     7.623    0.2%
  500      3003      8.42    0.2%
  520      3145     9.052    0.2%
  540      3259     10.96    0.3%
  560      3371     13.72    0.4%
  580      3502     8.609    0.2%
  600      3608     13.11    0.3%
  620      3747     13.63    0.3%
  640      3837     13.05    0.3%
  660      3943      16.6    0.4%
  680      4097     18.12    0.4%
  700      4202     9.469    0.2%
  720      4332     10.87    0.2%
  740      4436     16.24    0.3%
  760      4560     19.56    0.4%
  780      4700     15.78    0.3%
  800      4795     10.82    0.2%
  820      4919      19.8    0.4%
  840      5020     15.65    0.3%
  860      5151     17.74    0.3%
  880      5260     11.56    0.2%
  900      5377     19.11    0.3%
  920      5510     21.39    0.3%
  940      5709     14.45    0.2%
  960      5848      21.5    0.3%
  980      5982     17.01    0.2%
 1000      6060     22.65    0.3%

Quality and confidence:
param     error
c         0.004

Model:
Time ~=    19.22
    + c    5.998
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)

Pallet: "pallet_utility", Extrinsic: "dispatch_as", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

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

Model:
Time ~=    14.34
              µs

Reads = 0
Writes = 0

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

Model:
Time ~=    14.34
              µs

Reads = 0
Writes = 0


Parity Bot and others added 3 commits October 30, 2021 04:26
…path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_utility --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/utility/src/weights.rs --template=./.maintain/frame-weight-template.hbs
frame/support/src/traits/dispatch.rs Outdated Show resolved Hide resolved
})]
pub fn dispatch_as(
origin: OriginFor<T>,
as_origin: Box<T::PalletsOrigin>,
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to box it? It wasn't boxed before you added the benchmark. We should solve it there when possible.

Copy link
Contributor Author

@xlc xlc Oct 30, 2021

Choose a reason for hiding this comment

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

it is generally good idea to box big data structure in call parameter to avoid increase the Call enum size. the same reason box is used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I thought it was related to the benchmarks. Didn't know that this is a big argument, though.

frame/utility/src/benchmarking.rs Outdated Show resolved Hide resolved
frame/utility/src/lib.rs Outdated Show resolved Hide resolved
@azerella
Copy link

azerella commented Nov 1, 2021

bot merge

@paritytech-processbot
Copy link

Error: Response error (status 404 Not Found):

{"documentation_url":"https://docs.github.com/rest/reference/pulls#get-a-pull-request","message":"Not Found"}

@azerella
Copy link

azerella commented Nov 2, 2021

bot merge

@paritytech-processbot
Copy link

Error: Response error (status 404 Not Found):

{"documentation_url":"https://docs.github.com/rest/reference/pulls#get-a-pull-request","message":"Not Found"}

@azerella
Copy link

azerella commented Nov 2, 2021

bot merge

@paritytech-processbot
Copy link

Error: Response error (status 404 Not Found):

{"documentation_url":"https://docs.github.com/rest/reference/pulls#get-a-pull-request","message":"Not Found"}

@xlc
Copy link
Contributor Author

xlc commented Nov 2, 2021

Ummm... Is there some bots end up in an infinite loop or something?

@shawntabrizi
Copy link
Member

@xlc we are looking into it. We can merge manually if we need to, but better to let the bot engineers figure out what is going on here.

@xlc
Copy link
Contributor Author

xlc commented Nov 2, 2021

No problems. This isn’t a blocking issue for us so take your time.

@azerella
Copy link

azerella commented Nov 3, 2021

bot merge

@paritytech-processbot
Copy link

Error: Github API says paritytech/polkadot#4075 is not mergeable

@TriplEight
Copy link
Contributor

bot merge

@paritytech-processbot
Copy link

Error: Github API says paritytech/polkadot#4075 is not mergeable

@shawntabrizi shawntabrizi merged commit a946572 into paritytech:master Nov 4, 2021
@xlc xlc deleted the dispatch-as branch November 5, 2021 04:05
@viniul viniul added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Dec 8, 2021
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
* implement dispatch_as

* fix

* fix

* weight for dispatch_as

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

* fix

* Update frame/utility/src/benchmarking.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* fix issues

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
AurevoirXavier added a commit to darwinia-network/darwinia-common that referenced this pull request Aug 4, 2022
AurevoirXavier added a commit to darwinia-network/darwinia that referenced this pull request Aug 16, 2022
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* implement dispatch_as

* fix

* fix

* weight for dispatch_as

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

* fix

* Update frame/utility/src/benchmarking.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* fix issues

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

A way for root to dispatch on behalf other origin
9 participants