Skip to content

Commit

Permalink
feat(da_indexer): add l2Namespaces endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AllFi committed Nov 12, 2024
1 parent ff0b172 commit 426af11
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions da-indexer/da-indexer-logic/src/celestia/l2_router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl L2Router {
L2Type::Arbitrum => arbitrum::get_l2_batch(config, height, commitment).await,
}
}

pub fn get_namespaces(&self) -> Vec<String> {
self.routes.keys().cloned().collect()
}
}

pub fn new_client(config: &L2Config) -> Result<ClientWithMiddleware> {
Expand Down
3 changes: 3 additions & 0 deletions da-indexer/da-indexer-proto/proto/v1/api_config_http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions da-indexer/da-indexer-proto/proto/v1/da-indexer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion da-indexer/da-indexer-server/src/services/celestia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -103,4 +104,17 @@ impl Celestia for CelestiaService {
related_blobs,
}))
}

async fn get_l2_namespaces(
&self,
_request: Request<Empty>,
) -> Result<Response<CelestiaNamespaces>, 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 }))
}
}

0 comments on commit 426af11

Please sign in to comment.