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

Unified admin rpc #26

Merged
merged 17 commits into from
Dec 5, 2023
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
57 changes: 44 additions & 13 deletions kwil/admin/v0/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ syntax = "proto3";
package admin;
option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/admin/v0;admpb";

message PingRequest {
string message = 1;
}

message PingResponse {
string message = 1;
}

message VersionRequest {}
message VersionResponse {
string version_string = 1;
Expand All @@ -24,7 +16,7 @@ message StatusRequest {}
message StatusResponse {
NodeInfo node = 1;
SyncInfo sync = 2;
ValidatorInfo validator = 3;
Validator validator = 3;
}

message NodeInfo {
Expand All @@ -46,10 +38,9 @@ message SyncInfo {
bool syncing = 5;
}

message ValidatorInfo {
bytes pubkey = 1;
string pubkey_type = 2 [json_name = "pubkey_type"];
int64 power = 3;
message Validator {
bytes pubkey = 1; // ED25519 PubKey
int64 power = 2;
}

message Peer {
Expand All @@ -62,3 +53,43 @@ message PeersRequest {}
message PeersResponse {
repeated Peer peers = 1;
}

// the following are all transactions, and therefore return a tx.BroadcastResponse
message ApproveRequest {
bytes pubkey = 1;
}
message JoinRequest {}
message LeaveRequest {}
message RemoveRequest {
bytes pubkey = 1;
}

message JoinStatusRequest {
bytes pubkey = 1;
}
message JoinStatusResponse {
PendingJoin join_request = 1 [json_name = "join_request"];
}

message PendingJoin {
bytes candidate = 1; // ED25519 PubKey
int64 power = 2;
int64 expires_at = 3 [json_name = "expires_at"];
repeated bytes board = 4; // all validators
repeated bool approved = 5; // whether each validator has approved
}

message ListValidatorsRequest {}
message ListValidatorsResponse {
repeated Validator validators = 1;
}

message ListJoinRequestsRequest {}
message ListJoinRequestsResponse {
repeated PendingJoin join_requests = 1 [json_name = "join_requests"];
}

message GetConfigRequest {}
message GetConfigResponse {
bytes config = 1; // due to the size of the config, and how often it is updated, doing this for now
}
60 changes: 54 additions & 6 deletions kwil/admin/v0/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ package admin;
option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/admin/v0;admpb";

import "kwil/admin/v0/messages.proto";
import "kwil/tx/v1/broadcast.proto";

import "google/api/annotations.proto";

service AdminService {
rpc Ping(PingRequest) returns (PingResponse) {
option (google.api.http) = {
get: "/api/v0/ping"
};
}

rpc Version(VersionRequest) returns (VersionResponse) {
option (google.api.http) = {
get: "/api/v0/version"
Expand All @@ -30,4 +25,57 @@ service AdminService {
get: "/api/v0/peers"
};
}

rpc Approve(ApproveRequest) returns (tx.BroadcastResponse) {
option (google.api.http) = {
post: "/api/v0/approve"
body: "*"
};
}

rpc Join(JoinRequest) returns (tx.BroadcastResponse) {
option (google.api.http) = {
post: "/api/v0/join"
body: "*"
};
}

rpc Leave(LeaveRequest) returns (tx.BroadcastResponse) {
option (google.api.http) = {
post: "/api/v0/leave"
body: "*"
};
}

rpc Remove(RemoveRequest) returns (tx.BroadcastResponse) {
option (google.api.http) = {
post: "/api/v0/remove"
body: "*"
};
}

rpc JoinStatus(JoinStatusRequest) returns (JoinStatusResponse) {
option (google.api.http) = {
post: "/api/v0/joinstatus"
body: "*"
};
}

rpc ListValidators(ListValidatorsRequest) returns (ListValidatorsResponse) {
option (google.api.http) = {
get: "/api/v0/validators"
};
}

rpc ListPendingJoins(ListJoinRequestsRequest) returns (ListJoinRequestsResponse) {
option (google.api.http) = {
get: "/api/v0/pendingjoins"
};
}

rpc GetConfig(GetConfigRequest) returns (GetConfigResponse) {
option (google.api.http) = {
get: "/api/v0/config"
};
}
}
16 changes: 16 additions & 0 deletions kwil/function/v0/messages.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package function;
option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/function/v0;functionpb";

import "kwil/tx/v1/signature.proto";

message VerifySignatureRequest {
tx.Signature signature = 1;
bytes sender = 2;
bytes msg = 3;
}

message VerifySignatureResponse {
bool valid = 1;
string error = 2;
}
16 changes: 16 additions & 0 deletions kwil/function/v0/service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package function;
option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/function/v0;functionpb";

import "kwil/function/v0/messages.proto";

import "google/api/annotations.proto";

service FunctionService {
rpc VerifySignature(VerifySignatureRequest) returns (VerifySignatureResponse) {
option (google.api.http) = {
post: "/api/v1/verify_signature",
body: "*"
};
};
}
3 changes: 1 addition & 2 deletions kwil/tx/v1/call.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/tx/v1;txpb";

message CallRequest {
message Body{
string description = 1;
bytes payload = 2;
bytes payload = 1;
}

Body body = 1;
Expand Down
13 changes: 13 additions & 0 deletions kwil/tx/v1/dataset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ message Table {
string name = 1;
repeated Column columns = 2;
repeated Index indexes = 3;
repeated ForeignKey foreign_keys = 4 [json_name = "foreign_keys"];
}

message Column {
Expand Down Expand Up @@ -59,4 +60,16 @@ message Extensions {
string name = 1;
repeated ExtensionConfig initialization = 2;
string alias = 3;
}

message ForeignKey {
repeated string child_keys = 1 [json_name = "child_keys"];
repeated string parent_keys = 2 [json_name = "parent_keys"];
string parent_table = 3 [json_name = "parent_table"];
repeated ForeignKeyAction actions = 4;
}

message ForeignKeyAction {
string on = 1;
string do = 2;
}
8 changes: 7 additions & 1 deletion kwil/tx/v1/list.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ message ListDatabasesRequest {
}

message ListDatabasesResponse {
repeated string databases = 1;
repeated DatasetInfo databases = 1;
}

message DatasetInfo {
string name = 1;
bytes owner = 2;
string dbid = 3;
}
42 changes: 0 additions & 42 deletions kwil/tx/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import "kwil/tx/v1/config.proto";
import "kwil/tx/v1/list.proto";
import "kwil/tx/v1/dataset.proto";
import "kwil/tx/v1/call.proto";
import "kwil/tx/v1/validator.proto";
import "kwil/tx/v1/tx_query.proto";
import "kwil/tx/v1/signature.proto";

service TxService {
rpc ChainInfo(ChainInfoRequest) returns (ChainInfoResponse) {
Expand Down Expand Up @@ -76,39 +74,6 @@ service TxService {
};
}

rpc ApproveValidator(ValidatorApprovalRequest) returns (ValidatorApprovalResponse) {
option (google.api.http) = {
post: "/api/v1/approve_validator",
body: "*"
};
}

rpc ValidatorJoin(ValidatorJoinRequest) returns (ValidatorJoinResponse) {
option (google.api.http) = {
post: "/api/v1/validator_join",
body: "*"
};
}

rpc ValidatorLeave(ValidatorLeaveRequest) returns (ValidatorLeaveResponse) {
option (google.api.http) = {
post: "/api/v1/validator_leave",
body: "*"
};
}

rpc ValidatorJoinStatus(ValidatorJoinStatusRequest) returns (ValidatorJoinStatusResponse) {
option (google.api.http) = {
get: "/api/v1/validator_join_status/{pubkey}"
};
}

rpc CurrentValidators(CurrentValidatorsRequest) returns (CurrentValidatorsResponse) {
option (google.api.http) = {
get: "/api/v1/current_validators"
};
}

rpc Call(CallRequest) returns (CallResponse) {
option (google.api.http) = {
post: "/api/v1/call",
Expand All @@ -122,11 +87,4 @@ service TxService {
body: "*"
};
}

rpc VerifySignature(VerifySignatureRequest) returns (VerifySignatureResponse) {
option (google.api.http) = {
post: "/api/v1/verify_signature",
body: "*"
};
}
}
11 changes: 0 additions & 11 deletions kwil/tx/v1/signature.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,4 @@ option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/tx/v1;txpb";
message Signature {
bytes signature_bytes = 1 [json_name = "signature_bytes"];
string signature_type = 2 [json_name = "signature_type"];
}

message VerifySignatureRequest {
Signature signature = 1;
bytes sender = 2;
bytes msg = 3;
}

message VerifySignatureResponse {
bool valid = 1;
string error = 2;
}
64 changes: 0 additions & 64 deletions kwil/tx/v1/validator.proto

This file was deleted.