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

HRMP benchmarks #3876

Merged
merged 55 commits into from
Jan 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
743bbbe
wip template for hrmp benchmarks
kianenigma Sep 17, 2021
4c1e545
add all of the benchmarks, first draft
kianenigma Sep 20, 2021
d9cc590
Master.into()
kianenigma Sep 20, 2021
42ea875
File was not saved :/
kianenigma Sep 20, 2021
477731c
cargo +nightly fmt
kianenigma Sep 20, 2021
e7aadf5
Use configs
kianenigma Sep 21, 2021
9f0d525
add configs
kianenigma Sep 21, 2021
2387d7f
Merge branch 'master' of github.com:paritytech/polkadot into kiz-benc…
kianenigma Sep 21, 2021
21b2cf5
Fix rococo
kianenigma Sep 21, 2021
40eb5ca
Final touches
kianenigma Sep 21, 2021
a6a1af2
revert fmt changes, one last time
kianenigma Sep 21, 2021
948c03d
Fix wrappings
kianenigma Sep 21, 2021
7599df2
Master.into()
kianenigma Sep 21, 2021
d253c7b
Fix a bunch of tests
kianenigma Sep 21, 2021
7d830d9
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Sep 21, 2021
7cbd3ea
add to westend
kianenigma Sep 21, 2021
761d736
Merge branch 'kiz-bench-hrmp' of github.com:paritytech/polkadot into …
kianenigma Sep 21, 2021
2d08f7a
actually use everything
kianenigma Sep 21, 2021
e5b1711
Merge branch 'master' of https://github.com/paritytech/polkadot into …
Sep 21, 2021
0c06dce
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Sep 21, 2021
a383363
Update runtime/parachains/src/hrmp.rs
kianenigma Sep 22, 2021
2d850dd
Master.into()
kianenigma Sep 22, 2021
bd15361
Merge branch 'kiz-bench-hrmp' of github.com:paritytech/polkadot into …
kianenigma Sep 22, 2021
210fd05
use real weight in wnd
kianenigma Sep 22, 2021
dbd3467
reorg
kianenigma Sep 22, 2021
8f623a2
Master.into()
kianenigma Nov 1, 2021
132eecf
Merge branch 'master' of github.com:paritytech/polkadot into kiz-benc…
kianenigma Nov 4, 2021
80501a0
minor cleanup
kianenigma Nov 4, 2021
2b05e62
weigh some of the internal stuff as well
kianenigma Nov 4, 2021
5e0760a
Merge branch 'master' of https://github.com/paritytech/polkadot into …
Nov 5, 2021
7e0c420
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 5, 2021
6a2f991
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 5, 2021
35f028f
add files
kianenigma Nov 5, 2021
d84ecbc
Merge branch 'kiz-bench-hrmp' of github.com:paritytech/polkadot into …
kianenigma Nov 5, 2021
05da935
Master.into()
kianenigma Nov 5, 2021
2906568
Merge branch 'master' of github.com:paritytech/polkadot into kiz-benc…
kianenigma Nov 10, 2021
e79d7f7
add validation
kianenigma Nov 10, 2021
33c0fbb
fmt
kianenigma Nov 10, 2021
d16547d
addrress review comments
kianenigma Nov 18, 2021
323c238
fmt
pepyakin Nov 18, 2021
1d2e8d9
Master.into()
kianenigma Nov 26, 2021
551053a
Merge branch 'kiz-bench-hrmp' of github.com:paritytech/polkadot into …
kianenigma Nov 26, 2021
69593c5
Master is .into()'ed baby
kianenigma Dec 11, 2021
3255d9d
Master.into()
kianenigma Jan 20, 2022
7a3d6fe
final fixes
kianenigma Jan 20, 2022
0558cdf
all runtimes build
kianenigma Jan 20, 2022
a91ce3f
undo formatting
kianenigma Jan 20, 2022
4a1e33d
Master.into()
kianenigma Jan 20, 2022
ca91f06
Update runtime/parachains/src/hrmp.rs
kianenigma Jan 20, 2022
2cb4e67
non-controversial changes
kianenigma Jan 21, 2022
e22a79f
do it the parachain-way: use const instead of type configs for simpli…
kianenigma Jan 21, 2022
2ec5575
Merge branch 'kiz-bench-hrmp' of github.com:paritytech/polkadot into …
kianenigma Jan 21, 2022
a47ea77
borrow assert_storage_consistency_exhaustive
kianenigma Jan 21, 2022
745e146
move assert_storage_consistency_exhaustive to Pallet, so it can be re…
kianenigma Jan 21, 2022
523ff33
fix typo
kianenigma Jan 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add configs
  • Loading branch information
kianenigma committed Sep 21, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9f0d5251262fbf2e6c36d4afc86700dbb7bb26c1
2 changes: 2 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1134,6 +1134,8 @@ impl parachains_origin::Config for Runtime {}

impl parachains_configuration::Config for Runtime {
type WeightInfo = weights::runtime_parachains_configuration::WeightInfo<Runtime>;
type HrmpMaxOutboundChannelsBound = ConstU32<128>;
type HrmpMaxInboundChannelsBound = ConstU32<128>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rather arbitrary numbers.

}

impl parachains_shared::Config for Runtime {}
4 changes: 2 additions & 2 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -527,8 +527,8 @@ pub mod pallet {
) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_post_conclusion_acceptance_period, new)
!= new
sp_std::mem::replace(&mut config.dispute_post_conclusion_acceptance_period, new) !=
new
});
Ok(())
}
57 changes: 28 additions & 29 deletions runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ impl fmt::Debug for OutboundHrmpAcceptanceErr {
),
NotSorted { idx } => {
write!(fmt, "the HRMP messages are not sorted (first unsorted is at index {})", idx,)
}
},
NoSuchChannel { idx, channel_id } => write!(
fmt,
"the HRMP message at index {} is sent to a non existent channel {:?}->{:?}",
@@ -580,8 +580,8 @@ impl<T: Config> Pallet<T> {
Some(req_data) => req_data,
None => {
// Can't normally happen but no need to panic.
continue;
}
continue
},
};

// Return the deposit of the sender, but only if it is not the para being offboarded.
@@ -636,7 +636,7 @@ impl<T: Config> Pallet<T> {
fn process_hrmp_open_channel_requests(config: &HostConfiguration<T::BlockNumber>) {
let mut open_req_channels = <Self as Store>::HrmpOpenChannelRequestsList::get();
if open_req_channels.is_empty() {
return;
return
}

// iterate the vector starting from the end making our way to the beginning. This way we
@@ -645,7 +645,7 @@ impl<T: Config> Pallet<T> {
loop {
// bail if we've iterated over all items.
if idx == 0 {
break;
break
}

idx -= 1;
@@ -655,8 +655,8 @@ impl<T: Config> Pallet<T> {
);

if request.confirmed {
if <paras::Pallet<T>>::is_valid_para(channel_id.sender)
&& <paras::Pallet<T>>::is_valid_para(channel_id.recipient)
if <paras::Pallet<T>>::is_valid_para(channel_id.sender) &&
<paras::Pallet<T>>::is_valid_para(channel_id.recipient)
{
<Self as Store>::HrmpChannels::insert(
&channel_id,
@@ -756,14 +756,14 @@ impl<T: Config> Pallet<T> {
return Err(HrmpWatermarkAcceptanceErr::AdvancementRule {
new_watermark: new_hrmp_watermark,
last_watermark,
});
})
}
}
if new_hrmp_watermark > relay_chain_parent_number {
return Err(HrmpWatermarkAcceptanceErr::AheadRelayParent {
new_watermark: new_hrmp_watermark,
relay_chain_parent_number,
});
})
}

// Second, check where the watermark CAN land. It's one of the following:
@@ -780,7 +780,7 @@ impl<T: Config> Pallet<T> {
{
return Err(HrmpWatermarkAcceptanceErr::LandsOnBlockWithNoMessages {
new_watermark: new_hrmp_watermark,
});
})
}
Ok(())
}
@@ -795,7 +795,7 @@ impl<T: Config> Pallet<T> {
return Err(OutboundHrmpAcceptanceErr::MoreMessagesThanPermitted {
sent: out_hrmp_msgs.len() as u32,
permitted: config.hrmp_max_message_num_per_candidate,
});
})
}

let mut last_recipient = None::<ParaId>;
@@ -807,9 +807,8 @@ impl<T: Config> Pallet<T> {
// the messages must be sorted in ascending order and there must be no two messages sent
// to the same recipient. Thus we can check that every recipient is strictly greater than
// the previous one.
Some(last_recipient) if out_msg.recipient <= last_recipient => {
return Err(OutboundHrmpAcceptanceErr::NotSorted { idx })
}
Some(last_recipient) if out_msg.recipient <= last_recipient =>
return Err(OutboundHrmpAcceptanceErr::NotSorted { idx }),
_ => last_recipient = Some(out_msg.recipient),
}

@@ -826,7 +825,7 @@ impl<T: Config> Pallet<T> {
idx,
msg_size,
max_size: channel.max_message_size,
});
})
}

let new_total_size = channel.total_size + out_msg.data.len() as u32;
@@ -835,7 +834,7 @@ impl<T: Config> Pallet<T> {
idx,
total_size: new_total_size,
limit: channel.max_total_size,
});
})
}

let new_msg_count = channel.msg_count + 1;
@@ -844,7 +843,7 @@ impl<T: Config> Pallet<T> {
idx,
count: new_msg_count,
limit: channel.max_capacity,
});
})
}
}

@@ -930,8 +929,8 @@ impl<T: Config> Pallet<T> {
None => {
// apparently, that since acceptance of this candidate the recipient was
// offboarded and the channel no longer exists.
continue;
}
continue
},
};

let inbound = InboundHrmpMessage { sent_at: now, data: out_msg.data };
@@ -1589,13 +1588,13 @@ mod tests {
run_to_block(5, Some(vec![4, 5]));
Hrmp::hrmp_init_open_channel(para_a_origin.into(), para_b, 2, 8).unwrap();
assert_storage_consistency_exhaustive();
assert!(System::events().iter().any(|record| record.event
== MockEvent::Hrmp(Event::OpenChannelRequested(para_a, para_b, 2, 8))));
assert!(System::events().iter().any(|record| record.event ==
MockEvent::Hrmp(Event::OpenChannelRequested(para_a, para_b, 2, 8))));

Hrmp::hrmp_accept_open_channel(para_b_origin.into(), para_a).unwrap();
assert_storage_consistency_exhaustive();
assert!(System::events().iter().any(|record| record.event
== MockEvent::Hrmp(Event::OpenChannelAccepted(para_a, para_b))));
assert!(System::events().iter().any(|record| record.event ==
MockEvent::Hrmp(Event::OpenChannelAccepted(para_a, para_b))));

// Advance to a block 6, but without session change. That means that the channel has
// not been created yet.
@@ -1637,8 +1636,8 @@ mod tests {
run_to_block(8, Some(vec![8]));
assert!(!channel_exists(para_a, para_b));
assert_storage_consistency_exhaustive();
assert!(System::events().iter().any(|record| record.event
== MockEvent::Hrmp(Event::ChannelClosed(para_b, channel_id.clone()))));
assert!(System::events().iter().any(|record| record.event ==
MockEvent::Hrmp(Event::ChannelClosed(para_b, channel_id.clone()))));
});
}

@@ -2098,24 +2097,24 @@ mod benchmarking {
message_size
));
if matches!(until, ParachainSetupStep::Requested) {
return output;
return output
}

assert_ok!(Hrmp::<T>::hrmp_accept_open_channel(recipient_origin.into(), sender));
if matches!(until, ParachainSetupStep::Accepted) {
return output;
return output
}

Hrmp::<T>::process_hrmp_open_channel_requests(&Configuration::<T>::config());
if matches!(until, ParachainSetupStep::Established) {
return output;
return output
}

let channel_id = HrmpChannelId { sender, recipient };
assert_ok!(Hrmp::<T>::hrmp_close_channel(sender_origin.clone().into(), channel_id));
if matches!(until, ParachainSetupStep::CloseRequested) {
// NOTE: this is just for expressiveness, otherwise the if-statement could be omitted.
return output;
return output
}

output
2 changes: 1 addition & 1 deletion runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ impl UmpSink for TestUmpSink {
};
if weight > max_weight {
let id = sp_io::hashing::blake2_256(actual_msg);
return Err((id, weight));
return Err((id, weight))
}
PROCESSED.with(|opt_hook| {
opt_hook.borrow_mut().push((actual_origin, actual_msg.to_owned()));
15 changes: 9 additions & 6 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -568,6 +568,8 @@ impl parachains_origin::Config for Runtime {}

impl parachains_configuration::Config for Runtime {
type WeightInfo = parachains_configuration::weights::WeightInfo<Runtime>;
type HrmpMaxOutboundChannelsBound = ConstU32<128>;
type HrmpMaxInboundChannelsBound = ConstU32<128>;
}

impl parachains_shared::Config for Runtime {}
@@ -1069,14 +1071,15 @@ impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool {
match self {
ProxyType::Any => true,
ProxyType::CancelProxy =>
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
}
ProxyType::Auction => matches!(
c,
Call::Auctions { .. } |
Call::Crowdloan { .. } |
Call::Registrar { .. } |
Call::Slots { .. }
Call::Auctions { .. }
| Call::Crowdloan { .. }
| Call::Registrar { .. }
| Call::Slots { .. }
),
}
}