Files

359 lines
8.8 KiB
Protocol Buffer

// Copied from https://github.com/luxfi/netrunner/blob/v1.3.0/rpcpb/rpc.proto
// without gRPC gateway dependency
syntax = "proto3";
option go_package = "github.com/luxfi/netrunner;rpcpb";
package rpcpb;
service PingService {
rpc Ping(PingRequest) returns (PingResponse) {
}
}
message PingRequest {}
message PingResponse {
int32 pid = 1;
}
service ControlService {
rpc Start(StartRequest) returns (StartResponse) {
}
rpc CreateBlockchains(CreateBlockchainsRequest) returns (CreateBlockchainsResponse) {
}
rpc CreateSubnets(CreateSubnetsRequest) returns (CreateSubnetsResponse) {
}
rpc Health(HealthRequest) returns (HealthResponse) {
}
rpc URIs(URIsRequest) returns (URIsResponse) {
}
rpc Status(StatusRequest) returns (StatusResponse) {
}
rpc StreamStatus(StreamStatusRequest) returns (stream StreamStatusResponse) {
}
rpc RemoveNode(RemoveNodeRequest) returns (RemoveNodeResponse) {
}
rpc AddNode(AddNodeRequest) returns (AddNodeResponse) {
}
rpc RestartNode(RestartNodeRequest) returns (RestartNodeResponse) {
}
rpc Stop(StopRequest) returns (StopResponse) {
}
rpc AttachPeer(AttachPeerRequest) returns (AttachPeerResponse) {
}
rpc SendOutboundMessage(SendOutboundMessageRequest) returns (SendOutboundMessageResponse) {
}
rpc SaveSnapshot(SaveSnapshotRequest) returns (SaveSnapshotResponse) {
}
rpc LoadSnapshot(LoadSnapshotRequest) returns (LoadSnapshotResponse) {
}
rpc RemoveSnapshot(RemoveSnapshotRequest) returns (RemoveSnapshotResponse) {
}
rpc GetSnapshotNames(GetSnapshotNamesRequest) returns (GetSnapshotNamesResponse) {
}
}
message ClusterInfo {
repeated string node_names = 1;
map<string, NodeInfo> node_infos = 2;
int32 pid = 3;
string root_data_dir = 4;
bool healthy = 5;
// Maps from the node ID to its attached peer infos.
map<string, ListOfAttachedPeerInfo> attached_peer_infos = 6;
// Set to "true" once custom blockchains are ready.
bool custom_chains_healthy = 7;
// The map of blockchain IDs in "ids.ID" format to its blockchain information.
map<string, CustomChainInfo> custom_chains = 8;
repeated string subnets = 9;
}
message CustomChainInfo {
// Blockchain name given to the create blockchain TX
// Currently used to keep a record of the VM name,
// which is not saved anywhere and can't be recovered from VM ID
string chain_name = 1;
// VM ID in "ids.ID" format.
string vm_id = 2;
// Create subnet transaction ID -- subnet ID.
// The subnet ID must be whitelisted by the lux node.
string subnet_id = 3;
// Create blockchain transaction ID -- blockchain ID>
// The blockchain ID is used for RPC endpoints.
string chain_id = 4;
}
message NodeInfo {
string name = 1;
string exec_path = 2;
string uri = 3;
string id = 4;
string log_dir = 5;
string db_dir = 6;
string plugin_dir = 7;
string whitelisted_subnets = 8;
bytes config = 9;
}
message AttachedPeerInfo {
string id = 1;
}
message ListOfAttachedPeerInfo {
repeated AttachedPeerInfo peers = 1;
}
message StartRequest {
string exec_path = 1;
optional uint32 num_nodes = 2;
optional string whitelisted_subnets = 3;
optional string global_node_config = 4;
// Used for both database and log files.
optional string root_data_dir = 5;
// Build directory that contains the subdir 'plugins' from which to load all custom VM executables.
// If not specified, will be derived from the exec_path (its basedir)
optional string plugin_dir = 6;
// The list of:
// - custom chain's VM name
// - genesis file path
// - (optional) subnet id to use.
// - chain config file path
// - network upgrade file path
//
// subnet id must be always nil when using StartRequest, as the network is empty and has no preloaded
// subnet ids available.
//
// The matching file with the name in "ids.ID" format must exist.
// e.g., ids.ToID(hashing.ComputeHash256("subnetevm")).String()
// e.g., subnet-cli create VMID subnetevm
//
// If this field is set to none (by default), the node/netrunner
// does not install the custom chain and does not create the subnet,
// even if the VM binary exists on the local plugins directory.
repeated BlockchainSpec blockchain_specs = 7;
map<string, string> custom_node_configs = 8;
// Map of chain name to config file contents.
// If specified, will create a file "chainname/config.json" with
// the contents provided here.
map<string, string> chain_configs = 9;
// Map of chain name to upgrade file contents.
// If specified, will create a file "chainname/upgrade.json" with
// the contents provided here.
map<string, string> upgrade_configs = 10;
// reassign default/custom ports if they are already taken
optional bool reassign_ports_if_used = 11;
// use dynamic ports instead of default ones
optional bool dynamic_ports = 12;
}
message StartResponse {
ClusterInfo cluster_info = 1;
}
message BlockchainSpec {
string vm_name = 1;
string genesis = 2;
optional string subnet_id = 3;
string chain_config = 4;
string network_upgrade = 5;
}
message CreateBlockchainsRequest {
// The list of:
// - custom chain's VM name
// - genesis file path
// - (optional) subnet id to use.
// - chain config file path
// - network upgrade file path
//
// The matching file with the name in "ids.ID" format must exist.
// e.g., ids.ToID(hashing.ComputeHash256("subnetevm")).String()
// e.g., subnet-cli create VMID subnetevm
//
// If this field is set to none (by default), the node/netrunner
// will return error
repeated BlockchainSpec blockchain_specs = 1;
}
message CreateBlockchainsResponse {
ClusterInfo cluster_info = 1;
}
message CreateSubnetsRequest {
optional uint32 num_subnets = 1;
}
message CreateSubnetsResponse {
ClusterInfo cluster_info = 1;
}
message HealthRequest {}
message HealthResponse {
ClusterInfo cluster_info = 1;
}
message URIsRequest {}
message URIsResponse {
repeated string uris = 1;
}
message StatusRequest {}
message StatusResponse {
ClusterInfo cluster_info = 1;
}
message StreamStatusRequest {
int64 push_interval = 1;
}
message StreamStatusResponse {
ClusterInfo cluster_info = 1;
}
message RestartNodeRequest {
// Must be a valid node name.
string name = 1;
// Optional fields are set to the previous values if empty.
optional string exec_path = 2;
optional string whitelisted_subnets = 3;
// Map of chain name to config file contents.
// If specified, will create a file "chainname/config.json" with
// the contents provided here.
map<string, string> chain_configs = 4;
// Map of chain name to config file contents.
// If specified, will create a file "chainname/upgrade.json" with
// the contents provided here.
map<string, string> upgrade_configs = 5;
}
message RestartNodeResponse {
ClusterInfo cluster_info = 1;
}
message RemoveNodeRequest {
string name = 1;
}
message RemoveNodeResponse {
ClusterInfo cluster_info = 1;
}
message AddNodeRequest {
string name = 1;
string exec_path = 2;
optional string node_config = 3;
// Map of chain name to config file contents.
// If specified, will create a file "chainname/config.json" with
// the contents provided here.
map<string, string> chain_configs = 4;
// Map of chain name to config file contents.
// If specified, will create a file "chainname/upgrade.json" with
// the contents provided here.
map<string, string> upgrade_configs = 5;
}
message AddNodeResponse {
ClusterInfo cluster_info = 1;
}
message StopRequest {}
message StopResponse {
ClusterInfo cluster_info = 1;
}
message AttachPeerRequest {
string node_name = 1;
}
message AttachPeerResponse {
ClusterInfo cluster_info = 1;
AttachedPeerInfo attached_peer_info = 2;
}
message SendOutboundMessageRequest {
string node_name = 1;
string peer_id = 2;
uint32 op = 3;
bytes bytes = 4;
}
message SendOutboundMessageResponse {
bool sent = 1;
}
message SaveSnapshotRequest {
string snapshot_name = 1;
}
message SaveSnapshotResponse {
string snapshot_path = 1;
}
message LoadSnapshotRequest {
string snapshot_name = 1;
optional string exec_path = 2;
optional string plugin_dir = 3;
optional string root_data_dir = 4;
map<string, string> chain_configs = 5;
map<string, string> upgrade_configs = 6;
optional string global_node_config = 7;
optional bool reassign_ports_if_used = 8;
}
message LoadSnapshotResponse {
ClusterInfo cluster_info = 1;
}
message RemoveSnapshotRequest {
string snapshot_name = 1;
}
message RemoveSnapshotResponse {
}
message GetSnapshotNamesRequest {
}
message GetSnapshotNamesResponse {
repeated string snapshot_names = 1;
}