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

sui-rpc: rework proto files based on 'buf lint' #20837

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/sui-e2e-tests/tests/rpc/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use sui_macros::sim_test;
use sui_rpc_api::client::sdk::Client;
use sui_rpc_api::client::Client as CoreClient;
use sui_rpc_api::proto::node::node_client::NodeClient;
use sui_rpc_api::proto::node::node_service_client::NodeServiceClient;
use sui_rpc_api::proto::node::{
FullCheckpointObject, FullCheckpointTransaction, GetCheckpointOptions, GetCheckpointRequest,
GetCheckpointResponse, GetFullCheckpointOptions, GetFullCheckpointRequest,
Expand Down Expand Up @@ -50,7 +50,7 @@ async fn get_checkpoint() {
.await
.unwrap();

let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand Down Expand Up @@ -177,7 +177,7 @@ async fn get_full_checkpoint() {
.await
.unwrap();

let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-e2e-tests/tests/rpc/committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use sui_macros::sim_test;
use sui_rpc_api::client::sdk::Client;
use sui_rpc_api::proto::node::node_client::NodeClient;
use sui_rpc_api::proto::node::node_service_client::NodeServiceClient;
use sui_rpc_api::proto::node::GetCommitteeRequest;
use test_cluster::TestClusterBuilder;

Expand All @@ -12,7 +12,7 @@ async fn get_committee() {
let test_cluster = TestClusterBuilder::new().build().await;

let client = Client::new(test_cluster.rpc_url()).unwrap();
let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand Down
11 changes: 8 additions & 3 deletions crates/sui-e2e-tests/tests/rpc/node_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// SPDX-License-Identifier: Apache-2.0

use sui_macros::sim_test;
use sui_rpc_api::proto::node::node_client::NodeClient;
use sui_rpc_api::proto::node::node_service_client::NodeServiceClient;
use sui_rpc_api::proto::node::GetNodeInfoRequest;
use sui_rpc_api::proto::node::GetNodeInfoResponse;
use test_cluster::TestClusterBuilder;

#[sim_test]
async fn get_node_info() {
let test_cluster = TestClusterBuilder::new().build().await;

let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand All @@ -23,7 +24,11 @@ async fn get_node_info() {
lowest_available_checkpoint,
lowest_available_checkpoint_objects,
software_version,
} = grpc_client.get_node_info(()).await.unwrap().into_inner();
} = grpc_client
.get_node_info(GetNodeInfoRequest {})
.await
.unwrap()
.into_inner();

assert!(chain_id.is_some());
assert!(chain.is_some());
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-e2e-tests/tests/rpc/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use sui_macros::sim_test;
use sui_rpc_api::client::sdk::Client;
use sui_rpc_api::client::Client as CoreClient;
use sui_rpc_api::proto::node::node_client::NodeClient;
use sui_rpc_api::proto::node::node_service_client::NodeServiceClient;
use sui_rpc_api::proto::node::GetObjectOptions;
use sui_rpc_api::proto::node::GetObjectRequest;
use sui_rpc_api::proto::node::GetObjectResponse;
Expand All @@ -19,7 +19,7 @@ async fn get_object() {

let client = Client::new(test_cluster.rpc_url()).unwrap();
let core_client = CoreClient::new(test_cluster.rpc_url()).unwrap();
let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-e2e-tests/tests/rpc/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use sui_macros::sim_test;
use sui_rpc_api::client::sdk::Client;
use sui_rpc_api::proto::node::node_client::NodeClient;
use sui_rpc_api::proto::node::node_service_client::NodeServiceClient;
use sui_rpc_api::proto::node::{
GetTransactionOptions, GetTransactionRequest, GetTransactionResponse,
};
Expand All @@ -22,7 +22,7 @@ async fn get_transaction() {

let _transaction = client.get_transaction(&transaction_digest).await.unwrap();

let mut grpc_client = NodeClient::connect(test_cluster.rpc_url().to_owned())
let mut grpc_client = NodeServiceClient::connect(test_cluster.rpc_url().to_owned())
.await
.unwrap();

Expand Down
6 changes: 4 additions & 2 deletions crates/sui-rpc-api/proto/sui.node.v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import "sui.types.proto";
// Rpc Node interface
//

service Node {
rpc GetNodeInfo(google.protobuf.Empty) returns (GetNodeInfoResponse);
service NodeService {
rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse);
rpc GetCommittee(GetCommitteeRequest) returns (GetCommitteeResponse);

rpc GetObject(GetObjectRequest) returns (GetObjectResponse);
Expand All @@ -22,6 +22,8 @@ service Node {
rpc ExecuteTransaction(ExecuteTransactionRequest) returns (ExecuteTransactionResponse);
}

message GetNodeInfoRequest {}

message GetNodeInfoResponse {
// The chain identifier of the chain that this Node is on
optional sui.types.Digest chain_id = 1;
Expand Down
18 changes: 9 additions & 9 deletions crates/sui-rpc-api/proto/sui.types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ message StructTag {

message TypeTag {
oneof tag {
google.protobuf.Empty U8 = 1;
google.protobuf.Empty U16 = 2;
google.protobuf.Empty U32 = 3;
google.protobuf.Empty U64 = 4;
google.protobuf.Empty U128 = 5;
google.protobuf.Empty U256 = 6;
google.protobuf.Empty Bool = 7;
google.protobuf.Empty Address = 8;
google.protobuf.Empty Signer = 9;
google.protobuf.Empty u8 = 1;
google.protobuf.Empty u16 = 2;
google.protobuf.Empty u32 = 3;
google.protobuf.Empty u64 = 4;
google.protobuf.Empty u128 = 5;
google.protobuf.Empty u256 = 6;
google.protobuf.Empty bool = 7;
google.protobuf.Empty address = 8;
google.protobuf.Empty signer = 9;
TypeTag vector = 10;
StructTag struct = 11;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-rpc-api/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use reqwest;
use tap::Pipe;
use tonic::metadata::MetadataMap;

use crate::proto::node::node_client::NodeClient;
use crate::proto::node::node_service_client::NodeServiceClient;
use crate::proto::node::{
ExecuteTransactionResponse, GetCheckpointResponse, GetFullCheckpointResponse, GetObjectResponse,
};
Expand Down Expand Up @@ -59,8 +59,8 @@ impl Client {
Ok(Self { uri, channel })
}

pub fn raw_client(&self) -> NodeClient<tonic::transport::Channel> {
NodeClient::new(self.channel.clone())
pub fn raw_client(&self) -> NodeServiceClient<tonic::transport::Channel> {
NodeServiceClient::new(self.channel.clone())
}

pub async fn get_latest_checkpoint(&self) -> Result<CertifiedCheckpointSummary> {
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-rpc-api/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl Services {
}

#[tonic::async_trait]
impl crate::proto::node::node_server::Node for crate::RpcService {
impl crate::proto::node::node_service_server::NodeService for crate::RpcService {
async fn get_node_info(
&self,
_request: tonic::Request<()>,
_request: tonic::Request<crate::proto::node::GetNodeInfoRequest>,
) -> Result<tonic::Response<crate::proto::node::GetNodeInfoResponse>, tonic::Status> {
self.get_node_info()
.map(Into::into)
Expand Down
6 changes: 5 additions & 1 deletion crates/sui-rpc-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ impl RpcService {
let metrics = self.metrics.clone();

let mut router = {
let node_service = crate::proto::node::node_server::NodeServer::new(self.clone());
let node_service =
crate::proto::node::node_service_server::NodeServiceServer::new(self.clone());
// legacy node service
let node = crate::proto::node::node_server::NodeServer::new(self.clone());

let (mut health_reporter, health_service) = tonic_health::server::health_reporter();

Expand Down Expand Up @@ -112,6 +115,7 @@ impl RpcService {
.add_service(reflection_v1)
.add_service(reflection_v1alpha)
.add_service(node_service)
.add_service(node)
.into_router()
};

Expand Down
Binary file modified crates/sui-rpc-api/src/proto/generated/sui.node.v2.fds.bin
Binary file not shown.
Loading
Loading