-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(da-indexer): update celestia integration (#1132)
* feat: update celestia integration * fix: format * fix: refactor code * Update da-indexer/da-indexer-logic/src/celestia/parser.rs Co-authored-by: Lev Lymarenko <[email protected]> --------- Co-authored-by: Lev Lymarenko <[email protected]>
- Loading branch information
Showing
12 changed files
with
403 additions
and
254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::future::Future; | ||
|
||
use celestia_types::{AppVersion, ExtendedDataSquare}; | ||
use jsonrpsee::core::client::{ClientT, Error}; | ||
|
||
// celestia_rpc::Client doesn't support new version of share.GetEDS method | ||
// so we need to implement it manually | ||
mod rpc { | ||
use celestia_types::eds::RawExtendedDataSquare; | ||
use jsonrpsee::proc_macros::rpc; | ||
|
||
#[rpc(client)] | ||
pub trait Share { | ||
#[method(name = "share.GetEDS")] | ||
async fn share_get_eds(&self, height: u64) -> Result<RawExtendedDataSquare, client::Error>; | ||
} | ||
} | ||
|
||
pub trait ShareClient: ClientT { | ||
/// GetEDS gets the full EDS identified by the given root. | ||
fn share_get_eds<'a, 'b, 'fut>( | ||
&'a self, | ||
height: u64, | ||
app_version: u64, | ||
) -> impl Future<Output = Result<ExtendedDataSquare, Error>> + Send + 'fut | ||
where | ||
'a: 'fut, | ||
'b: 'fut, | ||
Self: Sized + Sync + 'fut, | ||
{ | ||
async move { | ||
let app_version = AppVersion::from_u64(app_version).ok_or_else(|| { | ||
let e = format!("Invalid or unsupported AppVersion: {app_version}"); | ||
Error::Custom(e) | ||
})?; | ||
|
||
let raw_eds = rpc::ShareClient::share_get_eds(self, height).await?; | ||
|
||
ExtendedDataSquare::from_raw(raw_eds, app_version) | ||
.map_err(|e| Error::Custom(e.to_string())) | ||
} | ||
} | ||
} | ||
|
||
impl<T> ShareClient for T where T: ClientT {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
mod client; | ||
pub mod da; | ||
pub mod job; | ||
pub mod l2_router; | ||
mod parser; | ||
pub mod repository; | ||
mod rpc_client; | ||
pub mod settings; | ||
#[cfg(test)] | ||
pub mod tests; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
da-indexer/da-indexer-logic/src/celestia/tests/data/eds_with_blobs.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
da-indexer/da-indexer-logic/src/celestia/tests/data/eds_without_blobs.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.