mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Bridges subtree sync (#3022)
* Squashed 'bridges/' changes from edf33a2c85..277f0d5496 277f0d5496 Dynamic fees for bridges-v1 (#2294) b1c51f7dd2 Finality loop refactoring (#2357) 620db2b10f Add equivocation detector crate and implement clients (#2348) (#2353) 3fe4b13eb4 Add basic equivocation detection pipeline schema (#2338) (#2341) git-subtree-dir: bridges git-subtree-split: 277f0d54961c800b231d8123c6445f378b1deb89 * [dynfees] Rococo/Wococo does not need congestion and dynamic fees (for now) * Fix * ".git/.scripts/commands/fmt/fmt.sh" * Forgotten bridges/Cargo.lock --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -387,6 +387,14 @@ impl Default for OutboundLaneData {
|
||||
}
|
||||
}
|
||||
|
||||
impl OutboundLaneData {
|
||||
/// Return nonces of all currently queued messages (i.e. messages that we believe
|
||||
/// are not delivered yet).
|
||||
pub fn queued_messages(&self) -> RangeInclusive<MessageNonce> {
|
||||
(self.latest_received_nonce + 1)..=self.latest_generated_nonce
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate the number of messages that the relayers have delivered.
|
||||
pub fn calc_relayers_rewards<AccountId>(
|
||||
messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
|
||||
|
||||
@@ -115,11 +115,26 @@ impl<AccountId> DeliveryConfirmationPayments<AccountId> for () {
|
||||
}
|
||||
}
|
||||
|
||||
/// Callback that is called at the source chain (bridge hub) when we get delivery confirmation
|
||||
/// for new messages.
|
||||
pub trait OnMessagesDelivered {
|
||||
/// New messages delivery has been confirmed.
|
||||
///
|
||||
/// The only argument of the function is the number of yet undelivered messages
|
||||
fn on_messages_delivered(lane: LaneId, enqueued_messages: MessageNonce);
|
||||
}
|
||||
|
||||
impl OnMessagesDelivered for () {
|
||||
fn on_messages_delivered(_lane: LaneId, _enqueued_messages: MessageNonce) {}
|
||||
}
|
||||
|
||||
/// Send message artifacts.
|
||||
#[derive(Eq, RuntimeDebug, PartialEq)]
|
||||
pub struct SendMessageArtifacts {
|
||||
/// Nonce of the message.
|
||||
pub nonce: MessageNonce,
|
||||
/// Number of enqueued messages at the lane, after the message is sent.
|
||||
pub enqueued_messages: MessageNonce,
|
||||
}
|
||||
|
||||
/// Messages bridge API to be used from other pallets.
|
||||
@@ -141,7 +156,7 @@ impl<Payload> MessagesBridge<Payload> for NoopMessagesBridge {
|
||||
type Error = &'static str;
|
||||
|
||||
fn send_message(_lane: LaneId, _message: Payload) -> Result<SendMessageArtifacts, Self::Error> {
|
||||
Ok(SendMessageArtifacts { nonce: 0 })
|
||||
Ok(SendMessageArtifacts { nonce: 0, enqueued_messages: 0 })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,15 @@ pub trait MessageDispatch {
|
||||
/// Fine-grained result of single message dispatch (for better diagnostic purposes)
|
||||
type DispatchLevelResult: Clone + sp_std::fmt::Debug + Eq;
|
||||
|
||||
/// Returns `true` if dispatcher is ready to accept additional messages. The `false` should
|
||||
/// be treated as a hint by both dispatcher and its consumers - i.e. dispatcher shall not
|
||||
/// simply drop messages if it returns `false`. The consumer may still call the `dispatch`
|
||||
/// if dispatcher has returned `false`.
|
||||
///
|
||||
/// We check it in the messages delivery transaction prologue. So if it becomes `false`
|
||||
/// after some portion of messages is already dispatched, it doesn't fail the whole transaction.
|
||||
fn is_active() -> bool;
|
||||
|
||||
/// Estimate dispatch weight.
|
||||
///
|
||||
/// This function must return correct upper bound of dispatch weight. The return value
|
||||
@@ -186,6 +195,10 @@ impl<MessagesProof, DispatchPayload: Decode> MessageDispatch
|
||||
type DispatchPayload = DispatchPayload;
|
||||
type DispatchLevelResult = ();
|
||||
|
||||
fn is_active() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn dispatch_weight(_message: &mut DispatchMessage<Self::DispatchPayload>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user