Skip to content

Commit

Permalink
companion: for call usage paritytech/substrate#9418 (#3522)
Browse files Browse the repository at this point in the history
* 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 <>
  • Loading branch information
gui1117 authored Aug 7, 2021
1 parent d16726a commit dfc2f75
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion polkadot/runtime/common/src/paras_sudo_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use runtime_parachains::{
paras::{self, ParaGenesisArgs},
ump, ParaLifecycle,
};
use sp_std::boxed::Box;

#[frame_support::pallet]
pub mod pallet {
Expand Down Expand Up @@ -132,7 +133,7 @@ pub mod pallet {
pub fn sudo_queue_downward_xcm(
origin: OriginFor<T>,
id: ParaId,
xcm: xcm::opaque::VersionedXcm,
xcm: Box<xcm::opaque::VersionedXcm>,
) -> DispatchResult {
ensure_root(origin)?;
ensure!(<paras::Pallet<T>>::is_valid_para(id), Error::<T>::ParaDoesntExist);
Expand Down
10 changes: 10 additions & 0 deletions polkadot/runtime/kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,13 @@ fn era_payout_should_give_sensible_results() {
assert_eq!(era_payout(75, 100, Perquintill::from_percent(10), Perquintill::one(), 0,), (10, 0));
assert_eq!(era_payout(80, 100, Perquintill::from_percent(10), Perquintill::one(), 0,), (6, 4));
}

#[test]
fn call_size() {
assert!(
core::mem::size_of::<Call>() <= 230,
"size of Call is more than 230 bytes: 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.",
);
}
15 changes: 15 additions & 0 deletions polkadot/runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,18 @@ mod test_fees {
assert!(active > target_voters, "we need to reevaluate the weight of the election system");
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn call_size() {
assert!(
core::mem::size_of::<Call>() <= 230,
"size of Call is more than 230 bytes: 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",
);
}
}
10 changes: 10 additions & 0 deletions polkadot/runtime/westend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ fn sample_size_is_sensible() {
BlockWeights::get().max_block
);
}

#[test]
fn call_size() {
assert!(
core::mem::size_of::<Call>() <= 230,
"size of Call is more than 230 bytes: 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.",
);
}

0 comments on commit dfc2f75

Please sign in to comment.