mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
Reward relayers for dispatching messages (#385)
* reward relayers for dispatching messages * clippy * Update modules/message-lane/src/lib.rs Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * added comment * Update modules/message-lane/src/inbound_lane.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update modules/message-lane/src/inbound_lane.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * SubmitterId + RelayerId -> AccountId * add confirmation_relayer arg to pay_relayer_reward * cargo fmt --all * removed verify_and_decode_messages_proof from SourceHeaderChain * &mut self -> RefCell * Optimize max messages at inbound lane (#418) * Add tests for checking messages above max limit Signed-off-by: MaciejBaj <macie.baj@gmail.com> * Extend the relayers entry of inbound lane by additional msg nonce Signed-off-by: MaciejBaj <macie.baj@gmail.com> * Support additional message nonce from inbound relayers Signed-off-by: MaciejBaj <macie.baj@gmail.com> * Code format Signed-off-by: MaciejBaj <macie.baj@gmail.com> * Merge messages range for highest relayers * Change unwrap() to ensure() while accessing relayers * Edit rustdocs for relayers deque at inbound lane data Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Declare additional relayers A & B and use across tests consistently Signed-off-by: MaciejBaj <macie.baj@gmail.com> * Remove duplicates and improve naming for inbound lane tests * Fix test checking max limit per inbound lane * Correct relayers rewards loop after a proof is received * Remove redundant check for messages ahead of received range * Correct grammar at inbound lane tests rustdocs Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Improve code quality of relayers updates 💅 Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Test dispatches above max limit from same relayer Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Fix typo. Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Maciej Baj <macie.baj@gmail.com> Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
c42023269a
commit
bff930d01e
@@ -25,7 +25,7 @@
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::RuntimeDebug;
|
||||
use sp_api::decl_runtime_apis;
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{collections::vec_deque::VecDeque, prelude::*};
|
||||
|
||||
pub mod source_chain;
|
||||
pub mod target_chain;
|
||||
@@ -70,14 +70,38 @@ pub struct Message<Fee> {
|
||||
}
|
||||
|
||||
/// Inbound lane data.
|
||||
#[derive(Default, Encode, Decode, Clone, RuntimeDebug, PartialEq)]
|
||||
pub struct InboundLaneData {
|
||||
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)]
|
||||
pub struct InboundLaneData<RelayerId> {
|
||||
/// Identifiers of relayers and messages that they have delivered (ordered by message nonce).
|
||||
/// It is guaranteed to have at most N entries, where N is configured at module level. If
|
||||
/// there are N entries in this vec, then:
|
||||
/// 1) all incoming messages are rejected if they're missing corresponding `proof-of(outbound-lane.state)`;
|
||||
/// 2) all incoming messages are rejected if `proof-of(outbound-lane.state).latest_received_nonce` is
|
||||
/// equal to `this.latest_confirmed_nonce`.
|
||||
/// Given what is said above, all nonces in this queue are in range (latest_confirmed_nonce; latest_received_nonce].
|
||||
///
|
||||
/// When a relayer sends a single message, both of MessageNonces are the same.
|
||||
/// When relayer sends messages in a batch, the first arg is the lowest nonce, second arg the highest nonce.
|
||||
/// Multiple dispatches from the same relayer one are allowed.
|
||||
pub relayers: VecDeque<(MessageNonce, MessageNonce, RelayerId)>,
|
||||
/// Nonce of latest message that we have received from bridged chain.
|
||||
pub latest_received_nonce: MessageNonce,
|
||||
/// Nonce of latest message that has been confirmed to the bridged chain.
|
||||
pub latest_confirmed_nonce: MessageNonce,
|
||||
}
|
||||
|
||||
impl<RelayerId> Default for InboundLaneData<RelayerId> {
|
||||
fn default() -> Self {
|
||||
InboundLaneData {
|
||||
relayers: VecDeque::new(),
|
||||
latest_received_nonce: 0,
|
||||
latest_confirmed_nonce: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Outbound lane data.
|
||||
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq)]
|
||||
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)]
|
||||
pub struct OutboundLaneData {
|
||||
/// Nonce of oldest message that we haven't yet pruned. May point to not-yet-generated message if
|
||||
/// all sent messages are already pruned.
|
||||
|
||||
Reference in New Issue
Block a user