-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve call, and usage in pallet utility #9418
Conversation
@jacogr I have 1 question and 1 note:
any remark is welcomed |
Box wrappings are ignored and stripped on the type parsing. (It has no meaning outside the Rust code) If there is a batch limit on constants, can be read. |
bin/node/runtime/src/lib.rs
Outdated
#[test] | ||
fn call_size() { | ||
assert!( | ||
core::mem::size_of::<Call>() <= 200, | ||
"size of Call is more than 200: some calls have too big arguments, use Box to reduce the | ||
size of Call. | ||
If the limit is too strong, maybe consider increase the limit to 300.", | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered making a static_assertion
instead to catch this at compile time instead?
https://docs.rs/static_assertions/1.1.0/static_assertions/macro.const_assert.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave a try but I think the error message is better with a regular assert.
But all in all this assert is not really important there is no important issue with using a big call enum
error[E0080]: evaluation of constant value failed
--> bin/node/runtime/src/lib.rs:1632:3
|
1632 | / static_assertions::const_assert!(
1633 | | core::mem::size_of::<Call>() <= 20,
1634 | | );
| |__________^ attempt to compute `0_usize - 1_usize`, which would overflow
|
= note: this error originates in the macro `static_assertions::const_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until const panics are a thing, static assertions are rather useless.
#[test] | ||
fn call_size() { | ||
assert!( | ||
core::mem::size_of::<Call>() <= 200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
200 is an arbitrary number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes IIRC it is the same number as clippy lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what clippy lint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks okay to me, probably need more input from others
bin/node/runtime/src/lib.rs
Outdated
#[test] | ||
fn call_size() { | ||
assert!( | ||
core::mem::size_of::<Call>() <= 200, | ||
"size of Call is more than 200: some calls have too big arguments, use Box to reduce the | ||
size of Call. | ||
If the limit is too strong, maybe consider increase the limit to 300.", | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until const panics are a thing, static assertions are rather useless.
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to prevent a large memory allocation before decoding, this pr is not good enough. this would only prevent it after decode the proposed solution from sr labs is to instead make the signature of However, this is potentially a huge performance decrease, especially as the vec size increases TODO: Follow up |
it is implemented here #9339 |
If we can not decode a call, it is invalid anyway. I don't see the reason why we need to work here on better solutions. |
I think this PR improve call by reducing its size, and makes utility batch function limit more explicit for users. So we can merge it. Otherwise we can close it |
I'm for merging this. |
okay, then lets go ahead and do that :) I just wanted to post what was said in my last meeting with the auditors. |
bot merge |
Waiting for commit status. |
* add test for call size * fix box arg * fix xcm variant length + increase limit a bit * fix para sudo wrapper call length * reorganize * fmt * fix tests * update Substrate Co-authored-by: parity-processbot <>
* add test for call size * fix box arg * fix xcm variant length + increase limit a bit * fix para sudo wrapper call length * reorganize * fmt * fix tests * update Substrate Co-authored-by: parity-processbot <>
* add test for call size * fix box arg * fix xcm variant length + increase limit a bit * fix para sudo wrapper call length * reorganize * fmt * fix tests * update Substrate Co-authored-by: parity-processbot <>
this decrease the length of call to less than 200 (184 exactly) bytes.
and improve the usage in utility.
companion: paritytech/polkadot#3522