diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index b810aa1522..7e7317f161 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -104,16 +104,16 @@ impl MessageBridge for WithRialtoMessageBridge { 0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391 } - fn this_weight_to_balance(weight: Weight) -> bp_rialto::Balance { + fn this_weight_to_this_balance(weight: Weight) -> bp_millau::Balance { ::WeightToFee::calc(&weight) } - fn bridged_weight_to_balance(weight: Weight) -> bp_millau::Balance { + fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_rialto::Balance { // we're using the same weights in both chains now ::WeightToFee::calc(&weight) } - fn this_chain_balance_to_bridged_chain_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance { + fn this_balance_to_bridged_balance(this_balance: bp_millau::Balance) -> bp_rialto::Balance { // 1:1 conversion that will probably change in the future this_balance } diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index 65797322bc..5a2cfba73d 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -104,16 +104,16 @@ impl MessageBridge for WithMillauMessageBridge { 0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391 } - fn this_weight_to_balance(weight: Weight) -> bp_rialto::Balance { + fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance { ::WeightToFee::calc(&weight) } - fn bridged_weight_to_balance(weight: Weight) -> bp_millau::Balance { + fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance { // we're using the same weights in both chains now ::WeightToFee::calc(&weight) } - fn this_chain_balance_to_bridged_chain_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance { + fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance { // 1:1 conversion that will probably change in the future this_balance } diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 264efd409c..9a934ee162 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -61,15 +61,13 @@ pub trait MessageBridge { fn weight_of_reward_confirmation_transaction_on_target_chain() -> WeightOf>; /// Convert weight of This chain to the fee (paid in Balance) of This chain. - fn this_weight_to_balance(weight: WeightOf>) -> BalanceOf>; + fn this_weight_to_this_balance(weight: WeightOf>) -> BalanceOf>; /// Convert weight of the Bridged chain to the fee (paid in Balance) of the Bridged chain. - fn bridged_weight_to_balance(weight: WeightOf>) -> BalanceOf>; + fn bridged_weight_to_bridged_balance(weight: WeightOf>) -> BalanceOf>; /// Convert This chain Balance into Bridged chain Balance. - fn this_chain_balance_to_bridged_chain_balance( - this_balance: BalanceOf>, - ) -> BalanceOf>; + fn this_balance_to_bridged_balance(this_balance: BalanceOf>) -> BalanceOf>; } /// Chain that has `message-lane` and `call-dispatch` modules. @@ -152,8 +150,7 @@ pub mod source { estimate_message_dispatch_and_delivery_fee::(payload, B::RELAYER_FEE_PERCENT)?; // compare with actual fee paid - let actual_fee_in_bridged_tokens = - B::this_chain_balance_to_bridged_chain_balance(*delivery_and_dispatch_fee); + let actual_fee_in_bridged_tokens = B::this_balance_to_bridged_balance(*delivery_and_dispatch_fee); if actual_fee_in_bridged_tokens < minimal_fee_in_bridged_tokens { return Err("Too low fee paid"); } @@ -171,13 +168,13 @@ pub mod source { relayer_fee_percent: u32, ) -> Result>, &'static str> { // the fee (in Bridged tokens) of all transactions that are made on the Bridged chain - let delivery_fee = B::bridged_weight_to_balance(B::weight_of_delivery_transaction()); - let dispatch_fee = B::bridged_weight_to_balance(payload.weight.into()); + let delivery_fee = B::bridged_weight_to_bridged_balance(B::weight_of_delivery_transaction()); + let dispatch_fee = B::bridged_weight_to_bridged_balance(payload.weight.into()); let reward_confirmation_fee = - B::bridged_weight_to_balance(B::weight_of_reward_confirmation_transaction_on_target_chain()); + B::bridged_weight_to_bridged_balance(B::weight_of_reward_confirmation_transaction_on_target_chain()); // the fee (in Bridged tokens) of all transactions that are made on This chain - let delivery_confirmation_fee = B::this_chain_balance_to_bridged_chain_balance(B::this_weight_to_balance( + let delivery_confirmation_fee = B::this_balance_to_bridged_balance(B::this_weight_to_this_balance( B::weight_of_delivery_confirmation_transaction_on_this_chain(), )); @@ -444,15 +441,15 @@ mod tests { REWARD_CONFIRMATION_TRANSACTION_WEIGHT } - fn this_weight_to_balance(weight: Weight) -> ThisChainBalance { + fn this_weight_to_this_balance(weight: Weight) -> ThisChainBalance { ThisChainBalance(weight as u32 * THIS_CHAIN_WEIGHT_TO_BALANCE_RATE as u32) } - fn bridged_weight_to_balance(weight: Weight) -> BridgedChainBalance { + fn bridged_weight_to_bridged_balance(weight: Weight) -> BridgedChainBalance { BridgedChainBalance(weight as u32 * BRIDGED_CHAIN_WEIGHT_TO_BALANCE_RATE as u32) } - fn this_chain_balance_to_bridged_chain_balance(this_balance: ThisChainBalance) -> BridgedChainBalance { + fn this_balance_to_bridged_balance(this_balance: ThisChainBalance) -> BridgedChainBalance { BridgedChainBalance(this_balance.0 * THIS_CHAIN_TO_BRIDGED_CHAIN_BALANCE_RATE as u32) } } @@ -483,15 +480,15 @@ mod tests { unreachable!() } - fn this_weight_to_balance(_weight: Weight) -> BridgedChainBalance { + fn this_weight_to_this_balance(_weight: Weight) -> BridgedChainBalance { unreachable!() } - fn bridged_weight_to_balance(_weight: Weight) -> ThisChainBalance { + fn bridged_weight_to_bridged_balance(_weight: Weight) -> ThisChainBalance { unreachable!() } - fn this_chain_balance_to_bridged_chain_balance(_this_balance: BridgedChainBalance) -> ThisChainBalance { + fn this_balance_to_bridged_balance(_this_balance: BridgedChainBalance) -> ThisChainBalance { unreachable!() } }