pay dispatch fee at target chain (#911)

* pay dispatch fee at target chain

* refund unspent dispatch weight to messages relayer

* test that transfer actually happens

* pay-at-target-cchain benchmarks + fix previous benchmarks (invalid signature)

* include/exclude pay-dispatch-fee weight from delivery_and_dispatch_fee/delivery tx cost

* remvoe some redundant traces

* enum DispatchFeePayment {}

* typo

* update docs

* (revert removal of valid check)

* Update modules/messages/src/benchmarking.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update modules/messages/src/benchmarking.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update modules/messages/src/benchmarking.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update modules/messages/src/benchmarking.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
Svyatoslav Nikolsky
2021-06-18 12:35:15 +03:00
committed by Bastian Köcher
parent 613803a15d
commit 20b7f341e1
27 changed files with 1052 additions and 278 deletions
@@ -72,7 +72,7 @@ mod tests {
#[test]
fn should_encode_raw_message() {
// given
let msg = "01000000e88514000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d3c040130000000000000000000000000";
let msg = "01000000e88514000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c040130000000000000000000000000";
let encode_message = EncodeMessage::from_iter(vec!["encode-message", "MillauToRialto", "raw", msg]);
// when
@@ -101,6 +101,6 @@ mod tests {
let hex = encode_message.encode().unwrap();
// then
assert_eq!(format!("{:?}", hex), "0x01000000e88514000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d3c040130000000000000000000000000");
assert_eq!(format!("{:?}", hex), "0x01000000e88514000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c040130000000000000000000000000");
}
}
@@ -22,6 +22,7 @@ use crate::cli::{
TargetSigningParams,
};
use bp_message_dispatch::{CallOrigin, MessagePayload};
use bp_runtime::messages::DispatchFeePayment;
use codec::Encode;
use frame_support::{dispatch::GetDispatchInfo, weights::Weight};
use relay_substrate_client::{Chain, TransactionSignScheme};
@@ -211,6 +212,7 @@ where
spec_version,
weight,
origin,
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
call: HexBytes::encode(call),
};
@@ -222,12 +224,14 @@ where
spec_version,
weight,
origin,
dispatch_fee_payment,
call,
} = payload;
MessagePayload {
spec_version,
weight,
origin,
dispatch_fee_payment,
call: call.0,
}
}
@@ -268,6 +272,7 @@ mod tests {
spec_version: relay_millau_client::Millau::RUNTIME_VERSION.spec_version,
weight: 1345000,
origin: CallOrigin::SourceAccount(sp_keyring::AccountKeyring::Alice.to_account_id()),
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
call: hex!("0401081234").to_vec(),
}
);
@@ -311,6 +316,7 @@ mod tests {
sp_keyring::AccountKeyring::Bob.into(),
signature,
),
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
call: hex!("0701081234").to_vec(),
}
);
@@ -204,7 +204,7 @@ mod tests {
// reserved for messages dispatch allows dispatch of non-trivial messages.
//
// Any significant change in this values should attract additional attention.
(1024, 216_583_333_334),
(814, 216_583_333_334),
);
}
}