Skip to content

Commit 95fa468

Browse files
author
tac0turtle
committed
update rpc with config server
1 parent d9d0d8d commit 95fa468

File tree

30 files changed

+938
-94
lines changed

30 files changed

+938
-94
lines changed

apps/evm/single/cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"path/filepath"
88

9-
"github.com/evstack/ev-node/da"
9+
"github.com/evstack/ev-node/core/da"
1010
"github.com/evstack/ev-node/da/jsonrpc"
1111
"github.com/evstack/ev-node/node"
1212
"github.com/evstack/ev-node/sequencers/single"

apps/grpc/single/cmd/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/spf13/cobra"
99

10+
coreda "github.com/evstack/ev-node/core/da"
1011
"github.com/evstack/ev-node/core/execution"
11-
"github.com/evstack/ev-node/da"
1212
"github.com/evstack/ev-node/da/jsonrpc"
1313
executiongrpc "github.com/evstack/ev-node/execution/grpc"
1414
"github.com/evstack/ev-node/node"
@@ -47,8 +47,8 @@ The execution client must implement the Evolve execution gRPC interface.`,
4747

4848
logger := rollcmd.SetupLogger(nodeConfig.Log)
4949

50-
headerNamespace := da.PrepareNamespace([]byte(nodeConfig.DA.HeaderNamespace))
51-
dataNamespace := da.PrepareNamespace([]byte(nodeConfig.DA.DataNamespace))
50+
headerNamespace := coreda.PrepareNamespace([]byte(nodeConfig.DA.HeaderNamespace))
51+
dataNamespace := coreda.PrepareNamespace([]byte(nodeConfig.DA.DataNamespace))
5252

5353
logger.Info().Str("headerNamespace", hex.EncodeToString(headerNamespace)).Str("dataNamespace", hex.EncodeToString(dataNamespace)).Msg("namespaces")
5454

apps/testapp/cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/spf13/cobra"
1010

1111
kvexecutor "github.com/evstack/ev-node/apps/testapp/kv"
12-
"github.com/evstack/ev-node/da"
12+
"github.com/evstack/ev-node/core/da"
1313
"github.com/evstack/ev-node/da/jsonrpc"
1414
"github.com/evstack/ev-node/node"
1515
rollcmd "github.com/evstack/ev-node/pkg/cmd"

apps/testapp/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ replace (
1111

1212
require (
1313
github.com/evstack/ev-node v0.0.0-00010101000000-000000000000
14+
github.com/evstack/ev-node/core v0.0.0-20250312114929-104787ba1a4c
1415
github.com/evstack/ev-node/da v0.0.0-00010101000000-000000000000
1516
github.com/evstack/ev-node/sequencers/single v0.0.0-00010101000000-000000000000
1617
github.com/ipfs/go-datastore v0.8.2
@@ -36,7 +37,6 @@ require (
3637
github.com/docker/go-units v0.5.0 // indirect
3738
github.com/dustin/go-humanize v1.0.1 // indirect
3839
github.com/elastic/gosigar v0.14.3 // indirect
39-
github.com/evstack/ev-node/core v0.0.0-20250312114929-104787ba1a4c // indirect
4040
github.com/filecoin-project/go-jsonrpc v0.7.1 // indirect
4141
github.com/flynn/noise v1.1.0 // indirect
4242
github.com/francoispqt/gojay v1.2.13 // indirect

client/crates/client/src/config.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::{client::Client, error::Result};
2+
use ev_types::v1::{config_service_client::ConfigServiceClient, GetNamespaceResponse};
3+
use tonic::Request;
4+
5+
pub struct ConfigClient {
6+
inner: ConfigServiceClient<tonic::transport::Channel>,
7+
}
8+
9+
impl ConfigClient {
10+
/// Create a new ConfigClient from a Client
11+
pub fn new(client: &Client) -> Self {
12+
let inner = ConfigServiceClient::new(client.channel().clone());
13+
Self { inner }
14+
}
15+
16+
/// Get the namespace for this network
17+
pub async fn get_namespace(&self) -> Result<GetNamespaceResponse> {
18+
let request = Request::new(());
19+
let response = self.inner.clone().get_namespace(request).await?;
20+
21+
Ok(response.into_inner())
22+
}
23+
24+
/// Get the header namespace
25+
pub async fn get_header_namespace(&self) -> Result<String> {
26+
let response = self.get_namespace().await?;
27+
Ok(response.header_namespace)
28+
}
29+
30+
/// Get the data namespace
31+
pub async fn get_data_namespace(&self) -> Result<String> {
32+
let response = self.get_namespace().await?;
33+
Ok(response.data_namespace)
34+
}
35+
}

client/crates/client/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! # Example
66
//!
77
//! ```no_run
8-
//! use ev_client::{Client, HealthClient};
8+
//! use ev_client::{Client, HealthClient, ConfigClient};
99
//!
1010
//! #[tokio::main]
1111
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -17,6 +17,12 @@
1717
//! let is_healthy = health.is_healthy().await?;
1818
//! println!("Node healthy: {}", is_healthy);
1919
//!
20+
//! // Get namespace configuration
21+
//! let config = ConfigClient::new(&client);
22+
//! let namespace = config.get_namespace().await?;
23+
//! println!("Header namespace: {}", namespace.header_namespace);
24+
//! println!("Data namespace: {}", namespace.data_namespace);
25+
//!
2026
//! Ok(())
2127
//! }
2228
//! ```
@@ -71,6 +77,7 @@
7177
//! ```
7278
7379
pub mod client;
80+
pub mod config;
7481
pub mod error;
7582
pub mod health;
7683
pub mod p2p;
@@ -79,6 +86,7 @@ pub mod store;
7986

8087
// Re-export main types for convenience
8188
pub use client::{Client, ClientBuilder};
89+
pub use config::ConfigClient;
8290
pub use error::{ClientError, Result};
8391
pub use health::HealthClient;
8492
pub use p2p::P2PClient;

client/crates/types/src/proto/evnode.v1.messages.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,12 @@ pub struct GetMetadataResponse {
418418
#[prost(bytes = "vec", tag = "1")]
419419
pub value: ::prost::alloc::vec::Vec<u8>,
420420
}
421+
/// GetNamespaceResponse returns the namespace for this network
422+
#[allow(clippy::derive_partial_eq_without_eq)]
423+
#[derive(Clone, PartialEq, ::prost::Message)]
424+
pub struct GetNamespaceResponse {
425+
#[prost(string, tag = "1")]
426+
pub header_namespace: ::prost::alloc::string::String,
427+
#[prost(string, tag = "2")]
428+
pub data_namespace: ::prost::alloc::string::String,
429+
}

0 commit comments

Comments
 (0)