mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 16:51:02 +00:00
only refund if all bundled messages have been delivered (#2019)
This commit is contained in:
committed by
Bastian Köcher
parent
f659ebed7a
commit
4d29753f73
@@ -344,6 +344,16 @@ where
|
||||
finality_proof_info.block_number,
|
||||
) {
|
||||
// we only refund relayer if all calls have updated chain state
|
||||
log::trace!(
|
||||
target: "runtime::bridge",
|
||||
"{} from parachain {} via {:?}: failed to refund relayer {:?}, because \
|
||||
relay chain finality proof has not been accepted",
|
||||
Self::IDENTIFIER,
|
||||
Para::Id::get(),
|
||||
Msgs::Id::get(),
|
||||
relayer,
|
||||
);
|
||||
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -366,15 +376,34 @@ where
|
||||
para_proof_info,
|
||||
) {
|
||||
// we only refund relayer if all calls have updated chain state
|
||||
log::trace!(
|
||||
target: "runtime::bridge",
|
||||
"{} from parachain {} via {:?}: failed to refund relayer {:?}, because \
|
||||
parachain finality proof has not been accepted",
|
||||
Self::IDENTIFIER,
|
||||
Para::Id::get(),
|
||||
Msgs::Id::get(),
|
||||
relayer,
|
||||
);
|
||||
|
||||
return Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the `ReceiveMessagesProof` call delivered at least some of the messages that
|
||||
// Check if the `ReceiveMessagesProof` call delivered all the messages that
|
||||
// it contained. If this happens, we consider the transaction "helpful" and refund it.
|
||||
let msgs_call_info = call_info.messages_call_info();
|
||||
if !MessagesCallHelper::<Runtime, Msgs::Instance>::was_partially_successful(msgs_call_info)
|
||||
{
|
||||
if !MessagesCallHelper::<Runtime, Msgs::Instance>::was_successful(msgs_call_info) {
|
||||
log::trace!(
|
||||
target: "runtime::bridge",
|
||||
"{} from parachain {} via {:?}: failed to refund relayer {:?}, because \
|
||||
some of messages have not been accepted",
|
||||
Self::IDENTIFIER,
|
||||
Para::Id::get(),
|
||||
Msgs::Id::get(),
|
||||
relayer,
|
||||
);
|
||||
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -1032,6 +1061,30 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn post_dispatch_ignores_transaction_that_has_not_delivered_all_messages() {
|
||||
run_test(|| {
|
||||
initialize_environment(200, 200, Default::default(), 150);
|
||||
|
||||
assert_storage_noop!(run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(())));
|
||||
assert_storage_noop!(run_post_dispatch(
|
||||
Some(parachain_finality_pre_dispatch_data()),
|
||||
Ok(())
|
||||
));
|
||||
assert_storage_noop!(run_post_dispatch(Some(delivery_pre_dispatch_data()), Ok(())));
|
||||
|
||||
assert_storage_noop!(run_post_dispatch(
|
||||
Some(all_finality_confirmation_pre_dispatch_data()),
|
||||
Ok(())
|
||||
));
|
||||
assert_storage_noop!(run_post_dispatch(
|
||||
Some(parachain_finality_confirmation_pre_dispatch_data()),
|
||||
Ok(())
|
||||
));
|
||||
assert_storage_noop!(run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(())));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn post_dispatch_refunds_relayer_in_all_finality_batch_with_extra_weight() {
|
||||
run_test(|| {
|
||||
|
||||
Reference in New Issue
Block a user