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

Add Blobstream Client to rpc crate #543

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ferret-san
Copy link

Adds the Blobstream trait for the Client to be able to make blobstream related requests. The blobstream service for celestia-node can be found here

#[rpc(client)]
pub trait Blobstream {
    /// GetDataRootTupleRoot retrieves the data root tuple root for a given range from start to end
    #[method(name = "blobstream.GetDataRootTupleRoot")]
    async fn get_data_root_tuple_root(
        &self,
        start: u64,
        end: u64,
    ) -> Result<DataRootTupleRoot, Error>;

    /// GetDataRootTupleInclusionProof returns a data root tuple inclusion proof for a given height
    /// between a range from start to end
    #[method(name = "blobstream.GetDataRootTupleInclusionProof")]
    async fn get_data_root_tuple_inclusion_proof(
        &self,
        height: u64,
        start: u64,
        end: u64,
    ) -> Result<DataRootTupleInclusionProof, Error>;
}

Copy link
Member

@zvolin zvolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! left some ideas

@@ -45,7 +45,7 @@ pub async fn new_test_client(auth_level: AuthLevel) -> Result<Client> {
let client = Client::new(&url, token.as_deref()).await?;

// minimum 2 blocks
client.header_wait_for_height(2).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this block, the account we use for blob submission should be founded with tia, why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when testing against mocha, if I had my node sync from a recent height and trusted hash, waiting for height 2 would trigger a warning on the node header not found (celestia-node), so removing it allowed me to test this, but we could have an env for this height and that way the test does not assume you have a node synced from genesis etc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can instead do a loop here, where we request network head and break if it is >2 and sleep otherwise


// DataRootTupleRoot is the root of the merkle tree created
// from a set of data root tuples.
pub type DataRootTupleRoot = Bytes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is a hash, could we alias it to celestia_types::Hash?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes can def do that

.await
.unwrap();

println!("data root tuple root: {:x?}", result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would combine those tests into a single one where we request a proof and the root and just call proof.verify(root).unwrap()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I pushed and opened the PR before making the test more robust if you will, let me get this under a single test 🫡

let client = new_test_client(AuthLevel::Write).await.unwrap();

let result = client
.get_data_root_tuple_root(4211296, 4211298)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those tests seem to fail on CI.

called `Result::unwrap()` on an `Err` value: Call(ErrorObject { code: ServerError(1), message: "end block 4211300 is higher than local chain height 28. Wait for the node until it syncs up to 4211300", data: None })

could you instead make header_get_network_head() request and adjust height accordingly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted!

Comment on lines +18 to +27
async fn get_data_root_tuple_root(
&self,
start: u64,
end: u64,
) -> Result<DataRootTupleRoot, Error>;

/// GetDataRootTupleInclusionProof returns a data root tuple inclusion proof for a given height
/// between a range from start to end
#[method(name = "blobstream.GetDataRootTupleInclusionProof")]
async fn get_data_root_tuple_inclusion_proof(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more thing, since those will be implicitly exposed on any jsonrpsee client, we have a convention of prefixing methods with the modeule name. Could you rename those to start with blobstream_?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so blobstream_get_data_root_tuple_root?

Ferret-san and others added 2 commits February 20, 2025 17:06
Co-authored-by: Maciej Zwoliński <mac.zwolinski@gmail.com>
Signed-off-by: Diego <31937514+Ferret-san@users.noreply.github.com>
Co-authored-by: Maciej Zwoliński <mac.zwolinski@gmail.com>
Signed-off-by: Diego <31937514+Ferret-san@users.noreply.github.com>
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.

2 participants