Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
11 changes: 11 additions & 0 deletions bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub const INITIAL_RIALTO_TO_MILLAU_CONVERSION_RATE: FixedU128 = FixedU128::from_
parameter_types! {
/// Rialto to Millau conversion rate. Initially we treat both tokens as equal.
pub storage RialtoToMillauConversionRate: FixedU128 = INITIAL_RIALTO_TO_MILLAU_CONVERSION_RATE;
/// If `true`, all Rialto -> Millau messages are rejected.
pub storage RejectOutboundMessages: bool = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not add this parameter directly to the pallet? This is not a bridge-specific parameter and as you mentioned it will need to be copy-pasted for every bridge instance.

We already have IsHalted in the pallet now. I think the two could either be merged in one Config object with two bool values or we could introduce enum OperatingMode { Full, Halted, Inbound }

The reason is that while the current solution reduces pallet-internal complexity it adds extra integration-level complexity and I feel that's already quite high.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm considering this as 'our way' to ease upgrade process. Other may choose their own paths to solve that. Or, if they have non-upgradeable chains (like Rialto and Millau), they may just not use parameters like that. I would avoid adding any functionality that may need to be customized to the pallet itself - the pallet itself is not trivial && having potentially unused stuff there is undesirable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually - what's more important is that additional storage read. So since I don't want to make messages more expensive, I'll implement your option then

}

/// Message payload for Millau -> Rialto messages.
Expand Down Expand Up @@ -104,6 +106,10 @@ impl messages::ThisChainWithMessages for Millau {
type Call = crate::Call;

fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
if RejectOutboundMessages::get() {
return false;
}

*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1]
}

Expand Down Expand Up @@ -247,6 +253,8 @@ impl SourceHeaderChain<bp_rialto::Balance> for Rialto {
pub enum MillauToRialtoMessagesParameter {
/// The conversion formula we use is: `MillauTokens = RialtoTokens * conversion_rate`.
RialtoToMillauConversionRate(FixedU128),
/// If `true`, all new outbound messages are rejected.
RejectOutboundMessages(bool),
}

impl MessagesParameter for MillauToRialtoMessagesParameter {
Expand All @@ -255,6 +263,9 @@ impl MessagesParameter for MillauToRialtoMessagesParameter {
MillauToRialtoMessagesParameter::RialtoToMillauConversionRate(ref conversion_rate) => {
RialtoToMillauConversionRate::set(conversion_rate)
}
MillauToRialtoMessagesParameter::RejectOutboundMessages(reject_outbound_messages) => {
RejectOutboundMessages::set(&reject_outbound_messages);
}
}
}
}
11 changes: 11 additions & 0 deletions bin/rialto/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub const INITIAL_MILLAU_TO_RIALTO_CONVERSION_RATE: FixedU128 = FixedU128::from_
parameter_types! {
/// Millau to Rialto conversion rate. Initially we treat both tokens as equal.
pub storage MillauToRialtoConversionRate: FixedU128 = INITIAL_MILLAU_TO_RIALTO_CONVERSION_RATE;
/// If `true`, all Rialto -> Millau messages are rejected.
pub storage RejectOutboundMessages: bool = false;
}

/// Message payload for Rialto -> Millau messages.
Expand Down Expand Up @@ -104,6 +106,10 @@ impl messages::ThisChainWithMessages for Rialto {
type Call = crate::Call;

fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
if RejectOutboundMessages::get() {
return false;
}

*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1]
}

Expand Down Expand Up @@ -247,6 +253,8 @@ impl SourceHeaderChain<bp_millau::Balance> for Millau {
pub enum RialtoToMillauMessagesParameter {
/// The conversion formula we use is: `RialtoTokens = MillauTokens * conversion_rate`.
MillauToRialtoConversionRate(FixedU128),
/// If `true`, all new outbound messages are rejected.
RejectOutboundMessages(bool),
}

impl MessagesParameter for RialtoToMillauMessagesParameter {
Expand All @@ -255,6 +263,9 @@ impl MessagesParameter for RialtoToMillauMessagesParameter {
RialtoToMillauMessagesParameter::MillauToRialtoConversionRate(ref conversion_rate) => {
MillauToRialtoConversionRate::set(conversion_rate)
}
RialtoToMillauMessagesParameter::RejectOutboundMessages(reject_outbound_messages) => {
RejectOutboundMessages::set(&reject_outbound_messages);
}
}
}
}
3 changes: 2 additions & 1 deletion deployments/types-millau.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
"BridgedHeader": "RialtoHeader",
"Parameter": {
"_enum": {
"MillauToRialtoConversionRate": "u128"
"MillauToRialtoConversionRate": "u128",
"RejectOutboundMessages": "bool"
}
}
}
3 changes: 2 additions & 1 deletion deployments/types-rialto.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
"BridgedHeader": "MillauHeader",
"Parameter": {
"_enum": {
"RialtoToMillauConversionRate": "u128"
"RialtoToMillauConversionRate": "u128",
"RejectOutboundMessages": "bool"
}
}
}
3 changes: 2 additions & 1 deletion deployments/types/millau.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"BridgedHeader": "RialtoHeader",
"Parameter": {
"_enum": {
"MillauToRialtoConversionRate": "u128"
"MillauToRialtoConversionRate": "u128",
"RejectOutboundMessages": "bool"
}
}
}
3 changes: 2 additions & 1 deletion deployments/types/rialto.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"BridgedHeader": "MillauHeader",
"Parameter": {
"_enum": {
"RialtoToMillauConversionRate": "u128"
"RialtoToMillauConversionRate": "u128",
"RejectOutboundMessages": "bool"
}
}
}
106 changes: 53 additions & 53 deletions modules/messages/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_bridge_messages
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-04-21, STEPS: [50, ], REPEAT: 20
//! DATE: 2021-05-28, STEPS: [50, ], REPEAT: 20
//! LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
//! CHAIN: Some("dev"), DB CACHE: 128
Expand Down Expand Up @@ -73,105 +73,105 @@ pub trait WeightInfo {
pub struct RialtoWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
fn send_minimal_message_worst_case() -> Weight {
(149_643_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
(168_213_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
fn send_1_kb_message_worst_case() -> Weight {
(153_329_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
(172_381_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
fn send_16_kb_message_worst_case() -> Weight {
(200_113_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
(225_099_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
fn increase_message_fee() -> Weight {
(6_407_252_000 as Weight)
(7_297_326_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn receive_single_message_proof() -> Weight {
(141_256_000 as Weight)
(147_614_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_two_messages_proof() -> Weight {
(247_723_000 as Weight)
(255_680_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
(159_731_000 as Weight)
(164_399_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_1_kb() -> Weight {
(168_546_000 as Weight)
(174_305_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_16_kb() -> Weight {
(450_087_000 as Weight)
(460_319_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_delivery_proof_for_single_message() -> Weight {
(164_519_000 as Weight)
(143_055_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
(173_300_000 as Weight)
(149_881_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
(246_205_000 as Weight)
(211_260_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn send_messages_of_various_lengths(i: u32) -> Weight {
(149_551_000 as Weight)
.saturating_add((3_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
(125_920_000 as Weight)
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
}
fn receive_multiple_messages_proof(i: u32) -> Weight {
(0 as Weight)
.saturating_add((114_817_000 as Weight).saturating_mul(i as Weight))
.saturating_add((118_679_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
(437_797_000 as Weight)
(470_524_000 as Weight)
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
(137_633_000 as Weight)
(107_411_000 as Weight)
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
(0 as Weight)
.saturating_add((118_482_000 as Weight).saturating_mul(i as Weight))
.saturating_add((121_054_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
(116_036_000 as Weight)
.saturating_add((7_118_000 as Weight).saturating_mul(i as Weight))
(122_522_000 as Weight)
.saturating_add((8_235_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
(172_780_000 as Weight)
.saturating_add((63_718_000 as Weight).saturating_mul(i as Weight))
(109_098_000 as Weight)
.saturating_add((70_167_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Expand All @@ -182,105 +182,105 @@ impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
// For backwards compatibility and tests
impl WeightInfo for () {
fn send_minimal_message_worst_case() -> Weight {
(149_643_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
(168_213_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
fn send_1_kb_message_worst_case() -> Weight {
(153_329_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
(172_381_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
fn send_16_kb_message_worst_case() -> Weight {
(200_113_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
(225_099_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
fn increase_message_fee() -> Weight {
(6_407_252_000 as Weight)
(7_297_326_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn receive_single_message_proof() -> Weight {
(141_256_000 as Weight)
(147_614_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_two_messages_proof() -> Weight {
(247_723_000 as Weight)
(255_680_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
(159_731_000 as Weight)
(164_399_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_1_kb() -> Weight {
(168_546_000 as Weight)
(174_305_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_single_message_proof_16_kb() -> Weight {
(450_087_000 as Weight)
(460_319_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_delivery_proof_for_single_message() -> Weight {
(164_519_000 as Weight)
(143_055_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
(173_300_000 as Weight)
(149_881_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
(246_205_000 as Weight)
(211_260_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
fn send_messages_of_various_lengths(i: u32) -> Weight {
(149_551_000 as Weight)
.saturating_add((3_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
(125_920_000 as Weight)
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
fn receive_multiple_messages_proof(i: u32) -> Weight {
(0 as Weight)
.saturating_add((114_817_000 as Weight).saturating_mul(i as Weight))
.saturating_add((118_679_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
(437_797_000 as Weight)
(470_524_000 as Weight)
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
(137_633_000 as Weight)
(107_411_000 as Weight)
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
(0 as Weight)
.saturating_add((118_482_000 as Weight).saturating_mul(i as Weight))
.saturating_add((121_054_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
(116_036_000 as Weight)
.saturating_add((7_118_000 as Weight).saturating_mul(i as Weight))
(122_522_000 as Weight)
.saturating_add((8_235_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
(172_780_000 as Weight)
.saturating_add((63_718_000 as Weight).saturating_mul(i as Weight))
(109_098_000 as Weight)
.saturating_add((70_167_000 as Weight).saturating_mul(i as Weight))
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
Expand Down
2 changes: 1 addition & 1 deletion relays/bin-substrate/src/messages_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ mod tests {
// reserved for messages dispatch allows dispatch of non-trivial messages.
//
// Any significant change in this values should attract additional attention.
(1013, 216_583_333_334),
(998, 216_583_333_334),
);
}
}