diff --git a/.protolint.yaml b/.protolint.yaml index 879745a..3aef447 100644 --- a/.protolint.yaml +++ b/.protolint.yaml @@ -41,12 +41,14 @@ lint: # We should probably turn this back on at some point, but pretty annoying RN - FIELDS_HAVE_COMMENT # I never want to turn this back on. Enums values should be self-explanatory + - ENUMS_HAVE_COMMENT - ENUM_FIELDS_HAVE_COMMENT # This one doesn't like single word RPCs, which I have no problem with - RPC_NAMES_CASE # In practice this creates a lot of meaningless comments, we can trust # authors to determine when comments will be useful or not - MESSAGES_HAVE_COMMENT + - RPCS_HAVE_COMMENT - SERVICES_HAVE_COMMENT # Linter rules option. diff --git a/proto/identity/api/v1/identity.proto b/proto/identity/api/v1/identity.proto index 09113b5..b1c4692 100644 --- a/proto/identity/api/v1/identity.proto +++ b/proto/identity/api/v1/identity.proto @@ -4,16 +4,15 @@ package xmtp.identity.api.v1; import "google/api/annotations.proto"; import "identity/associations/association.proto"; -import "identity/associations/signature.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "github.com/xmtp/proto/v3/go/mls/api/v1"; option java_package = "org.xmtp.proto.mls.api.v1"; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { - title: "IdentityApi"; - version: "1.0"; - }; + title: "IdentityApi" + version: "1.0" + } }; // RPCs for the new MLS API diff --git a/proto/xmtpv4/message_api/message_api.proto b/proto/xmtpv4/message_api/message_api.proto index 76bec62..428d019 100644 --- a/proto/xmtpv4/message_api/message_api.proto +++ b/proto/xmtpv4/message_api/message_api.proto @@ -8,21 +8,6 @@ import "xmtpv4/envelopes/envelopes.proto"; option go_package = "github.com/xmtp/proto/v3/go/xmtpv4/message_api"; -// Misbehavior types -enum Misbehavior { - MISBEHAVIOR_UNSPECIFIED = 0; - MISBEHAVIOR_UNAVAILABLE_NODE = 1; - MISBEHAVIOR_OUT_OF_ORDER_ORIGINATOR_SID = 2; - MISBEHAVIOR_DUPLICATE_ORIGINATOR_SID = 3; - MISBEHAVIOR_CYCLICAL_MESSAGE_ORDERING = 4; -} - -// Reports node misbehavior, submittable by nodes or by clients -message MisbehaviorReport { - Misbehavior type = 1; - repeated xmtp.xmtpv4.envelopes.OriginatorEnvelope envelopes = 2; -} - // Query for envelopes, shared by query and subscribe endpoints // Either topics or originator_node_ids may be set, but not both message EnvelopesQuery { @@ -83,9 +68,7 @@ message GetInboxIdsResponse { repeated Response responses = 1; } -// Replication API service ReplicationApi { - // Subscribe to envelopes rpc SubscribeEnvelopes(SubscribeEnvelopesRequest) returns (stream SubscribeEnvelopesResponse) { option (google.api.http) = { post: "/mls/v2/subscribe-envelopes" @@ -93,7 +76,6 @@ service ReplicationApi { }; } - // Query envelopes rpc QueryEnvelopes(QueryEnvelopesRequest) returns (QueryEnvelopesResponse) { option (google.api.http) = { post: "/mls/v2/query-envelopes" @@ -101,7 +83,6 @@ service ReplicationApi { }; } - // Publish envelope rpc PublishPayerEnvelopes(PublishPayerEnvelopesRequest) returns (PublishPayerEnvelopesResponse) { option (google.api.http) = { post: "/mls/v2/publish-payer-envelopes" @@ -109,7 +90,6 @@ service ReplicationApi { }; } - // Get inbox ids rpc GetInboxIds(GetInboxIdsRequest) returns (GetInboxIdsResponse) { option (google.api.http) = { post: "/mls/v2/get-inbox-ids" diff --git a/proto/xmtpv4/message_api/misbehavior_api.proto b/proto/xmtpv4/message_api/misbehavior_api.proto new file mode 100644 index 0000000..bf47ebc --- /dev/null +++ b/proto/xmtpv4/message_api/misbehavior_api.proto @@ -0,0 +1,87 @@ +// API for reporting and querying node misbehavior in decentralized XMTP +syntax = "proto3"; + +package xmtp.xmtpv4.message_api; + +import "google/api/annotations.proto"; +import "identity/associations/signature.proto"; +import "xmtpv4/envelopes/envelopes.proto"; +import "xmtpv4/message_api/message_api.proto"; + +option go_package = "github.com/xmtp/proto/v3/go/xmtpv4/message_api"; + +enum Misbehavior { + MISBEHAVIOR_UNSPECIFIED = 0; + MISBEHAVIOR_UNRESPONSIVE_NODE = 1; + MISBEHAVIOR_SLOW_NODE = 2; + MISBEHAVIOR_FAILED_REQUEST = 3; + MISBEHAVIOR_OUT_OF_ORDER = 4; + MISBEHAVIOR_DUPLICATE_SEQUENCE_ID = 5; + MISBEHAVIOR_CAUSAL_ORDERING = 6; + MISBEHAVIOR_INVALID_PAYLOAD = 7; + MISBEHAVIOR_BLOCKCHAIN_INCONSISTENCY = 8; +} + +message LivenessFailure { + uint32 response_time_ns = 1; + oneof request { + xmtp.xmtpv4.message_api.SubscribeEnvelopesRequest subscribe = 2; + xmtp.xmtpv4.message_api.QueryEnvelopesRequest query = 3; + xmtp.xmtpv4.message_api.PublishPayerEnvelopesRequest publish = 4; + } +} + +message SafetyFailure { + repeated xmtp.xmtpv4.envelopes.OriginatorEnvelope envelopes = 1; +} + +message UnsignedMisbehaviorReport { + uint64 reporter_time_ns = 1; + uint32 misbehaving_node_id = 2; + Misbehavior type = 3; + oneof failure { + LivenessFailure liveness = 4; + SafetyFailure safety = 5; + } + // Nodes must verify this field is false for client-submitted reports + bool submitted_by_node = 6; +} + +message MisbehaviorReport { + // Server time when the report was stored. Used only for querying reports. + // This field is not signed. + uint64 server_time_ns = 1; + bytes unsigned_misbehavior_report = 2; + // Signed by the node hosting the report + xmtp.identity.associations.RecoverableEcdsaSignature signature = 3; +} + +message SubmitMisbehaviorReportRequest { + UnsignedMisbehaviorReport report = 1; +} + +message SubmitMisbehaviorReportResponse {} + +message QueryMisbehaviorReportsRequest { + uint64 after_ns = 1; +} + +message QueryMisbehaviorReportsResponse { + repeated MisbehaviorReport reports = 1; +} + +service MisbehaviorApi { + rpc SubmitMisbehaviorReport(SubmitMisbehaviorReportRequest) returns (SubmitMisbehaviorReportResponse) { + option (google.api.http) = { + post: "/mls/v2/submit-misbehavior-report" + body: "*" + }; + } + + rpc QueryMisbehaviorReports(QueryMisbehaviorReportsRequest) returns (QueryMisbehaviorReportsResponse) { + option (google.api.http) = { + post: "/mls/v2/query-misbehavior-reports" + body: "*" + }; + } +}