Skip to content

Commit

Permalink
Flesh out misbehavior reports (#237)
Browse files Browse the repository at this point in the history
1. Fleshes out the misbehavior report types and fields
2. Defines endpoints for storing and retrieving misbehavior reports
  • Loading branch information
richardhuaaa authored Jan 3, 2025
1 parent 7181f0e commit 0bc2969
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .protolint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions proto/identity/api/v1/identity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions proto/xmtpv4/message_api/message_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -83,33 +68,28 @@ 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"
body: "*"
};
}

// Query envelopes
rpc QueryEnvelopes(QueryEnvelopesRequest) returns (QueryEnvelopesResponse) {
option (google.api.http) = {
post: "/mls/v2/query-envelopes"
body: "*"
};
}

// Publish envelope
rpc PublishPayerEnvelopes(PublishPayerEnvelopesRequest) returns (PublishPayerEnvelopesResponse) {
option (google.api.http) = {
post: "/mls/v2/publish-payer-envelopes"
body: "*"
};
}

// Get inbox ids
rpc GetInboxIds(GetInboxIdsRequest) returns (GetInboxIdsResponse) {
option (google.api.http) = {
post: "/mls/v2/get-inbox-ids"
Expand Down
87 changes: 87 additions & 0 deletions proto/xmtpv4/message_api/misbehavior_api.proto
Original file line number Diff line number Diff line change
@@ -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: "*"
};
}
}

0 comments on commit 0bc2969

Please sign in to comment.