Reject delivery transactions with at least one obsolete message (#2021)

* reject delivery transactions with at least one obsolete message

* clippy

* allow empty delivery transactions with rewards confirmations BUT only when there's no room left in the unrewarded relayers vector

* clippy

* allow empty delivery transactions if no message slots in unrewarded relayers vector
This commit is contained in:
Svyatoslav Nikolsky
2023-04-10 12:49:15 +03:00
committed by Bastian Köcher
parent 3b968a2aba
commit ceea1a10f7
4 changed files with 351 additions and 34 deletions
@@ -461,6 +461,7 @@ mod tests {
},
messages_call_ext::{
BaseMessagesProofInfo, ReceiveMessagesDeliveryProofInfo, ReceiveMessagesProofInfo,
UnrewardedRelayerOccupation,
},
mock::*,
};
@@ -567,7 +568,11 @@ mod tests {
bridged_header_hash: Default::default(),
storage_proof: vec![],
lane: TestLaneId::get(),
nonces_start: best_message,
nonces_start: pallet_bridge_messages::InboundLanes::<TestRuntime>::get(
TEST_LANE_ID,
)
.last_delivered_nonce() +
1,
nonces_end: best_message,
},
messages_count: 1,
@@ -658,8 +663,12 @@ mod tests {
MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo(
BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: Some(UnrewardedRelayerOccupation {
free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(),
free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(),
}),
},
)),
),
@@ -683,8 +692,9 @@ mod tests {
MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo(
BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: None,
},
)),
),
@@ -703,8 +713,12 @@ mod tests {
MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo(
BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: Some(UnrewardedRelayerOccupation {
free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(),
free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(),
}),
},
)),
),
@@ -723,8 +737,9 @@ mod tests {
MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo(
BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: None,
},
)),
),
@@ -737,8 +752,12 @@ mod tests {
call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesProof(
ReceiveMessagesProofInfo(BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: Some(UnrewardedRelayerOccupation {
free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(),
free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(),
}),
}),
)),
}
@@ -750,8 +769,9 @@ mod tests {
call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesDeliveryProof(
ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo {
lane_id: TEST_LANE_ID,
best_bundled_nonce: 200,
bundled_range: 101..=200,
best_stored_nonce: 100,
unrewarded_relayers: None,
}),
)),
}