mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 18:27:56 +00:00
This reverts commit ad4299f6c91ce4c50cb6fbc739a0c788e2920956.
This commit is contained in:
committed by
Bastian Köcher
parent
a88207876c
commit
eb5a3eecd2
@@ -70,7 +70,6 @@ pub trait MessageBridge {
|
||||
/// Convert Bridged chain balance into This chain balance.
|
||||
fn bridged_balance_to_this_balance(
|
||||
bridged_balance: BalanceOf<BridgedChain<Self>>,
|
||||
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> BalanceOf<ThisChain<Self>>;
|
||||
}
|
||||
|
||||
@@ -317,11 +316,8 @@ pub mod source {
|
||||
pallet_bridge_dispatch::verify_message_origin(submitter, payload)
|
||||
.map_err(|_| BAD_ORIGIN)?;
|
||||
|
||||
let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::<B>(
|
||||
payload,
|
||||
B::RELAYER_FEE_PERCENT,
|
||||
None,
|
||||
)?;
|
||||
let minimal_fee_in_this_tokens =
|
||||
estimate_message_dispatch_and_delivery_fee::<B>(payload, B::RELAYER_FEE_PERCENT)?;
|
||||
|
||||
// compare with actual fee paid
|
||||
if *delivery_and_dispatch_fee < minimal_fee_in_this_tokens {
|
||||
@@ -375,7 +371,6 @@ pub mod source {
|
||||
pub fn estimate_message_dispatch_and_delivery_fee<B: MessageBridge>(
|
||||
payload: &FromThisChainMessagePayload<B>,
|
||||
relayer_fee_percent: u32,
|
||||
bridged_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Result<BalanceOf<ThisChain<B>>, &'static str> {
|
||||
// the fee (in Bridged tokens) of all transactions that are made on the Bridged chain
|
||||
//
|
||||
@@ -396,11 +391,8 @@ pub mod source {
|
||||
ThisChain::<B>::transaction_payment(confirmation_transaction);
|
||||
|
||||
// minimal fee (in This tokens) is a sum of all required fees
|
||||
let minimal_fee = B::bridged_balance_to_this_balance(
|
||||
delivery_transaction_fee,
|
||||
bridged_to_this_conversion_rate,
|
||||
)
|
||||
.checked_add(&confirmation_transaction_fee);
|
||||
let minimal_fee = B::bridged_balance_to_this_balance(delivery_transaction_fee)
|
||||
.checked_add(&confirmation_transaction_fee);
|
||||
|
||||
// before returning, add extra fee that is paid to the relayer (relayer interest)
|
||||
minimal_fee
|
||||
@@ -806,12 +798,8 @@ mod tests {
|
||||
|
||||
fn bridged_balance_to_this_balance(
|
||||
bridged_balance: BridgedChainBalance,
|
||||
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> ThisChainBalance {
|
||||
let conversion_rate = bridged_to_this_conversion_rate_override
|
||||
.map(|r| r.to_float() as u32)
|
||||
.unwrap_or(BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE);
|
||||
ThisChainBalance(bridged_balance.0 * conversion_rate)
|
||||
ThisChainBalance(bridged_balance.0 * BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE as u32)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,10 +817,7 @@ mod tests {
|
||||
type ThisChain = BridgedChain;
|
||||
type BridgedChain = ThisChain;
|
||||
|
||||
fn bridged_balance_to_this_balance(
|
||||
_this_balance: ThisChainBalance,
|
||||
_bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> BridgedChainBalance {
|
||||
fn bridged_balance_to_this_balance(_this_balance: ThisChainBalance) -> BridgedChainBalance {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
@@ -1110,7 +1095,6 @@ mod tests {
|
||||
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||
&payload,
|
||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||
None,
|
||||
),
|
||||
Ok(ThisChainBalance(EXPECTED_MINIMAL_FEE)),
|
||||
);
|
||||
@@ -1122,7 +1106,6 @@ mod tests {
|
||||
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||
&payload_with_pay_on_target,
|
||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||
None,
|
||||
)
|
||||
.expect(
|
||||
"estimate_message_dispatch_and_delivery_fee failed for pay-at-target-chain message",
|
||||
@@ -1589,21 +1572,4 @@ mod tests {
|
||||
100 + 50 * 10 + 777,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conversion_rate_override_works() {
|
||||
let payload = regular_outbound_message_payload();
|
||||
let regular_fee = source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||
&payload,
|
||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||
None,
|
||||
);
|
||||
let overrided_fee = source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||
&payload,
|
||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||
Some(FixedU128::from_float((BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE * 2) as f64)),
|
||||
);
|
||||
|
||||
assert!(regular_fee < overrided_fee);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user