Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connector redesign #132

Open
3 tasks
isabellelaususan opened this issue Jun 28, 2023 · 0 comments
Open
3 tasks

Connector redesign #132

isabellelaususan opened this issue Jun 28, 2023 · 0 comments
Assignees
Labels
connector Connector parent epic release-nov

Comments

@isabellelaususan
Copy link

isabellelaususan commented Jun 28, 2023

Feature description
Connector redesign based on this document
https://www.notion.so/teamanalog/Connector-Redesign-5a2dd536e3284aa7917ee3a3552124a7

/// Possible transaction statuses returned from [`Client::poll_next_event()`].
pub enum TxStatus<ID> {
    /// Transaction is part of the future queue.
    Validated,
    /// The transaction has been broadcast to other nodes.
    Broadcasted,
    /// Transaction is no longer in a best block.
    NoLongerInBestBlock,
    /// Transaction has been included in block with given hash.
    InBestBlock(ID),
    /// Transaction has been finalized by a finality-gadget, e.g GRANDPA
    InFinalizedBlock(ID),
    /// Something went wrong in the node.
    Error {
        /// Human readable message; what went wrong.
        message: String,
    },
    /// Transaction is invalid (bad nonce, signature etc).
    Invalid {
        /// Human readable message; why was it invalid.
        message: String,
    },
    /// The transaction was dropped.
    Dropped {
        /// Human readable message; why was it dropped.
        message: String,
    },
}

/// Event generated by the `Client`.
pub enum ClientEvent<T: Client> {
    /// Event generated by the Client
    Notify(T::Event),

    /// Informs that the tx status was updated
    TxStatus { id: T::TransactionIdentifier, result: Result<TxStatus<T>, T::Error> },
    
    /// Query Result
    Query { id: T::QueryId, result: Result<T::ViewCallResult, T::Error> },

    /// Close the connection for the given reason.
    Close(T::Error),
}

pub trait Client: Sized {
    // Transactions
    type TransactionIdentifier;
    type Transaction: Encode + Decode;
    
    // View Calls
    type ViewCallIdentifier;
    type ViewCall: Encode + Decode;
    type ViewCallResult: Encode + Decode;

    // Client Events
    type Event;
    type Error: Debug;

    /// Submits a signed transaction
    fn submit(
        &mut self,
        tx: Self::Transaction,
    ) -> Result<Self::TransactionIdentifier, Self::Error>;

    /// Query some read-only data
    fn view_call(
        &mut self,
        query: Self::ViewCall,
    ) -> Result<Self::ViewCallIdentifier, Self::Error>;

    /// Should behave like `Stream::poll()`.
    fn poll_next_event(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<ClientEvent<Self>>;
}

Expected output

  • Make connector API Opaque
  • Detect availability errors (ex: offline RPC, unsync Client, request timeout, fatal errors, etc)
  • Detect protocol errors (ex: eth_call which reverts, out of gas, invalid view call, etc)

Tests instructions

  • Unit tests
  • Integration tests

References Material

  • Technical Specs
  • Related docs
  • Example code

Additional Information

@isabellelaususan isabellelaususan added this to the Milestone Q3 2023 milestone Jun 28, 2023
@Lohann Lohann changed the title Connector refactoring/integration refactoring Connector redesign Oct 16, 2023
@Lohann Lohann assigned Lohann and unassigned Haider-Ali-DS Oct 16, 2023
@Lohann Lohann added the connector Connector parent epic label Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connector Connector parent epic release-nov
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants