diff --git a/kwil/admin/v0/messages.proto b/kwil/admin/v0/messages.proto index e9cadf0..bdae7d9 100644 --- a/kwil/admin/v0/messages.proto +++ b/kwil/admin/v0/messages.proto @@ -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; @@ -24,7 +16,7 @@ message StatusRequest {} message StatusResponse { NodeInfo node = 1; SyncInfo sync = 2; - ValidatorInfo validator = 3; + Validator validator = 3; } message NodeInfo { @@ -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 { @@ -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 +} \ No newline at end of file diff --git a/kwil/admin/v0/service.proto b/kwil/admin/v0/service.proto index e003302..1e8e863 100644 --- a/kwil/admin/v0/service.proto +++ b/kwil/admin/v0/service.proto @@ -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" @@ -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" + }; + } } diff --git a/kwil/function/v0/messages.proto b/kwil/function/v0/messages.proto new file mode 100644 index 0000000..cc7425e --- /dev/null +++ b/kwil/function/v0/messages.proto @@ -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; + } \ No newline at end of file diff --git a/kwil/function/v0/service.proto b/kwil/function/v0/service.proto new file mode 100644 index 0000000..48cfa94 --- /dev/null +++ b/kwil/function/v0/service.proto @@ -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: "*" + }; + }; +} \ No newline at end of file diff --git a/kwil/tx/v1/call.proto b/kwil/tx/v1/call.proto index 9f7484d..30306a7 100644 --- a/kwil/tx/v1/call.proto +++ b/kwil/tx/v1/call.proto @@ -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; diff --git a/kwil/tx/v1/dataset.proto b/kwil/tx/v1/dataset.proto index 07ab1b2..e0ffded 100644 --- a/kwil/tx/v1/dataset.proto +++ b/kwil/tx/v1/dataset.proto @@ -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 { @@ -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; } \ No newline at end of file diff --git a/kwil/tx/v1/list.proto b/kwil/tx/v1/list.proto index 93cfb92..c160c21 100644 --- a/kwil/tx/v1/list.proto +++ b/kwil/tx/v1/list.proto @@ -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; } \ No newline at end of file diff --git a/kwil/tx/v1/service.proto b/kwil/tx/v1/service.proto index eb8564c..e104c16 100644 --- a/kwil/tx/v1/service.proto +++ b/kwil/tx/v1/service.proto @@ -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) { @@ -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", @@ -122,11 +87,4 @@ service TxService { body: "*" }; } - - rpc VerifySignature(VerifySignatureRequest) returns (VerifySignatureResponse) { - option (google.api.http) = { - post: "/api/v1/verify_signature", - body: "*" - }; - } } \ No newline at end of file diff --git a/kwil/tx/v1/signature.proto b/kwil/tx/v1/signature.proto index dc2a0dd..d13d0fb 100644 --- a/kwil/tx/v1/signature.proto +++ b/kwil/tx/v1/signature.proto @@ -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; } \ No newline at end of file diff --git a/kwil/tx/v1/validator.proto b/kwil/tx/v1/validator.proto deleted file mode 100644 index 08d91e4..0000000 --- a/kwil/tx/v1/validator.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; -package tx; -option go_package = "github.com/kwilteam/kwil-db/core/rpc/protobuf/tx/v1;txpb"; - - -import "kwil/tx/v1/tx.proto"; - -message Validator { - bytes pubkey = 1; // ED25519 PubKey - int64 power = 2; -} - -enum RequestStatus { - OK = 0; - ERROR = 1; -} - -message ValidatorApprovalRequest { - bytes PubKey = 1; // ED25519 PubKey -} - -message ValidatorApprovalResponse { - RequestStatus status = 1; - string log = 2; -} - -/* - If power is 0, the validator will be removed from the validator set - If power is > 0, if the validator is in the approved validator list, validator will be added to the validator set - Base64 encoded both pubkey and validator power -*/ -// TODO: these should not wrap Transactions; all of these should just get forwarded to the broadcast endpoint -message ValidatorJoinRequest { - tx.Transaction tx = 1; -} - -message ValidatorJoinResponse { - tx.TransactionStatus receipt = 1; -} - -message ValidatorLeaveRequest { - tx.Transaction tx = 1; -} - -message ValidatorLeaveResponse { - tx.TransactionStatus receipt = 1; -} - -message CurrentValidatorsRequest { -} - -message CurrentValidatorsResponse { - repeated Validator validators = 1; -} - -message ValidatorJoinStatusRequest { - bytes pubkey = 1; // ED25519 PubKey -} - -message ValidatorJoinStatusResponse { - repeated bytes approved_validators = 1 [json_name = "approved_validators"]; - repeated bytes pending_validators = 2 [json_name = "pending_validators"]; - int64 power = 3; -}