Skip to content

Commit 36f0662

Browse files
committed
[Indexer-Grpc-V2] Add protos.
1 parent 366f027 commit 36f0662

File tree

14 files changed

+4223
-245
lines changed

14 files changed

+4223
-245
lines changed

ecosystem/indexer-grpc/indexer-grpc-fullnode/src/fullnode_data_service.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use aptos_logger::{error, info};
77
use aptos_moving_average::MovingAverage;
88
use aptos_protos::internal::fullnode::v1::{
99
fullnode_data_server::FullnodeData, stream_status::StatusType, transactions_from_node_response,
10-
GetTransactionsFromNodeRequest, StreamStatus, TransactionsFromNodeResponse,
10+
GetTransactionsFromNodeRequest, PingFullnodeRequest, PingFullnodeResponse, StreamStatus,
11+
TransactionsFromNodeResponse,
1112
};
1213
use futures::Stream;
1314
use std::pin::Pin;
@@ -156,6 +157,13 @@ impl FullnodeData for FullnodeDataService {
156157
Box::pin(output_stream) as Self::GetTransactionsFromNodeStream
157158
))
158159
}
160+
161+
async fn ping(
162+
&self,
163+
_request: Request<PingFullnodeRequest>,
164+
) -> Result<Response<PingFullnodeResponse>, Status> {
165+
unimplemented!()
166+
}
159167
}
160168

161169
pub fn get_status(
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright © Aptos Foundation
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
syntax = "proto3";
5+
6+
package aptos.indexer.v1;
7+
8+
import "aptos/indexer/v1/raw_data.proto";
9+
import "aptos/transaction/v1/transaction.proto";
10+
import "aptos/util/timestamp/timestamp.proto";
11+
12+
message StreamProgressSampleProto {
13+
optional aptos.util.timestamp.Timestamp timestamp = 1;
14+
uint64 version = 2;
15+
uint64 size_bytes = 3;
16+
}
17+
18+
message StreamProgress {
19+
repeated StreamProgressSampleProto samples = 1;
20+
}
21+
22+
message ActiveStream {
23+
optional string id = 1;
24+
optional aptos.util.timestamp.Timestamp start_time = 2;
25+
uint64 start_version = 3;
26+
optional uint64 end_version = 4;
27+
28+
optional StreamProgress progress = 5;
29+
}
30+
31+
message StreamInfo {
32+
repeated ActiveStream active_streams = 1;
33+
}
34+
35+
message LiveDataServiceInfo {
36+
optional uint64 chain_id = 1;
37+
optional aptos.util.timestamp.Timestamp timestamp = 2;
38+
optional uint64 known_latest_version = 3;
39+
optional StreamInfo stream_info = 4;
40+
// If not present, it means the data service is not available to serve anything yet.
41+
optional uint64 min_servable_version = 5;
42+
}
43+
44+
message HistoricalDataServiceInfo {
45+
optional uint64 chain_id = 1;
46+
optional aptos.util.timestamp.Timestamp timestamp = 2;
47+
optional uint64 known_latest_version = 3;
48+
optional StreamInfo stream_info = 4;
49+
}
50+
51+
message FullnodeInfo {
52+
optional uint64 chain_id = 1;
53+
optional aptos.util.timestamp.Timestamp timestamp = 2;
54+
optional uint64 known_latest_version = 3;
55+
}
56+
57+
message GrpcManagerInfo {
58+
optional uint64 chain_id = 1;
59+
optional aptos.util.timestamp.Timestamp timestamp = 2;
60+
optional uint64 known_latest_version = 3;
61+
optional string master_address = 4;
62+
}
63+
64+
message ServiceInfo {
65+
optional string address = 1;
66+
oneof info {
67+
LiveDataServiceInfo live_data_service_info = 2;
68+
HistoricalDataServiceInfo historical_data_service_info = 3;
69+
FullnodeInfo fullnode_info = 4;
70+
GrpcManagerInfo grpc_manager_info = 5;
71+
}
72+
}
73+
74+
message HeartbeatRequest {
75+
optional ServiceInfo service_info = 1;
76+
}
77+
78+
message HeartbeatResponse {
79+
optional uint64 known_latest_version = 1;
80+
}
81+
82+
message PingDataServiceRequest {
83+
optional uint64 known_latest_version = 1;
84+
// `true` for live data service, `false` for historical data service.
85+
bool ping_live_data_service = 2;
86+
}
87+
88+
message PingDataServiceResponse {
89+
oneof info {
90+
LiveDataServiceInfo live_data_service_info = 1;
91+
HistoricalDataServiceInfo historical_data_service_info = 2;
92+
}
93+
}
94+
95+
message GetDataServiceForRequestRequest {
96+
optional GetTransactionsRequest user_request = 1;
97+
}
98+
99+
message GetDataServiceForRequestResponse {
100+
string data_service_address = 1;
101+
}
102+
103+
service GrpcManager {
104+
rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
105+
rpc GetTransactions(GetTransactionsRequest) returns (TransactionsResponse);
106+
rpc GetDataServiceForRequest(GetDataServiceForRequestRequest) returns (GetDataServiceForRequestResponse);
107+
}
108+
109+
service DataService {
110+
rpc Ping(PingDataServiceRequest) returns (PingDataServiceResponse);
111+
rpc GetTransactions(GetTransactionsRequest) returns (stream TransactionsResponse);
112+
}

protos/proto/aptos/internal/fullnode/v1/fullnode_data.proto

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ syntax = "proto3";
66
package aptos.internal.fullnode.v1;
77

88
import "aptos/transaction/v1/transaction.proto";
9+
import "aptos/indexer/v1/grpc.proto";
910

1011
// Transaction data is transferred via 1 stream with batches until terminated.
1112
// One stream consists:
@@ -52,6 +53,14 @@ message TransactionsFromNodeResponse {
5253
uint32 chain_id = 3;
5354
}
5455

56+
message PingFullnodeRequest {
57+
}
58+
59+
message PingFullnodeResponse {
60+
optional aptos.indexer.v1.FullnodeInfo info = 1;
61+
}
62+
5563
service FullnodeData {
64+
rpc Ping(PingFullnodeRequest) returns (PingFullnodeResponse);
5665
rpc GetTransactionsFromNode(GetTransactionsFromNodeRequest) returns (stream TransactionsFromNodeResponse);
5766
}

protos/python/aptos_protos/aptos/internal/fullnode/v1/fullnode_data_pb2.py

+18-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/python/aptos_protos/aptos/internal/fullnode/v1/fullnode_data_pb2.pyi

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing import Mapping as _Mapping
44
from typing import Optional as _Optional
55
from typing import Union as _Union
66

7+
from aptos.indexer.v1 import grpc_pb2 as _grpc_pb2
78
from aptos.transaction.v1 import transaction_pb2 as _transaction_pb2
89
from google.protobuf import descriptor as _descriptor
910
from google.protobuf import message as _message
@@ -75,3 +76,15 @@ class TransactionsFromNodeResponse(_message.Message):
7576
data: _Optional[_Union[TransactionsOutput, _Mapping]] = ...,
7677
chain_id: _Optional[int] = ...,
7778
) -> None: ...
79+
80+
class PingFullnodeRequest(_message.Message):
81+
__slots__ = []
82+
def __init__(self) -> None: ...
83+
84+
class PingFullnodeResponse(_message.Message):
85+
__slots__ = ["info"]
86+
INFO_FIELD_NUMBER: _ClassVar[int]
87+
info: _grpc_pb2.FullnodeInfo
88+
def __init__(
89+
self, info: _Optional[_Union[_grpc_pb2.FullnodeInfo, _Mapping]] = ...
90+
) -> None: ...

protos/python/aptos_protos/aptos/internal/fullnode/v1/fullnode_data_pb2_grpc.py

+45
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def __init__(self, channel):
1515
Args:
1616
channel: A grpc.Channel.
1717
"""
18+
self.Ping = channel.unary_unary(
19+
"/aptos.internal.fullnode.v1.FullnodeData/Ping",
20+
request_serializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeRequest.SerializeToString,
21+
response_deserializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeResponse.FromString,
22+
)
1823
self.GetTransactionsFromNode = channel.unary_stream(
1924
"/aptos.internal.fullnode.v1.FullnodeData/GetTransactionsFromNode",
2025
request_serializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.GetTransactionsFromNodeRequest.SerializeToString,
@@ -25,6 +30,12 @@ def __init__(self, channel):
2530
class FullnodeDataServicer(object):
2631
"""Missing associated documentation comment in .proto file."""
2732

33+
def Ping(self, request, context):
34+
"""Missing associated documentation comment in .proto file."""
35+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
36+
context.set_details("Method not implemented!")
37+
raise NotImplementedError("Method not implemented!")
38+
2839
def GetTransactionsFromNode(self, request, context):
2940
"""Missing associated documentation comment in .proto file."""
3041
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -34,6 +45,11 @@ def GetTransactionsFromNode(self, request, context):
3445

3546
def add_FullnodeDataServicer_to_server(servicer, server):
3647
rpc_method_handlers = {
48+
"Ping": grpc.unary_unary_rpc_method_handler(
49+
servicer.Ping,
50+
request_deserializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeRequest.FromString,
51+
response_serializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeResponse.SerializeToString,
52+
),
3753
"GetTransactionsFromNode": grpc.unary_stream_rpc_method_handler(
3854
servicer.GetTransactionsFromNode,
3955
request_deserializer=aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.GetTransactionsFromNodeRequest.FromString,
@@ -50,6 +66,35 @@ def add_FullnodeDataServicer_to_server(servicer, server):
5066
class FullnodeData(object):
5167
"""Missing associated documentation comment in .proto file."""
5268

69+
@staticmethod
70+
def Ping(
71+
request,
72+
target,
73+
options=(),
74+
channel_credentials=None,
75+
call_credentials=None,
76+
insecure=False,
77+
compression=None,
78+
wait_for_ready=None,
79+
timeout=None,
80+
metadata=None,
81+
):
82+
return grpc.experimental.unary_unary(
83+
request,
84+
target,
85+
"/aptos.internal.fullnode.v1.FullnodeData/Ping",
86+
aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeRequest.SerializeToString,
87+
aptos_dot_internal_dot_fullnode_dot_v1_dot_fullnode__data__pb2.PingFullnodeResponse.FromString,
88+
options,
89+
channel_credentials,
90+
insecure,
91+
call_credentials,
92+
compression,
93+
wait_for_ready,
94+
timeout,
95+
metadata,
96+
)
97+
5398
@staticmethod
5499
def GetTransactionsFromNode(
55100
request,

0 commit comments

Comments
 (0)