diff --git a/da-indexer/da-indexer-logic/src/celestia/l2_router/mod.rs b/da-indexer/da-indexer-logic/src/celestia/l2_router/mod.rs index 31932d1d7..ff5698793 100644 --- a/da-indexer/da-indexer-logic/src/celestia/l2_router/mod.rs +++ b/da-indexer/da-indexer-logic/src/celestia/l2_router/mod.rs @@ -57,6 +57,10 @@ impl L2Router { L2Type::Arbitrum => arbitrum::get_l2_batch(config, height, commitment).await, } } + + pub fn get_namespaces(&self) -> Vec { + self.routes.keys().cloned().collect() + } } pub fn new_client(config: &L2Config) -> Result { diff --git a/da-indexer/da-indexer-proto/proto/v1/api_config_http.yaml b/da-indexer/da-indexer-proto/proto/v1/api_config_http.yaml index 2f88c9dab..2a072bb4c 100644 --- a/da-indexer/da-indexer-proto/proto/v1/api_config_http.yaml +++ b/da-indexer/da-indexer-proto/proto/v1/api_config_http.yaml @@ -10,6 +10,9 @@ http: - selector: blockscout.daIndexer.v1.CelestiaService.GetL2BatchMetadata get: /api/v1/celestia/l2BatchMetadata + - selector: blockscout.daIndexer.v1.CelestiaService.GetL2Namespaces + get: /api/v1/celestia/l2Namespaces + - selector: blockscout.daIndexer.v1.EigenDaService.GetBlob get: /api/v1/eigenda/blob diff --git a/da-indexer/da-indexer-proto/proto/v1/da-indexer.proto b/da-indexer/da-indexer-proto/proto/v1/da-indexer.proto index 1206f8d0b..58db00820 100644 --- a/da-indexer/da-indexer-proto/proto/v1/da-indexer.proto +++ b/da-indexer/da-indexer-proto/proto/v1/da-indexer.proto @@ -8,6 +8,7 @@ option go_package = "github.com/blockscout/blockscout-rs/da-indexer"; service CelestiaService { rpc GetBlob(GetCelestiaBlobRequest) returns (CelestiaBlob) {} rpc GetL2BatchMetadata(CelestiaBlobId) returns (CelestiaL2BatchMetadata) {} + rpc GetL2Namespaces(Empty) returns (CelestiaNamespaces) {} } service EigenDaService { @@ -48,6 +49,12 @@ message CelestiaL2BatchMetadata { repeated CelestiaBlobId related_blobs = 10; } +message Empty {} + +message CelestiaNamespaces { + repeated string namespaces = 1; +} + message GetEigenDaBlobRequest { string batch_header_hash = 1; uint32 blob_index = 2; diff --git a/da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml b/da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml index a253c726e..751480c4c 100644 --- a/da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml +++ b/da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml @@ -67,6 +67,20 @@ paths: type: string tags: - CelestiaService + /api/v1/celestia/l2Namespaces: + get: + operationId: CelestiaService_GetL2Namespaces + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v1CelestiaNamespaces' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/rpcStatus' + tags: + - CelestiaService /api/v1/eigenda/blob: get: operationId: EigenDaService_GetBlob @@ -206,6 +220,13 @@ definitions: items: type: object $ref: '#/definitions/v1CelestiaBlobId' + v1CelestiaNamespaces: + type: object + properties: + namespaces: + type: array + items: + type: string v1EigenDaBlob: type: object properties: diff --git a/da-indexer/da-indexer-server/src/services/celestia.rs b/da-indexer/da-indexer-server/src/services/celestia.rs index 9da71d040..cff91b9d8 100644 --- a/da-indexer/da-indexer-server/src/services/celestia.rs +++ b/da-indexer/da-indexer-server/src/services/celestia.rs @@ -2,7 +2,8 @@ use crate::proto::celestia_service_server::CelestiaService as Celestia; use base64::prelude::*; use da_indexer_logic::celestia::{l2_router::L2Router, repository::blobs}; use da_indexer_proto::blockscout::da_indexer::v1::{ - CelestiaBlob, CelestiaBlobId, CelestiaL2BatchMetadata, GetCelestiaBlobRequest, + CelestiaBlob, CelestiaBlobId, CelestiaL2BatchMetadata, CelestiaNamespaces, Empty, + GetCelestiaBlobRequest, }; use sea_orm::DatabaseConnection; use tonic::{Request, Response, Status}; @@ -103,4 +104,17 @@ impl Celestia for CelestiaService { related_blobs, })) } + + async fn get_l2_namespaces( + &self, + _request: Request, + ) -> Result, Status> { + let l2_router = self + .l2_router + .as_ref() + .ok_or(Status::unimplemented("l2 router is not configured"))?; + + let namespaces = l2_router.get_namespaces(); + Ok(Response::new(CelestiaNamespaces { namespaces })) + } }