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

Retrieve Cardano blocks with chainsync in pallas #1590

Closed
4 tasks done
Tracked by #1457 ...
jpraynaud opened this issue Mar 26, 2024 · 2 comments · Fixed by #1680
Closed
4 tasks done
Tracked by #1457 ...

Retrieve Cardano blocks with chainsync in pallas #1590

jpraynaud opened this issue Mar 26, 2024 · 2 comments · Fixed by #1680
Assignees
Labels
feature 🚀 New implemented feature good first issue 👋 Good for newcomers

Comments

@jpraynaud
Copy link
Member

jpraynaud commented Mar 26, 2024

Why

We want to retrieve blocks from the Cardano node by using the chainsync mini protocol instead of reading the immutable files: this will allow us to get data closer to the tip of the chain (e.g. volatile data). This will also enable Mithril node transactions database warm-up in a background thread.

What

Create a PallasBlockReader that can interact with Cardano chainsync mini protocol and implements the draft trait ChainBlockReader:

/// The parsed chain block representation
pub type ParsedBlock = pallas::MultiEraBlock;

/// The action that indicates what to do next when scanning the chain
pub enum ChainBlockNextAction {
    /// RollForward event (we are still on the correct fork)
    RollForward {
        /// The next point in the chain to read
        next_point: ChainPoint,
        /// The parsed block 
        block: ParsedBlock,
    },
    /// RollBackward event (we are on an incorrect fork, we need to get back a point to roll forward again)
    RollBackward {
        /// The rollback point in the chain to read (as a new valid point to read from on the main chain, which has already been seen)
        rollback_point: ChainPoint,
    },
}

/// The trait that reads events to either:
/// - read next block on the chain
/// - rollback to another point in case of rollback
/// - do nothing
pub trait ChainBlockReader {
    //// Get next chain block action
    async fn get_next_chain_block(&self, point: &ChainPoint) -> StdResult<Option<ChainBlockNextAction>>;
}

How

  • Add a new chain_reader module in mithril-common
  • Define the trait ChainBlockReader
  • Implement a PallasBlockReader for the ChainBlockReader trait
  • Implement a FakeBlockReader for the ChainBlockReader trait (that we can feed with appropriate list of ChainBlockNext events)

Resources

See

@jpraynaud jpraynaud added good first issue 👋 Good for newcomers prototype 🛠️ Prototype/PoC of a feature labels Mar 26, 2024
@jpraynaud
Copy link
Member Author

FYI, @falcucci is working on the issue 👍

@falcucci
Copy link
Collaborator

falcucci commented Apr 12, 2024

@jpraynaud 🫡

@jpraynaud jpraynaud self-assigned this May 15, 2024
@jpraynaud jpraynaud changed the title Retrieves Cardano blocks with chainsync in pallas PoC Retrieve Cardano blocks with chainsync in pallas PoC May 22, 2024
@jpraynaud jpraynaud added feature 🚀 New implemented feature and removed prototype 🛠️ Prototype/PoC of a feature labels May 23, 2024
@jpraynaud jpraynaud changed the title Retrieve Cardano blocks with chainsync in pallas PoC Retrieve Cardano blocks with chainsync in pallas May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New implemented feature good first issue 👋 Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants