Skip to content

feat(utxo-rpc): Add support for BlockFetch by Slot or Height and DumpHistory to support BlockHeight#154

Closed
Mercurial wants to merge 1 commit intotxpipe:mainfrom
Mercurial:feat/fetch-block-dump-history-by-slot-or-height
Closed

feat(utxo-rpc): Add support for BlockFetch by Slot or Height and DumpHistory to support BlockHeight#154
Mercurial wants to merge 1 commit intotxpipe:mainfrom
Mercurial:feat/fetch-block-dump-history-by-slot-or-height

Conversation

@Mercurial
Copy link
Copy Markdown
Contributor

Work In Progress to support block fetch not only by hash but also by Slot or Height.

As of right now only fetching by block hash is supported.

async fn fetch_block(
        &self,
        request: Request<FetchBlockRequest>,
    ) -> Result<Response<FetchBlockResponse>, Status> {
        let message = request.into_inner();

        let blocks: Result<Vec<_>, _> = message
            .r#ref
            .iter()
            .map(|r| bytes_to_hash(&r.hash))
            .map(|hash| self.chain.get_block(hash))
            .collect();

        let out: Vec<_> = blocks
            .map_err(|_err| Status::internal("can't query block"))?
            .iter()
            .flatten()
            .map(|b| raw_to_anychain(b))
            .collect();

        let response = FetchBlockResponse { block: out };

        Ok(Response::new(response))
    }

Aswell as next_token in the DumpHistoryResponse needs to support Block->Height according to the BlockRef structure in the U5C specification.

image

I'm thinking this would need some kind of new KeyValueStore within pallas-rolldb similiar to

// slot => block hash
pub struct HashBySlotKV;

impl KVTable<DBInt, DBHash> for HashBySlotKV {
    const CF_NAME: &'static str = "HashBySlotKV";
}

it could be something like

// height => block hash
pub struct HashBySlotKV;

impl KVTable<DBInt, DBHash> for HashByHeightKV {
    const CF_NAME: &'static str = "HashByHeightKV";
}

but I think the main hurdle is that the block height / number doesn't seem to be a first-class-citizen field within the pipeline.

image image image

Looking for feedback / suggestions

@Mercurial
Copy link
Copy Markdown
Contributor Author

nvm as per discussion with Santi BlockRef for UTxORPC should only have hash and index to be utxo chain agnostic. So this feature is not needed

@Mercurial Mercurial closed this Jan 29, 2024
@Mercurial Mercurial deleted the feat/fetch-block-dump-history-by-slot-or-height branch October 4, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant