From 831b4e673c93100980bae20baaa867e900a7edc3 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:59:02 -0700 Subject: [PATCH 01/24] Initial commit --- dev/run | 5 +- pkg/identity/queries.sql | 12 + pkg/identity/queries/db.go | 31 + pkg/identity/queries/models.go | 52 ++ pkg/identity/queries/queries.sql.go | 80 +++ .../mls/20240411200242_init-identity.up.sql | 7 + .../identity/associations/association.pb.go | 648 ++++++++++++++---- .../identity/associations/signature.pb.go | 139 ++-- pkg/proto/keystore_api/v1/keystore.pb.go | 497 +++++++------- .../conversation_reference.pb.go | 38 +- pkg/proto/mls/database/intents.pb.go | 98 +-- .../mls/message_contents/group_metadata.pb.go | 292 ++++---- .../group_mutable_metadata.pb.go | 72 +- pkg/proto/mls_validation/v1/service.pb.go | 439 ++++++++---- .../mls_validation/v1/service_grpc.pb.go | 39 ++ .../identity/api/v1/identity.swagger.json | 12 +- .../mls_validation/v1/service.swagger.json | 325 +++++++++ sqlc.yaml | 11 + 18 files changed, 1982 insertions(+), 815 deletions(-) create mode 100644 pkg/identity/queries.sql create mode 100644 pkg/identity/queries/db.go create mode 100644 pkg/identity/queries/models.go create mode 100644 pkg/identity/queries/queries.sql.go create mode 100644 sqlc.yaml diff --git a/dev/run b/dev/run index a995db08..a160bc5b 100755 --- a/dev/run +++ b/dev/run @@ -2,8 +2,8 @@ set -e MESSAGE_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" -MLS_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" -AUTHZ_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" +MLS_DB_DSN="postgres://postgres:xmtp@localhost:7654/postgres?sslmode=disable" +AUTHZ_DB_DSN="postgres://postgres:xmtp@localhost:6543/postgres?sslmode=disable" NODE_KEY="8a30dcb604b0b53627a5adc054dbf434b446628d4bd1eccc681d223f0550ce67" go run cmd/xmtpd/main.go \ @@ -15,6 +15,7 @@ go run cmd/xmtpd/main.go \ --store.reader-db-connection-string "${MESSAGE_DB_DSN}" \ --store.metrics-period 5s \ --mls-store.db-connection-string "${MLS_DB_DSN}" \ + --mls-validation.grpc-address=validation:50051 \ --authz-db-connection-string "${AUTHZ_DB_DSN}" \ --go-profiling \ "$@" diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql new file mode 100644 index 00000000..e29e5c5b --- /dev/null +++ b/pkg/identity/queries.sql @@ -0,0 +1,12 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS ( + SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) +) +SELECT a.* FROM inbox_log AS a +JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go new file mode 100644 index 00000000..fa785733 --- /dev/null +++ b/pkg/identity/queries/db.go @@ -0,0 +1,31 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "context" + "database/sql" +) + +type DBTX interface { + ExecContext(context.Context, string, ...interface{}) (sql.Result, error) + PrepareContext(context.Context, string) (*sql.Stmt, error) + QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) + QueryRowContext(context.Context, string, ...interface{}) *sql.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx *sql.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go new file mode 100644 index 00000000..cc2ae9d3 --- /dev/null +++ b/pkg/identity/queries/models.go @@ -0,0 +1,52 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "database/sql" + "time" +) + +type AddressLog struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +type GroupMessage struct { + ID int64 + CreatedAt time.Time + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +type InboxLog struct { + SequenceID int64 + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +type Installation struct { + ID []byte + WalletAddress string + CreatedAt int64 + UpdatedAt int64 + CredentialIdentity []byte + RevokedAt sql.NullInt64 + KeyPackage []byte + Expiration int64 +} + +type WelcomeMessage struct { + ID int64 + CreatedAt time.Time + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go new file mode 100644 index 00000000..5441410f --- /dev/null +++ b/pkg/identity/queries/queries.sql.go @@ -0,0 +1,80 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" +) + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogs = `-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS (VALUES ($1)) +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a +JOIN b ON a.inbox_id = b.inbox_id +WHERE a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} diff --git a/pkg/migrations/mls/20240411200242_init-identity.up.sql b/pkg/migrations/mls/20240411200242_init-identity.up.sql index 4fdeef44..a764f57b 100644 --- a/pkg/migrations/mls/20240411200242_init-identity.up.sql +++ b/pkg/migrations/mls/20240411200242_init-identity.up.sql @@ -25,3 +25,10 @@ CREATE TABLE address_log ( --bun:split CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); + +-- bun:split + +CREATE TYPE inbox_filter AS ( + sequence_id BIGINT, + inbox_id TEXT +); \ No newline at end of file diff --git a/pkg/proto/identity/associations/association.pb.go b/pkg/proto/identity/associations/association.pb.go index 0f048ecb..bd74cbd7 100644 --- a/pkg/proto/identity/associations/association.pb.go +++ b/pkg/proto/identity/associations/association.pb.go @@ -104,6 +104,62 @@ func (*MemberIdentifier_Address) isMemberIdentifier_Kind() {} func (*MemberIdentifier_InstallationPublicKey) isMemberIdentifier_Kind() {} +// single member that optionally indicates the member that added them +type Member struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identifier *MemberIdentifier `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` + AddedByEntity *MemberIdentifier `protobuf:"bytes,2,opt,name=added_by_entity,json=addedByEntity,proto3,oneof" json:"added_by_entity,omitempty"` +} + +func (x *Member) Reset() { + *x = Member{} + if protoimpl.UnsafeEnabled { + mi := &file_identity_associations_association_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Member) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Member) ProtoMessage() {} + +func (x *Member) ProtoReflect() protoreflect.Message { + mi := &file_identity_associations_association_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Member.ProtoReflect.Descriptor instead. +func (*Member) Descriptor() ([]byte, []int) { + return file_identity_associations_association_proto_rawDescGZIP(), []int{1} +} + +func (x *Member) GetIdentifier() *MemberIdentifier { + if x != nil { + return x.Identifier + } + return nil +} + +func (x *Member) GetAddedByEntity() *MemberIdentifier { + if x != nil { + return x.AddedByEntity + } + return nil +} + // The first entry of any XID log. The XID must be deterministically derivable // from the address and nonce. // The recovery address defaults to the initial associated_address unless @@ -121,7 +177,7 @@ type CreateInbox struct { func (x *CreateInbox) Reset() { *x = CreateInbox{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[1] + mi := &file_identity_associations_association_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -134,7 +190,7 @@ func (x *CreateInbox) String() string { func (*CreateInbox) ProtoMessage() {} func (x *CreateInbox) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[1] + mi := &file_identity_associations_association_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -147,7 +203,7 @@ func (x *CreateInbox) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateInbox.ProtoReflect.Descriptor instead. func (*CreateInbox) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{1} + return file_identity_associations_association_proto_rawDescGZIP(), []int{2} } func (x *CreateInbox) GetInitialAddress() string { @@ -188,7 +244,7 @@ type AddAssociation struct { func (x *AddAssociation) Reset() { *x = AddAssociation{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[2] + mi := &file_identity_associations_association_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -201,7 +257,7 @@ func (x *AddAssociation) String() string { func (*AddAssociation) ProtoMessage() {} func (x *AddAssociation) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[2] + mi := &file_identity_associations_association_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -214,7 +270,7 @@ func (x *AddAssociation) ProtoReflect() protoreflect.Message { // Deprecated: Use AddAssociation.ProtoReflect.Descriptor instead. func (*AddAssociation) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{2} + return file_identity_associations_association_proto_rawDescGZIP(), []int{3} } func (x *AddAssociation) GetNewMemberIdentifier() *MemberIdentifier { @@ -251,7 +307,7 @@ type RevokeAssociation struct { func (x *RevokeAssociation) Reset() { *x = RevokeAssociation{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[3] + mi := &file_identity_associations_association_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -264,7 +320,7 @@ func (x *RevokeAssociation) String() string { func (*RevokeAssociation) ProtoMessage() {} func (x *RevokeAssociation) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[3] + mi := &file_identity_associations_association_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -277,7 +333,7 @@ func (x *RevokeAssociation) ProtoReflect() protoreflect.Message { // Deprecated: Use RevokeAssociation.ProtoReflect.Descriptor instead. func (*RevokeAssociation) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{3} + return file_identity_associations_association_proto_rawDescGZIP(), []int{4} } func (x *RevokeAssociation) GetMemberToRevoke() *MemberIdentifier { @@ -309,7 +365,7 @@ type ChangeRecoveryAddress struct { func (x *ChangeRecoveryAddress) Reset() { *x = ChangeRecoveryAddress{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[4] + mi := &file_identity_associations_association_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -322,7 +378,7 @@ func (x *ChangeRecoveryAddress) String() string { func (*ChangeRecoveryAddress) ProtoMessage() {} func (x *ChangeRecoveryAddress) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[4] + mi := &file_identity_associations_association_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -335,7 +391,7 @@ func (x *ChangeRecoveryAddress) ProtoReflect() protoreflect.Message { // Deprecated: Use ChangeRecoveryAddress.ProtoReflect.Descriptor instead. func (*ChangeRecoveryAddress) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{4} + return file_identity_associations_association_proto_rawDescGZIP(), []int{5} } func (x *ChangeRecoveryAddress) GetNewRecoveryAddress() string { @@ -370,7 +426,7 @@ type IdentityAction struct { func (x *IdentityAction) Reset() { *x = IdentityAction{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[5] + mi := &file_identity_associations_association_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -383,7 +439,7 @@ func (x *IdentityAction) String() string { func (*IdentityAction) ProtoMessage() {} func (x *IdentityAction) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[5] + mi := &file_identity_associations_association_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -396,7 +452,7 @@ func (x *IdentityAction) ProtoReflect() protoreflect.Message { // Deprecated: Use IdentityAction.ProtoReflect.Descriptor instead. func (*IdentityAction) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{5} + return file_identity_associations_association_proto_rawDescGZIP(), []int{6} } func (m *IdentityAction) GetKind() isIdentityAction_Kind { @@ -482,7 +538,7 @@ type IdentityUpdate struct { func (x *IdentityUpdate) Reset() { *x = IdentityUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_identity_associations_association_proto_msgTypes[6] + mi := &file_identity_associations_association_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -495,7 +551,7 @@ func (x *IdentityUpdate) String() string { func (*IdentityUpdate) ProtoMessage() {} func (x *IdentityUpdate) ProtoReflect() protoreflect.Message { - mi := &file_identity_associations_association_proto_msgTypes[6] + mi := &file_identity_associations_association_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -508,7 +564,7 @@ func (x *IdentityUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use IdentityUpdate.ProtoReflect.Descriptor instead. func (*IdentityUpdate) Descriptor() ([]byte, []int) { - return file_identity_associations_association_proto_rawDescGZIP(), []int{6} + return file_identity_associations_association_proto_rawDescGZIP(), []int{7} } func (x *IdentityUpdate) GetActions() []*IdentityAction { @@ -532,6 +588,190 @@ func (x *IdentityUpdate) GetInboxId() string { return "" } +// Map of members belonging to an inbox_id +type MemberMap struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *MemberIdentifier `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value *Member `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *MemberMap) Reset() { + *x = MemberMap{} + if protoimpl.UnsafeEnabled { + mi := &file_identity_associations_association_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MemberMap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MemberMap) ProtoMessage() {} + +func (x *MemberMap) ProtoReflect() protoreflect.Message { + mi := &file_identity_associations_association_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MemberMap.ProtoReflect.Descriptor instead. +func (*MemberMap) Descriptor() ([]byte, []int) { + return file_identity_associations_association_proto_rawDescGZIP(), []int{8} +} + +func (x *MemberMap) GetKey() *MemberIdentifier { + if x != nil { + return x.Key + } + return nil +} + +func (x *MemberMap) GetValue() *Member { + if x != nil { + return x.Value + } + return nil +} + +// A final association state resulting from multiple `IdentityUpdates` +type AssociationState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InboxId string `protobuf:"bytes,1,opt,name=inbox_id,json=inboxId,proto3" json:"inbox_id,omitempty"` + Members []*MemberMap `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` + RecoveryAddress string `protobuf:"bytes,3,opt,name=recovery_address,json=recoveryAddress,proto3" json:"recovery_address,omitempty"` + SeenSignatures [][]byte `protobuf:"bytes,4,rep,name=seen_signatures,json=seenSignatures,proto3" json:"seen_signatures,omitempty"` +} + +func (x *AssociationState) Reset() { + *x = AssociationState{} + if protoimpl.UnsafeEnabled { + mi := &file_identity_associations_association_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AssociationState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AssociationState) ProtoMessage() {} + +func (x *AssociationState) ProtoReflect() protoreflect.Message { + mi := &file_identity_associations_association_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AssociationState.ProtoReflect.Descriptor instead. +func (*AssociationState) Descriptor() ([]byte, []int) { + return file_identity_associations_association_proto_rawDescGZIP(), []int{9} +} + +func (x *AssociationState) GetInboxId() string { + if x != nil { + return x.InboxId + } + return "" +} + +func (x *AssociationState) GetMembers() []*MemberMap { + if x != nil { + return x.Members + } + return nil +} + +func (x *AssociationState) GetRecoveryAddress() string { + if x != nil { + return x.RecoveryAddress + } + return "" +} + +func (x *AssociationState) GetSeenSignatures() [][]byte { + if x != nil { + return x.SeenSignatures + } + return nil +} + +// / state diff between two final AssociationStates +type AssociationStateDiff struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NewMembers []*MemberIdentifier `protobuf:"bytes,1,rep,name=new_members,json=newMembers,proto3" json:"new_members,omitempty"` + RemovedMembers []*MemberIdentifier `protobuf:"bytes,2,rep,name=removed_members,json=removedMembers,proto3" json:"removed_members,omitempty"` +} + +func (x *AssociationStateDiff) Reset() { + *x = AssociationStateDiff{} + if protoimpl.UnsafeEnabled { + mi := &file_identity_associations_association_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AssociationStateDiff) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AssociationStateDiff) ProtoMessage() {} + +func (x *AssociationStateDiff) ProtoReflect() protoreflect.Message { + mi := &file_identity_associations_association_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AssociationStateDiff.ProtoReflect.Descriptor instead. +func (*AssociationStateDiff) Descriptor() ([]byte, []int) { + return file_identity_associations_association_proto_rawDescGZIP(), []int{10} +} + +func (x *AssociationStateDiff) GetNewMembers() []*MemberIdentifier { + if x != nil { + return x.NewMembers + } + return nil +} + +func (x *AssociationStateDiff) GetRemovedMembers() []*MemberIdentifier { + if x != nil { + return x.RemovedMembers + } + return nil +} + var File_identity_associations_association_proto protoreflect.FileDescriptor var file_identity_associations_association_proto_rawDesc = []byte{ @@ -548,111 +788,157 @@ var file_identity_associations_association_proto_rawDesc = []byte{ 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x15, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xaf, - 0x01, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, 0x27, - 0x0a, 0x0f, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x61, 0x0a, - 0x19, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x17, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x22, 0xae, 0x02, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x60, 0x0a, 0x15, 0x6e, 0x65, 0x77, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x52, 0x13, 0x6e, 0x65, 0x77, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x61, 0x0a, 0x19, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, - 0x67, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xc5, + 0x01, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x4c, 0x0a, 0x0a, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, + 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0a, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x59, 0x0a, 0x0f, 0x61, 0x64, 0x64, 0x65, 0x64, + 0x5f, 0x62, 0x79, 0x5f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x48, 0x00, + 0x52, 0x0d, 0x61, 0x64, 0x64, 0x65, 0x64, 0x42, 0x79, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x88, + 0x01, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x61, 0x64, 0x64, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x5f, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0xaf, 0x01, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, 0x27, 0x0a, 0x0f, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, + 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, + 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x61, 0x0a, 0x19, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, - 0x17, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x53, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x57, 0x0a, 0x14, 0x6e, 0x65, 0x77, 0x5f, - 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x12, 0x6e, - 0x65, 0x77, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x56, 0x0a, 0x10, 0x6d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x5f, 0x74, 0x6f, 0x5f, 0x72, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, - 0x0e, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x6f, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x12, - 0x63, 0x0a, 0x1a, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x18, 0x72, 0x65, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x69, 0x67, 0x6e, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x22, 0xbf, 0x01, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, - 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, - 0x0a, 0x14, 0x6e, 0x65, 0x77, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x6e, 0x65, - 0x77, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x74, 0x0a, 0x23, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, - 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, - 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x52, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xdc, 0x02, 0x0a, 0x0e, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4c, 0x0a, 0x0c, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x27, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x48, 0x00, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, 0x3e, 0x0a, 0x03, 0x61, 0x64, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x48, 0x00, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, 0x47, 0x0a, 0x06, 0x72, 0x65, 0x76, 0x6f, 0x6b, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, + 0x17, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xae, 0x02, 0x0a, 0x0e, 0x41, 0x64, 0x64, + 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x60, 0x0a, 0x15, 0x6e, + 0x65, 0x77, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, + 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x13, 0x6e, 0x65, 0x77, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x61, 0x0a, + 0x19, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x17, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, + 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x12, 0x57, 0x0a, 0x14, 0x6e, 0x65, 0x77, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x12, 0x6e, 0x65, 0x77, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x11, 0x52, 0x65, + 0x76, 0x6f, 0x6b, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x56, 0x0a, 0x10, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x74, 0x6f, 0x5f, 0x72, 0x65, 0x76, + 0x6f, 0x6b, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0e, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x54, + 0x6f, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x63, 0x0a, 0x1a, 0x72, 0x65, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x52, 0x18, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xbf, 0x01, 0x0a, + 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x6e, 0x65, 0x77, 0x5f, 0x72, 0x65, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x6e, 0x65, 0x77, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x74, 0x0a, 0x23, 0x65, 0x78, 0x69, 0x73, + 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x20, 0x65, 0x78, + 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xdc, + 0x02, 0x0a, 0x0e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x4c, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x62, 0x6f, + 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x76, 0x6f, 0x6b, 0x65, - 0x12, 0x6b, 0x0a, 0x17, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x31, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x48, 0x00, 0x52, 0x15, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x06, 0x0a, - 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x0e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x07, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, + 0x48, 0x00, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, + 0x3e, 0x0a, 0x03, 0x61, 0x64, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x03, 0x61, 0x64, 0x64, 0x12, + 0x47, 0x0a, 0x06, 0x72, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x76, + 0x6f, 0x6b, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, + 0x52, 0x06, 0x72, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x6b, 0x0a, 0x17, 0x63, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x41, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, - 0x0a, 0x13, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4e, 0x73, 0x12, 0x19, - 0x0a, 0x08, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x49, 0x64, 0x42, 0xfa, 0x01, 0x0a, 0x1e, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x10, 0x41, 0x73, - 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, - 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa2, 0x02, - 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xe2, 0x02, - 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, 0x3a, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x48, 0x00, 0x52, 0x15, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xa1, 0x01, + 0x0a, 0x0e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x12, 0x44, 0x0a, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x11, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x4e, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x49, + 0x64, 0x22, 0x85, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4d, 0x61, 0x70, 0x12, + 0x3e, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x38, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc2, 0x01, 0x0a, 0x10, 0x41, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x19, + 0x0a, 0x08, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x49, 0x64, 0x12, 0x3f, 0x0a, 0x07, 0x6d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x6d, 0x74, + 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4d, 0x61, + 0x70, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x65, 0x6e, 0x5f, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, + 0x73, 0x65, 0x65, 0x6e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0xbc, + 0x01, 0x0a, 0x14, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x44, 0x69, 0x66, 0x66, 0x12, 0x4d, 0x0a, 0x0b, 0x6e, 0x65, 0x77, 0x5f, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x65, 0x77, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x55, 0x0a, 0x0f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x64, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0e, 0x72, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x42, 0xfa, 0x01, + 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x42, 0x10, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, + 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x2e, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0xe2, 0x02, 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x58, 0x6d, + 0x74, 0x70, 0x3a, 0x3a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, 0x3a, 0x41, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -667,35 +953,46 @@ func file_identity_associations_association_proto_rawDescGZIP() []byte { return file_identity_associations_association_proto_rawDescData } -var file_identity_associations_association_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_identity_associations_association_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_identity_associations_association_proto_goTypes = []interface{}{ (*MemberIdentifier)(nil), // 0: xmtp.identity.associations.MemberIdentifier - (*CreateInbox)(nil), // 1: xmtp.identity.associations.CreateInbox - (*AddAssociation)(nil), // 2: xmtp.identity.associations.AddAssociation - (*RevokeAssociation)(nil), // 3: xmtp.identity.associations.RevokeAssociation - (*ChangeRecoveryAddress)(nil), // 4: xmtp.identity.associations.ChangeRecoveryAddress - (*IdentityAction)(nil), // 5: xmtp.identity.associations.IdentityAction - (*IdentityUpdate)(nil), // 6: xmtp.identity.associations.IdentityUpdate - (*Signature)(nil), // 7: xmtp.identity.associations.Signature + (*Member)(nil), // 1: xmtp.identity.associations.Member + (*CreateInbox)(nil), // 2: xmtp.identity.associations.CreateInbox + (*AddAssociation)(nil), // 3: xmtp.identity.associations.AddAssociation + (*RevokeAssociation)(nil), // 4: xmtp.identity.associations.RevokeAssociation + (*ChangeRecoveryAddress)(nil), // 5: xmtp.identity.associations.ChangeRecoveryAddress + (*IdentityAction)(nil), // 6: xmtp.identity.associations.IdentityAction + (*IdentityUpdate)(nil), // 7: xmtp.identity.associations.IdentityUpdate + (*MemberMap)(nil), // 8: xmtp.identity.associations.MemberMap + (*AssociationState)(nil), // 9: xmtp.identity.associations.AssociationState + (*AssociationStateDiff)(nil), // 10: xmtp.identity.associations.AssociationStateDiff + (*Signature)(nil), // 11: xmtp.identity.associations.Signature } var file_identity_associations_association_proto_depIdxs = []int32{ - 7, // 0: xmtp.identity.associations.CreateInbox.initial_address_signature:type_name -> xmtp.identity.associations.Signature - 0, // 1: xmtp.identity.associations.AddAssociation.new_member_identifier:type_name -> xmtp.identity.associations.MemberIdentifier - 7, // 2: xmtp.identity.associations.AddAssociation.existing_member_signature:type_name -> xmtp.identity.associations.Signature - 7, // 3: xmtp.identity.associations.AddAssociation.new_member_signature:type_name -> xmtp.identity.associations.Signature - 0, // 4: xmtp.identity.associations.RevokeAssociation.member_to_revoke:type_name -> xmtp.identity.associations.MemberIdentifier - 7, // 5: xmtp.identity.associations.RevokeAssociation.recovery_address_signature:type_name -> xmtp.identity.associations.Signature - 7, // 6: xmtp.identity.associations.ChangeRecoveryAddress.existing_recovery_address_signature:type_name -> xmtp.identity.associations.Signature - 1, // 7: xmtp.identity.associations.IdentityAction.create_inbox:type_name -> xmtp.identity.associations.CreateInbox - 2, // 8: xmtp.identity.associations.IdentityAction.add:type_name -> xmtp.identity.associations.AddAssociation - 3, // 9: xmtp.identity.associations.IdentityAction.revoke:type_name -> xmtp.identity.associations.RevokeAssociation - 4, // 10: xmtp.identity.associations.IdentityAction.change_recovery_address:type_name -> xmtp.identity.associations.ChangeRecoveryAddress - 5, // 11: xmtp.identity.associations.IdentityUpdate.actions:type_name -> xmtp.identity.associations.IdentityAction - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 0, // 0: xmtp.identity.associations.Member.identifier:type_name -> xmtp.identity.associations.MemberIdentifier + 0, // 1: xmtp.identity.associations.Member.added_by_entity:type_name -> xmtp.identity.associations.MemberIdentifier + 11, // 2: xmtp.identity.associations.CreateInbox.initial_address_signature:type_name -> xmtp.identity.associations.Signature + 0, // 3: xmtp.identity.associations.AddAssociation.new_member_identifier:type_name -> xmtp.identity.associations.MemberIdentifier + 11, // 4: xmtp.identity.associations.AddAssociation.existing_member_signature:type_name -> xmtp.identity.associations.Signature + 11, // 5: xmtp.identity.associations.AddAssociation.new_member_signature:type_name -> xmtp.identity.associations.Signature + 0, // 6: xmtp.identity.associations.RevokeAssociation.member_to_revoke:type_name -> xmtp.identity.associations.MemberIdentifier + 11, // 7: xmtp.identity.associations.RevokeAssociation.recovery_address_signature:type_name -> xmtp.identity.associations.Signature + 11, // 8: xmtp.identity.associations.ChangeRecoveryAddress.existing_recovery_address_signature:type_name -> xmtp.identity.associations.Signature + 2, // 9: xmtp.identity.associations.IdentityAction.create_inbox:type_name -> xmtp.identity.associations.CreateInbox + 3, // 10: xmtp.identity.associations.IdentityAction.add:type_name -> xmtp.identity.associations.AddAssociation + 4, // 11: xmtp.identity.associations.IdentityAction.revoke:type_name -> xmtp.identity.associations.RevokeAssociation + 5, // 12: xmtp.identity.associations.IdentityAction.change_recovery_address:type_name -> xmtp.identity.associations.ChangeRecoveryAddress + 6, // 13: xmtp.identity.associations.IdentityUpdate.actions:type_name -> xmtp.identity.associations.IdentityAction + 0, // 14: xmtp.identity.associations.MemberMap.key:type_name -> xmtp.identity.associations.MemberIdentifier + 1, // 15: xmtp.identity.associations.MemberMap.value:type_name -> xmtp.identity.associations.Member + 8, // 16: xmtp.identity.associations.AssociationState.members:type_name -> xmtp.identity.associations.MemberMap + 0, // 17: xmtp.identity.associations.AssociationStateDiff.new_members:type_name -> xmtp.identity.associations.MemberIdentifier + 0, // 18: xmtp.identity.associations.AssociationStateDiff.removed_members:type_name -> xmtp.identity.associations.MemberIdentifier + 19, // [19:19] is the sub-list for method output_type + 19, // [19:19] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name } func init() { file_identity_associations_association_proto_init() } @@ -718,7 +1015,7 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateInbox); i { + switch v := v.(*Member); i { case 0: return &v.state case 1: @@ -730,7 +1027,7 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddAssociation); i { + switch v := v.(*CreateInbox); i { case 0: return &v.state case 1: @@ -742,7 +1039,7 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RevokeAssociation); i { + switch v := v.(*AddAssociation); i { case 0: return &v.state case 1: @@ -754,7 +1051,7 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ChangeRecoveryAddress); i { + switch v := v.(*RevokeAssociation); i { case 0: return &v.state case 1: @@ -766,7 +1063,7 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*IdentityAction); i { + switch v := v.(*ChangeRecoveryAddress); i { case 0: return &v.state case 1: @@ -778,6 +1075,18 @@ func file_identity_associations_association_proto_init() { } } file_identity_associations_association_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IdentityAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_identity_associations_association_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*IdentityUpdate); i { case 0: return &v.state @@ -789,12 +1098,49 @@ func file_identity_associations_association_proto_init() { return nil } } + file_identity_associations_association_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MemberMap); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_identity_associations_association_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AssociationState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_identity_associations_association_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AssociationStateDiff); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_identity_associations_association_proto_msgTypes[0].OneofWrappers = []interface{}{ (*MemberIdentifier_Address)(nil), (*MemberIdentifier_InstallationPublicKey)(nil), } - file_identity_associations_association_proto_msgTypes[5].OneofWrappers = []interface{}{ + file_identity_associations_association_proto_msgTypes[1].OneofWrappers = []interface{}{} + file_identity_associations_association_proto_msgTypes[6].OneofWrappers = []interface{}{ (*IdentityAction_CreateInbox)(nil), (*IdentityAction_Add)(nil), (*IdentityAction_Revoke)(nil), @@ -806,7 +1152,7 @@ func file_identity_associations_association_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_identity_associations_association_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/proto/identity/associations/signature.pb.go b/pkg/proto/identity/associations/signature.pb.go index 9a49794b..8f9824dc 100644 --- a/pkg/proto/identity/associations/signature.pb.go +++ b/pkg/proto/identity/associations/signature.pb.go @@ -78,7 +78,10 @@ type RecoverableEd25519Signature struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // 64 bytes [R(32 bytes) || S(32 bytes)] Bytes []byte `protobuf:"bytes,1,opt,name=bytes,proto3" json:"bytes,omitempty"` + // 32 bytes + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` } func (x *RecoverableEd25519Signature) Reset() { @@ -120,15 +123,22 @@ func (x *RecoverableEd25519Signature) GetBytes() []byte { return nil } +func (x *RecoverableEd25519Signature) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + // Smart wallet signature type Erc1271Signature struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // CAIP-10 contract address + // CAIP-10 // https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + AccountId string `protobuf:"bytes,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` // Specify the block number to verify the signature against BlockNumber uint64 `protobuf:"varint,2,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` // The actual signature bytes @@ -167,9 +177,9 @@ func (*Erc1271Signature) Descriptor() ([]byte, []int) { return file_identity_associations_signature_proto_rawDescGZIP(), []int{2} } -func (x *Erc1271Signature) GetContractAddress() string { +func (x *Erc1271Signature) GetAccountId() string { if x != nil { - return x.ContractAddress + return x.AccountId } return "" } @@ -377,71 +387,72 @@ var file_identity_associations_signature_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x19, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x33, 0x0a, 0x1b, 0x52, 0x65, 0x63, + 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x52, 0x0a, 0x1b, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x7e, - 0x0a, 0x10, 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, - 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xbc, - 0x01, 0x0a, 0x18, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, - 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, 0x0a, 0x0d, 0x64, - 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, - 0x64, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x6c, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x53, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x6d, - 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xff, 0x02, - 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x50, 0x0a, 0x07, 0x65, - 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, - 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, - 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x06, 0x65, 0x72, 0x63, 0x31, 0x39, 0x31, 0x12, 0x49, 0x0a, - 0x08, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x32, 0x37, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x72, 0x63, - 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, - 0x07, 0x65, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x12, 0x64, 0x0a, 0x10, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x72, 0x0a, + 0x10, 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x22, 0xbc, 0x01, 0x0a, 0x18, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, + 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x53, 0x69, + 0x67, 0x6e, 0x65, 0x64, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x52, 0x0c, 0x64, + 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x53, 0x0a, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x22, 0xff, 0x02, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x50, + 0x0a, 0x07, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x35, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x06, 0x65, 0x72, 0x63, 0x31, 0x39, 0x31, + 0x12, 0x49, 0x0a, 0x08, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x32, 0x37, 0x31, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, 0x32, 0x35, 0x35, - 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x12, 0x62, - 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x72, 0x63, 0x5f, - 0x31, 0x39, 0x31, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x78, 0x6d, 0x74, 0x70, - 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, - 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, - 0x00, 0x52, 0x0f, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x45, 0x72, 0x63, 0x31, - 0x39, 0x31, 0x42, 0x0b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x42, - 0xf8, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, + 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x48, 0x00, 0x52, 0x07, 0x65, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x12, 0x64, 0x0a, 0x10, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x42, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, - 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x2e, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, + 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, + 0x32, 0x35, 0x35, 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, + 0x52, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, + 0x79, 0x12, 0x62, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, + 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x45, + 0x72, 0x63, 0x31, 0x39, 0x31, 0x42, 0x0b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x42, 0xf8, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, + 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, + 0x74, 0x70, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xe2, 0x02, 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0xe2, 0x02, 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x58, 0x6d, - 0x74, 0x70, 0x3a, 0x3a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, 0x3a, 0x41, 0x73, - 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6e, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x1c, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, + 0x3a, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/keystore_api/v1/keystore.pb.go b/pkg/proto/keystore_api/v1/keystore.pb.go index 155e836c..3aa3a2ee 100644 --- a/pkg/proto/keystore_api/v1/keystore.pb.go +++ b/pkg/proto/keystore_api/v1/keystore.pb.go @@ -718,9 +718,10 @@ type CreateInviteRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Context *message_contents.InvitationV1_Context `protobuf:"bytes,1,opt,name=context,proto3" json:"context,omitempty"` - Recipient *message_contents.SignedPublicKeyBundle `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"` - CreatedNs uint64 `protobuf:"varint,3,opt,name=created_ns,json=createdNs,proto3" json:"created_ns,omitempty"` + Context *message_contents.InvitationV1_Context `protobuf:"bytes,1,opt,name=context,proto3" json:"context,omitempty"` + Recipient *message_contents.SignedPublicKeyBundle `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"` + CreatedNs uint64 `protobuf:"varint,3,opt,name=created_ns,json=createdNs,proto3" json:"created_ns,omitempty"` + ConsentProof *message_contents.ConsentProofPayload `protobuf:"bytes,4,opt,name=consent_proof,json=consentProof,proto3" json:"consent_proof,omitempty"` } func (x *CreateInviteRequest) Reset() { @@ -776,6 +777,13 @@ func (x *CreateInviteRequest) GetCreatedNs() uint64 { return 0 } +func (x *CreateInviteRequest) GetConsentProof() *message_contents.ConsentProofPayload { + if x != nil { + return x.ConsentProof + } + return nil +} + // Response to a CreateInviteRequest type CreateInviteResponse struct { state protoimpl.MessageState @@ -3042,8 +3050,8 @@ var file_keystore_api_v1_keystore_proto_rawDesc = []byte{ 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0xc7, - 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x52, + 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0x98, + 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x45, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, @@ -3055,210 +3063,215 @@ var file_keystore_api_v1_keystore_proto_rawDesc = []byte{ 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x73, 0x22, 0x82, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x50, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, - 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xcf, 0x01, - 0x0a, 0x12, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x4c, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, - 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, - 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x73, 0x1a, 0x6b, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, - 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, 0x70, - 0x69, 0x63, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, - 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x4e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, - 0xf0, 0x02, 0x0a, 0x13, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x6d, 0x74, - 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, 0x86, 0x02, 0x0a, 0x08, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, - 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, - 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3b, 0x0a, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x6d, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x73, 0x12, 0x4f, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x50, + 0x72, 0x6f, 0x6f, 0x66, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x0c, 0x63, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x82, 0x01, 0x0a, 0x14, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xcf, + 0x01, 0x0a, 0x12, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4c, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, + 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x1a, 0x6b, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, + 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, + 0x70, 0x69, 0x63, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x4e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x22, 0xf0, 0x02, 0x0a, 0x13, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x5b, 0x0a, 0x07, 0x53, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x12, 0x50, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, - 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, - 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x51, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0c, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4e, - 0x73, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x22, 0x70, 0x0a, 0x1a, 0x53, 0x61, 0x76, 0x65, 0x56, 0x31, 0x43, - 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, + 0x76, 0x31, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, + 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, 0x86, 0x02, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, + 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x61, 0x76, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3b, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x5b, 0x0a, 0x07, 0x53, 0x75, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x50, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x76, 0x65, + 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x51, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, + 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, + 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x4e, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x5f, 0x6e, 0x73, 0x22, 0x70, 0x0a, 0x1a, 0x53, 0x61, 0x76, 0x65, 0x56, 0x31, + 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, + 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x53, 0x61, 0x76, 0x65, + 0x56, 0x31, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6e, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x43, 0x6f, + 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, - 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x53, 0x61, 0x76, 0x65, 0x56, - 0x31, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6e, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, - 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x52, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, - 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x41, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x4b, 0x65, 0x79, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x61, 0x6c, 0x6c, - 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xea, 0x01, 0x0a, 0x19, 0x47, 0x65, - 0x74, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, - 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, + 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x41, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x4b, 0x65, + 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x61, 0x6c, + 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xea, 0x01, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, - 0x75, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, 0x52, 0x45, 0x5f, 0x53, 0x54, - 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, 0x52, 0x45, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x49, - 0x5a, 0x45, 0x44, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, 0x52, - 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, - 0x49, 0x5a, 0x45, 0x44, 0x10, 0x02, 0x22, 0x5c, 0x0a, 0x13, 0x49, 0x6e, 0x69, 0x74, 0x4b, 0x65, - 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3b, 0x0a, - 0x02, 0x76, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, 0x70, - 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x2e, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x42, 0x75, 0x6e, 0x64, - 0x6c, 0x65, 0x56, 0x31, 0x48, 0x00, 0x52, 0x02, 0x76, 0x31, 0x42, 0x08, 0x0a, 0x06, 0x62, 0x75, - 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x51, 0x0a, 0x14, 0x49, 0x6e, 0x69, 0x74, 0x4b, 0x65, 0x79, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x6d, - 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x7f, 0x0a, 0x11, 0x53, 0x69, 0x67, 0x6e, 0x44, - 0x69, 0x67, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x64, 0x69, - 0x67, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0c, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x69, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0c, 0x70, 0x72, 0x65, - 0x6b, 0x65, 0x79, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x48, - 0x00, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x6b, 0x65, 0x79, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x42, 0x08, - 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x52, - 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x38, 0x0a, 0x08, 0x6a, 0x6f, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, - 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, - 0x65, 0x52, 0x07, 0x6a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x22, 0x37, 0x0a, 0x15, 0x47, 0x65, - 0x74, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x75, 0x6e, 0x5f, - 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x75, - 0x6e, 0x4e, 0x73, 0x22, 0x6f, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x73, 0x68, - 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x08, 0x6a, 0x6f, - 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x78, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x22, 0x75, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, 0x52, 0x45, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, 0x52, 0x45, 0x5f, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, + 0x49, 0x5a, 0x45, 0x44, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x45, 0x59, 0x53, 0x54, 0x4f, + 0x52, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, + 0x4c, 0x49, 0x5a, 0x45, 0x44, 0x10, 0x02, 0x22, 0x5c, 0x0a, 0x13, 0x49, 0x6e, 0x69, 0x74, 0x4b, + 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3b, + 0x0a, 0x02, 0x76, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, + 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x2e, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x42, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x56, 0x31, 0x48, 0x00, 0x52, 0x02, 0x76, 0x31, 0x42, 0x08, 0x0a, 0x06, 0x62, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x51, 0x0a, 0x14, 0x49, 0x6e, 0x69, 0x74, 0x4b, 0x65, 0x79, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x6a, 0x6f, 0x62, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x75, 0x6e, - 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x52, - 0x75, 0x6e, 0x4e, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x52, 0x65, 0x66, 0x72, 0x65, - 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc8, 0x02, - 0x0a, 0x08, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x4d, 0x61, 0x70, 0x12, 0x42, 0x0a, 0x06, 0x74, 0x6f, - 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, 0x74, + 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x7f, 0x0a, 0x11, 0x53, 0x69, 0x67, 0x6e, + 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, + 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x64, + 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0c, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0c, 0x70, 0x72, + 0x65, 0x6b, 0x65, 0x79, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, + 0x48, 0x00, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x6b, 0x65, 0x79, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x42, + 0x08, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x14, 0x47, 0x65, 0x74, + 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x38, 0x0a, 0x08, 0x6a, 0x6f, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4a, 0x6f, 0x62, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x07, 0x6a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x22, 0x37, 0x0a, 0x15, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x75, 0x6e, + 0x5f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x52, + 0x75, 0x6e, 0x4e, 0x73, 0x22, 0x6f, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x52, 0x65, 0x66, 0x65, 0x73, + 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x08, 0x6a, + 0x6f, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, + 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x6a, 0x6f, + 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x75, + 0x6e, 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, + 0x52, 0x75, 0x6e, 0x4e, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x52, 0x65, 0x66, 0x72, + 0x65, 0x73, 0x68, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc8, + 0x02, 0x0a, 0x08, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x4d, 0x61, 0x70, 0x12, 0x42, 0x0a, 0x06, 0x74, + 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x4d, 0x61, 0x70, 0x2e, 0x54, 0x6f, 0x70, 0x69, + 0x63, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x1a, + 0x92, 0x01, 0x0a, 0x09, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, + 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x73, 0x12, 0x21, 0x0a, 0x0c, + 0x70, 0x65, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x43, 0x0a, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x49, 0x6e, 0x76, 0x69, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x52, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x63, 0x0a, 0x0b, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, + 0x63, 0x4d, 0x61, 0x70, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x38, 0x0a, 0x1e, 0x47, 0x65, 0x74, + 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, + 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, 0x6f, 0x70, + 0x69, 0x63, 0x73, 0x22, 0xd5, 0x03, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, + 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x60, 0x0a, 0x09, 0x68, 0x6d, 0x61, 0x63, 0x5f, + 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x4d, 0x61, 0x70, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x1a, 0x92, - 0x01, 0x0a, 0x09, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, - 0x65, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x70, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x43, - 0x0a, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x49, 0x6e, 0x76, 0x69, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x52, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x1a, 0x63, 0x0a, 0x0b, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, - 0x4d, 0x61, 0x70, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x38, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x43, - 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, - 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x6f, - 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, 0x6f, 0x70, 0x69, - 0x63, 0x73, 0x22, 0xd5, 0x03, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, - 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x60, 0x0a, 0x09, 0x68, 0x6d, 0x61, 0x63, 0x5f, 0x6b, - 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x78, 0x6d, 0x74, 0x70, - 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, - 0x68, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x1a, 0x6c, 0x0a, 0x0b, 0x48, 0x6d, 0x61, 0x63, - 0x4b, 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x42, 0x0a, 0x1e, 0x74, 0x68, 0x69, 0x72, 0x74, - 0x79, 0x5f, 0x64, 0x61, 0x79, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x73, 0x5f, 0x73, 0x69, - 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x1a, 0x74, 0x68, 0x69, 0x72, 0x74, 0x79, 0x44, 0x61, 0x79, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, - 0x73, 0x53, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x68, - 0x6d, 0x61, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x68, - 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x1a, 0x65, 0x0a, 0x08, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, - 0x79, 0x73, 0x12, 0x59, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, - 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, - 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, - 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0x7b, 0x0a, - 0x0d, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x54, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x3e, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, - 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x68, 0x0a, 0x09, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4f, 0x44, - 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x50, 0x55, 0x54, 0x10, - 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x5f, - 0x4e, 0x4f, 0x5f, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x52, 0x45, 0x4b, - 0x45, 0x59, 0x10, 0x02, 0x2a, 0x70, 0x0a, 0x07, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x18, 0x0a, 0x14, 0x4a, 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, 0x42, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, 0x56, 0x31, - 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, - 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, 0x56, 0x32, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4a, - 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, - 0x50, 0x50, 0x50, 0x50, 0x10, 0x03, 0x42, 0xde, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, - 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, - 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x65, 0x79, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x6b, 0x65, 0x79, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x58, 0x4b, - 0x58, 0xaa, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, - 0x65, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4b, - 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, - 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x41, 0x70, 0x69, - 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x08, 0x68, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x1a, 0x6c, 0x0a, 0x0b, 0x48, 0x6d, 0x61, + 0x63, 0x4b, 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x42, 0x0a, 0x1e, 0x74, 0x68, 0x69, 0x72, + 0x74, 0x79, 0x5f, 0x64, 0x61, 0x79, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x73, 0x5f, 0x73, + 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x1a, 0x74, 0x68, 0x69, 0x72, 0x74, 0x79, 0x44, 0x61, 0x79, 0x50, 0x65, 0x72, 0x69, 0x6f, + 0x64, 0x73, 0x53, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x19, 0x0a, 0x08, + 0x68, 0x6d, 0x61, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, + 0x68, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x1a, 0x65, 0x0a, 0x08, 0x48, 0x6d, 0x61, 0x63, 0x4b, + 0x65, 0x79, 0x73, 0x12, 0x59, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, + 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, + 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, + 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0x7b, + 0x0a, 0x0d, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x54, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x3e, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, + 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x6d, 0x61, 0x63, 0x4b, 0x65, 0x79, 0x73, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x68, 0x0a, 0x09, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x52, 0x52, 0x4f, + 0x52, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4f, + 0x44, 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x50, 0x55, 0x54, + 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4f, 0x44, 0x45, + 0x5f, 0x4e, 0x4f, 0x5f, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x52, 0x45, + 0x4b, 0x45, 0x59, 0x10, 0x02, 0x2a, 0x70, 0x0a, 0x07, 0x4a, 0x6f, 0x62, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x18, 0x0a, 0x14, 0x4a, 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, + 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, 0x56, + 0x31, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, 0x56, 0x32, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, + 0x4a, 0x4f, 0x42, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, + 0x5f, 0x50, 0x50, 0x50, 0x50, 0x10, 0x03, 0x42, 0xde, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, + 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x65, + 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x6b, 0x65, + 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x58, + 0x4b, 0x58, 0xaa, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x5c, + 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, + 0x1f, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x41, 0x70, + 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4b, 0x65, 0x79, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -3332,11 +3345,12 @@ var file_keystore_api_v1_keystore_proto_goTypes = []interface{}{ nil, // 53: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeysEntry (*message_contents.InvitationV1_Context)(nil), // 54: xmtp.message_contents.InvitationV1.Context (*message_contents.SignedPublicKeyBundle)(nil), // 55: xmtp.message_contents.SignedPublicKeyBundle - (*message_contents.ConversationReference)(nil), // 56: xmtp.message_contents.ConversationReference - (*message_contents.PrivateKeyBundleV1)(nil), // 57: xmtp.message_contents.PrivateKeyBundleV1 - (*message_contents.Ciphertext)(nil), // 58: xmtp.message_contents.Ciphertext - (*message_contents.PublicKeyBundle)(nil), // 59: xmtp.message_contents.PublicKeyBundle - (*message_contents.InvitationV1)(nil), // 60: xmtp.message_contents.InvitationV1 + (*message_contents.ConsentProofPayload)(nil), // 56: xmtp.message_contents.ConsentProofPayload + (*message_contents.ConversationReference)(nil), // 57: xmtp.message_contents.ConversationReference + (*message_contents.PrivateKeyBundleV1)(nil), // 58: xmtp.message_contents.PrivateKeyBundleV1 + (*message_contents.Ciphertext)(nil), // 59: xmtp.message_contents.Ciphertext + (*message_contents.PublicKeyBundle)(nil), // 60: xmtp.message_contents.PublicKeyBundle + (*message_contents.InvitationV1)(nil), // 61: xmtp.message_contents.InvitationV1 } var file_keystore_api_v1_keystore_proto_depIdxs = []int32{ 0, // 0: xmtp.keystore_api.v1.KeystoreError.code:type_name -> xmtp.keystore_api.v1.ErrorCode @@ -3351,41 +3365,42 @@ var file_keystore_api_v1_keystore_proto_depIdxs = []int32{ 45, // 9: xmtp.keystore_api.v1.SelfDecryptRequest.requests:type_name -> xmtp.keystore_api.v1.SelfDecryptRequest.Request 54, // 10: xmtp.keystore_api.v1.CreateInviteRequest.context:type_name -> xmtp.message_contents.InvitationV1.Context 55, // 11: xmtp.keystore_api.v1.CreateInviteRequest.recipient:type_name -> xmtp.message_contents.SignedPublicKeyBundle - 56, // 12: xmtp.keystore_api.v1.CreateInviteResponse.conversation:type_name -> xmtp.message_contents.ConversationReference - 46, // 13: xmtp.keystore_api.v1.SaveInvitesRequest.requests:type_name -> xmtp.keystore_api.v1.SaveInvitesRequest.Request - 47, // 14: xmtp.keystore_api.v1.SaveInvitesResponse.responses:type_name -> xmtp.keystore_api.v1.SaveInvitesResponse.Response - 56, // 15: xmtp.keystore_api.v1.SaveV1ConversationsRequest.conversations:type_name -> xmtp.message_contents.ConversationReference - 56, // 16: xmtp.keystore_api.v1.GetConversationsResponse.conversations:type_name -> xmtp.message_contents.ConversationReference - 2, // 17: xmtp.keystore_api.v1.GetKeystoreStatusResponse.status:type_name -> xmtp.keystore_api.v1.GetKeystoreStatusResponse.KeystoreStatus - 57, // 18: xmtp.keystore_api.v1.InitKeystoreRequest.v1:type_name -> xmtp.message_contents.PrivateKeyBundleV1 - 3, // 19: xmtp.keystore_api.v1.InitKeystoreResponse.error:type_name -> xmtp.keystore_api.v1.KeystoreError - 1, // 20: xmtp.keystore_api.v1.GetRefreshJobRequest.job_type:type_name -> xmtp.keystore_api.v1.JobType - 1, // 21: xmtp.keystore_api.v1.SetRefeshJobRequest.job_type:type_name -> xmtp.keystore_api.v1.JobType - 50, // 22: xmtp.keystore_api.v1.TopicMap.topics:type_name -> xmtp.keystore_api.v1.TopicMap.TopicsEntry - 53, // 23: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.hmac_keys:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeysEntry - 58, // 24: xmtp.keystore_api.v1.DecryptV1Request.Request.payload:type_name -> xmtp.message_contents.Ciphertext - 59, // 25: xmtp.keystore_api.v1.DecryptV1Request.Request.peer_keys:type_name -> xmtp.message_contents.PublicKeyBundle - 36, // 26: xmtp.keystore_api.v1.DecryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.DecryptResponse.Response.Success - 3, // 27: xmtp.keystore_api.v1.DecryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError - 58, // 28: xmtp.keystore_api.v1.DecryptV2Request.Request.payload:type_name -> xmtp.message_contents.Ciphertext - 59, // 29: xmtp.keystore_api.v1.EncryptV1Request.Request.recipient:type_name -> xmtp.message_contents.PublicKeyBundle - 40, // 30: xmtp.keystore_api.v1.EncryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.EncryptResponse.Response.Success - 3, // 31: xmtp.keystore_api.v1.EncryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError - 58, // 32: xmtp.keystore_api.v1.EncryptResponse.Response.Success.encrypted:type_name -> xmtp.message_contents.Ciphertext - 44, // 33: xmtp.keystore_api.v1.SelfEncryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.SelfEncryptResponse.Response.Success - 3, // 34: xmtp.keystore_api.v1.SelfEncryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError - 48, // 35: xmtp.keystore_api.v1.SaveInvitesResponse.Response.result:type_name -> xmtp.keystore_api.v1.SaveInvitesResponse.Response.Success - 3, // 36: xmtp.keystore_api.v1.SaveInvitesResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError - 56, // 37: xmtp.keystore_api.v1.SaveInvitesResponse.Response.Success.conversation:type_name -> xmtp.message_contents.ConversationReference - 60, // 38: xmtp.keystore_api.v1.TopicMap.TopicData.invitation:type_name -> xmtp.message_contents.InvitationV1 - 49, // 39: xmtp.keystore_api.v1.TopicMap.TopicsEntry.value:type_name -> xmtp.keystore_api.v1.TopicMap.TopicData - 51, // 40: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeys.values:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeyData - 52, // 41: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeysEntry.value:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeys - 42, // [42:42] is the sub-list for method output_type - 42, // [42:42] is the sub-list for method input_type - 42, // [42:42] is the sub-list for extension type_name - 42, // [42:42] is the sub-list for extension extendee - 0, // [0:42] is the sub-list for field type_name + 56, // 12: xmtp.keystore_api.v1.CreateInviteRequest.consent_proof:type_name -> xmtp.message_contents.ConsentProofPayload + 57, // 13: xmtp.keystore_api.v1.CreateInviteResponse.conversation:type_name -> xmtp.message_contents.ConversationReference + 46, // 14: xmtp.keystore_api.v1.SaveInvitesRequest.requests:type_name -> xmtp.keystore_api.v1.SaveInvitesRequest.Request + 47, // 15: xmtp.keystore_api.v1.SaveInvitesResponse.responses:type_name -> xmtp.keystore_api.v1.SaveInvitesResponse.Response + 57, // 16: xmtp.keystore_api.v1.SaveV1ConversationsRequest.conversations:type_name -> xmtp.message_contents.ConversationReference + 57, // 17: xmtp.keystore_api.v1.GetConversationsResponse.conversations:type_name -> xmtp.message_contents.ConversationReference + 2, // 18: xmtp.keystore_api.v1.GetKeystoreStatusResponse.status:type_name -> xmtp.keystore_api.v1.GetKeystoreStatusResponse.KeystoreStatus + 58, // 19: xmtp.keystore_api.v1.InitKeystoreRequest.v1:type_name -> xmtp.message_contents.PrivateKeyBundleV1 + 3, // 20: xmtp.keystore_api.v1.InitKeystoreResponse.error:type_name -> xmtp.keystore_api.v1.KeystoreError + 1, // 21: xmtp.keystore_api.v1.GetRefreshJobRequest.job_type:type_name -> xmtp.keystore_api.v1.JobType + 1, // 22: xmtp.keystore_api.v1.SetRefeshJobRequest.job_type:type_name -> xmtp.keystore_api.v1.JobType + 50, // 23: xmtp.keystore_api.v1.TopicMap.topics:type_name -> xmtp.keystore_api.v1.TopicMap.TopicsEntry + 53, // 24: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.hmac_keys:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeysEntry + 59, // 25: xmtp.keystore_api.v1.DecryptV1Request.Request.payload:type_name -> xmtp.message_contents.Ciphertext + 60, // 26: xmtp.keystore_api.v1.DecryptV1Request.Request.peer_keys:type_name -> xmtp.message_contents.PublicKeyBundle + 36, // 27: xmtp.keystore_api.v1.DecryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.DecryptResponse.Response.Success + 3, // 28: xmtp.keystore_api.v1.DecryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError + 59, // 29: xmtp.keystore_api.v1.DecryptV2Request.Request.payload:type_name -> xmtp.message_contents.Ciphertext + 60, // 30: xmtp.keystore_api.v1.EncryptV1Request.Request.recipient:type_name -> xmtp.message_contents.PublicKeyBundle + 40, // 31: xmtp.keystore_api.v1.EncryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.EncryptResponse.Response.Success + 3, // 32: xmtp.keystore_api.v1.EncryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError + 59, // 33: xmtp.keystore_api.v1.EncryptResponse.Response.Success.encrypted:type_name -> xmtp.message_contents.Ciphertext + 44, // 34: xmtp.keystore_api.v1.SelfEncryptResponse.Response.result:type_name -> xmtp.keystore_api.v1.SelfEncryptResponse.Response.Success + 3, // 35: xmtp.keystore_api.v1.SelfEncryptResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError + 48, // 36: xmtp.keystore_api.v1.SaveInvitesResponse.Response.result:type_name -> xmtp.keystore_api.v1.SaveInvitesResponse.Response.Success + 3, // 37: xmtp.keystore_api.v1.SaveInvitesResponse.Response.error:type_name -> xmtp.keystore_api.v1.KeystoreError + 57, // 38: xmtp.keystore_api.v1.SaveInvitesResponse.Response.Success.conversation:type_name -> xmtp.message_contents.ConversationReference + 61, // 39: xmtp.keystore_api.v1.TopicMap.TopicData.invitation:type_name -> xmtp.message_contents.InvitationV1 + 49, // 40: xmtp.keystore_api.v1.TopicMap.TopicsEntry.value:type_name -> xmtp.keystore_api.v1.TopicMap.TopicData + 51, // 41: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeys.values:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeyData + 52, // 42: xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeysEntry.value:type_name -> xmtp.keystore_api.v1.GetConversationHmacKeysResponse.HmacKeys + 43, // [43:43] is the sub-list for method output_type + 43, // [43:43] is the sub-list for method input_type + 43, // [43:43] is the sub-list for extension type_name + 43, // [43:43] is the sub-list for extension extendee + 0, // [0:43] is the sub-list for field type_name } func init() { file_keystore_api_v1_keystore_proto_init() } diff --git a/pkg/proto/message_contents/conversation_reference.pb.go b/pkg/proto/message_contents/conversation_reference.pb.go index 85143c82..1aadc264 100644 --- a/pkg/proto/message_contents/conversation_reference.pb.go +++ b/pkg/proto/message_contents/conversation_reference.pb.go @@ -28,10 +28,11 @@ type ConversationReference struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` - PeerAddress string `protobuf:"bytes,2,opt,name=peer_address,json=peerAddress,proto3" json:"peer_address,omitempty"` - CreatedNs uint64 `protobuf:"varint,3,opt,name=created_ns,json=createdNs,proto3" json:"created_ns,omitempty"` - Context *InvitationV1_Context `protobuf:"bytes,4,opt,name=context,proto3" json:"context,omitempty"` + Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + PeerAddress string `protobuf:"bytes,2,opt,name=peer_address,json=peerAddress,proto3" json:"peer_address,omitempty"` + CreatedNs uint64 `protobuf:"varint,3,opt,name=created_ns,json=createdNs,proto3" json:"created_ns,omitempty"` + Context *InvitationV1_Context `protobuf:"bytes,4,opt,name=context,proto3" json:"context,omitempty"` + ConsentProofPayload *ConsentProofPayload `protobuf:"bytes,5,opt,name=consent_proof_payload,json=consentProofPayload,proto3" json:"consent_proof_payload,omitempty"` } func (x *ConversationReference) Reset() { @@ -94,6 +95,13 @@ func (x *ConversationReference) GetContext() *InvitationV1_Context { return nil } +func (x *ConversationReference) GetConsentProofPayload() *ConsentProofPayload { + if x != nil { + return x.ConsentProofPayload + } + return nil +} + var File_message_contents_conversation_reference_proto protoreflect.FileDescriptor var file_message_contents_conversation_reference_proto_rawDesc = []byte{ @@ -103,7 +111,7 @@ var file_message_contents_conversation_reference_proto_rawDesc = []byte{ 0x15, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x21, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x01, 0x0a, 0x15, 0x43, 0x6f, + 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x02, 0x0a, 0x15, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x65, 0x65, @@ -115,7 +123,13 @@ var file_message_contents_conversation_reference_proto_rawDesc = []byte{ 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x42, 0xe1, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x78, 0x74, 0x12, 0x5e, 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x13, 0x63, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x50, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x42, 0xe1, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x1a, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, @@ -148,14 +162,16 @@ var file_message_contents_conversation_reference_proto_msgTypes = make([]protoim var file_message_contents_conversation_reference_proto_goTypes = []interface{}{ (*ConversationReference)(nil), // 0: xmtp.message_contents.ConversationReference (*InvitationV1_Context)(nil), // 1: xmtp.message_contents.InvitationV1.Context + (*ConsentProofPayload)(nil), // 2: xmtp.message_contents.ConsentProofPayload } var file_message_contents_conversation_reference_proto_depIdxs = []int32{ 1, // 0: xmtp.message_contents.ConversationReference.context:type_name -> xmtp.message_contents.InvitationV1.Context - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 1: xmtp.message_contents.ConversationReference.consent_proof_payload:type_name -> xmtp.message_contents.ConsentProofPayload + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_message_contents_conversation_reference_proto_init() } diff --git a/pkg/proto/mls/database/intents.pb.go b/pkg/proto/mls/database/intents.pb.go index f1b0f9cf..43cbe452 100644 --- a/pkg/proto/mls/database/intents.pb.go +++ b/pkg/proto/mls/database/intents.pb.go @@ -692,7 +692,8 @@ type UpdateMetadataData_V1 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GroupName string `protobuf:"bytes,1,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + FieldName string `protobuf:"bytes,1,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"` + FieldValue string `protobuf:"bytes,2,opt,name=field_value,json=fieldValue,proto3" json:"field_value,omitempty"` } func (x *UpdateMetadataData_V1) Reset() { @@ -727,9 +728,16 @@ func (*UpdateMetadataData_V1) Descriptor() ([]byte, []int) { return file_mls_database_intents_proto_rawDescGZIP(), []int{6, 0} } -func (x *UpdateMetadataData_V1) GetGroupName() string { +func (x *UpdateMetadataData_V1) GetFieldName() string { if x != nil { - return x.GroupName + return x.FieldName + } + return "" +} + +func (x *UpdateMetadataData_V1) GetFieldValue() string { + if x != nil { + return x.FieldValue } return "" } @@ -908,51 +916,53 @@ var file_mls_database_intents_proto_rawDesc = []byte{ 0x4f, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x52, 0x1a, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4f, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x42, 0x09, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x80, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa1, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3a, 0x0a, 0x02, 0x76, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x44, 0x61, - 0x74, 0x61, 0x2e, 0x56, 0x31, 0x48, 0x00, 0x52, 0x02, 0x76, 0x31, 0x1a, 0x23, 0x0a, 0x02, 0x56, - 0x31, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, - 0x42, 0x09, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xe8, 0x02, 0x0a, 0x10, - 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x57, 0x0a, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, - 0x6c, 0x73, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x6e, - 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x65, 0x6e, - 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x1a, 0x61, 0x0a, 0x0c, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x4b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x0f, 0x68, 0x70, 0x6b, 0x65, 0x5f, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x68, - 0x70, 0x6b, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x1a, 0x8f, 0x01, 0x0a, - 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x12, 0x56, 0x0a, - 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, - 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, - 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, - 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x06, - 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x42, 0xc0, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, - 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x42, 0x0c, 0x49, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, - 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x2f, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x61, 0x73, 0x65, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x44, 0xaa, 0x02, 0x11, 0x58, 0x6d, - 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0xca, - 0x02, 0x11, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x44, 0x61, 0x74, 0x61, 0x62, - 0x61, 0x73, 0x65, 0xe2, 0x02, 0x1d, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x44, - 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, 0x3a, - 0x3a, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x74, 0x61, 0x2e, 0x56, 0x31, 0x48, 0x00, 0x52, 0x02, 0x76, 0x31, 0x1a, 0x44, 0x0a, 0x02, 0x56, + 0x31, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x42, 0x09, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xe8, 0x02, 0x0a, + 0x10, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x57, 0x0a, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6d, 0x6c, 0x73, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x50, 0x6f, 0x73, + 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, + 0x6e, 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x65, + 0x6e, 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x1a, 0x61, 0x0a, 0x0c, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x0f, 0x68, 0x70, 0x6b, 0x65, 0x5f, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, + 0x68, 0x70, 0x6b, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x1a, 0x8f, 0x01, + 0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x73, 0x12, 0x56, + 0x0a, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, + 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, + 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0e, 0x77, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, + 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x42, 0xc0, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, + 0x65, 0x42, 0x0c, 0x49, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, + 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, + 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x2f, 0x64, 0x61, + 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x44, 0xaa, 0x02, 0x11, 0x58, + 0x6d, 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, + 0xca, 0x02, 0x11, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x44, 0x61, 0x74, 0x61, + 0x62, 0x61, 0x73, 0x65, 0xe2, 0x02, 0x1d, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, + 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, + 0x3a, 0x3a, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/pkg/proto/mls/message_contents/group_metadata.pb.go b/pkg/proto/mls/message_contents/group_metadata.pb.go index a16d667f..833c3bc0 100644 --- a/pkg/proto/mls/message_contents/group_metadata.pb.go +++ b/pkg/proto/mls/message_contents/group_metadata.pb.go @@ -248,9 +248,9 @@ type PolicySet struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AddMemberPolicy *MembershipPolicy `protobuf:"bytes,1,opt,name=add_member_policy,json=addMemberPolicy,proto3" json:"add_member_policy,omitempty"` - RemoveMemberPolicy *MembershipPolicy `protobuf:"bytes,2,opt,name=remove_member_policy,json=removeMemberPolicy,proto3" json:"remove_member_policy,omitempty"` - UpdateGroupNamePolicy *MetadataPolicy `protobuf:"bytes,3,opt,name=update_group_name_policy,json=updateGroupNamePolicy,proto3" json:"update_group_name_policy,omitempty"` + AddMemberPolicy *MembershipPolicy `protobuf:"bytes,1,opt,name=add_member_policy,json=addMemberPolicy,proto3" json:"add_member_policy,omitempty"` + RemoveMemberPolicy *MembershipPolicy `protobuf:"bytes,2,opt,name=remove_member_policy,json=removeMemberPolicy,proto3" json:"remove_member_policy,omitempty"` + UpdateMetadataPolicy map[string]*MetadataPolicy `protobuf:"bytes,3,rep,name=update_metadata_policy,json=updateMetadataPolicy,proto3" json:"update_metadata_policy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *PolicySet) Reset() { @@ -299,9 +299,9 @@ func (x *PolicySet) GetRemoveMemberPolicy() *MembershipPolicy { return nil } -func (x *PolicySet) GetUpdateGroupNamePolicy() *MetadataPolicy { +func (x *PolicySet) GetUpdateMetadataPolicy() map[string]*MetadataPolicy { if x != nil { - return x.UpdateGroupNamePolicy + return x.UpdateMetadataPolicy } return nil } @@ -510,7 +510,7 @@ type MembershipPolicy_AndCondition struct { func (x *MembershipPolicy_AndCondition) Reset() { *x = MembershipPolicy_AndCondition{} if protoimpl.UnsafeEnabled { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[4] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -523,7 +523,7 @@ func (x *MembershipPolicy_AndCondition) String() string { func (*MembershipPolicy_AndCondition) ProtoMessage() {} func (x *MembershipPolicy_AndCondition) ProtoReflect() protoreflect.Message { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[4] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -558,7 +558,7 @@ type MembershipPolicy_AnyCondition struct { func (x *MembershipPolicy_AnyCondition) Reset() { *x = MembershipPolicy_AnyCondition{} if protoimpl.UnsafeEnabled { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[5] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -571,7 +571,7 @@ func (x *MembershipPolicy_AnyCondition) String() string { func (*MembershipPolicy_AnyCondition) ProtoMessage() {} func (x *MembershipPolicy_AnyCondition) ProtoReflect() protoreflect.Message { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[5] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -606,7 +606,7 @@ type MetadataPolicy_AndCondition struct { func (x *MetadataPolicy_AndCondition) Reset() { *x = MetadataPolicy_AndCondition{} if protoimpl.UnsafeEnabled { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[6] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -619,7 +619,7 @@ func (x *MetadataPolicy_AndCondition) String() string { func (*MetadataPolicy_AndCondition) ProtoMessage() {} func (x *MetadataPolicy_AndCondition) ProtoReflect() protoreflect.Message { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[6] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -654,7 +654,7 @@ type MetadataPolicy_AnyCondition struct { func (x *MetadataPolicy_AnyCondition) Reset() { *x = MetadataPolicy_AnyCondition{} if protoimpl.UnsafeEnabled { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[7] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -667,7 +667,7 @@ func (x *MetadataPolicy_AnyCondition) String() string { func (*MetadataPolicy_AnyCondition) ProtoMessage() {} func (x *MetadataPolicy_AnyCondition) ProtoReflect() protoreflect.Message { - mi := &file_mls_message_contents_group_metadata_proto_msgTypes[7] + mi := &file_mls_message_contents_group_metadata_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -711,8 +711,8 @@ var file_mls_message_contents_group_metadata_proto_rawDesc = []byte{ 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x53, 0x65, 0x74, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x22, 0xa7, - 0x02, 0x0a, 0x09, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x53, 0x65, 0x74, 0x12, 0x57, 0x0a, 0x11, + 0x79, 0x53, 0x65, 0x74, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x22, 0xad, + 0x03, 0x0a, 0x09, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x53, 0x65, 0x74, 0x12, 0x57, 0x0a, 0x11, 0x61, 0x64, 0x64, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, @@ -724,114 +724,122 @@ var file_mls_message_contents_group_metadata_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x12, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x12, 0x62, 0x0a, 0x18, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, - 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x52, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, - 0x6d, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0xdc, 0x04, 0x0a, 0x10, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x4c, 0x0a, - 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x78, 0x6d, - 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, - 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x48, 0x00, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x0d, 0x61, - 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, - 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, - 0x61, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x0d, - 0x61, 0x6e, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x2e, 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, - 0x0c, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x57, 0x0a, - 0x0c, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, - 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x2b, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, - 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x1a, 0x57, 0x0a, 0x0c, 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, - 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, - 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x22, - 0x7e, 0x0a, 0x0a, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1b, 0x0a, - 0x17, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, - 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x42, 0x41, - 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, - 0x01, 0x12, 0x14, 0x0a, 0x10, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, - 0x5f, 0x44, 0x45, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x26, 0x0a, 0x22, 0x42, 0x41, 0x53, 0x45, 0x5f, - 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x46, 0x5f, - 0x41, 0x43, 0x54, 0x4f, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x4f, 0x52, 0x10, 0x03, 0x42, - 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x85, 0x05, 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x52, 0x0a, 0x04, 0x62, 0x61, - 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6c, 0x69, 0x63, 0x79, 0x12, 0x74, 0x0a, 0x16, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x53, 0x65, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x72, 0x0a, 0x19, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x3f, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x61, 0x73, 0x65, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x48, 0x00, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x5d, - 0x0a, 0x0d, 0x61, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, + 0x69, 0x63, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xdc, + 0x04, 0x0a, 0x10, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x12, 0x4c, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x36, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x42, + 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x48, 0x00, 0x52, 0x04, 0x62, 0x61, 0x73, + 0x65, 0x12, 0x5f, 0x0a, 0x0d, 0x61, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x0d, 0x61, 0x6e, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x1a, 0x57, 0x0a, 0x0c, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x2e, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, - 0x0c, 0x61, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5d, 0x0a, - 0x0d, 0x61, 0x6e, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, - 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, - 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, - 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x55, 0x0a, 0x0c, - 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x08, - 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, + 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x1a, 0x57, 0x0a, 0x0c, + 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x08, + 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x68, 0x69, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, 0x6c, + 0x69, 0x63, 0x69, 0x65, 0x73, 0x22, 0x7e, 0x0a, 0x0a, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, + 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x15, 0x0a, 0x11, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, + 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x42, 0x41, 0x53, 0x45, 0x5f, + 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x44, 0x45, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x26, 0x0a, + 0x22, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, + 0x4f, 0x57, 0x5f, 0x49, 0x46, 0x5f, 0x41, 0x43, 0x54, 0x4f, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x4f, 0x52, 0x10, 0x03, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x85, 0x05, + 0x0a, 0x0e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x12, 0x52, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, - 0x69, 0x65, 0x73, 0x1a, 0x55, 0x0a, 0x0c, 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, - 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x22, 0xaa, 0x01, 0x0a, 0x12, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x12, 0x24, 0x0a, 0x20, 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, - 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x4d, 0x45, 0x54, 0x41, 0x44, - 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, - 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x54, 0x41, 0x44, + 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x48, 0x00, 0x52, 0x04, + 0x62, 0x61, 0x73, 0x65, 0x12, 0x5d, 0x0a, 0x0d, 0x61, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x5d, 0x0a, 0x0d, 0x61, 0x6e, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x6d, 0x74, + 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x1a, 0x55, 0x0a, 0x0c, 0x41, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, + 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x1a, 0x55, 0x0a, 0x0c, 0x41, 0x6e, 0x79, + 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x08, 0x70, 0x6f, 0x6c, + 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, + 0x22, 0xaa, 0x01, 0x0a, 0x12, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x61, 0x73, + 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x24, 0x0a, 0x20, 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, - 0x44, 0x45, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x2f, 0x0a, 0x2b, 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, - 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, - 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x46, 0x5f, 0x41, 0x43, 0x54, 0x4f, 0x52, 0x5f, 0x43, 0x52, - 0x45, 0x41, 0x54, 0x4f, 0x52, 0x10, 0x03, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x2a, - 0x6c, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, 0x53, 0x41, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, - 0x53, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, - 0x50, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, 0x53, 0x41, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x4d, 0x10, 0x02, 0x42, 0xf2, 0x01, - 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x42, - 0x12, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, - 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, - 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, 0x2e, - 0x4d, 0x6c, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x73, 0xca, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xe2, 0x02, - 0x24, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, - 0x73, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1e, 0x0a, + 0x1a, 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, + 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x1d, 0x0a, + 0x19, 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, + 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x44, 0x45, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x2f, 0x0a, 0x2b, + 0x4d, 0x45, 0x54, 0x41, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x50, 0x4f, + 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x46, 0x5f, 0x41, 0x43, + 0x54, 0x4f, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x4f, 0x52, 0x10, 0x03, 0x42, 0x06, 0x0a, + 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x2a, 0x6c, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x1d, 0x43, 0x4f, 0x4e, + 0x56, 0x45, 0x52, 0x53, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, + 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, + 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, 0x53, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4e, + 0x56, 0x45, 0x52, 0x53, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, + 0x4d, 0x10, 0x02, 0x42, 0xf2, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x12, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, + 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x4d, 0xaa, 0x02, + 0x18, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xca, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, + 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x73, 0xe2, 0x02, 0x24, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x58, 0x6d, + 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -847,7 +855,7 @@ func file_mls_message_contents_group_metadata_proto_rawDescGZIP() []byte { } var file_mls_message_contents_group_metadata_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_mls_message_contents_group_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_mls_message_contents_group_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_mls_message_contents_group_metadata_proto_goTypes = []interface{}{ (ConversationType)(0), // 0: xmtp.mls.message_contents.ConversationType (MembershipPolicy_BasePolicy)(0), // 1: xmtp.mls.message_contents.MembershipPolicy.BasePolicy @@ -856,32 +864,34 @@ var file_mls_message_contents_group_metadata_proto_goTypes = []interface{}{ (*PolicySet)(nil), // 4: xmtp.mls.message_contents.PolicySet (*MembershipPolicy)(nil), // 5: xmtp.mls.message_contents.MembershipPolicy (*MetadataPolicy)(nil), // 6: xmtp.mls.message_contents.MetadataPolicy - (*MembershipPolicy_AndCondition)(nil), // 7: xmtp.mls.message_contents.MembershipPolicy.AndCondition - (*MembershipPolicy_AnyCondition)(nil), // 8: xmtp.mls.message_contents.MembershipPolicy.AnyCondition - (*MetadataPolicy_AndCondition)(nil), // 9: xmtp.mls.message_contents.MetadataPolicy.AndCondition - (*MetadataPolicy_AnyCondition)(nil), // 10: xmtp.mls.message_contents.MetadataPolicy.AnyCondition + nil, // 7: xmtp.mls.message_contents.PolicySet.UpdateMetadataPolicyEntry + (*MembershipPolicy_AndCondition)(nil), // 8: xmtp.mls.message_contents.MembershipPolicy.AndCondition + (*MembershipPolicy_AnyCondition)(nil), // 9: xmtp.mls.message_contents.MembershipPolicy.AnyCondition + (*MetadataPolicy_AndCondition)(nil), // 10: xmtp.mls.message_contents.MetadataPolicy.AndCondition + (*MetadataPolicy_AnyCondition)(nil), // 11: xmtp.mls.message_contents.MetadataPolicy.AnyCondition } var file_mls_message_contents_group_metadata_proto_depIdxs = []int32{ 0, // 0: xmtp.mls.message_contents.GroupMetadataV1.conversation_type:type_name -> xmtp.mls.message_contents.ConversationType 4, // 1: xmtp.mls.message_contents.GroupMetadataV1.policies:type_name -> xmtp.mls.message_contents.PolicySet 5, // 2: xmtp.mls.message_contents.PolicySet.add_member_policy:type_name -> xmtp.mls.message_contents.MembershipPolicy 5, // 3: xmtp.mls.message_contents.PolicySet.remove_member_policy:type_name -> xmtp.mls.message_contents.MembershipPolicy - 6, // 4: xmtp.mls.message_contents.PolicySet.update_group_name_policy:type_name -> xmtp.mls.message_contents.MetadataPolicy + 7, // 4: xmtp.mls.message_contents.PolicySet.update_metadata_policy:type_name -> xmtp.mls.message_contents.PolicySet.UpdateMetadataPolicyEntry 1, // 5: xmtp.mls.message_contents.MembershipPolicy.base:type_name -> xmtp.mls.message_contents.MembershipPolicy.BasePolicy - 7, // 6: xmtp.mls.message_contents.MembershipPolicy.and_condition:type_name -> xmtp.mls.message_contents.MembershipPolicy.AndCondition - 8, // 7: xmtp.mls.message_contents.MembershipPolicy.any_condition:type_name -> xmtp.mls.message_contents.MembershipPolicy.AnyCondition + 8, // 6: xmtp.mls.message_contents.MembershipPolicy.and_condition:type_name -> xmtp.mls.message_contents.MembershipPolicy.AndCondition + 9, // 7: xmtp.mls.message_contents.MembershipPolicy.any_condition:type_name -> xmtp.mls.message_contents.MembershipPolicy.AnyCondition 2, // 8: xmtp.mls.message_contents.MetadataPolicy.base:type_name -> xmtp.mls.message_contents.MetadataPolicy.MetadataBasePolicy - 9, // 9: xmtp.mls.message_contents.MetadataPolicy.and_condition:type_name -> xmtp.mls.message_contents.MetadataPolicy.AndCondition - 10, // 10: xmtp.mls.message_contents.MetadataPolicy.any_condition:type_name -> xmtp.mls.message_contents.MetadataPolicy.AnyCondition - 5, // 11: xmtp.mls.message_contents.MembershipPolicy.AndCondition.policies:type_name -> xmtp.mls.message_contents.MembershipPolicy - 5, // 12: xmtp.mls.message_contents.MembershipPolicy.AnyCondition.policies:type_name -> xmtp.mls.message_contents.MembershipPolicy - 6, // 13: xmtp.mls.message_contents.MetadataPolicy.AndCondition.policies:type_name -> xmtp.mls.message_contents.MetadataPolicy - 6, // 14: xmtp.mls.message_contents.MetadataPolicy.AnyCondition.policies:type_name -> xmtp.mls.message_contents.MetadataPolicy - 15, // [15:15] is the sub-list for method output_type - 15, // [15:15] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 10, // 9: xmtp.mls.message_contents.MetadataPolicy.and_condition:type_name -> xmtp.mls.message_contents.MetadataPolicy.AndCondition + 11, // 10: xmtp.mls.message_contents.MetadataPolicy.any_condition:type_name -> xmtp.mls.message_contents.MetadataPolicy.AnyCondition + 6, // 11: xmtp.mls.message_contents.PolicySet.UpdateMetadataPolicyEntry.value:type_name -> xmtp.mls.message_contents.MetadataPolicy + 5, // 12: xmtp.mls.message_contents.MembershipPolicy.AndCondition.policies:type_name -> xmtp.mls.message_contents.MembershipPolicy + 5, // 13: xmtp.mls.message_contents.MembershipPolicy.AnyCondition.policies:type_name -> xmtp.mls.message_contents.MembershipPolicy + 6, // 14: xmtp.mls.message_contents.MetadataPolicy.AndCondition.policies:type_name -> xmtp.mls.message_contents.MetadataPolicy + 6, // 15: xmtp.mls.message_contents.MetadataPolicy.AnyCondition.policies:type_name -> xmtp.mls.message_contents.MetadataPolicy + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_mls_message_contents_group_metadata_proto_init() } @@ -938,7 +948,7 @@ func file_mls_message_contents_group_metadata_proto_init() { return nil } } - file_mls_message_contents_group_metadata_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_mls_message_contents_group_metadata_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MembershipPolicy_AndCondition); i { case 0: return &v.state @@ -950,7 +960,7 @@ func file_mls_message_contents_group_metadata_proto_init() { return nil } } - file_mls_message_contents_group_metadata_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_mls_message_contents_group_metadata_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MembershipPolicy_AnyCondition); i { case 0: return &v.state @@ -962,7 +972,7 @@ func file_mls_message_contents_group_metadata_proto_init() { return nil } } - file_mls_message_contents_group_metadata_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_mls_message_contents_group_metadata_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MetadataPolicy_AndCondition); i { case 0: return &v.state @@ -974,7 +984,7 @@ func file_mls_message_contents_group_metadata_proto_init() { return nil } } - file_mls_message_contents_group_metadata_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_mls_message_contents_group_metadata_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MetadataPolicy_AnyCondition); i { case 0: return &v.state @@ -1003,7 +1013,7 @@ func file_mls_message_contents_group_metadata_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_mls_message_contents_group_metadata_proto_rawDesc, NumEnums: 3, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/proto/mls/message_contents/group_mutable_metadata.pb.go b/pkg/proto/mls/message_contents/group_mutable_metadata.pb.go index 5076345c..4000efcc 100644 --- a/pkg/proto/mls/message_contents/group_mutable_metadata.pb.go +++ b/pkg/proto/mls/message_contents/group_mutable_metadata.pb.go @@ -28,7 +28,7 @@ type GroupMutableMetadataV1 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GroupName string `protobuf:"bytes,1,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + Attributes map[string]string `protobuf:"bytes,1,rep,name=attributes,proto3" json:"attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Map to store various metadata attributes } func (x *GroupMutableMetadataV1) Reset() { @@ -63,11 +63,11 @@ func (*GroupMutableMetadataV1) Descriptor() ([]byte, []int) { return file_mls_message_contents_group_mutable_metadata_proto_rawDescGZIP(), []int{0} } -func (x *GroupMutableMetadataV1) GetGroupName() string { +func (x *GroupMutableMetadataV1) GetAttributes() map[string]string { if x != nil { - return x.GroupName + return x.Attributes } - return "" + return nil } var File_mls_message_contents_group_mutable_metadata_proto protoreflect.FileDescriptor @@ -77,27 +77,35 @@ var file_mls_message_contents_group_mutable_metadata_proto_rawDesc = []byte{ 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x37, - 0x0a, 0x16, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x56, 0x31, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0xf9, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xba, + 0x01, 0x0a, 0x16, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x56, 0x31, 0x12, 0x61, 0x0a, 0x0a, 0x61, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x19, 0x47, 0x72, 0x6f, 0x75, 0x70, - 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, - 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, - 0x6c, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, - 0x2e, 0x4d, 0x6c, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x73, 0xca, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xe2, - 0x02, 0x24, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, - 0x6c, 0x73, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, + 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x56, 0x31, + 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, + 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0xf9, 0x01, 0x0a, 0x1d, + 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x42, 0x19, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, + 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x4d, 0xaa, 0x02, 0x18, + 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0xca, 0x02, 0x18, 0x58, 0x6d, 0x74, 0x70, 0x5c, + 0x4d, 0x6c, 0x73, 0x5c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x73, 0xe2, 0x02, 0x24, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x5c, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x58, 0x6d, 0x74, + 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, 0x3a, 0x3a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -112,16 +120,18 @@ func file_mls_message_contents_group_mutable_metadata_proto_rawDescGZIP() []byte return file_mls_message_contents_group_mutable_metadata_proto_rawDescData } -var file_mls_message_contents_group_mutable_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_mls_message_contents_group_mutable_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_mls_message_contents_group_mutable_metadata_proto_goTypes = []interface{}{ (*GroupMutableMetadataV1)(nil), // 0: xmtp.mls.message_contents.GroupMutableMetadataV1 + nil, // 1: xmtp.mls.message_contents.GroupMutableMetadataV1.AttributesEntry } var file_mls_message_contents_group_mutable_metadata_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: xmtp.mls.message_contents.GroupMutableMetadataV1.attributes:type_name -> xmtp.mls.message_contents.GroupMutableMetadataV1.AttributesEntry + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_mls_message_contents_group_mutable_metadata_proto_init() } @@ -149,7 +159,7 @@ func file_mls_message_contents_group_mutable_metadata_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_mls_message_contents_group_mutable_metadata_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/proto/mls_validation/v1/service.pb.go b/pkg/proto/mls_validation/v1/service.pb.go index ddde5af9..bd495198 100644 --- a/pkg/proto/mls_validation/v1/service.pb.go +++ b/pkg/proto/mls_validation/v1/service.pb.go @@ -9,6 +9,7 @@ package mls_validationv1 import ( + associations "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -214,6 +215,120 @@ func (x *ValidateGroupMessagesResponse) GetResponses() []*ValidateGroupMessagesR return nil } +// Request to get a final association state for identity updates +type GetAssociationStateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // List of identity updates + OldUpdates []*associations.IdentityUpdate `protobuf:"bytes,1,rep,name=old_updates,json=oldUpdates,proto3" json:"old_updates,omitempty"` + NewUpdates []*associations.IdentityUpdate `protobuf:"bytes,2,rep,name=new_updates,json=newUpdates,proto3" json:"new_updates,omitempty"` +} + +func (x *GetAssociationStateRequest) Reset() { + *x = GetAssociationStateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mls_validation_v1_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAssociationStateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAssociationStateRequest) ProtoMessage() {} + +func (x *GetAssociationStateRequest) ProtoReflect() protoreflect.Message { + mi := &file_mls_validation_v1_service_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAssociationStateRequest.ProtoReflect.Descriptor instead. +func (*GetAssociationStateRequest) Descriptor() ([]byte, []int) { + return file_mls_validation_v1_service_proto_rawDescGZIP(), []int{4} +} + +func (x *GetAssociationStateRequest) GetOldUpdates() []*associations.IdentityUpdate { + if x != nil { + return x.OldUpdates + } + return nil +} + +func (x *GetAssociationStateRequest) GetNewUpdates() []*associations.IdentityUpdate { + if x != nil { + return x.NewUpdates + } + return nil +} + +// Response to GetAssociationStateRequest, containing the final association state +// for an InboxID +type GetAssociationStateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AssociationState *associations.AssociationState `protobuf:"bytes,1,opt,name=association_state,json=associationState,proto3" json:"association_state,omitempty"` + StateDiff *associations.AssociationStateDiff `protobuf:"bytes,2,opt,name=state_diff,json=stateDiff,proto3" json:"state_diff,omitempty"` +} + +func (x *GetAssociationStateResponse) Reset() { + *x = GetAssociationStateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mls_validation_v1_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAssociationStateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAssociationStateResponse) ProtoMessage() {} + +func (x *GetAssociationStateResponse) ProtoReflect() protoreflect.Message { + mi := &file_mls_validation_v1_service_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetAssociationStateResponse.ProtoReflect.Descriptor instead. +func (*GetAssociationStateResponse) Descriptor() ([]byte, []int) { + return file_mls_validation_v1_service_proto_rawDescGZIP(), []int{5} +} + +func (x *GetAssociationStateResponse) GetAssociationState() *associations.AssociationState { + if x != nil { + return x.AssociationState + } + return nil +} + +func (x *GetAssociationStateResponse) GetStateDiff() *associations.AssociationStateDiff { + if x != nil { + return x.StateDiff + } + return nil +} + // Wrapper for each key package type ValidateKeyPackagesRequest_KeyPackage struct { state protoimpl.MessageState @@ -226,7 +341,7 @@ type ValidateKeyPackagesRequest_KeyPackage struct { func (x *ValidateKeyPackagesRequest_KeyPackage) Reset() { *x = ValidateKeyPackagesRequest_KeyPackage{} if protoimpl.UnsafeEnabled { - mi := &file_mls_validation_v1_service_proto_msgTypes[4] + mi := &file_mls_validation_v1_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -239,7 +354,7 @@ func (x *ValidateKeyPackagesRequest_KeyPackage) String() string { func (*ValidateKeyPackagesRequest_KeyPackage) ProtoMessage() {} func (x *ValidateKeyPackagesRequest_KeyPackage) ProtoReflect() protoreflect.Message { - mi := &file_mls_validation_v1_service_proto_msgTypes[4] + mi := &file_mls_validation_v1_service_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -279,7 +394,7 @@ type ValidateKeyPackagesResponse_ValidationResponse struct { func (x *ValidateKeyPackagesResponse_ValidationResponse) Reset() { *x = ValidateKeyPackagesResponse_ValidationResponse{} if protoimpl.UnsafeEnabled { - mi := &file_mls_validation_v1_service_proto_msgTypes[5] + mi := &file_mls_validation_v1_service_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -292,7 +407,7 @@ func (x *ValidateKeyPackagesResponse_ValidationResponse) String() string { func (*ValidateKeyPackagesResponse_ValidationResponse) ProtoMessage() {} func (x *ValidateKeyPackagesResponse_ValidationResponse) ProtoReflect() protoreflect.Message { - mi := &file_mls_validation_v1_service_proto_msgTypes[5] + mi := &file_mls_validation_v1_service_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -362,7 +477,7 @@ type ValidateGroupMessagesRequest_GroupMessage struct { func (x *ValidateGroupMessagesRequest_GroupMessage) Reset() { *x = ValidateGroupMessagesRequest_GroupMessage{} if protoimpl.UnsafeEnabled { - mi := &file_mls_validation_v1_service_proto_msgTypes[6] + mi := &file_mls_validation_v1_service_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -375,7 +490,7 @@ func (x *ValidateGroupMessagesRequest_GroupMessage) String() string { func (*ValidateGroupMessagesRequest_GroupMessage) ProtoMessage() {} func (x *ValidateGroupMessagesRequest_GroupMessage) ProtoReflect() protoreflect.Message { - mi := &file_mls_validation_v1_service_proto_msgTypes[6] + mi := &file_mls_validation_v1_service_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -412,7 +527,7 @@ type ValidateGroupMessagesResponse_ValidationResponse struct { func (x *ValidateGroupMessagesResponse_ValidationResponse) Reset() { *x = ValidateGroupMessagesResponse_ValidationResponse{} if protoimpl.UnsafeEnabled { - mi := &file_mls_validation_v1_service_proto_msgTypes[7] + mi := &file_mls_validation_v1_service_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -425,7 +540,7 @@ func (x *ValidateGroupMessagesResponse_ValidationResponse) String() string { func (*ValidateGroupMessagesResponse_ValidationResponse) ProtoMessage() {} func (x *ValidateGroupMessagesResponse_ValidationResponse) ProtoReflect() protoreflect.Message { - mi := &file_mls_validation_v1_service_proto_msgTypes[7] + mi := &file_mls_validation_v1_service_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -468,108 +583,143 @@ var file_mls_validation_v1_service_proto_rawDesc = []byte{ 0x0a, 0x1f, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x22, 0xd4, 0x01, 0x0a, 0x1a, 0x56, 0x61, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x27, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0xd4, 0x01, 0x0a, 0x1a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, + 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x60, 0x0a, 0x0c, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, + 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x4b, 0x65, 0x79, 0x50, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x6b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x73, 0x1a, 0x54, 0x0a, 0x0a, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x12, 0x46, 0x0a, 0x20, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x74, 0x6c, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1c, 0x6b, 0x65, 0x79, + 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6c, 0x73, 0x53, + 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x22, 0x82, 0x03, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x60, 0x0a, 0x0c, 0x6b, 0x65, 0x79, 0x5f, - 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, - 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x2e, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x6b, - 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x54, 0x0a, 0x0a, 0x4b, 0x65, - 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x46, 0x0a, 0x20, 0x6b, 0x65, 0x79, 0x5f, - 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x74, 0x6c, - 0x73, 0x5f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x1c, 0x6b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, 0x79, - 0x74, 0x65, 0x73, 0x54, 0x6c, 0x73, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, - 0x22, 0x82, 0x03, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, - 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x64, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, 0xfc, 0x01, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x13, 0x0a, - 0x05, 0x69, 0x73, 0x5f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, - 0x4f, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x72, 0x65, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x17, 0x63, 0x72, - 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe4, 0x01, 0x0a, 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x09, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, + 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, + 0xfc, 0x01, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x13, 0x0a, 0x05, 0x69, 0x73, 0x5f, 0x6f, 0x6b, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x27, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, + 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x17, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, + 0x6c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1e, + 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe4, + 0x01, 0x0a, 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x68, 0x0a, 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, + 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x5a, 0x0a, 0x0c, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4a, 0x0a, 0x22, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x5f, 0x74, 0x6c, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6c, 0x73, 0x53, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x22, 0xf2, 0x01, 0x0a, 0x1d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x68, 0x0a, 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x78, 0x6d, 0x74, + 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, + 0x69, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x13, 0x0a, 0x05, 0x69, 0x73, 0x5f, 0x6f, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0xb6, 0x01, 0x0a, 0x1a, 0x47, + 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4b, 0x0a, 0x0b, 0x6f, 0x6c, 0x64, + 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x6f, 0x6c, 0x64, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x0b, 0x6e, 0x65, 0x77, 0x5f, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x78, 0x6d, + 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x6e, 0x65, 0x77, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x73, 0x22, 0xc9, 0x01, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x11, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x10, 0x61, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, + 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x44, 0x69, 0x66, 0x66, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x44, 0x69, 0x66, 0x66, 0x32, + 0x9e, 0x03, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x70, + 0x69, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, + 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x32, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, + 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, + 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x86, 0x01, 0x0a, 0x15, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x34, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x52, 0x0d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x1a, 0x5a, 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x4a, 0x0a, 0x22, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x74, 0x6c, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x69, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1e, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, - 0x6c, 0x73, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x22, 0xf2, 0x01, 0x0a, - 0x1d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, - 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x48, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x1a, 0x69, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x13, 0x0a, 0x05, - 0x69, 0x73, 0x5f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, - 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, - 0x64, 0x32, 0x9b, 0x02, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x41, 0x70, 0x69, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x32, 0x2e, 0x78, 0x6d, - 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, - 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x33, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x86, 0x01, 0x0a, 0x15, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x12, 0x34, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, - 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0xeb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, - 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x0c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x49, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, - 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x58, 0xaa, - 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, - 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0xe2, - 0x02, 0x21, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x17, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, 0x5f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x80, 0x01, + 0x0a, 0x13, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x32, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, 0x73, + 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x78, 0x6d, 0x74, 0x70, + 0x2e, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0xeb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x6c, + 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x42, + 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x49, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, + 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, + 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6c, 0x73, 0x5f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x58, 0x4d, 0x58, + 0xaa, 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x2e, 0x4d, 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x15, 0x58, 0x6d, 0x74, 0x70, 0x5c, + 0x4d, 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x21, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x4d, 0x6c, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x17, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x4d, 0x6c, 0x73, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -584,31 +734,42 @@ func file_mls_validation_v1_service_proto_rawDescGZIP() []byte { return file_mls_validation_v1_service_proto_rawDescData } -var file_mls_validation_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_mls_validation_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_mls_validation_v1_service_proto_goTypes = []interface{}{ (*ValidateKeyPackagesRequest)(nil), // 0: xmtp.mls_validation.v1.ValidateKeyPackagesRequest (*ValidateKeyPackagesResponse)(nil), // 1: xmtp.mls_validation.v1.ValidateKeyPackagesResponse (*ValidateGroupMessagesRequest)(nil), // 2: xmtp.mls_validation.v1.ValidateGroupMessagesRequest (*ValidateGroupMessagesResponse)(nil), // 3: xmtp.mls_validation.v1.ValidateGroupMessagesResponse - (*ValidateKeyPackagesRequest_KeyPackage)(nil), // 4: xmtp.mls_validation.v1.ValidateKeyPackagesRequest.KeyPackage - (*ValidateKeyPackagesResponse_ValidationResponse)(nil), // 5: xmtp.mls_validation.v1.ValidateKeyPackagesResponse.ValidationResponse - (*ValidateGroupMessagesRequest_GroupMessage)(nil), // 6: xmtp.mls_validation.v1.ValidateGroupMessagesRequest.GroupMessage - (*ValidateGroupMessagesResponse_ValidationResponse)(nil), // 7: xmtp.mls_validation.v1.ValidateGroupMessagesResponse.ValidationResponse + (*GetAssociationStateRequest)(nil), // 4: xmtp.mls_validation.v1.GetAssociationStateRequest + (*GetAssociationStateResponse)(nil), // 5: xmtp.mls_validation.v1.GetAssociationStateResponse + (*ValidateKeyPackagesRequest_KeyPackage)(nil), // 6: xmtp.mls_validation.v1.ValidateKeyPackagesRequest.KeyPackage + (*ValidateKeyPackagesResponse_ValidationResponse)(nil), // 7: xmtp.mls_validation.v1.ValidateKeyPackagesResponse.ValidationResponse + (*ValidateGroupMessagesRequest_GroupMessage)(nil), // 8: xmtp.mls_validation.v1.ValidateGroupMessagesRequest.GroupMessage + (*ValidateGroupMessagesResponse_ValidationResponse)(nil), // 9: xmtp.mls_validation.v1.ValidateGroupMessagesResponse.ValidationResponse + (*associations.IdentityUpdate)(nil), // 10: xmtp.identity.associations.IdentityUpdate + (*associations.AssociationState)(nil), // 11: xmtp.identity.associations.AssociationState + (*associations.AssociationStateDiff)(nil), // 12: xmtp.identity.associations.AssociationStateDiff } var file_mls_validation_v1_service_proto_depIdxs = []int32{ - 4, // 0: xmtp.mls_validation.v1.ValidateKeyPackagesRequest.key_packages:type_name -> xmtp.mls_validation.v1.ValidateKeyPackagesRequest.KeyPackage - 5, // 1: xmtp.mls_validation.v1.ValidateKeyPackagesResponse.responses:type_name -> xmtp.mls_validation.v1.ValidateKeyPackagesResponse.ValidationResponse - 6, // 2: xmtp.mls_validation.v1.ValidateGroupMessagesRequest.group_messages:type_name -> xmtp.mls_validation.v1.ValidateGroupMessagesRequest.GroupMessage - 7, // 3: xmtp.mls_validation.v1.ValidateGroupMessagesResponse.responses:type_name -> xmtp.mls_validation.v1.ValidateGroupMessagesResponse.ValidationResponse - 0, // 4: xmtp.mls_validation.v1.ValidationApi.ValidateKeyPackages:input_type -> xmtp.mls_validation.v1.ValidateKeyPackagesRequest - 2, // 5: xmtp.mls_validation.v1.ValidationApi.ValidateGroupMessages:input_type -> xmtp.mls_validation.v1.ValidateGroupMessagesRequest - 1, // 6: xmtp.mls_validation.v1.ValidationApi.ValidateKeyPackages:output_type -> xmtp.mls_validation.v1.ValidateKeyPackagesResponse - 3, // 7: xmtp.mls_validation.v1.ValidationApi.ValidateGroupMessages:output_type -> xmtp.mls_validation.v1.ValidateGroupMessagesResponse - 6, // [6:8] is the sub-list for method output_type - 4, // [4:6] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 6, // 0: xmtp.mls_validation.v1.ValidateKeyPackagesRequest.key_packages:type_name -> xmtp.mls_validation.v1.ValidateKeyPackagesRequest.KeyPackage + 7, // 1: xmtp.mls_validation.v1.ValidateKeyPackagesResponse.responses:type_name -> xmtp.mls_validation.v1.ValidateKeyPackagesResponse.ValidationResponse + 8, // 2: xmtp.mls_validation.v1.ValidateGroupMessagesRequest.group_messages:type_name -> xmtp.mls_validation.v1.ValidateGroupMessagesRequest.GroupMessage + 9, // 3: xmtp.mls_validation.v1.ValidateGroupMessagesResponse.responses:type_name -> xmtp.mls_validation.v1.ValidateGroupMessagesResponse.ValidationResponse + 10, // 4: xmtp.mls_validation.v1.GetAssociationStateRequest.old_updates:type_name -> xmtp.identity.associations.IdentityUpdate + 10, // 5: xmtp.mls_validation.v1.GetAssociationStateRequest.new_updates:type_name -> xmtp.identity.associations.IdentityUpdate + 11, // 6: xmtp.mls_validation.v1.GetAssociationStateResponse.association_state:type_name -> xmtp.identity.associations.AssociationState + 12, // 7: xmtp.mls_validation.v1.GetAssociationStateResponse.state_diff:type_name -> xmtp.identity.associations.AssociationStateDiff + 0, // 8: xmtp.mls_validation.v1.ValidationApi.ValidateKeyPackages:input_type -> xmtp.mls_validation.v1.ValidateKeyPackagesRequest + 2, // 9: xmtp.mls_validation.v1.ValidationApi.ValidateGroupMessages:input_type -> xmtp.mls_validation.v1.ValidateGroupMessagesRequest + 4, // 10: xmtp.mls_validation.v1.ValidationApi.GetAssociationState:input_type -> xmtp.mls_validation.v1.GetAssociationStateRequest + 1, // 11: xmtp.mls_validation.v1.ValidationApi.ValidateKeyPackages:output_type -> xmtp.mls_validation.v1.ValidateKeyPackagesResponse + 3, // 12: xmtp.mls_validation.v1.ValidationApi.ValidateGroupMessages:output_type -> xmtp.mls_validation.v1.ValidateGroupMessagesResponse + 5, // 13: xmtp.mls_validation.v1.ValidationApi.GetAssociationState:output_type -> xmtp.mls_validation.v1.GetAssociationStateResponse + 11, // [11:14] is the sub-list for method output_type + 8, // [8:11] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_mls_validation_v1_service_proto_init() } @@ -666,7 +827,7 @@ func file_mls_validation_v1_service_proto_init() { } } file_mls_validation_v1_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ValidateKeyPackagesRequest_KeyPackage); i { + switch v := v.(*GetAssociationStateRequest); i { case 0: return &v.state case 1: @@ -678,7 +839,7 @@ func file_mls_validation_v1_service_proto_init() { } } file_mls_validation_v1_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ValidateKeyPackagesResponse_ValidationResponse); i { + switch v := v.(*GetAssociationStateResponse); i { case 0: return &v.state case 1: @@ -690,7 +851,7 @@ func file_mls_validation_v1_service_proto_init() { } } file_mls_validation_v1_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ValidateGroupMessagesRequest_GroupMessage); i { + switch v := v.(*ValidateKeyPackagesRequest_KeyPackage); i { case 0: return &v.state case 1: @@ -702,6 +863,30 @@ func file_mls_validation_v1_service_proto_init() { } } file_mls_validation_v1_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidateKeyPackagesResponse_ValidationResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mls_validation_v1_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidateGroupMessagesRequest_GroupMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mls_validation_v1_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ValidateGroupMessagesResponse_ValidationResponse); i { case 0: return &v.state @@ -720,7 +905,7 @@ func file_mls_validation_v1_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_mls_validation_v1_service_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/proto/mls_validation/v1/service_grpc.pb.go b/pkg/proto/mls_validation/v1/service_grpc.pb.go index a0e21c24..80a4724c 100644 --- a/pkg/proto/mls_validation/v1/service_grpc.pb.go +++ b/pkg/proto/mls_validation/v1/service_grpc.pb.go @@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( ValidationApi_ValidateKeyPackages_FullMethodName = "/xmtp.mls_validation.v1.ValidationApi/ValidateKeyPackages" ValidationApi_ValidateGroupMessages_FullMethodName = "/xmtp.mls_validation.v1.ValidationApi/ValidateGroupMessages" + ValidationApi_GetAssociationState_FullMethodName = "/xmtp.mls_validation.v1.ValidationApi/GetAssociationState" ) // ValidationApiClient is the client API for ValidationApi service. @@ -33,6 +34,8 @@ type ValidationApiClient interface { ValidateKeyPackages(ctx context.Context, in *ValidateKeyPackagesRequest, opts ...grpc.CallOption) (*ValidateKeyPackagesResponse, error) // Validates and parses a group message and returns relevant details ValidateGroupMessages(ctx context.Context, in *ValidateGroupMessagesRequest, opts ...grpc.CallOption) (*ValidateGroupMessagesResponse, error) + // Gets the final association state for a batch of identity updates + GetAssociationState(ctx context.Context, in *GetAssociationStateRequest, opts ...grpc.CallOption) (*GetAssociationStateResponse, error) } type validationApiClient struct { @@ -61,6 +64,15 @@ func (c *validationApiClient) ValidateGroupMessages(ctx context.Context, in *Val return out, nil } +func (c *validationApiClient) GetAssociationState(ctx context.Context, in *GetAssociationStateRequest, opts ...grpc.CallOption) (*GetAssociationStateResponse, error) { + out := new(GetAssociationStateResponse) + err := c.cc.Invoke(ctx, ValidationApi_GetAssociationState_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ValidationApiServer is the server API for ValidationApi service. // All implementations must embed UnimplementedValidationApiServer // for forward compatibility @@ -69,6 +81,8 @@ type ValidationApiServer interface { ValidateKeyPackages(context.Context, *ValidateKeyPackagesRequest) (*ValidateKeyPackagesResponse, error) // Validates and parses a group message and returns relevant details ValidateGroupMessages(context.Context, *ValidateGroupMessagesRequest) (*ValidateGroupMessagesResponse, error) + // Gets the final association state for a batch of identity updates + GetAssociationState(context.Context, *GetAssociationStateRequest) (*GetAssociationStateResponse, error) mustEmbedUnimplementedValidationApiServer() } @@ -82,6 +96,9 @@ func (UnimplementedValidationApiServer) ValidateKeyPackages(context.Context, *Va func (UnimplementedValidationApiServer) ValidateGroupMessages(context.Context, *ValidateGroupMessagesRequest) (*ValidateGroupMessagesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ValidateGroupMessages not implemented") } +func (UnimplementedValidationApiServer) GetAssociationState(context.Context, *GetAssociationStateRequest) (*GetAssociationStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAssociationState not implemented") +} func (UnimplementedValidationApiServer) mustEmbedUnimplementedValidationApiServer() {} // UnsafeValidationApiServer may be embedded to opt out of forward compatibility for this service. @@ -131,6 +148,24 @@ func _ValidationApi_ValidateGroupMessages_Handler(srv interface{}, ctx context.C return interceptor(ctx, in, info, handler) } +func _ValidationApi_GetAssociationState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAssociationStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ValidationApiServer).GetAssociationState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ValidationApi_GetAssociationState_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ValidationApiServer).GetAssociationState(ctx, req.(*GetAssociationStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + // ValidationApi_ServiceDesc is the grpc.ServiceDesc for ValidationApi service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -146,6 +181,10 @@ var ValidationApi_ServiceDesc = grpc.ServiceDesc{ MethodName: "ValidateGroupMessages", Handler: _ValidationApi_ValidateGroupMessages_Handler, }, + { + MethodName: "GetAssociationState", + Handler: _ValidationApi_GetAssociationState_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "mls_validation/v1/service.proto", diff --git a/pkg/proto/openapi/identity/api/v1/identity.swagger.json b/pkg/proto/openapi/identity/api/v1/identity.swagger.json index c0e1850b..ce2bc819 100644 --- a/pkg/proto/openapi/identity/api/v1/identity.swagger.json +++ b/pkg/proto/openapi/identity/api/v1/identity.swagger.json @@ -213,9 +213,9 @@ "associationsErc1271Signature": { "type": "object", "properties": { - "contractAddress": { + "accountId": { "type": "string", - "title": "CAIP-10 contract address\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" + "title": "CAIP-10\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" }, "blockNumber": { "type": "string", @@ -298,7 +298,13 @@ "properties": { "bytes": { "type": "string", - "format": "byte" + "format": "byte", + "title": "64 bytes [R(32 bytes) || S(32 bytes)]" + }, + "publicKey": { + "type": "string", + "format": "byte", + "title": "32 bytes" } }, "title": "EdDSA signature for 25519" diff --git a/pkg/proto/openapi/mls_validation/v1/service.swagger.json b/pkg/proto/openapi/mls_validation/v1/service.swagger.json index 9a0048c7..e581e909 100644 --- a/pkg/proto/openapi/mls_validation/v1/service.swagger.json +++ b/pkg/proto/openapi/mls_validation/v1/service.swagger.json @@ -17,6 +17,307 @@ ], "paths": {}, "definitions": { + "SignatureECDSACompact": { + "type": "object", + "properties": { + "bytes": { + "type": "string", + "format": "byte", + "title": "compact representation [ R || S ], 64 bytes" + }, + "recovery": { + "type": "integer", + "format": "int64", + "title": "recovery bit" + } + }, + "title": "ECDSA signature bytes and the recovery bit" + }, + "SignatureWalletECDSACompact": { + "type": "object", + "properties": { + "bytes": { + "type": "string", + "format": "byte", + "title": "compact representation [ R || S ], 64 bytes" + }, + "recovery": { + "type": "integer", + "format": "int64", + "title": "recovery bit" + } + }, + "description": "ECDSA signature bytes and the recovery bit\nproduced by xmtp-js::PublicKey.signWithWallet function, i.e.\nEIP-191 signature of a \"Create Identity\" message with the key embedded.\nUsed to sign identity keys." + }, + "associationsAddAssociation": { + "type": "object", + "properties": { + "newMemberIdentifier": { + "$ref": "#/definitions/associationsMemberIdentifier" + }, + "existingMemberSignature": { + "$ref": "#/definitions/identityassociationsSignature" + }, + "newMemberSignature": { + "$ref": "#/definitions/identityassociationsSignature" + } + }, + "description": "Adds a new member for an XID - either an addressable member such as a\nwallet, or an installation acting on behalf of an address.\nA key-pair that has been associated with one role MUST not be permitted to be\nassociated with a different role." + }, + "associationsAssociationState": { + "type": "object", + "properties": { + "inboxId": { + "type": "string" + }, + "members": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/associationsMemberMap" + } + }, + "recoveryAddress": { + "type": "string" + }, + "seenSignatures": { + "type": "array", + "items": { + "type": "string", + "format": "byte" + } + } + }, + "title": "A final association state resulting from multiple `IdentityUpdates`" + }, + "associationsAssociationStateDiff": { + "type": "object", + "properties": { + "newMembers": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/associationsMemberIdentifier" + } + }, + "removedMembers": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/associationsMemberIdentifier" + } + } + }, + "title": "/ state diff between two final AssociationStates" + }, + "associationsChangeRecoveryAddress": { + "type": "object", + "properties": { + "newRecoveryAddress": { + "type": "string" + }, + "existingRecoveryAddressSignature": { + "$ref": "#/definitions/identityassociationsSignature" + } + }, + "description": "Changes the recovery address for an XID. The recovery address is not required\nto be a member of the XID. In addition to being able to add members, the\nrecovery address can also revoke members." + }, + "associationsCreateInbox": { + "type": "object", + "properties": { + "initialAddress": { + "type": "string" + }, + "nonce": { + "type": "string", + "format": "uint64" + }, + "initialAddressSignature": { + "$ref": "#/definitions/identityassociationsSignature", + "title": "Must be an addressable member" + } + }, + "description": "The first entry of any XID log. The XID must be deterministically derivable\nfrom the address and nonce.\nThe recovery address defaults to the initial associated_address unless\nthere is a subsequent ChangeRecoveryAddress in the log." + }, + "associationsErc1271Signature": { + "type": "object", + "properties": { + "accountId": { + "type": "string", + "title": "CAIP-10\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" + }, + "blockNumber": { + "type": "string", + "format": "uint64", + "title": "Specify the block number to verify the signature against" + }, + "signature": { + "type": "string", + "format": "byte", + "title": "The actual signature bytes" + } + }, + "title": "Smart wallet signature" + }, + "associationsIdentityAction": { + "type": "object", + "properties": { + "createInbox": { + "$ref": "#/definitions/associationsCreateInbox" + }, + "add": { + "$ref": "#/definitions/associationsAddAssociation" + }, + "revoke": { + "$ref": "#/definitions/associationsRevokeAssociation" + }, + "changeRecoveryAddress": { + "$ref": "#/definitions/associationsChangeRecoveryAddress" + } + }, + "title": "A single identity operation" + }, + "associationsIdentityUpdate": { + "type": "object", + "properties": { + "actions": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/associationsIdentityAction" + } + }, + "clientTimestampNs": { + "type": "string", + "format": "uint64" + }, + "inboxId": { + "type": "string" + } + }, + "description": "One or more identity actions that were signed together.\nExample: [CreateXid, AddAssociation, ChangeRecoveryAddress]\n1. The batched signature text is created by concatenating the signature text\n of each association together with a separator, '\\n\\n\\n'.\n2. The user signs this concatenated result.\n3. The resulting signature is added to each association proto where relevant.\n The same signature may be used for multiple associations in the array." + }, + "associationsLegacyDelegatedSignature": { + "type": "object", + "properties": { + "delegatedKey": { + "$ref": "#/definitions/message_contentsSignedPublicKey" + }, + "signature": { + "$ref": "#/definitions/identityassociationsRecoverableEcdsaSignature" + } + }, + "description": "An existing address on xmtpv2 may have already signed a legacy identity key\nof type SignedPublicKey via the 'Create Identity' signature.\nFor migration to xmtpv3, the legacy key is permitted to sign on behalf of the\naddress to create a matching xmtpv3 installation key.\nThis signature type can ONLY be used for CreateXid and AddAssociation\npayloads, and can only be used once in xmtpv3." + }, + "associationsMember": { + "type": "object", + "properties": { + "identifier": { + "$ref": "#/definitions/associationsMemberIdentifier" + }, + "addedByEntity": { + "$ref": "#/definitions/associationsMemberIdentifier" + } + }, + "title": "single member that optionally indicates the member that added them" + }, + "associationsMemberIdentifier": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "installationPublicKey": { + "type": "string", + "format": "byte" + } + }, + "title": "The identifier for a member of an XID" + }, + "associationsMemberMap": { + "type": "object", + "properties": { + "key": { + "$ref": "#/definitions/associationsMemberIdentifier" + }, + "value": { + "$ref": "#/definitions/associationsMember" + } + }, + "title": "Map of members belonging to an inbox_id" + }, + "associationsRecoverableEd25519Signature": { + "type": "object", + "properties": { + "bytes": { + "type": "string", + "format": "byte", + "title": "64 bytes [R(32 bytes) || S(32 bytes)]" + }, + "publicKey": { + "type": "string", + "format": "byte", + "title": "32 bytes" + } + }, + "title": "EdDSA signature for 25519" + }, + "associationsRevokeAssociation": { + "type": "object", + "properties": { + "memberToRevoke": { + "$ref": "#/definitions/associationsMemberIdentifier" + }, + "recoveryAddressSignature": { + "$ref": "#/definitions/identityassociationsSignature" + } + }, + "description": "Revokes a member from an XID. The recovery address must sign the revocation." + }, + "identityassociationsRecoverableEcdsaSignature": { + "type": "object", + "properties": { + "bytes": { + "type": "string", + "format": "byte", + "title": "65-bytes [ R || S || V ], with recovery id as the last byte" + } + }, + "title": "RecoverableEcdsaSignature for EIP-191 and V2 signatures" + }, + "identityassociationsSignature": { + "type": "object", + "properties": { + "erc191": { + "$ref": "#/definitions/identityassociationsRecoverableEcdsaSignature" + }, + "erc1271": { + "$ref": "#/definitions/associationsErc1271Signature" + }, + "installationKey": { + "$ref": "#/definitions/associationsRecoverableEd25519Signature" + }, + "delegatedErc191": { + "$ref": "#/definitions/associationsLegacyDelegatedSignature" + } + }, + "title": "A wrapper for all possible signature types" + }, + "message_contentsSignedPublicKey": { + "type": "object", + "properties": { + "keyBytes": { + "type": "string", + "format": "byte", + "title": "embeds an UnsignedPublicKey" + }, + "signature": { + "$ref": "#/definitions/xmtpmessage_contentsSignature", + "title": "signs key_bytes" + } + }, + "title": "SignedPublicKey" + }, "protobufAny": { "type": "object", "properties": { @@ -45,6 +346,18 @@ } } }, + "v1GetAssociationStateResponse": { + "type": "object", + "properties": { + "associationState": { + "$ref": "#/definitions/associationsAssociationState" + }, + "stateDiff": { + "$ref": "#/definitions/associationsAssociationStateDiff" + } + }, + "title": "Response to GetAssociationStateRequest, containing the final association state\nfor an InboxID" + }, "v1ValidateGroupMessagesRequestGroupMessage": { "type": "object", "properties": { @@ -132,6 +445,18 @@ } }, "title": "An individual response to one key package" + }, + "xmtpmessage_contentsSignature": { + "type": "object", + "properties": { + "ecdsaCompact": { + "$ref": "#/definitions/SignatureECDSACompact" + }, + "walletEcdsaCompact": { + "$ref": "#/definitions/SignatureWalletECDSACompact" + } + }, + "description": "Signature represents a generalized public key signature,\ndefined as a union to support cryptographic algorithm agility." } } } diff --git a/sqlc.yaml b/sqlc.yaml new file mode 100644 index 00000000..527b1566 --- /dev/null +++ b/sqlc.yaml @@ -0,0 +1,11 @@ +version: "2" +sql: + - engine: "postgresql" + queries: "pkg/identity/queries.sql" + schema: "pkg/migrations/mls" + database: + uri: "postgres://postgres:xmtp@localhost:7654/postgres" + gen: + go: + package: "queries" + out: "pkg/identity/queries" From a99c43b7b63a9e50371dcc586e0cb65919329870 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:15:17 -0700 Subject: [PATCH 02/24] Set up sqlc --- go.mod | 13 +- go.sum | 22 +- pkg/identity/queries.sql | 12 - pkg/identity/queries/queries.sql.go | 80 --- .../mls/20240411200242_init-identity.up.sql | 9 +- .../20240425021053_add-inbox-filters.down.sql | 5 + .../20240425021053_add-inbox-filters.up.sql | 8 + pkg/mls/store/queries.sql | 78 +++ pkg/{identity => mls/store}/queries/db.go | 0 pkg/{identity => mls/store}/queries/models.go | 0 pkg/mls/store/queries/queries.sql.go | 472 ++++++++++++++++++ pkg/server/pgxdb.go | 49 ++ pkg/server/server.go | 2 +- pkg/testing/store.go | 25 +- sqlc.yaml | 6 +- 15 files changed, 665 insertions(+), 116 deletions(-) delete mode 100644 pkg/identity/queries.sql delete mode 100644 pkg/identity/queries/queries.sql.go create mode 100644 pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql create mode 100644 pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql create mode 100644 pkg/mls/store/queries.sql rename pkg/{identity => mls/store}/queries/db.go (100%) rename pkg/{identity => mls/store}/queries/models.go (100%) create mode 100644 pkg/mls/store/queries/queries.sql.go create mode 100644 pkg/server/pgxdb.go diff --git a/go.mod b/go.mod index 83044d23..28fef3cf 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.0 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/huandu/go-sqlbuilder v1.13.0 + github.com/jackc/pgx/v5 v5.5.5 github.com/jarcoal/httpmock v1.2.0 github.com/jessevdk/go-flags v1.4.0 github.com/libp2p/go-libp2p v0.29.2 @@ -39,6 +40,12 @@ require ( gopkg.in/DataDog/dd-trace-go.v1 v1.40.1 ) +require ( + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/puddle/v2 v2.2.1 // indirect +) + require ( github.com/DataDog/datadog-agent/pkg/obfuscate v0.0.0-20211129110424-6491aa3bf583 // indirect github.com/DataDog/datadog-go v4.8.2+incompatible // indirect @@ -170,12 +177,12 @@ require ( go.uber.org/dig v1.17.0 // indirect go.uber.org/fx v1.20.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.13.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect golang.org/x/tools v0.12.1-0.20230818130535-1517d1a3ba60 // indirect golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect diff --git a/go.sum b/go.sum index c40fd15d..d3e17389 100644 --- a/go.sum +++ b/go.sum @@ -571,6 +571,7 @@ github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bY github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= @@ -584,6 +585,8 @@ github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= @@ -602,12 +605,16 @@ github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9s github.com/jackc/pgx/v4 v4.8.1/go.mod h1:4HOLxrl8wToZJReD04/yB20GDwf4KBYETvlHciCnwW0= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc= @@ -668,8 +675,8 @@ github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= @@ -970,6 +977,7 @@ github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRr github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -1239,8 +1247,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1442,8 +1450,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1457,8 +1465,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql deleted file mode 100644 index e29e5c5b..00000000 --- a/pkg/identity/queries.sql +++ /dev/null @@ -1,12 +0,0 @@ --- name: GetAllInboxLogs :many -SELECT * FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE; - --- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS ( - SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) -) -SELECT a.* FROM inbox_log AS a -JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go deleted file mode 100644 index 5441410f..00000000 --- a/pkg/identity/queries/queries.sql.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 -// source: queries.sql - -package queries - -import ( - "context" -) - -const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE -` - -func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getInboxLogs = `-- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS (VALUES ($1)) -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a -JOIN b ON a.inbox_id = b.inbox_id -WHERE a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC -` - -func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} diff --git a/pkg/migrations/mls/20240411200242_init-identity.up.sql b/pkg/migrations/mls/20240411200242_init-identity.up.sql index a764f57b..cc56762e 100644 --- a/pkg/migrations/mls/20240411200242_init-identity.up.sql +++ b/pkg/migrations/mls/20240411200242_init-identity.up.sql @@ -24,11 +24,4 @@ CREATE TABLE address_log ( --bun:split -CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); - --- bun:split - -CREATE TYPE inbox_filter AS ( - sequence_id BIGINT, - inbox_id TEXT -); \ No newline at end of file +CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); \ No newline at end of file diff --git a/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql b/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql new file mode 100644 index 00000000..f5b5f1c0 --- /dev/null +++ b/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql @@ -0,0 +1,5 @@ +SET statement_timeout = 0; + +--bun:split + +DROP TYPE IF EXISTS inbox_filter; \ No newline at end of file diff --git a/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql b/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql new file mode 100644 index 00000000..edd4b911 --- /dev/null +++ b/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql @@ -0,0 +1,8 @@ +SET statement_timeout = 0; + +--bun:split + +CREATE TYPE inbox_filter AS ( + inbox_id TEXT, + sequence_id BIGINT +); diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql new file mode 100644 index 00000000..6436fd3b --- /dev/null +++ b/pkg/mls/store/queries.sql @@ -0,0 +1,78 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogFiltered :many +SELECT a.* FROM inbox_log AS a +JOIN ( + SELECT * FROM json_populate_recordset(null::inbox_filter, sqlc.arg(filters)) as b(inbox_id, sequence_id) +) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; + +-- name: InsertInboxLog :one +INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) +VALUES ($1, $2, $3) +RETURNING sequence_id; + +-- name: CreateInstallation :exec +INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) +VALUES ($1, $2, $3, $3, $4, $5, $6); + +-- name: UpdateKeyPackage :execrows +UPDATE installations +SET key_package = @key_package, updated_at = @updated_at, expiration = @expiration +WHERE id = @id; + +-- name: FetchKeyPackages :many +SELECT id, key_package FROM installations +WHERE ID IN (@ids); + +-- name: GetIdentityUpdates :many +SELECT * FROM installations +WHERE wallet_address IN (@wallet_addresses) +AND (created_at > @start_time OR revoked_at > @start_time) +ORDER BY created_at ASC; + +-- name: RevokeInstallation :exec +UPDATE installations +SET revoked_at = @revoked_at +WHERE id = @installation_id +AND revoked_at IS NULL; + +-- name: InsertGroupMessage :one +INSERT INTO group_messages (group_id, data, group_id_data_hash) +VALUES ($1, $2, $3) +RETURNING *; + +-- name: InsertWelcomeMessage :one +INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) +VALUES ($1, $2, $3, $4) +RETURNING *; + +-- name: QueryGroupMessagesAsc :many +SELECT * FROM group_messages +WHERE group_id = @group_id +ORDER BY id ASC +LIMIT @numrows; + +-- name: QueryGroupMessagesDesc :many +SELECT * FROM group_messages +WHERE group_id = @group_id +ORDER BY id DESC +LIMIT @numrows; + +-- name: QueryGroupMessagesWithCursorAsc :many +SELECT * FROM group_messages +WHERE group_id = $1 +AND id > $2 +ORDER BY id ASC +LIMIT $3; + +-- name: QueryGroupMessagesWithCursorDesc :many +SELECT * FROM group_messages +WHERE group_id = $1 +AND id < $2 +ORDER BY id DESC +LIMIT $3; + diff --git a/pkg/identity/queries/db.go b/pkg/mls/store/queries/db.go similarity index 100% rename from pkg/identity/queries/db.go rename to pkg/mls/store/queries/db.go diff --git a/pkg/identity/queries/models.go b/pkg/mls/store/queries/models.go similarity index 100% rename from pkg/identity/queries/models.go rename to pkg/mls/store/queries/models.go diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go new file mode 100644 index 00000000..337eebd8 --- /dev/null +++ b/pkg/mls/store/queries/queries.sql.go @@ -0,0 +1,472 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" + "database/sql" + "encoding/json" +) + +const createInstallation = `-- name: CreateInstallation :exec +INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) +VALUES ($1, $2, $3, $3, $4, $5, $6) +` + +type CreateInstallationParams struct { + ID []byte + WalletAddress string + CreatedAt int64 + CredentialIdentity []byte + KeyPackage []byte + Expiration int64 +} + +func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallationParams) error { + _, err := q.db.ExecContext(ctx, createInstallation, + arg.ID, + arg.WalletAddress, + arg.CreatedAt, + arg.CredentialIdentity, + arg.KeyPackage, + arg.Expiration, + ) + return err +} + +const fetchKeyPackages = `-- name: FetchKeyPackages :many +SELECT id, key_package FROM installations +WHERE ID IN ($1) +` + +type FetchKeyPackagesRow struct { + ID []byte + KeyPackage []byte +} + +func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) + if err != nil { + return nil, err + } + defer rows.Close() + var items []FetchKeyPackagesRow + for rows.Next() { + var i FetchKeyPackagesRow + if err := rows.Scan(&i.ID, &i.KeyPackage); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getIdentityUpdates = `-- name: GetIdentityUpdates :many +SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations +WHERE wallet_address IN ($1) +AND (created_at > $2 OR revoked_at > $2) +ORDER BY created_at ASC +` + +type GetIdentityUpdatesParams struct { + WalletAddresses string + StartTime int64 +} + +func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Installation + for rows.Next() { + var i Installation + if err := rows.Scan( + &i.ID, + &i.WalletAddress, + &i.CreatedAt, + &i.UpdatedAt, + &i.CredentialIdentity, + &i.RevokedAt, + &i.KeyPackage, + &i.Expiration, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogFiltered = `-- name: GetInboxLogFiltered :many +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log AS a +JOIN ( + SELECT inbox_id, sequence_id FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) +) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessage) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogFiltered, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const insertGroupMessage = `-- name: InsertGroupMessage :one +INSERT INTO group_messages (group_id, data, group_id_data_hash) +VALUES ($1, $2, $3) +RETURNING id, created_at, group_id, data, group_id_data_hash +` + +type InsertGroupMessageParams struct { + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +func (q *Queries) InsertGroupMessage(ctx context.Context, arg InsertGroupMessageParams) (GroupMessage, error) { + row := q.db.QueryRowContext(ctx, insertGroupMessage, arg.GroupID, arg.Data, arg.GroupIDDataHash) + var i GroupMessage + err := row.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ) + return i, err +} + +const insertInboxLog = `-- name: InsertInboxLog :one +INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) +VALUES ($1, $2, $3) +RETURNING sequence_id +` + +type InsertInboxLogParams struct { + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +func (q *Queries) InsertInboxLog(ctx context.Context, arg InsertInboxLogParams) (int64, error) { + row := q.db.QueryRowContext(ctx, insertInboxLog, arg.InboxID, arg.ServerTimestampNs, arg.IdentityUpdateProto) + var sequence_id int64 + err := row.Scan(&sequence_id) + return sequence_id, err +} + +const insertWelcomeMessage = `-- name: InsertWelcomeMessage :one +INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) +VALUES ($1, $2, $3, $4) +RETURNING id, created_at, installation_key, data, installation_key_data_hash, hpke_public_key +` + +type InsertWelcomeMessageParams struct { + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} + +func (q *Queries) InsertWelcomeMessage(ctx context.Context, arg InsertWelcomeMessageParams) (WelcomeMessage, error) { + row := q.db.QueryRowContext(ctx, insertWelcomeMessage, + arg.InstallationKey, + arg.Data, + arg.InstallationKeyDataHash, + arg.HpkePublicKey, + ) + var i WelcomeMessage + err := row.Scan( + &i.ID, + &i.CreatedAt, + &i.InstallationKey, + &i.Data, + &i.InstallationKeyDataHash, + &i.HpkePublicKey, + ) + return i, err +} + +const queryGroupMessagesAsc = `-- name: QueryGroupMessagesAsc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +ORDER BY id ASC +LIMIT $2 +` + +type QueryGroupMessagesAscParams struct { + GroupID []byte + Numrows int32 +} + +func (q *Queries) QueryGroupMessagesAsc(ctx context.Context, arg QueryGroupMessagesAscParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesAsc, arg.GroupID, arg.Numrows) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesDesc = `-- name: QueryGroupMessagesDesc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +ORDER BY id DESC +LIMIT $2 +` + +type QueryGroupMessagesDescParams struct { + GroupID []byte + Numrows int32 +} + +func (q *Queries) QueryGroupMessagesDesc(ctx context.Context, arg QueryGroupMessagesDescParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesDesc, arg.GroupID, arg.Numrows) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesWithCursorAsc = `-- name: QueryGroupMessagesWithCursorAsc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +AND id > $2 +ORDER BY id ASC +LIMIT $3 +` + +type QueryGroupMessagesWithCursorAscParams struct { + GroupID []byte + ID int64 + Limit int32 +} + +func (q *Queries) QueryGroupMessagesWithCursorAsc(ctx context.Context, arg QueryGroupMessagesWithCursorAscParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesWithCursorAsc, arg.GroupID, arg.ID, arg.Limit) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesWithCursorDesc = `-- name: QueryGroupMessagesWithCursorDesc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +AND id < $2 +ORDER BY id DESC +LIMIT $3 +` + +type QueryGroupMessagesWithCursorDescParams struct { + GroupID []byte + ID int64 + Limit int32 +} + +func (q *Queries) QueryGroupMessagesWithCursorDesc(ctx context.Context, arg QueryGroupMessagesWithCursorDescParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesWithCursorDesc, arg.GroupID, arg.ID, arg.Limit) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const revokeInstallation = `-- name: RevokeInstallation :exec +UPDATE installations +SET revoked_at = $1 +WHERE id = $2 +AND revoked_at IS NULL +` + +type RevokeInstallationParams struct { + RevokedAt sql.NullInt64 + InstallationID []byte +} + +func (q *Queries) RevokeInstallation(ctx context.Context, arg RevokeInstallationParams) error { + _, err := q.db.ExecContext(ctx, revokeInstallation, arg.RevokedAt, arg.InstallationID) + return err +} + +const updateKeyPackage = `-- name: UpdateKeyPackage :execrows +UPDATE installations +SET key_package = $1, updated_at = $2, expiration = $3 +WHERE id = $4 +` + +type UpdateKeyPackageParams struct { + KeyPackage []byte + UpdatedAt int64 + Expiration int64 + ID []byte +} + +func (q *Queries) UpdateKeyPackage(ctx context.Context, arg UpdateKeyPackageParams) (int64, error) { + result, err := q.db.ExecContext(ctx, updateKeyPackage, + arg.KeyPackage, + arg.UpdatedAt, + arg.Expiration, + arg.ID, + ) + if err != nil { + return 0, err + } + return result.RowsAffected() +} diff --git a/pkg/server/pgxdb.go b/pkg/server/pgxdb.go new file mode 100644 index 00000000..20988164 --- /dev/null +++ b/pkg/server/pgxdb.go @@ -0,0 +1,49 @@ +package server + +import ( + "context" + "database/sql" + "fmt" + "time" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" + "github.com/jackc/pgx/v5/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/pgdialect" +) + +func newPgxDb(dsn string, waitForDB, statementTimeout time.Duration) (*sql.DB, error) { + config, err := pgxpool.ParseConfig(dsn) + if err != nil { + return nil, err + } + config.ConnConfig.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol + config.ConnConfig.RuntimeParams["statement_timeout"] = fmt.Sprint(statementTimeout.Milliseconds()) + + dbpool, err := pgxpool.NewWithConfig(context.Background(), config) + if err != nil { + return nil, err + } + db := stdlib.OpenDBFromPool(dbpool) + + waitUntil := time.Now().Add(waitForDB) + + err = db.Ping() + for err != nil && time.Now().Before(waitUntil) { + time.Sleep(3 * time.Second) + err = db.Ping() + } + + return db, nil +} + +func newBunPgxDb(dsn string, waitForDB, statementTimeout time.Duration) (*bun.DB, error) { + pgxDb, err := newPgxDb(dsn, waitForDB, statementTimeout) + if err != nil { + return nil, err + } + + return bun.NewDB(pgxDb, pgdialect.New()), nil +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 13d3e1b9..6dc0e4af 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -231,7 +231,7 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error) var MLSStore *mlsstore.Store if options.MLSStore.DbConnectionString != "" { - if s.mlsDB, err = createBunDB(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout, options.MLSStore.WriteTimeout, options.MLSStore.MaxOpenConns); err != nil { + if s.mlsDB, err = newBunPGXDb(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout); err != nil { return nil, errors.Wrap(err, "creating mls db") } diff --git a/pkg/testing/store.go b/pkg/testing/store.go index bb4c4aff..cb30a27a 100644 --- a/pkg/testing/store.go +++ b/pkg/testing/store.go @@ -5,6 +5,8 @@ import ( "database/sql" "testing" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/stdlib" "github.com/stretchr/testify/require" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect/pgdialect" @@ -36,6 +38,27 @@ func NewDB(t testing.TB) (*sql.DB, string, func()) { } } +func NewPGXDB(t testing.TB) (*sql.DB, string, func()) { + dsn := localTestDBDSNPrefix + localTestDBDSNSuffix + config, err := pgx.ParseConfig(dsn) + require.NoError(t, err) + ctlDB := stdlib.OpenDB(*config) + dbName := "test_" + RandomStringLower(12) + _, err = ctlDB.Exec("CREATE DATABASE " + dbName) + require.NoError(t, err) + + dsn = localTestDBDSNPrefix + "/" + dbName + localTestDBDSNSuffix + config2, err := pgx.ParseConfig(dsn) + require.NoError(t, err) + db := stdlib.OpenDB(*config2) + return db, dsn, func() { + db.Close() + _, err = ctlDB.Exec("DROP DATABASE " + dbName) + require.NoError(t, err) + ctlDB.Close() + } +} + func NewAuthzDB(t testing.TB) (*bun.DB, string, func()) { db, dsn, cleanup := NewDB(t) bunDB := bun.NewDB(db, pgdialect.New()) @@ -51,7 +74,7 @@ func NewAuthzDB(t testing.TB) (*bun.DB, string, func()) { } func NewMLSDB(t *testing.T) (*bun.DB, string, func()) { - db, dsn, cleanup := NewDB(t) + db, dsn, cleanup := NewPGXDB(t) bunDB := bun.NewDB(db, pgdialect.New()) ctx := context.Background() diff --git a/sqlc.yaml b/sqlc.yaml index 527b1566..30575b4c 100644 --- a/sqlc.yaml +++ b/sqlc.yaml @@ -1,11 +1,9 @@ version: "2" sql: - engine: "postgresql" - queries: "pkg/identity/queries.sql" + queries: "pkg/mls/store/queries.sql" schema: "pkg/migrations/mls" - database: - uri: "postgres://postgres:xmtp@localhost:7654/postgres" gen: go: package: "queries" - out: "pkg/identity/queries" + out: "pkg/mls/store/queries" From 86b7131408030a258815cb24adb108d7165b1ca6 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:59:02 -0700 Subject: [PATCH 03/24] Initial commit --- dev/run | 5 +- pkg/identity/queries.sql | 12 ++ pkg/identity/queries/db.go | 31 ++++ pkg/identity/queries/models.go | 52 +++++++ pkg/identity/queries/queries.sql.go | 80 ++++++++++ .../mls/20240411200242_init-identity.up.sql | 7 + .../identity/associations/signature.pb.go | 139 ++++++++++-------- .../identity/api/v1/identity.swagger.json | 12 +- .../mls_validation/v1/service.swagger.json | 12 +- sqlc.yaml | 11 ++ 10 files changed, 289 insertions(+), 72 deletions(-) create mode 100644 pkg/identity/queries.sql create mode 100644 pkg/identity/queries/db.go create mode 100644 pkg/identity/queries/models.go create mode 100644 pkg/identity/queries/queries.sql.go create mode 100644 sqlc.yaml diff --git a/dev/run b/dev/run index a995db08..a160bc5b 100755 --- a/dev/run +++ b/dev/run @@ -2,8 +2,8 @@ set -e MESSAGE_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" -MLS_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" -AUTHZ_DB_DSN="postgres://postgres:xmtp@localhost:15432/postgres?sslmode=disable" +MLS_DB_DSN="postgres://postgres:xmtp@localhost:7654/postgres?sslmode=disable" +AUTHZ_DB_DSN="postgres://postgres:xmtp@localhost:6543/postgres?sslmode=disable" NODE_KEY="8a30dcb604b0b53627a5adc054dbf434b446628d4bd1eccc681d223f0550ce67" go run cmd/xmtpd/main.go \ @@ -15,6 +15,7 @@ go run cmd/xmtpd/main.go \ --store.reader-db-connection-string "${MESSAGE_DB_DSN}" \ --store.metrics-period 5s \ --mls-store.db-connection-string "${MLS_DB_DSN}" \ + --mls-validation.grpc-address=validation:50051 \ --authz-db-connection-string "${AUTHZ_DB_DSN}" \ --go-profiling \ "$@" diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql new file mode 100644 index 00000000..e29e5c5b --- /dev/null +++ b/pkg/identity/queries.sql @@ -0,0 +1,12 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS ( + SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) +) +SELECT a.* FROM inbox_log AS a +JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go new file mode 100644 index 00000000..fa785733 --- /dev/null +++ b/pkg/identity/queries/db.go @@ -0,0 +1,31 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "context" + "database/sql" +) + +type DBTX interface { + ExecContext(context.Context, string, ...interface{}) (sql.Result, error) + PrepareContext(context.Context, string) (*sql.Stmt, error) + QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) + QueryRowContext(context.Context, string, ...interface{}) *sql.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx *sql.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go new file mode 100644 index 00000000..cc2ae9d3 --- /dev/null +++ b/pkg/identity/queries/models.go @@ -0,0 +1,52 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "database/sql" + "time" +) + +type AddressLog struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +type GroupMessage struct { + ID int64 + CreatedAt time.Time + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +type InboxLog struct { + SequenceID int64 + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +type Installation struct { + ID []byte + WalletAddress string + CreatedAt int64 + UpdatedAt int64 + CredentialIdentity []byte + RevokedAt sql.NullInt64 + KeyPackage []byte + Expiration int64 +} + +type WelcomeMessage struct { + ID int64 + CreatedAt time.Time + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go new file mode 100644 index 00000000..5441410f --- /dev/null +++ b/pkg/identity/queries/queries.sql.go @@ -0,0 +1,80 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" +) + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogs = `-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS (VALUES ($1)) +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a +JOIN b ON a.inbox_id = b.inbox_id +WHERE a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} diff --git a/pkg/migrations/mls/20240411200242_init-identity.up.sql b/pkg/migrations/mls/20240411200242_init-identity.up.sql index 4fdeef44..a764f57b 100644 --- a/pkg/migrations/mls/20240411200242_init-identity.up.sql +++ b/pkg/migrations/mls/20240411200242_init-identity.up.sql @@ -25,3 +25,10 @@ CREATE TABLE address_log ( --bun:split CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); + +-- bun:split + +CREATE TYPE inbox_filter AS ( + sequence_id BIGINT, + inbox_id TEXT +); \ No newline at end of file diff --git a/pkg/proto/identity/associations/signature.pb.go b/pkg/proto/identity/associations/signature.pb.go index 9a49794b..8f9824dc 100644 --- a/pkg/proto/identity/associations/signature.pb.go +++ b/pkg/proto/identity/associations/signature.pb.go @@ -78,7 +78,10 @@ type RecoverableEd25519Signature struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // 64 bytes [R(32 bytes) || S(32 bytes)] Bytes []byte `protobuf:"bytes,1,opt,name=bytes,proto3" json:"bytes,omitempty"` + // 32 bytes + PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` } func (x *RecoverableEd25519Signature) Reset() { @@ -120,15 +123,22 @@ func (x *RecoverableEd25519Signature) GetBytes() []byte { return nil } +func (x *RecoverableEd25519Signature) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + // Smart wallet signature type Erc1271Signature struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // CAIP-10 contract address + // CAIP-10 // https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + AccountId string `protobuf:"bytes,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` // Specify the block number to verify the signature against BlockNumber uint64 `protobuf:"varint,2,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` // The actual signature bytes @@ -167,9 +177,9 @@ func (*Erc1271Signature) Descriptor() ([]byte, []int) { return file_identity_associations_signature_proto_rawDescGZIP(), []int{2} } -func (x *Erc1271Signature) GetContractAddress() string { +func (x *Erc1271Signature) GetAccountId() string { if x != nil { - return x.ContractAddress + return x.AccountId } return "" } @@ -377,71 +387,72 @@ var file_identity_associations_signature_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x19, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x33, 0x0a, 0x1b, 0x52, 0x65, 0x63, + 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x52, 0x0a, 0x1b, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x7e, - 0x0a, 0x10, 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, - 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xbc, - 0x01, 0x0a, 0x18, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, - 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, 0x0a, 0x0d, 0x64, - 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, - 0x64, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x6c, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x53, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x6d, - 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xff, 0x02, - 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x50, 0x0a, 0x07, 0x65, - 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, - 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, - 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x06, 0x65, 0x72, 0x63, 0x31, 0x39, 0x31, 0x12, 0x49, 0x0a, - 0x08, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x32, 0x37, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x72, 0x63, - 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, - 0x07, 0x65, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x12, 0x64, 0x0a, 0x10, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x72, 0x0a, + 0x10, 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x22, 0xbc, 0x01, 0x0a, 0x18, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, + 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x53, 0x69, + 0x67, 0x6e, 0x65, 0x64, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x52, 0x0c, 0x64, + 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x53, 0x0a, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, + 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x22, 0xff, 0x02, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x50, + 0x0a, 0x07, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x35, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x63, 0x64, 0x73, 0x61, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x06, 0x65, 0x72, 0x63, 0x31, 0x39, 0x31, + 0x12, 0x49, 0x0a, 0x08, 0x65, 0x72, 0x63, 0x5f, 0x31, 0x32, 0x37, 0x31, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, 0x32, 0x35, 0x35, - 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x12, 0x62, - 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x72, 0x63, 0x5f, - 0x31, 0x39, 0x31, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x78, 0x6d, 0x74, 0x70, - 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x6c, - 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, - 0x00, 0x52, 0x0f, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x45, 0x72, 0x63, 0x31, - 0x39, 0x31, 0x42, 0x0b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x42, - 0xf8, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, + 0x45, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x48, 0x00, 0x52, 0x07, 0x65, 0x72, 0x63, 0x31, 0x32, 0x37, 0x31, 0x12, 0x64, 0x0a, 0x10, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x42, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2d, - 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x2e, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, + 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x64, + 0x32, 0x35, 0x35, 0x31, 0x39, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, 0x00, + 0x52, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, + 0x79, 0x12, 0x62, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, + 0x72, 0x63, 0x5f, 0x31, 0x39, 0x31, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x78, + 0x6d, 0x74, 0x70, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x64, 0x45, + 0x72, 0x63, 0x31, 0x39, 0x31, 0x42, 0x0b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x42, 0xf8, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x6d, 0x74, 0x70, 0x2e, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2f, 0x78, 0x6d, 0x74, 0x70, 0x2d, 0x6e, 0x6f, + 0x64, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xa2, 0x02, 0x03, 0x58, 0x49, 0x41, 0xaa, 0x02, 0x1a, 0x58, 0x6d, + 0x74, 0x70, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xca, 0x02, 0x1a, 0x58, 0x6d, 0x74, 0x70, 0x5c, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0xe2, 0x02, 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0xe2, 0x02, 0x26, 0x58, 0x6d, 0x74, 0x70, 0x5c, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x5c, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x58, 0x6d, - 0x74, 0x70, 0x3a, 0x3a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, 0x3a, 0x41, 0x73, - 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6e, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x1c, 0x58, 0x6d, 0x74, 0x70, 0x3a, 0x3a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x3a, + 0x3a, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/openapi/identity/api/v1/identity.swagger.json b/pkg/proto/openapi/identity/api/v1/identity.swagger.json index c0e1850b..ce2bc819 100644 --- a/pkg/proto/openapi/identity/api/v1/identity.swagger.json +++ b/pkg/proto/openapi/identity/api/v1/identity.swagger.json @@ -213,9 +213,9 @@ "associationsErc1271Signature": { "type": "object", "properties": { - "contractAddress": { + "accountId": { "type": "string", - "title": "CAIP-10 contract address\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" + "title": "CAIP-10\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" }, "blockNumber": { "type": "string", @@ -298,7 +298,13 @@ "properties": { "bytes": { "type": "string", - "format": "byte" + "format": "byte", + "title": "64 bytes [R(32 bytes) || S(32 bytes)]" + }, + "publicKey": { + "type": "string", + "format": "byte", + "title": "32 bytes" } }, "title": "EdDSA signature for 25519" diff --git a/pkg/proto/openapi/mls_validation/v1/service.swagger.json b/pkg/proto/openapi/mls_validation/v1/service.swagger.json index 736ffc92..e581e909 100644 --- a/pkg/proto/openapi/mls_validation/v1/service.swagger.json +++ b/pkg/proto/openapi/mls_validation/v1/service.swagger.json @@ -142,9 +142,9 @@ "associationsErc1271Signature": { "type": "object", "properties": { - "contractAddress": { + "accountId": { "type": "string", - "title": "CAIP-10 contract address\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" + "title": "CAIP-10\nhttps://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md" }, "blockNumber": { "type": "string", @@ -251,7 +251,13 @@ "properties": { "bytes": { "type": "string", - "format": "byte" + "format": "byte", + "title": "64 bytes [R(32 bytes) || S(32 bytes)]" + }, + "publicKey": { + "type": "string", + "format": "byte", + "title": "32 bytes" } }, "title": "EdDSA signature for 25519" diff --git a/sqlc.yaml b/sqlc.yaml new file mode 100644 index 00000000..527b1566 --- /dev/null +++ b/sqlc.yaml @@ -0,0 +1,11 @@ +version: "2" +sql: + - engine: "postgresql" + queries: "pkg/identity/queries.sql" + schema: "pkg/migrations/mls" + database: + uri: "postgres://postgres:xmtp@localhost:7654/postgres" + gen: + go: + package: "queries" + out: "pkg/identity/queries" From 2fa85f6c63cfb8f0dfd157771847789063c7c185 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:15:17 -0700 Subject: [PATCH 04/24] Set up sqlc --- go.mod | 13 +- go.sum | 22 +- pkg/identity/queries.sql | 12 - pkg/identity/queries/queries.sql.go | 80 --- .../mls/20240411200242_init-identity.up.sql | 9 +- .../20240425021053_add-inbox-filters.down.sql | 5 + .../20240425021053_add-inbox-filters.up.sql | 8 + pkg/mls/store/queries.sql | 78 +++ pkg/{identity => mls/store}/queries/db.go | 0 pkg/{identity => mls/store}/queries/models.go | 0 pkg/mls/store/queries/queries.sql.go | 472 ++++++++++++++++++ pkg/server/pgxdb.go | 49 ++ pkg/server/server.go | 2 +- pkg/testing/store.go | 25 +- sqlc.yaml | 6 +- 15 files changed, 665 insertions(+), 116 deletions(-) delete mode 100644 pkg/identity/queries.sql delete mode 100644 pkg/identity/queries/queries.sql.go create mode 100644 pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql create mode 100644 pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql create mode 100644 pkg/mls/store/queries.sql rename pkg/{identity => mls/store}/queries/db.go (100%) rename pkg/{identity => mls/store}/queries/models.go (100%) create mode 100644 pkg/mls/store/queries/queries.sql.go create mode 100644 pkg/server/pgxdb.go diff --git a/go.mod b/go.mod index 83044d23..28fef3cf 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.0 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/huandu/go-sqlbuilder v1.13.0 + github.com/jackc/pgx/v5 v5.5.5 github.com/jarcoal/httpmock v1.2.0 github.com/jessevdk/go-flags v1.4.0 github.com/libp2p/go-libp2p v0.29.2 @@ -39,6 +40,12 @@ require ( gopkg.in/DataDog/dd-trace-go.v1 v1.40.1 ) +require ( + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/puddle/v2 v2.2.1 // indirect +) + require ( github.com/DataDog/datadog-agent/pkg/obfuscate v0.0.0-20211129110424-6491aa3bf583 // indirect github.com/DataDog/datadog-go v4.8.2+incompatible // indirect @@ -170,12 +177,12 @@ require ( go.uber.org/dig v1.17.0 // indirect go.uber.org/fx v1.20.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.13.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect golang.org/x/tools v0.12.1-0.20230818130535-1517d1a3ba60 // indirect golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect diff --git a/go.sum b/go.sum index c40fd15d..d3e17389 100644 --- a/go.sum +++ b/go.sum @@ -571,6 +571,7 @@ github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bY github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= @@ -584,6 +585,8 @@ github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= @@ -602,12 +605,16 @@ github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9s github.com/jackc/pgx/v4 v4.8.1/go.mod h1:4HOLxrl8wToZJReD04/yB20GDwf4KBYETvlHciCnwW0= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc= @@ -668,8 +675,8 @@ github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= @@ -970,6 +977,7 @@ github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRr github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -1239,8 +1247,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1442,8 +1450,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1457,8 +1465,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql deleted file mode 100644 index e29e5c5b..00000000 --- a/pkg/identity/queries.sql +++ /dev/null @@ -1,12 +0,0 @@ --- name: GetAllInboxLogs :many -SELECT * FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE; - --- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS ( - SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) -) -SELECT a.* FROM inbox_log AS a -JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go deleted file mode 100644 index 5441410f..00000000 --- a/pkg/identity/queries/queries.sql.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 -// source: queries.sql - -package queries - -import ( - "context" -) - -const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE -` - -func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getInboxLogs = `-- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS (VALUES ($1)) -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a -JOIN b ON a.inbox_id = b.inbox_id -WHERE a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC -` - -func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} diff --git a/pkg/migrations/mls/20240411200242_init-identity.up.sql b/pkg/migrations/mls/20240411200242_init-identity.up.sql index a764f57b..cc56762e 100644 --- a/pkg/migrations/mls/20240411200242_init-identity.up.sql +++ b/pkg/migrations/mls/20240411200242_init-identity.up.sql @@ -24,11 +24,4 @@ CREATE TABLE address_log ( --bun:split -CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); - --- bun:split - -CREATE TYPE inbox_filter AS ( - sequence_id BIGINT, - inbox_id TEXT -); \ No newline at end of file +CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); \ No newline at end of file diff --git a/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql b/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql new file mode 100644 index 00000000..f5b5f1c0 --- /dev/null +++ b/pkg/migrations/mls/20240425021053_add-inbox-filters.down.sql @@ -0,0 +1,5 @@ +SET statement_timeout = 0; + +--bun:split + +DROP TYPE IF EXISTS inbox_filter; \ No newline at end of file diff --git a/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql b/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql new file mode 100644 index 00000000..edd4b911 --- /dev/null +++ b/pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql @@ -0,0 +1,8 @@ +SET statement_timeout = 0; + +--bun:split + +CREATE TYPE inbox_filter AS ( + inbox_id TEXT, + sequence_id BIGINT +); diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql new file mode 100644 index 00000000..6436fd3b --- /dev/null +++ b/pkg/mls/store/queries.sql @@ -0,0 +1,78 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogFiltered :many +SELECT a.* FROM inbox_log AS a +JOIN ( + SELECT * FROM json_populate_recordset(null::inbox_filter, sqlc.arg(filters)) as b(inbox_id, sequence_id) +) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; + +-- name: InsertInboxLog :one +INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) +VALUES ($1, $2, $3) +RETURNING sequence_id; + +-- name: CreateInstallation :exec +INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) +VALUES ($1, $2, $3, $3, $4, $5, $6); + +-- name: UpdateKeyPackage :execrows +UPDATE installations +SET key_package = @key_package, updated_at = @updated_at, expiration = @expiration +WHERE id = @id; + +-- name: FetchKeyPackages :many +SELECT id, key_package FROM installations +WHERE ID IN (@ids); + +-- name: GetIdentityUpdates :many +SELECT * FROM installations +WHERE wallet_address IN (@wallet_addresses) +AND (created_at > @start_time OR revoked_at > @start_time) +ORDER BY created_at ASC; + +-- name: RevokeInstallation :exec +UPDATE installations +SET revoked_at = @revoked_at +WHERE id = @installation_id +AND revoked_at IS NULL; + +-- name: InsertGroupMessage :one +INSERT INTO group_messages (group_id, data, group_id_data_hash) +VALUES ($1, $2, $3) +RETURNING *; + +-- name: InsertWelcomeMessage :one +INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) +VALUES ($1, $2, $3, $4) +RETURNING *; + +-- name: QueryGroupMessagesAsc :many +SELECT * FROM group_messages +WHERE group_id = @group_id +ORDER BY id ASC +LIMIT @numrows; + +-- name: QueryGroupMessagesDesc :many +SELECT * FROM group_messages +WHERE group_id = @group_id +ORDER BY id DESC +LIMIT @numrows; + +-- name: QueryGroupMessagesWithCursorAsc :many +SELECT * FROM group_messages +WHERE group_id = $1 +AND id > $2 +ORDER BY id ASC +LIMIT $3; + +-- name: QueryGroupMessagesWithCursorDesc :many +SELECT * FROM group_messages +WHERE group_id = $1 +AND id < $2 +ORDER BY id DESC +LIMIT $3; + diff --git a/pkg/identity/queries/db.go b/pkg/mls/store/queries/db.go similarity index 100% rename from pkg/identity/queries/db.go rename to pkg/mls/store/queries/db.go diff --git a/pkg/identity/queries/models.go b/pkg/mls/store/queries/models.go similarity index 100% rename from pkg/identity/queries/models.go rename to pkg/mls/store/queries/models.go diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go new file mode 100644 index 00000000..337eebd8 --- /dev/null +++ b/pkg/mls/store/queries/queries.sql.go @@ -0,0 +1,472 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" + "database/sql" + "encoding/json" +) + +const createInstallation = `-- name: CreateInstallation :exec +INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) +VALUES ($1, $2, $3, $3, $4, $5, $6) +` + +type CreateInstallationParams struct { + ID []byte + WalletAddress string + CreatedAt int64 + CredentialIdentity []byte + KeyPackage []byte + Expiration int64 +} + +func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallationParams) error { + _, err := q.db.ExecContext(ctx, createInstallation, + arg.ID, + arg.WalletAddress, + arg.CreatedAt, + arg.CredentialIdentity, + arg.KeyPackage, + arg.Expiration, + ) + return err +} + +const fetchKeyPackages = `-- name: FetchKeyPackages :many +SELECT id, key_package FROM installations +WHERE ID IN ($1) +` + +type FetchKeyPackagesRow struct { + ID []byte + KeyPackage []byte +} + +func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) + if err != nil { + return nil, err + } + defer rows.Close() + var items []FetchKeyPackagesRow + for rows.Next() { + var i FetchKeyPackagesRow + if err := rows.Scan(&i.ID, &i.KeyPackage); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getIdentityUpdates = `-- name: GetIdentityUpdates :many +SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations +WHERE wallet_address IN ($1) +AND (created_at > $2 OR revoked_at > $2) +ORDER BY created_at ASC +` + +type GetIdentityUpdatesParams struct { + WalletAddresses string + StartTime int64 +} + +func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Installation + for rows.Next() { + var i Installation + if err := rows.Scan( + &i.ID, + &i.WalletAddress, + &i.CreatedAt, + &i.UpdatedAt, + &i.CredentialIdentity, + &i.RevokedAt, + &i.KeyPackage, + &i.Expiration, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogFiltered = `-- name: GetInboxLogFiltered :many +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log AS a +JOIN ( + SELECT inbox_id, sequence_id FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) +) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessage) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogFiltered, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const insertGroupMessage = `-- name: InsertGroupMessage :one +INSERT INTO group_messages (group_id, data, group_id_data_hash) +VALUES ($1, $2, $3) +RETURNING id, created_at, group_id, data, group_id_data_hash +` + +type InsertGroupMessageParams struct { + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +func (q *Queries) InsertGroupMessage(ctx context.Context, arg InsertGroupMessageParams) (GroupMessage, error) { + row := q.db.QueryRowContext(ctx, insertGroupMessage, arg.GroupID, arg.Data, arg.GroupIDDataHash) + var i GroupMessage + err := row.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ) + return i, err +} + +const insertInboxLog = `-- name: InsertInboxLog :one +INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) +VALUES ($1, $2, $3) +RETURNING sequence_id +` + +type InsertInboxLogParams struct { + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +func (q *Queries) InsertInboxLog(ctx context.Context, arg InsertInboxLogParams) (int64, error) { + row := q.db.QueryRowContext(ctx, insertInboxLog, arg.InboxID, arg.ServerTimestampNs, arg.IdentityUpdateProto) + var sequence_id int64 + err := row.Scan(&sequence_id) + return sequence_id, err +} + +const insertWelcomeMessage = `-- name: InsertWelcomeMessage :one +INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) +VALUES ($1, $2, $3, $4) +RETURNING id, created_at, installation_key, data, installation_key_data_hash, hpke_public_key +` + +type InsertWelcomeMessageParams struct { + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} + +func (q *Queries) InsertWelcomeMessage(ctx context.Context, arg InsertWelcomeMessageParams) (WelcomeMessage, error) { + row := q.db.QueryRowContext(ctx, insertWelcomeMessage, + arg.InstallationKey, + arg.Data, + arg.InstallationKeyDataHash, + arg.HpkePublicKey, + ) + var i WelcomeMessage + err := row.Scan( + &i.ID, + &i.CreatedAt, + &i.InstallationKey, + &i.Data, + &i.InstallationKeyDataHash, + &i.HpkePublicKey, + ) + return i, err +} + +const queryGroupMessagesAsc = `-- name: QueryGroupMessagesAsc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +ORDER BY id ASC +LIMIT $2 +` + +type QueryGroupMessagesAscParams struct { + GroupID []byte + Numrows int32 +} + +func (q *Queries) QueryGroupMessagesAsc(ctx context.Context, arg QueryGroupMessagesAscParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesAsc, arg.GroupID, arg.Numrows) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesDesc = `-- name: QueryGroupMessagesDesc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +ORDER BY id DESC +LIMIT $2 +` + +type QueryGroupMessagesDescParams struct { + GroupID []byte + Numrows int32 +} + +func (q *Queries) QueryGroupMessagesDesc(ctx context.Context, arg QueryGroupMessagesDescParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesDesc, arg.GroupID, arg.Numrows) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesWithCursorAsc = `-- name: QueryGroupMessagesWithCursorAsc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +AND id > $2 +ORDER BY id ASC +LIMIT $3 +` + +type QueryGroupMessagesWithCursorAscParams struct { + GroupID []byte + ID int64 + Limit int32 +} + +func (q *Queries) QueryGroupMessagesWithCursorAsc(ctx context.Context, arg QueryGroupMessagesWithCursorAscParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesWithCursorAsc, arg.GroupID, arg.ID, arg.Limit) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const queryGroupMessagesWithCursorDesc = `-- name: QueryGroupMessagesWithCursorDesc :many +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +WHERE group_id = $1 +AND id < $2 +ORDER BY id DESC +LIMIT $3 +` + +type QueryGroupMessagesWithCursorDescParams struct { + GroupID []byte + ID int64 + Limit int32 +} + +func (q *Queries) QueryGroupMessagesWithCursorDesc(ctx context.Context, arg QueryGroupMessagesWithCursorDescParams) ([]GroupMessage, error) { + rows, err := q.db.QueryContext(ctx, queryGroupMessagesWithCursorDesc, arg.GroupID, arg.ID, arg.Limit) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GroupMessage + for rows.Next() { + var i GroupMessage + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.GroupID, + &i.Data, + &i.GroupIDDataHash, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const revokeInstallation = `-- name: RevokeInstallation :exec +UPDATE installations +SET revoked_at = $1 +WHERE id = $2 +AND revoked_at IS NULL +` + +type RevokeInstallationParams struct { + RevokedAt sql.NullInt64 + InstallationID []byte +} + +func (q *Queries) RevokeInstallation(ctx context.Context, arg RevokeInstallationParams) error { + _, err := q.db.ExecContext(ctx, revokeInstallation, arg.RevokedAt, arg.InstallationID) + return err +} + +const updateKeyPackage = `-- name: UpdateKeyPackage :execrows +UPDATE installations +SET key_package = $1, updated_at = $2, expiration = $3 +WHERE id = $4 +` + +type UpdateKeyPackageParams struct { + KeyPackage []byte + UpdatedAt int64 + Expiration int64 + ID []byte +} + +func (q *Queries) UpdateKeyPackage(ctx context.Context, arg UpdateKeyPackageParams) (int64, error) { + result, err := q.db.ExecContext(ctx, updateKeyPackage, + arg.KeyPackage, + arg.UpdatedAt, + arg.Expiration, + arg.ID, + ) + if err != nil { + return 0, err + } + return result.RowsAffected() +} diff --git a/pkg/server/pgxdb.go b/pkg/server/pgxdb.go new file mode 100644 index 00000000..20988164 --- /dev/null +++ b/pkg/server/pgxdb.go @@ -0,0 +1,49 @@ +package server + +import ( + "context" + "database/sql" + "fmt" + "time" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" + "github.com/jackc/pgx/v5/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/pgdialect" +) + +func newPgxDb(dsn string, waitForDB, statementTimeout time.Duration) (*sql.DB, error) { + config, err := pgxpool.ParseConfig(dsn) + if err != nil { + return nil, err + } + config.ConnConfig.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol + config.ConnConfig.RuntimeParams["statement_timeout"] = fmt.Sprint(statementTimeout.Milliseconds()) + + dbpool, err := pgxpool.NewWithConfig(context.Background(), config) + if err != nil { + return nil, err + } + db := stdlib.OpenDBFromPool(dbpool) + + waitUntil := time.Now().Add(waitForDB) + + err = db.Ping() + for err != nil && time.Now().Before(waitUntil) { + time.Sleep(3 * time.Second) + err = db.Ping() + } + + return db, nil +} + +func newBunPgxDb(dsn string, waitForDB, statementTimeout time.Duration) (*bun.DB, error) { + pgxDb, err := newPgxDb(dsn, waitForDB, statementTimeout) + if err != nil { + return nil, err + } + + return bun.NewDB(pgxDb, pgdialect.New()), nil +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 13d3e1b9..6dc0e4af 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -231,7 +231,7 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error) var MLSStore *mlsstore.Store if options.MLSStore.DbConnectionString != "" { - if s.mlsDB, err = createBunDB(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout, options.MLSStore.WriteTimeout, options.MLSStore.MaxOpenConns); err != nil { + if s.mlsDB, err = newBunPGXDb(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout); err != nil { return nil, errors.Wrap(err, "creating mls db") } diff --git a/pkg/testing/store.go b/pkg/testing/store.go index bb4c4aff..cb30a27a 100644 --- a/pkg/testing/store.go +++ b/pkg/testing/store.go @@ -5,6 +5,8 @@ import ( "database/sql" "testing" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/stdlib" "github.com/stretchr/testify/require" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect/pgdialect" @@ -36,6 +38,27 @@ func NewDB(t testing.TB) (*sql.DB, string, func()) { } } +func NewPGXDB(t testing.TB) (*sql.DB, string, func()) { + dsn := localTestDBDSNPrefix + localTestDBDSNSuffix + config, err := pgx.ParseConfig(dsn) + require.NoError(t, err) + ctlDB := stdlib.OpenDB(*config) + dbName := "test_" + RandomStringLower(12) + _, err = ctlDB.Exec("CREATE DATABASE " + dbName) + require.NoError(t, err) + + dsn = localTestDBDSNPrefix + "/" + dbName + localTestDBDSNSuffix + config2, err := pgx.ParseConfig(dsn) + require.NoError(t, err) + db := stdlib.OpenDB(*config2) + return db, dsn, func() { + db.Close() + _, err = ctlDB.Exec("DROP DATABASE " + dbName) + require.NoError(t, err) + ctlDB.Close() + } +} + func NewAuthzDB(t testing.TB) (*bun.DB, string, func()) { db, dsn, cleanup := NewDB(t) bunDB := bun.NewDB(db, pgdialect.New()) @@ -51,7 +74,7 @@ func NewAuthzDB(t testing.TB) (*bun.DB, string, func()) { } func NewMLSDB(t *testing.T) (*bun.DB, string, func()) { - db, dsn, cleanup := NewDB(t) + db, dsn, cleanup := NewPGXDB(t) bunDB := bun.NewDB(db, pgdialect.New()) ctx := context.Background() diff --git a/sqlc.yaml b/sqlc.yaml index 527b1566..30575b4c 100644 --- a/sqlc.yaml +++ b/sqlc.yaml @@ -1,11 +1,9 @@ version: "2" sql: - engine: "postgresql" - queries: "pkg/identity/queries.sql" + queries: "pkg/mls/store/queries.sql" schema: "pkg/migrations/mls" - database: - uri: "postgres://postgres:xmtp@localhost:7654/postgres" gen: go: package: "queries" - out: "pkg/identity/queries" + out: "pkg/mls/store/queries" From fa8b6f73e4f69182031a747966d4126432429e07 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:27:54 -0700 Subject: [PATCH 05/24] Migrate first store methods to sqlc --- pkg/mls/store/queries.sql | 4 +- pkg/mls/store/queries/filters.go | 18 +++ pkg/mls/store/queries/queries.sql.go | 14 +- pkg/mls/store/store.go | 209 +++++++++++++-------------- 4 files changed, 127 insertions(+), 118 deletions(-) create mode 100644 pkg/mls/store/queries/filters.go diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 6436fd3b..57b04b4b 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -26,11 +26,11 @@ WHERE id = @id; -- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN (@ids); +WHERE id = ANY (sqlc.arg(installation_ids)::bytea[]); -- name: GetIdentityUpdates :many SELECT * FROM installations -WHERE wallet_address IN (@wallet_addresses) +WHERE wallet_address = ANY (@wallet_addresses::text[]) AND (created_at > @start_time OR revoked_at > @start_time) ORDER BY created_at ASC; diff --git a/pkg/mls/store/queries/filters.go b/pkg/mls/store/queries/filters.go new file mode 100644 index 00000000..38ed8dd6 --- /dev/null +++ b/pkg/mls/store/queries/filters.go @@ -0,0 +1,18 @@ +package queries + +import "encoding/json" + +type InboxLogFilter struct { + InboxId string `json:"inbox_id"` + SequenceId int64 `json:"sequence_id"` +} + +type InboxLogFilterList []InboxLogFilter + +func (f *InboxLogFilterList) ToSql() (json.RawMessage, error) { + jsonBytes, err := json.Marshal(f) + if err != nil { + return nil, err + } + return jsonBytes, nil +} diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 337eebd8..c9556056 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -9,6 +9,8 @@ import ( "context" "database/sql" "encoding/json" + + "github.com/lib/pq" ) const createInstallation = `-- name: CreateInstallation :exec @@ -39,7 +41,7 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation const fetchKeyPackages = `-- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN ($1) +WHERE id = ANY ($1::bytea[]) ` type FetchKeyPackagesRow struct { @@ -47,8 +49,8 @@ type FetchKeyPackagesRow struct { KeyPackage []byte } -func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { - rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) +func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, pq.Array(installationIds)) if err != nil { return nil, err } @@ -106,18 +108,18 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL const getIdentityUpdates = `-- name: GetIdentityUpdates :many SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address IN ($1) +WHERE wallet_address = ANY ($1::text[]) AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` type GetIdentityUpdatesParams struct { - WalletAddresses string + WalletAddresses []string StartTime int64 } func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { - rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, pq.Array(arg.WalletAddresses), arg.StartTime) if err != nil { return nil, err } diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index f26a42d3..9e5f6da5 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -12,6 +12,7 @@ import ( "github.com/uptrace/bun" "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -22,9 +23,10 @@ import ( const maxPageSize = 100 type Store struct { - config Config - log *zap.Logger - db *bun.DB + config Config + log *zap.Logger + db *bun.DB + queries *queries.Queries } type IdentityStore interface { @@ -37,7 +39,7 @@ type MlsStore interface { CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error - FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) + FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) InsertWelcomeMessage(ctx context.Context, installationId []byte, data []byte, hpkePublicKey []byte) (*WelcomeMessage, error) @@ -52,9 +54,10 @@ func New(ctx context.Context, config Config) (*Store, error) { } } s := &Store{ - log: config.Log.Named("mlsstore"), - db: config.DB, - config: config, + log: config.Log.Named("mlsstore"), + db: config.DB, + config: config, + queries: queries.New(config.DB.DB), } if err := s.migrate(ctx); err != nil { @@ -70,54 +73,42 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish return nil, errors.New("IdentityUpdate is required") } - // TODO: Implement serializable isolation level once supported - if err := s.db.RunInTx(ctx, &sql.TxOptions{ /*Isolation: sql.LevelSerializable*/ }, func(ctx context.Context, tx bun.Tx) error { - inbox_log_entries := make([]*InboxLogEntry, 0) - - if err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("inbox_id = ?", new_update.GetInboxId()). - Order("sequence_id ASC"). - For("UPDATE"). - Scan(ctx); err != nil { + if err := s.RunInTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable}, func(ctx context.Context, txQueries *queries.Queries) error { + inboxLogEntries, err := txQueries.GetAllInboxLogs(ctx, new_update.GetInboxId()) + if err != nil { return err } - if len(inbox_log_entries) >= 256 { + if len(inboxLogEntries) >= 256 { return errors.New("inbox log is full") } - updates := make([]*associations.IdentityUpdate, 0, len(inbox_log_entries)+1) - for _, log := range inbox_log_entries { - identity_update := &associations.IdentityUpdate{} - if err := proto.Unmarshal(log.IdentityUpdateProto, identity_update); err != nil { + updates := make([]*associations.IdentityUpdate, 0, len(inboxLogEntries)+1) + for _, log := range inboxLogEntries { + identityUpdate := &associations.IdentityUpdate{} + if err := proto.Unmarshal(log.IdentityUpdateProto, identityUpdate); err != nil { return err } - updates = append(updates, identity_update) + updates = append(updates, identityUpdate) } _ = append(updates, new_update) // TODO: Validate the updates, and abort transaction if failed - proto_bytes, err := proto.Marshal(new_update) + protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - new_entry := InboxLogEntry{ - InboxId: new_update.GetInboxId(), + _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), - IdentityUpdateProto: proto_bytes, - } + IdentityUpdateProto: protoBytes, + }) - _, err = s.db.NewInsert(). - Model(&new_entry). - Returning("sequence_id"). - Exec(ctx) if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id return nil @@ -130,36 +121,47 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) { reqs := batched_req.GetRequests() - resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + filters := make(queries.InboxLogFilterList, len(reqs)) for i, req := range reqs { - inbox_log_entries := make([]*InboxLogEntry, 0) - - err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("sequence_id > ?", req.GetSequenceId()). - Where("inbox_id = ?", req.GetInboxId()). - Order("sequence_id ASC"). - Scan(ctx) - if err != nil { - return nil, err + filters[i] = queries.InboxLogFilter{ + InboxId: req.InboxId, + SequenceId: int64(req.SequenceId), } + } + filterBytes, err := filters.ToSql() + if err != nil { + return nil, err + } - updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(inbox_log_entries)) - for j, entry := range inbox_log_entries { + results, err := s.queries.GetInboxLogFiltered(ctx, filterBytes) + if err != nil { + return nil, err + } + + // Organize the results by inbox ID + resultMap := make(map[string][]queries.InboxLog) + for _, result := range results { + resultMap[result.InboxID] = append(resultMap[result.InboxID], result) + } + + resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + for i, req := range reqs { + logEntries := resultMap[req.InboxId] + updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(logEntries)) + for j, entry := range logEntries { identity_update := &associations.IdentityUpdate{} if err := proto.Unmarshal(entry.IdentityUpdateProto, identity_update); err != nil { return nil, err } updates[j] = &identity.GetIdentityUpdatesResponse_IdentityUpdateLog{ - SequenceId: entry.SequenceId, + SequenceId: uint64(entry.SequenceID), ServerTimestampNs: uint64(entry.ServerTimestampNs), Update: identity_update, } } - resps[i] = &identity.GetIdentityUpdatesResponse_Response{ - InboxId: req.GetInboxId(), + InboxId: req.InboxId, Updates: updates, } } @@ -173,78 +175,45 @@ func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdent func (s *Store) CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error { createdAt := nowNs() - installation := Installation{ + return s.queries.CreateInstallation(ctx, queries.CreateInstallationParams{ ID: installationId, WalletAddress: walletAddress, CreatedAt: createdAt, - UpdatedAt: createdAt, CredentialIdentity: credentialIdentity, - - KeyPackage: keyPackage, - Expiration: expiration, - } - - _, err := s.db.NewInsert(). - Model(&installation). - Ignore(). - Exec(ctx) - return err + KeyPackage: keyPackage, + Expiration: int64(expiration), + }) } // Insert a new key package, ignoring any that may already exist func (s *Store) UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error { - installation := Installation{ - ID: installationId, - UpdatedAt: nowNs(), - + rowsUpdated, err := s.queries.UpdateKeyPackage(ctx, queries.UpdateKeyPackageParams{ + ID: installationId, + UpdatedAt: nowNs(), KeyPackage: keyPackage, - Expiration: expiration, - } + Expiration: int64(expiration), + }) - res, err := s.db.NewUpdate(). - Model(&installation). - OmitZero(). - WherePK(). - Exec(ctx) if err != nil { return err } - rows, err := res.RowsAffected() - if err != nil { - return err - } - if rows == 0 { + + if rowsUpdated == 0 { return errors.New("installation id unknown") } + return nil } -func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) { - installations := make([]*Installation, 0) - - err := s.db.NewSelect(). - Model(&installations). - Where("ID IN (?)", bun.In(installationIds)). - Scan(ctx, &installations) - if err != nil { - return nil, err - } - - return installations, nil +func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) { + return s.queries.FetchKeyPackages(ctx, installationIds) } func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) { - updated := make([]*Installation, 0) - // Find all installations that were changed since the startTimeNs - err := s.db.NewSelect(). - Model(&updated). - Where("wallet_address IN (?)", bun.In(walletAddresses)). - WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery { - return q.Where("created_at > ?", startTimeNs).WhereOr("revoked_at > ?", startTimeNs) - }). - Order("created_at ASC"). - Scan(ctx) - + updated, err := s.queries.GetIdentityUpdates(ctx, queries.GetIdentityUpdatesParams{ + WalletAddresses: walletAddresses, + StartTime: startTimeNs, + }) if err != nil { return nil, err } @@ -260,11 +229,11 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string TimestampNs: uint64(installation.CreatedAt), }) } - if installation.RevokedAt != nil && *installation.RevokedAt > startTimeNs { + if installation.RevokedAt.Valid && installation.RevokedAt.Int64 > startTimeNs { out[installation.WalletAddress] = append(out[installation.WalletAddress], IdentityUpdate{ Kind: Revoke, InstallationKey: installation.ID, - TimestampNs: uint64(*installation.RevokedAt), + TimestampNs: uint64(installation.RevokedAt.Int64), }) } } @@ -277,14 +246,10 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string } func (s *Store) RevokeInstallation(ctx context.Context, installationId []byte) error { - _, err := s.db.NewUpdate(). - Model(&Installation{}). - Set("revoked_at = ?", nowNs()). - Where("id = ?", installationId). - Where("revoked_at IS NULL"). - Exec(ctx) - - return err + return s.queries.RevokeInstallation(ctx, queries.RevokeInstallationParams{ + RevokedAt: sql.NullInt64{Valid: true, Int64: nowNs()}, + InstallationID: installationId, + }) } func (s *Store) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) { @@ -534,3 +499,27 @@ func IsAlreadyExistsError(err error) bool { _, ok := err.(*AlreadyExistsError) return ok } + +func (s *Store) RunInTx( + ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, txQueries *queries.Queries) error, +) error { + tx, err := s.db.DB.BeginTx(ctx, opts) + if err != nil { + return err + } + + var done bool + + defer func() { + if !done { + _ = tx.Rollback() + } + }() + + if err := fn(ctx, s.queries.WithTx(tx)); err != nil { + return err + } + + done = true + return tx.Commit() +} From 7629bc7ee27594d3cee5e0e149a795a18e84ed46 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:27:54 -0700 Subject: [PATCH 06/24] Migrate first store methods to sqlc --- pkg/mls/store/queries.sql | 4 +- pkg/mls/store/queries/filters.go | 18 +++ pkg/mls/store/queries/queries.sql.go | 14 +- pkg/mls/store/store.go | 209 +++++++++++++-------------- 4 files changed, 127 insertions(+), 118 deletions(-) create mode 100644 pkg/mls/store/queries/filters.go diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 6436fd3b..57b04b4b 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -26,11 +26,11 @@ WHERE id = @id; -- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN (@ids); +WHERE id = ANY (sqlc.arg(installation_ids)::bytea[]); -- name: GetIdentityUpdates :many SELECT * FROM installations -WHERE wallet_address IN (@wallet_addresses) +WHERE wallet_address = ANY (@wallet_addresses::text[]) AND (created_at > @start_time OR revoked_at > @start_time) ORDER BY created_at ASC; diff --git a/pkg/mls/store/queries/filters.go b/pkg/mls/store/queries/filters.go new file mode 100644 index 00000000..38ed8dd6 --- /dev/null +++ b/pkg/mls/store/queries/filters.go @@ -0,0 +1,18 @@ +package queries + +import "encoding/json" + +type InboxLogFilter struct { + InboxId string `json:"inbox_id"` + SequenceId int64 `json:"sequence_id"` +} + +type InboxLogFilterList []InboxLogFilter + +func (f *InboxLogFilterList) ToSql() (json.RawMessage, error) { + jsonBytes, err := json.Marshal(f) + if err != nil { + return nil, err + } + return jsonBytes, nil +} diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 337eebd8..c9556056 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -9,6 +9,8 @@ import ( "context" "database/sql" "encoding/json" + + "github.com/lib/pq" ) const createInstallation = `-- name: CreateInstallation :exec @@ -39,7 +41,7 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation const fetchKeyPackages = `-- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN ($1) +WHERE id = ANY ($1::bytea[]) ` type FetchKeyPackagesRow struct { @@ -47,8 +49,8 @@ type FetchKeyPackagesRow struct { KeyPackage []byte } -func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { - rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) +func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, pq.Array(installationIds)) if err != nil { return nil, err } @@ -106,18 +108,18 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL const getIdentityUpdates = `-- name: GetIdentityUpdates :many SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address IN ($1) +WHERE wallet_address = ANY ($1::text[]) AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` type GetIdentityUpdatesParams struct { - WalletAddresses string + WalletAddresses []string StartTime int64 } func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { - rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, pq.Array(arg.WalletAddresses), arg.StartTime) if err != nil { return nil, err } diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index f26a42d3..9e5f6da5 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -12,6 +12,7 @@ import ( "github.com/uptrace/bun" "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -22,9 +23,10 @@ import ( const maxPageSize = 100 type Store struct { - config Config - log *zap.Logger - db *bun.DB + config Config + log *zap.Logger + db *bun.DB + queries *queries.Queries } type IdentityStore interface { @@ -37,7 +39,7 @@ type MlsStore interface { CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error - FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) + FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) InsertWelcomeMessage(ctx context.Context, installationId []byte, data []byte, hpkePublicKey []byte) (*WelcomeMessage, error) @@ -52,9 +54,10 @@ func New(ctx context.Context, config Config) (*Store, error) { } } s := &Store{ - log: config.Log.Named("mlsstore"), - db: config.DB, - config: config, + log: config.Log.Named("mlsstore"), + db: config.DB, + config: config, + queries: queries.New(config.DB.DB), } if err := s.migrate(ctx); err != nil { @@ -70,54 +73,42 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish return nil, errors.New("IdentityUpdate is required") } - // TODO: Implement serializable isolation level once supported - if err := s.db.RunInTx(ctx, &sql.TxOptions{ /*Isolation: sql.LevelSerializable*/ }, func(ctx context.Context, tx bun.Tx) error { - inbox_log_entries := make([]*InboxLogEntry, 0) - - if err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("inbox_id = ?", new_update.GetInboxId()). - Order("sequence_id ASC"). - For("UPDATE"). - Scan(ctx); err != nil { + if err := s.RunInTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable}, func(ctx context.Context, txQueries *queries.Queries) error { + inboxLogEntries, err := txQueries.GetAllInboxLogs(ctx, new_update.GetInboxId()) + if err != nil { return err } - if len(inbox_log_entries) >= 256 { + if len(inboxLogEntries) >= 256 { return errors.New("inbox log is full") } - updates := make([]*associations.IdentityUpdate, 0, len(inbox_log_entries)+1) - for _, log := range inbox_log_entries { - identity_update := &associations.IdentityUpdate{} - if err := proto.Unmarshal(log.IdentityUpdateProto, identity_update); err != nil { + updates := make([]*associations.IdentityUpdate, 0, len(inboxLogEntries)+1) + for _, log := range inboxLogEntries { + identityUpdate := &associations.IdentityUpdate{} + if err := proto.Unmarshal(log.IdentityUpdateProto, identityUpdate); err != nil { return err } - updates = append(updates, identity_update) + updates = append(updates, identityUpdate) } _ = append(updates, new_update) // TODO: Validate the updates, and abort transaction if failed - proto_bytes, err := proto.Marshal(new_update) + protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - new_entry := InboxLogEntry{ - InboxId: new_update.GetInboxId(), + _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), - IdentityUpdateProto: proto_bytes, - } + IdentityUpdateProto: protoBytes, + }) - _, err = s.db.NewInsert(). - Model(&new_entry). - Returning("sequence_id"). - Exec(ctx) if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id return nil @@ -130,36 +121,47 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) { reqs := batched_req.GetRequests() - resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + filters := make(queries.InboxLogFilterList, len(reqs)) for i, req := range reqs { - inbox_log_entries := make([]*InboxLogEntry, 0) - - err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("sequence_id > ?", req.GetSequenceId()). - Where("inbox_id = ?", req.GetInboxId()). - Order("sequence_id ASC"). - Scan(ctx) - if err != nil { - return nil, err + filters[i] = queries.InboxLogFilter{ + InboxId: req.InboxId, + SequenceId: int64(req.SequenceId), } + } + filterBytes, err := filters.ToSql() + if err != nil { + return nil, err + } - updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(inbox_log_entries)) - for j, entry := range inbox_log_entries { + results, err := s.queries.GetInboxLogFiltered(ctx, filterBytes) + if err != nil { + return nil, err + } + + // Organize the results by inbox ID + resultMap := make(map[string][]queries.InboxLog) + for _, result := range results { + resultMap[result.InboxID] = append(resultMap[result.InboxID], result) + } + + resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + for i, req := range reqs { + logEntries := resultMap[req.InboxId] + updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(logEntries)) + for j, entry := range logEntries { identity_update := &associations.IdentityUpdate{} if err := proto.Unmarshal(entry.IdentityUpdateProto, identity_update); err != nil { return nil, err } updates[j] = &identity.GetIdentityUpdatesResponse_IdentityUpdateLog{ - SequenceId: entry.SequenceId, + SequenceId: uint64(entry.SequenceID), ServerTimestampNs: uint64(entry.ServerTimestampNs), Update: identity_update, } } - resps[i] = &identity.GetIdentityUpdatesResponse_Response{ - InboxId: req.GetInboxId(), + InboxId: req.InboxId, Updates: updates, } } @@ -173,78 +175,45 @@ func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdent func (s *Store) CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error { createdAt := nowNs() - installation := Installation{ + return s.queries.CreateInstallation(ctx, queries.CreateInstallationParams{ ID: installationId, WalletAddress: walletAddress, CreatedAt: createdAt, - UpdatedAt: createdAt, CredentialIdentity: credentialIdentity, - - KeyPackage: keyPackage, - Expiration: expiration, - } - - _, err := s.db.NewInsert(). - Model(&installation). - Ignore(). - Exec(ctx) - return err + KeyPackage: keyPackage, + Expiration: int64(expiration), + }) } // Insert a new key package, ignoring any that may already exist func (s *Store) UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error { - installation := Installation{ - ID: installationId, - UpdatedAt: nowNs(), - + rowsUpdated, err := s.queries.UpdateKeyPackage(ctx, queries.UpdateKeyPackageParams{ + ID: installationId, + UpdatedAt: nowNs(), KeyPackage: keyPackage, - Expiration: expiration, - } + Expiration: int64(expiration), + }) - res, err := s.db.NewUpdate(). - Model(&installation). - OmitZero(). - WherePK(). - Exec(ctx) if err != nil { return err } - rows, err := res.RowsAffected() - if err != nil { - return err - } - if rows == 0 { + + if rowsUpdated == 0 { return errors.New("installation id unknown") } + return nil } -func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) { - installations := make([]*Installation, 0) - - err := s.db.NewSelect(). - Model(&installations). - Where("ID IN (?)", bun.In(installationIds)). - Scan(ctx, &installations) - if err != nil { - return nil, err - } - - return installations, nil +func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) { + return s.queries.FetchKeyPackages(ctx, installationIds) } func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) { - updated := make([]*Installation, 0) - // Find all installations that were changed since the startTimeNs - err := s.db.NewSelect(). - Model(&updated). - Where("wallet_address IN (?)", bun.In(walletAddresses)). - WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery { - return q.Where("created_at > ?", startTimeNs).WhereOr("revoked_at > ?", startTimeNs) - }). - Order("created_at ASC"). - Scan(ctx) - + updated, err := s.queries.GetIdentityUpdates(ctx, queries.GetIdentityUpdatesParams{ + WalletAddresses: walletAddresses, + StartTime: startTimeNs, + }) if err != nil { return nil, err } @@ -260,11 +229,11 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string TimestampNs: uint64(installation.CreatedAt), }) } - if installation.RevokedAt != nil && *installation.RevokedAt > startTimeNs { + if installation.RevokedAt.Valid && installation.RevokedAt.Int64 > startTimeNs { out[installation.WalletAddress] = append(out[installation.WalletAddress], IdentityUpdate{ Kind: Revoke, InstallationKey: installation.ID, - TimestampNs: uint64(*installation.RevokedAt), + TimestampNs: uint64(installation.RevokedAt.Int64), }) } } @@ -277,14 +246,10 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string } func (s *Store) RevokeInstallation(ctx context.Context, installationId []byte) error { - _, err := s.db.NewUpdate(). - Model(&Installation{}). - Set("revoked_at = ?", nowNs()). - Where("id = ?", installationId). - Where("revoked_at IS NULL"). - Exec(ctx) - - return err + return s.queries.RevokeInstallation(ctx, queries.RevokeInstallationParams{ + RevokedAt: sql.NullInt64{Valid: true, Int64: nowNs()}, + InstallationID: installationId, + }) } func (s *Store) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) { @@ -534,3 +499,27 @@ func IsAlreadyExistsError(err error) bool { _, ok := err.(*AlreadyExistsError) return ok } + +func (s *Store) RunInTx( + ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, txQueries *queries.Queries) error, +) error { + tx, err := s.db.DB.BeginTx(ctx, opts) + if err != nil { + return err + } + + var done bool + + defer func() { + if !done { + _ = tx.Rollback() + } + }() + + if err := fn(ctx, s.queries.WithTx(tx)); err != nil { + return err + } + + done = true + return tx.Commit() +} From 003476faded42dcf823302489101b7ff40f3cfe3 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:27:54 -0700 Subject: [PATCH 07/24] Migrate first store methods to sqlc --- pkg/mls/store/queries.sql | 4 +- pkg/mls/store/queries/filters.go | 18 +++ pkg/mls/store/queries/queries.sql.go | 14 +- pkg/mls/store/store.go | 209 +++++++++++++-------------- 4 files changed, 127 insertions(+), 118 deletions(-) create mode 100644 pkg/mls/store/queries/filters.go diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 6436fd3b..57b04b4b 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -26,11 +26,11 @@ WHERE id = @id; -- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN (@ids); +WHERE id = ANY (sqlc.arg(installation_ids)::bytea[]); -- name: GetIdentityUpdates :many SELECT * FROM installations -WHERE wallet_address IN (@wallet_addresses) +WHERE wallet_address = ANY (@wallet_addresses::text[]) AND (created_at > @start_time OR revoked_at > @start_time) ORDER BY created_at ASC; diff --git a/pkg/mls/store/queries/filters.go b/pkg/mls/store/queries/filters.go new file mode 100644 index 00000000..38ed8dd6 --- /dev/null +++ b/pkg/mls/store/queries/filters.go @@ -0,0 +1,18 @@ +package queries + +import "encoding/json" + +type InboxLogFilter struct { + InboxId string `json:"inbox_id"` + SequenceId int64 `json:"sequence_id"` +} + +type InboxLogFilterList []InboxLogFilter + +func (f *InboxLogFilterList) ToSql() (json.RawMessage, error) { + jsonBytes, err := json.Marshal(f) + if err != nil { + return nil, err + } + return jsonBytes, nil +} diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 337eebd8..c9556056 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -9,6 +9,8 @@ import ( "context" "database/sql" "encoding/json" + + "github.com/lib/pq" ) const createInstallation = `-- name: CreateInstallation :exec @@ -39,7 +41,7 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation const fetchKeyPackages = `-- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN ($1) +WHERE id = ANY ($1::bytea[]) ` type FetchKeyPackagesRow struct { @@ -47,8 +49,8 @@ type FetchKeyPackagesRow struct { KeyPackage []byte } -func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { - rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) +func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, pq.Array(installationIds)) if err != nil { return nil, err } @@ -106,18 +108,18 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL const getIdentityUpdates = `-- name: GetIdentityUpdates :many SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address IN ($1) +WHERE wallet_address = ANY ($1::text[]) AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` type GetIdentityUpdatesParams struct { - WalletAddresses string + WalletAddresses []string StartTime int64 } func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { - rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, pq.Array(arg.WalletAddresses), arg.StartTime) if err != nil { return nil, err } diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index f26a42d3..9e5f6da5 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -12,6 +12,7 @@ import ( "github.com/uptrace/bun" "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -22,9 +23,10 @@ import ( const maxPageSize = 100 type Store struct { - config Config - log *zap.Logger - db *bun.DB + config Config + log *zap.Logger + db *bun.DB + queries *queries.Queries } type IdentityStore interface { @@ -37,7 +39,7 @@ type MlsStore interface { CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error - FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) + FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) InsertWelcomeMessage(ctx context.Context, installationId []byte, data []byte, hpkePublicKey []byte) (*WelcomeMessage, error) @@ -52,9 +54,10 @@ func New(ctx context.Context, config Config) (*Store, error) { } } s := &Store{ - log: config.Log.Named("mlsstore"), - db: config.DB, - config: config, + log: config.Log.Named("mlsstore"), + db: config.DB, + config: config, + queries: queries.New(config.DB.DB), } if err := s.migrate(ctx); err != nil { @@ -70,54 +73,42 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish return nil, errors.New("IdentityUpdate is required") } - // TODO: Implement serializable isolation level once supported - if err := s.db.RunInTx(ctx, &sql.TxOptions{ /*Isolation: sql.LevelSerializable*/ }, func(ctx context.Context, tx bun.Tx) error { - inbox_log_entries := make([]*InboxLogEntry, 0) - - if err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("inbox_id = ?", new_update.GetInboxId()). - Order("sequence_id ASC"). - For("UPDATE"). - Scan(ctx); err != nil { + if err := s.RunInTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable}, func(ctx context.Context, txQueries *queries.Queries) error { + inboxLogEntries, err := txQueries.GetAllInboxLogs(ctx, new_update.GetInboxId()) + if err != nil { return err } - if len(inbox_log_entries) >= 256 { + if len(inboxLogEntries) >= 256 { return errors.New("inbox log is full") } - updates := make([]*associations.IdentityUpdate, 0, len(inbox_log_entries)+1) - for _, log := range inbox_log_entries { - identity_update := &associations.IdentityUpdate{} - if err := proto.Unmarshal(log.IdentityUpdateProto, identity_update); err != nil { + updates := make([]*associations.IdentityUpdate, 0, len(inboxLogEntries)+1) + for _, log := range inboxLogEntries { + identityUpdate := &associations.IdentityUpdate{} + if err := proto.Unmarshal(log.IdentityUpdateProto, identityUpdate); err != nil { return err } - updates = append(updates, identity_update) + updates = append(updates, identityUpdate) } _ = append(updates, new_update) // TODO: Validate the updates, and abort transaction if failed - proto_bytes, err := proto.Marshal(new_update) + protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - new_entry := InboxLogEntry{ - InboxId: new_update.GetInboxId(), + _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), - IdentityUpdateProto: proto_bytes, - } + IdentityUpdateProto: protoBytes, + }) - _, err = s.db.NewInsert(). - Model(&new_entry). - Returning("sequence_id"). - Exec(ctx) if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id return nil @@ -130,36 +121,47 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) { reqs := batched_req.GetRequests() - resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + filters := make(queries.InboxLogFilterList, len(reqs)) for i, req := range reqs { - inbox_log_entries := make([]*InboxLogEntry, 0) - - err := s.db.NewSelect(). - Model(&inbox_log_entries). - Where("sequence_id > ?", req.GetSequenceId()). - Where("inbox_id = ?", req.GetInboxId()). - Order("sequence_id ASC"). - Scan(ctx) - if err != nil { - return nil, err + filters[i] = queries.InboxLogFilter{ + InboxId: req.InboxId, + SequenceId: int64(req.SequenceId), } + } + filterBytes, err := filters.ToSql() + if err != nil { + return nil, err + } - updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(inbox_log_entries)) - for j, entry := range inbox_log_entries { + results, err := s.queries.GetInboxLogFiltered(ctx, filterBytes) + if err != nil { + return nil, err + } + + // Organize the results by inbox ID + resultMap := make(map[string][]queries.InboxLog) + for _, result := range results { + resultMap[result.InboxID] = append(resultMap[result.InboxID], result) + } + + resps := make([]*identity.GetIdentityUpdatesResponse_Response, len(reqs)) + for i, req := range reqs { + logEntries := resultMap[req.InboxId] + updates := make([]*identity.GetIdentityUpdatesResponse_IdentityUpdateLog, len(logEntries)) + for j, entry := range logEntries { identity_update := &associations.IdentityUpdate{} if err := proto.Unmarshal(entry.IdentityUpdateProto, identity_update); err != nil { return nil, err } updates[j] = &identity.GetIdentityUpdatesResponse_IdentityUpdateLog{ - SequenceId: entry.SequenceId, + SequenceId: uint64(entry.SequenceID), ServerTimestampNs: uint64(entry.ServerTimestampNs), Update: identity_update, } } - resps[i] = &identity.GetIdentityUpdatesResponse_Response{ - InboxId: req.GetInboxId(), + InboxId: req.InboxId, Updates: updates, } } @@ -173,78 +175,45 @@ func (s *Store) GetInboxLogs(ctx context.Context, batched_req *identity.GetIdent func (s *Store) CreateInstallation(ctx context.Context, installationId []byte, walletAddress string, credentialIdentity, keyPackage []byte, expiration uint64) error { createdAt := nowNs() - installation := Installation{ + return s.queries.CreateInstallation(ctx, queries.CreateInstallationParams{ ID: installationId, WalletAddress: walletAddress, CreatedAt: createdAt, - UpdatedAt: createdAt, CredentialIdentity: credentialIdentity, - - KeyPackage: keyPackage, - Expiration: expiration, - } - - _, err := s.db.NewInsert(). - Model(&installation). - Ignore(). - Exec(ctx) - return err + KeyPackage: keyPackage, + Expiration: int64(expiration), + }) } // Insert a new key package, ignoring any that may already exist func (s *Store) UpdateKeyPackage(ctx context.Context, installationId, keyPackage []byte, expiration uint64) error { - installation := Installation{ - ID: installationId, - UpdatedAt: nowNs(), - + rowsUpdated, err := s.queries.UpdateKeyPackage(ctx, queries.UpdateKeyPackageParams{ + ID: installationId, + UpdatedAt: nowNs(), KeyPackage: keyPackage, - Expiration: expiration, - } + Expiration: int64(expiration), + }) - res, err := s.db.NewUpdate(). - Model(&installation). - OmitZero(). - WherePK(). - Exec(ctx) if err != nil { return err } - rows, err := res.RowsAffected() - if err != nil { - return err - } - if rows == 0 { + + if rowsUpdated == 0 { return errors.New("installation id unknown") } + return nil } -func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]*Installation, error) { - installations := make([]*Installation, 0) - - err := s.db.NewSelect(). - Model(&installations). - Where("ID IN (?)", bun.In(installationIds)). - Scan(ctx, &installations) - if err != nil { - return nil, err - } - - return installations, nil +func (s *Store) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]queries.FetchKeyPackagesRow, error) { + return s.queries.FetchKeyPackages(ctx, installationIds) } func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string, startTimeNs int64) (map[string]IdentityUpdateList, error) { - updated := make([]*Installation, 0) - // Find all installations that were changed since the startTimeNs - err := s.db.NewSelect(). - Model(&updated). - Where("wallet_address IN (?)", bun.In(walletAddresses)). - WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery { - return q.Where("created_at > ?", startTimeNs).WhereOr("revoked_at > ?", startTimeNs) - }). - Order("created_at ASC"). - Scan(ctx) - + updated, err := s.queries.GetIdentityUpdates(ctx, queries.GetIdentityUpdatesParams{ + WalletAddresses: walletAddresses, + StartTime: startTimeNs, + }) if err != nil { return nil, err } @@ -260,11 +229,11 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string TimestampNs: uint64(installation.CreatedAt), }) } - if installation.RevokedAt != nil && *installation.RevokedAt > startTimeNs { + if installation.RevokedAt.Valid && installation.RevokedAt.Int64 > startTimeNs { out[installation.WalletAddress] = append(out[installation.WalletAddress], IdentityUpdate{ Kind: Revoke, InstallationKey: installation.ID, - TimestampNs: uint64(*installation.RevokedAt), + TimestampNs: uint64(installation.RevokedAt.Int64), }) } } @@ -277,14 +246,10 @@ func (s *Store) GetIdentityUpdates(ctx context.Context, walletAddresses []string } func (s *Store) RevokeInstallation(ctx context.Context, installationId []byte) error { - _, err := s.db.NewUpdate(). - Model(&Installation{}). - Set("revoked_at = ?", nowNs()). - Where("id = ?", installationId). - Where("revoked_at IS NULL"). - Exec(ctx) - - return err + return s.queries.RevokeInstallation(ctx, queries.RevokeInstallationParams{ + RevokedAt: sql.NullInt64{Valid: true, Int64: nowNs()}, + InstallationID: installationId, + }) } func (s *Store) InsertGroupMessage(ctx context.Context, groupId []byte, data []byte) (*GroupMessage, error) { @@ -534,3 +499,27 @@ func IsAlreadyExistsError(err error) bool { _, ok := err.(*AlreadyExistsError) return ok } + +func (s *Store) RunInTx( + ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, txQueries *queries.Queries) error, +) error { + tx, err := s.db.DB.BeginTx(ctx, opts) + if err != nil { + return err + } + + var done bool + + defer func() { + if !done { + _ = tx.Rollback() + } + }() + + if err := fn(ctx, s.queries.WithTx(tx)); err != nil { + return err + } + + done = true + return tx.Commit() +} From 3e8f57ade0add7da668ecf8db2f170a0233c4ea9 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 08:32:07 -0700 Subject: [PATCH 08/24] Add GetAddressLog SQL --- pkg/mls/store/models.go | 9 ++++ pkg/mls/store/queries.sql | 21 +++++++++ pkg/mls/store/queries/queries.sql.go | 51 ++++++++++++++++++++++ pkg/mls/store/store.go | 32 ++++++++++++++ pkg/mls/store/store_test.go | 64 ++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+) diff --git a/pkg/mls/store/models.go b/pkg/mls/store/models.go index 4ac6342f..47d7145b 100644 --- a/pkg/mls/store/models.go +++ b/pkg/mls/store/models.go @@ -6,6 +6,15 @@ import ( "github.com/uptrace/bun" ) +type AddressLogEntry struct { + bun.BaseModel `bun:"table:address_log"` + + Address string `bun:",notnull"` + InboxId string `bun:",notnull"` + AssociationSequenceId *uint64 `bun:","` + RevocationSequenceId *uint64 `bun:","` +} + type InboxLogEntry struct { bun.BaseModel `bun:"table:inbox_log"` diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 57b04b4b..76bc1375 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -10,6 +10,27 @@ JOIN ( ) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC; +-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY (@addresses::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; + -- name: InsertInboxLog :one INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) VALUES ($1, $2, $3) diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index c9556056..b2ef7b4d 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -72,6 +72,57 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte return items, nil } +const getAddressLogs = `-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY ($1::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +` + +type GetAddressLogsRow struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 +} + +func (q *Queries) GetAddressLogs(ctx context.Context, addresses []string) ([]GetAddressLogsRow, error) { + rows, err := q.db.QueryContext(ctx, getAddressLogs, pq.Array(addresses)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GetAddressLogsRow + for rows.Next() { + var i GetAddressLogsRow + if err := rows.Scan(&i.Address, &i.InboxID, &i.AssociationSequenceID); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getAllInboxLogs = `-- name: GetAllInboxLogs :many SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log WHERE inbox_id = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index 9e5f6da5..db2300da 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -32,6 +32,7 @@ type Store struct { type IdentityStore interface { PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) + GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } type MlsStore interface { @@ -67,6 +68,37 @@ func New(ctx context.Context, config Config) (*Store, error) { return s, nil } +func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) { + + addresses := []string{} + for _, request := range req.Requests { + addresses = append(addresses, request.GetAddress()) + } + + addressLogEntries, err := s.queries.GetAddressLogs(ctx, addresses) + if err != nil { + return nil, err + } + + out := make([]*identity.GetInboxIdsResponse_Response, len(addresses)) + + for index, address := range addresses { + resp := identity.GetInboxIdsResponse_Response{} + resp.Address = address + + for _, log_entry := range addressLogEntries { + if log_entry.Address == address { + resp.InboxId = &log_entry.InboxID + } + } + out[index] = &resp + } + + return &identity.GetInboxIdsResponse{ + Responses: out, + }, nil +} + func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 379584f0..0f74996e 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" + identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" ) @@ -26,6 +27,69 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } +func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { + + entry := AddressLogEntry{ + Address: address, + InboxId: inboxId, + AssociationSequenceId: associationSequenceId, + RevocationSequenceId: nil, + } + ctx := context.Background() + + _, err := store.db.NewInsert(). + Model(&entry). + Exec(ctx) + + return err +} + +func TestInboxIds(t *testing.T) { + store, cleanup := NewTestStore(t) + defer cleanup() + + seq, rev := uint64(1), uint64(5) + err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(2), uint64(8) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(3), uint64(9) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(4), uint64(1) + err = InsertAddressLog(store, "address", "correct", &seq, &rev) + require.NoError(t, err) + + reqs := make([]*identity.GetInboxIdsRequest_Request, 0) + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{ + Address: "address", + }) + req := &identity.GetInboxIdsRequest{ + Requests: reqs, + } + resp, _ := store.GetInboxIds(context.Background(), req) + t.Log(resp) + + require.Equal(t, "correct", *resp.Responses[0].InboxId) + + seq = uint64(5) + err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) + + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{Address: "address2"}) + req = &identity.GetInboxIdsRequest{ + Requests: reqs, + } + seq, rev = uint64(8), uint64(2) + err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "inbox2", *resp.Responses[1].InboxId) +} + func TestCreateInstallation(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() From 2b5d5f89b956b5ac7f2aba006f2410dcc8390e15 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 08:32:07 -0700 Subject: [PATCH 09/24] Add GetAddressLog SQL --- pkg/mls/store/models.go | 9 ++++ pkg/mls/store/queries.sql | 21 +++++++++ pkg/mls/store/queries/queries.sql.go | 51 ++++++++++++++++++++++ pkg/mls/store/store.go | 32 ++++++++++++++ pkg/mls/store/store_test.go | 64 ++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+) diff --git a/pkg/mls/store/models.go b/pkg/mls/store/models.go index 4ac6342f..47d7145b 100644 --- a/pkg/mls/store/models.go +++ b/pkg/mls/store/models.go @@ -6,6 +6,15 @@ import ( "github.com/uptrace/bun" ) +type AddressLogEntry struct { + bun.BaseModel `bun:"table:address_log"` + + Address string `bun:",notnull"` + InboxId string `bun:",notnull"` + AssociationSequenceId *uint64 `bun:","` + RevocationSequenceId *uint64 `bun:","` +} + type InboxLogEntry struct { bun.BaseModel `bun:"table:inbox_log"` diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 57b04b4b..76bc1375 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -10,6 +10,27 @@ JOIN ( ) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC; +-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY (@addresses::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; + -- name: InsertInboxLog :one INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) VALUES ($1, $2, $3) diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index c9556056..b2ef7b4d 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -72,6 +72,57 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte return items, nil } +const getAddressLogs = `-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY ($1::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +` + +type GetAddressLogsRow struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 +} + +func (q *Queries) GetAddressLogs(ctx context.Context, addresses []string) ([]GetAddressLogsRow, error) { + rows, err := q.db.QueryContext(ctx, getAddressLogs, pq.Array(addresses)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GetAddressLogsRow + for rows.Next() { + var i GetAddressLogsRow + if err := rows.Scan(&i.Address, &i.InboxID, &i.AssociationSequenceID); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getAllInboxLogs = `-- name: GetAllInboxLogs :many SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log WHERE inbox_id = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index 9e5f6da5..db2300da 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -32,6 +32,7 @@ type Store struct { type IdentityStore interface { PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) + GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } type MlsStore interface { @@ -67,6 +68,37 @@ func New(ctx context.Context, config Config) (*Store, error) { return s, nil } +func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) { + + addresses := []string{} + for _, request := range req.Requests { + addresses = append(addresses, request.GetAddress()) + } + + addressLogEntries, err := s.queries.GetAddressLogs(ctx, addresses) + if err != nil { + return nil, err + } + + out := make([]*identity.GetInboxIdsResponse_Response, len(addresses)) + + for index, address := range addresses { + resp := identity.GetInboxIdsResponse_Response{} + resp.Address = address + + for _, log_entry := range addressLogEntries { + if log_entry.Address == address { + resp.InboxId = &log_entry.InboxID + } + } + out[index] = &resp + } + + return &identity.GetInboxIdsResponse{ + Responses: out, + }, nil +} + func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 379584f0..0f74996e 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" + identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" ) @@ -26,6 +27,69 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } +func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { + + entry := AddressLogEntry{ + Address: address, + InboxId: inboxId, + AssociationSequenceId: associationSequenceId, + RevocationSequenceId: nil, + } + ctx := context.Background() + + _, err := store.db.NewInsert(). + Model(&entry). + Exec(ctx) + + return err +} + +func TestInboxIds(t *testing.T) { + store, cleanup := NewTestStore(t) + defer cleanup() + + seq, rev := uint64(1), uint64(5) + err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(2), uint64(8) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(3), uint64(9) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(4), uint64(1) + err = InsertAddressLog(store, "address", "correct", &seq, &rev) + require.NoError(t, err) + + reqs := make([]*identity.GetInboxIdsRequest_Request, 0) + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{ + Address: "address", + }) + req := &identity.GetInboxIdsRequest{ + Requests: reqs, + } + resp, _ := store.GetInboxIds(context.Background(), req) + t.Log(resp) + + require.Equal(t, "correct", *resp.Responses[0].InboxId) + + seq = uint64(5) + err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) + + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{Address: "address2"}) + req = &identity.GetInboxIdsRequest{ + Requests: reqs, + } + seq, rev = uint64(8), uint64(2) + err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "inbox2", *resp.Responses[1].InboxId) +} + func TestCreateInstallation(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() From 783c7ac3d7466f03216319ddd343d4e13bea90b9 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 07:36:38 -0700 Subject: [PATCH 10/24] Merge branch '04-24-migrate_first_store_methods_to_sqlc' of github.com:xmtp/xmtp-node-go into 04-24-migrate_first_store_methods_to_sqlc From 7919c2eb28e750a70c036cf61c89729b8e2105ae Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 08:32:07 -0700 Subject: [PATCH 11/24] Add GetAddressLog SQL --- pkg/mls/store/models.go | 9 ++++ pkg/mls/store/queries.sql | 14 ++++++ pkg/mls/store/queries/queries.sql.go | 51 ++++++++++++++++++++++ pkg/mls/store/store.go | 32 ++++++++++++++ pkg/mls/store/store_test.go | 64 ++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+) diff --git a/pkg/mls/store/models.go b/pkg/mls/store/models.go index 4ac6342f..47d7145b 100644 --- a/pkg/mls/store/models.go +++ b/pkg/mls/store/models.go @@ -6,6 +6,15 @@ import ( "github.com/uptrace/bun" ) +type AddressLogEntry struct { + bun.BaseModel `bun:"table:address_log"` + + Address string `bun:",notnull"` + InboxId string `bun:",notnull"` + AssociationSequenceId *uint64 `bun:","` + RevocationSequenceId *uint64 `bun:","` +} + type InboxLogEntry struct { bun.BaseModel `bun:"table:inbox_log"` diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 0246b9fb..71b29f4c 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -13,6 +13,20 @@ FROM inbox_log AS a ) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC; +-- name: GetAddressLogs :many +SELECT a.address, + a.inbox_id, + a.association_sequence_id +FROM address_log a + INNER JOIN ( + SELECT address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM address_log + WHERE address = ANY (@addresses::text []) + AND revocation_sequence_id IS NULL + GROUP BY address + ) b ON a.address = b.address + AND a.association_sequence_id = b.max_association_sequence_id; -- name: InsertInboxLog :one INSERT INTO inbox_log ( inbox_id, diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 8a2d795d..614bf469 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -82,6 +82,57 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte return items, nil } +const getAddressLogs = `-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY ($1::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +` + +type GetAddressLogsRow struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 +} + +func (q *Queries) GetAddressLogs(ctx context.Context, addresses []string) ([]GetAddressLogsRow, error) { + rows, err := q.db.QueryContext(ctx, getAddressLogs, pq.Array(addresses)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GetAddressLogsRow + for rows.Next() { + var i GetAddressLogsRow + if err := rows.Scan(&i.Address, &i.InboxID, &i.AssociationSequenceID); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getAllInboxLogs = `-- name: GetAllInboxLogs :many SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index 9e5f6da5..db2300da 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -32,6 +32,7 @@ type Store struct { type IdentityStore interface { PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) + GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } type MlsStore interface { @@ -67,6 +68,37 @@ func New(ctx context.Context, config Config) (*Store, error) { return s, nil } +func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) { + + addresses := []string{} + for _, request := range req.Requests { + addresses = append(addresses, request.GetAddress()) + } + + addressLogEntries, err := s.queries.GetAddressLogs(ctx, addresses) + if err != nil { + return nil, err + } + + out := make([]*identity.GetInboxIdsResponse_Response, len(addresses)) + + for index, address := range addresses { + resp := identity.GetInboxIdsResponse_Response{} + resp.Address = address + + for _, log_entry := range addressLogEntries { + if log_entry.Address == address { + resp.InboxId = &log_entry.InboxID + } + } + out[index] = &resp + } + + return &identity.GetInboxIdsResponse{ + Responses: out, + }, nil +} + func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 379584f0..0f74996e 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" + identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" ) @@ -26,6 +27,69 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } +func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { + + entry := AddressLogEntry{ + Address: address, + InboxId: inboxId, + AssociationSequenceId: associationSequenceId, + RevocationSequenceId: nil, + } + ctx := context.Background() + + _, err := store.db.NewInsert(). + Model(&entry). + Exec(ctx) + + return err +} + +func TestInboxIds(t *testing.T) { + store, cleanup := NewTestStore(t) + defer cleanup() + + seq, rev := uint64(1), uint64(5) + err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(2), uint64(8) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(3), uint64(9) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(4), uint64(1) + err = InsertAddressLog(store, "address", "correct", &seq, &rev) + require.NoError(t, err) + + reqs := make([]*identity.GetInboxIdsRequest_Request, 0) + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{ + Address: "address", + }) + req := &identity.GetInboxIdsRequest{ + Requests: reqs, + } + resp, _ := store.GetInboxIds(context.Background(), req) + t.Log(resp) + + require.Equal(t, "correct", *resp.Responses[0].InboxId) + + seq = uint64(5) + err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) + + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{Address: "address2"}) + req = &identity.GetInboxIdsRequest{ + Requests: reqs, + } + seq, rev = uint64(8), uint64(2) + err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "inbox2", *resp.Responses[1].InboxId) +} + func TestCreateInstallation(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() From 0129dc5df866e7c4467f49f0a63adaec7ef5d13e Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:59:02 -0700 Subject: [PATCH 12/24] Initial commit --- pkg/identity/queries.sql | 12 +++ pkg/identity/queries/db.go | 31 +++++++ pkg/identity/queries/models.go | 52 ++++++++++++ pkg/identity/queries/queries.sql.go | 80 +++++++++++++++++++ .../mls/20240411200242_init-identity.up.sql | 4 - 5 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 pkg/identity/queries.sql create mode 100644 pkg/identity/queries/db.go create mode 100644 pkg/identity/queries/models.go create mode 100644 pkg/identity/queries/queries.sql.go diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql new file mode 100644 index 00000000..e29e5c5b --- /dev/null +++ b/pkg/identity/queries.sql @@ -0,0 +1,12 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS ( + SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) +) +SELECT a.* FROM inbox_log AS a +JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go new file mode 100644 index 00000000..fa785733 --- /dev/null +++ b/pkg/identity/queries/db.go @@ -0,0 +1,31 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "context" + "database/sql" +) + +type DBTX interface { + ExecContext(context.Context, string, ...interface{}) (sql.Result, error) + PrepareContext(context.Context, string) (*sql.Stmt, error) + QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) + QueryRowContext(context.Context, string, ...interface{}) *sql.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx *sql.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go new file mode 100644 index 00000000..cc2ae9d3 --- /dev/null +++ b/pkg/identity/queries/models.go @@ -0,0 +1,52 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "database/sql" + "time" +) + +type AddressLog struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +type GroupMessage struct { + ID int64 + CreatedAt time.Time + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +type InboxLog struct { + SequenceID int64 + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +type Installation struct { + ID []byte + WalletAddress string + CreatedAt int64 + UpdatedAt int64 + CredentialIdentity []byte + RevokedAt sql.NullInt64 + KeyPackage []byte + Expiration int64 +} + +type WelcomeMessage struct { + ID int64 + CreatedAt time.Time + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go new file mode 100644 index 00000000..5441410f --- /dev/null +++ b/pkg/identity/queries/queries.sql.go @@ -0,0 +1,80 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" +) + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogs = `-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS (VALUES ($1)) +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a +JOIN b ON a.inbox_id = b.inbox_id +WHERE a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} diff --git a/pkg/migrations/mls/20240411200242_init-identity.up.sql b/pkg/migrations/mls/20240411200242_init-identity.up.sql index cc56762e..d3399c0b 100644 --- a/pkg/migrations/mls/20240411200242_init-identity.up.sql +++ b/pkg/migrations/mls/20240411200242_init-identity.up.sql @@ -1,7 +1,6 @@ SET statement_timeout = 0; --bun:split - CREATE TABLE inbox_log ( sequence_id BIGSERIAL PRIMARY KEY, inbox_id TEXT NOT NULL, @@ -10,11 +9,9 @@ CREATE TABLE inbox_log ( ); --bun:split - CREATE INDEX idx_inbox_log_inbox_id ON inbox_log(inbox_id); --bun:split - CREATE TABLE address_log ( address TEXT NOT NULL, inbox_id TEXT NOT NULL, @@ -23,5 +20,4 @@ CREATE TABLE address_log ( ); --bun:split - CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); \ No newline at end of file From 83420c2a8d4356f241fc305dae81d982a3de14c0 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:15:17 -0700 Subject: [PATCH 13/24] Set up sqlc --- pkg/identity/queries.sql | 12 ----- pkg/identity/queries/db.go | 31 ----------- pkg/identity/queries/models.go | 52 ------------------- pkg/identity/queries/queries.sql.go | 80 ----------------------------- 4 files changed, 175 deletions(-) delete mode 100644 pkg/identity/queries.sql delete mode 100644 pkg/identity/queries/db.go delete mode 100644 pkg/identity/queries/models.go delete mode 100644 pkg/identity/queries/queries.sql.go diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql deleted file mode 100644 index e29e5c5b..00000000 --- a/pkg/identity/queries.sql +++ /dev/null @@ -1,12 +0,0 @@ --- name: GetAllInboxLogs :many -SELECT * FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE; - --- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS ( - SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) -) -SELECT a.* FROM inbox_log AS a -JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go deleted file mode 100644 index fa785733..00000000 --- a/pkg/identity/queries/db.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 - -package queries - -import ( - "context" - "database/sql" -) - -type DBTX interface { - ExecContext(context.Context, string, ...interface{}) (sql.Result, error) - PrepareContext(context.Context, string) (*sql.Stmt, error) - QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) - QueryRowContext(context.Context, string, ...interface{}) *sql.Row -} - -func New(db DBTX) *Queries { - return &Queries{db: db} -} - -type Queries struct { - db DBTX -} - -func (q *Queries) WithTx(tx *sql.Tx) *Queries { - return &Queries{ - db: tx, - } -} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go deleted file mode 100644 index cc2ae9d3..00000000 --- a/pkg/identity/queries/models.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 - -package queries - -import ( - "database/sql" - "time" -) - -type AddressLog struct { - Address string - InboxID string - AssociationSequenceID sql.NullInt64 - RevocationSequenceID sql.NullInt64 -} - -type GroupMessage struct { - ID int64 - CreatedAt time.Time - GroupID []byte - Data []byte - GroupIDDataHash []byte -} - -type InboxLog struct { - SequenceID int64 - InboxID string - ServerTimestampNs int64 - IdentityUpdateProto []byte -} - -type Installation struct { - ID []byte - WalletAddress string - CreatedAt int64 - UpdatedAt int64 - CredentialIdentity []byte - RevokedAt sql.NullInt64 - KeyPackage []byte - Expiration int64 -} - -type WelcomeMessage struct { - ID int64 - CreatedAt time.Time - InstallationKey []byte - Data []byte - InstallationKeyDataHash []byte - HpkePublicKey []byte -} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go deleted file mode 100644 index 5441410f..00000000 --- a/pkg/identity/queries/queries.sql.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 -// source: queries.sql - -package queries - -import ( - "context" -) - -const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE -` - -func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getInboxLogs = `-- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS (VALUES ($1)) -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a -JOIN b ON a.inbox_id = b.inbox_id -WHERE a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC -` - -func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} From 57a4ea280ecc026211cef29dedeebb06f49e89da Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 07:59:02 -0700 Subject: [PATCH 14/24] Initial commit --- pkg/identity/queries.sql | 12 +++++ pkg/identity/queries/db.go | 31 +++++++++++ pkg/identity/queries/models.go | 52 +++++++++++++++++++ pkg/identity/queries/queries.sql.go | 80 +++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 pkg/identity/queries.sql create mode 100644 pkg/identity/queries/db.go create mode 100644 pkg/identity/queries/models.go create mode 100644 pkg/identity/queries/queries.sql.go diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql new file mode 100644 index 00000000..e29e5c5b --- /dev/null +++ b/pkg/identity/queries.sql @@ -0,0 +1,12 @@ +-- name: GetAllInboxLogs :many +SELECT * FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE; + +-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS ( + SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) +) +SELECT a.* FROM inbox_log AS a +JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go new file mode 100644 index 00000000..fa785733 --- /dev/null +++ b/pkg/identity/queries/db.go @@ -0,0 +1,31 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "context" + "database/sql" +) + +type DBTX interface { + ExecContext(context.Context, string, ...interface{}) (sql.Result, error) + PrepareContext(context.Context, string) (*sql.Stmt, error) + QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) + QueryRowContext(context.Context, string, ...interface{}) *sql.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx *sql.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go new file mode 100644 index 00000000..cc2ae9d3 --- /dev/null +++ b/pkg/identity/queries/models.go @@ -0,0 +1,52 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package queries + +import ( + "database/sql" + "time" +) + +type AddressLog struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +type GroupMessage struct { + ID int64 + CreatedAt time.Time + GroupID []byte + Data []byte + GroupIDDataHash []byte +} + +type InboxLog struct { + SequenceID int64 + InboxID string + ServerTimestampNs int64 + IdentityUpdateProto []byte +} + +type Installation struct { + ID []byte + WalletAddress string + CreatedAt int64 + UpdatedAt int64 + CredentialIdentity []byte + RevokedAt sql.NullInt64 + KeyPackage []byte + Expiration int64 +} + +type WelcomeMessage struct { + ID int64 + CreatedAt time.Time + InstallationKey []byte + Data []byte + InstallationKeyDataHash []byte + HpkePublicKey []byte +} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go new file mode 100644 index 00000000..5441410f --- /dev/null +++ b/pkg/identity/queries/queries.sql.go @@ -0,0 +1,80 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package queries + +import ( + "context" +) + +const getAllInboxLogs = `-- name: GetAllInboxLogs :many +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +WHERE inbox_id = $1 +ORDER BY sequence_id ASC FOR UPDATE +` + +func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const getInboxLogs = `-- name: GetInboxLogs :many +WITH b (inbox_id, sequence_id) AS (VALUES ($1)) +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a +JOIN b ON a.inbox_id = b.inbox_id +WHERE a.sequence_id > b.sequence_id +ORDER BY a.sequence_id ASC +` + +func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { + rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) + if err != nil { + return nil, err + } + defer rows.Close() + var items []InboxLog + for rows.Next() { + var i InboxLog + if err := rows.Scan( + &i.SequenceID, + &i.InboxID, + &i.ServerTimestampNs, + &i.IdentityUpdateProto, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} From 696e17cdc1f956c6b98c5ed8a2e4b25613158336 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:15:17 -0700 Subject: [PATCH 15/24] Set up sqlc --- pkg/identity/queries.sql | 12 ----- pkg/identity/queries/db.go | 31 ----------- pkg/identity/queries/models.go | 52 ------------------- pkg/identity/queries/queries.sql.go | 80 ----------------------------- pkg/mls/store/queries.sql | 56 +++++++++++++++++--- 5 files changed, 50 insertions(+), 181 deletions(-) delete mode 100644 pkg/identity/queries.sql delete mode 100644 pkg/identity/queries/db.go delete mode 100644 pkg/identity/queries/models.go delete mode 100644 pkg/identity/queries/queries.sql.go diff --git a/pkg/identity/queries.sql b/pkg/identity/queries.sql deleted file mode 100644 index e29e5c5b..00000000 --- a/pkg/identity/queries.sql +++ /dev/null @@ -1,12 +0,0 @@ --- name: GetAllInboxLogs :many -SELECT * FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE; - --- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS ( - SELECT * FROM unnest(@filters::record[]) AS (inbox_id TEXT, sequence_id BIGINT) -) -SELECT a.* FROM inbox_log AS a -JOIN b ON a.inbox_id = b.inbox_id AND a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC; \ No newline at end of file diff --git a/pkg/identity/queries/db.go b/pkg/identity/queries/db.go deleted file mode 100644 index fa785733..00000000 --- a/pkg/identity/queries/db.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 - -package queries - -import ( - "context" - "database/sql" -) - -type DBTX interface { - ExecContext(context.Context, string, ...interface{}) (sql.Result, error) - PrepareContext(context.Context, string) (*sql.Stmt, error) - QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) - QueryRowContext(context.Context, string, ...interface{}) *sql.Row -} - -func New(db DBTX) *Queries { - return &Queries{db: db} -} - -type Queries struct { - db DBTX -} - -func (q *Queries) WithTx(tx *sql.Tx) *Queries { - return &Queries{ - db: tx, - } -} diff --git a/pkg/identity/queries/models.go b/pkg/identity/queries/models.go deleted file mode 100644 index cc2ae9d3..00000000 --- a/pkg/identity/queries/models.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 - -package queries - -import ( - "database/sql" - "time" -) - -type AddressLog struct { - Address string - InboxID string - AssociationSequenceID sql.NullInt64 - RevocationSequenceID sql.NullInt64 -} - -type GroupMessage struct { - ID int64 - CreatedAt time.Time - GroupID []byte - Data []byte - GroupIDDataHash []byte -} - -type InboxLog struct { - SequenceID int64 - InboxID string - ServerTimestampNs int64 - IdentityUpdateProto []byte -} - -type Installation struct { - ID []byte - WalletAddress string - CreatedAt int64 - UpdatedAt int64 - CredentialIdentity []byte - RevokedAt sql.NullInt64 - KeyPackage []byte - Expiration int64 -} - -type WelcomeMessage struct { - ID int64 - CreatedAt time.Time - InstallationKey []byte - Data []byte - InstallationKeyDataHash []byte - HpkePublicKey []byte -} diff --git a/pkg/identity/queries/queries.sql.go b/pkg/identity/queries/queries.sql.go deleted file mode 100644 index 5441410f..00000000 --- a/pkg/identity/queries/queries.sql.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.26.0 -// source: queries.sql - -package queries - -import ( - "context" -) - -const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log -WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE -` - -func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getAllInboxLogs, inboxID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const getInboxLogs = `-- name: GetInboxLogs :many -WITH b (inbox_id, sequence_id) AS (VALUES ($1)) -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log as a -JOIN b ON a.inbox_id = b.inbox_id -WHERE a.sequence_id > b.sequence_id -ORDER BY a.sequence_id ASC -` - -func (q *Queries) GetInboxLogs(ctx context.Context, filters interface{}) ([]InboxLog, error) { - rows, err := q.db.QueryContext(ctx, getInboxLogs, filters) - if err != nil { - return nil, err - } - defer rows.Close() - var items []InboxLog - for rows.Next() { - var i InboxLog - if err := rows.Scan( - &i.SequenceID, - &i.InboxID, - &i.ServerTimestampNs, - &i.IdentityUpdateProto, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 7bd43e35..f0a039ae 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -62,50 +62,94 @@ ORDER BY created_at ASC; -- name: RevokeInstallation :exec UPDATE installations SET revoked_at = @revoked_at -WHERE id = @installation_id +WHERE id = @installation_id << << << < HEAD AND revoked_at IS NULL; --- name: InsertGroupMessage :one +== == == = +AND revoked_at IS NULL; + +>> >> >> > a99c43b ( + Set up sqlc +) -- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3) RETURNING *; -- name: InsertWelcomeMessage :one +<< << << < HEAD INSERT INTO welcome_messages ( installation_key, data, installation_key_data_hash, hpke_public_key + ) == == == = +INSERT INTO welcome_messages ( + installation_key, + data, + installation_key_data_hash, + hpke_public_key + ) >> >> >> > a99c43b ( + Set up sqlc ) VALUES ($1, $2, $3, $4) RETURNING *; -- name: QueryGroupMessagesAsc :many +<< << << < HEAD SELECT * -FROM group_messages +FROM group_messages == == == = +SELECT * +FROM group_messages >> >> >> > a99c43b ( + Set up sqlc + ) WHERE group_id = @group_id ORDER BY id ASC LIMIT @numrows; -- name: QueryGroupMessagesDesc :many +<< << << < HEAD SELECT * -FROM group_messages +FROM group_messages == == == = +SELECT * +FROM group_messages >> >> >> > a99c43b ( + Set up sqlc + ) WHERE group_id = @group_id ORDER BY id DESC LIMIT @numrows; -- name: QueryGroupMessagesWithCursorAsc :many +<< << << < HEAD SELECT * FROM group_messages WHERE group_id = $1 - AND id > $2 + AND id > $2 == == == = +SELECT * +FROM group_messages +WHERE group_id = $1 + AND id > $2 >> >> >> > a99c43b ( + Set up sqlc + ) ORDER BY id ASC LIMIT $3; -- name: QueryGroupMessagesWithCursorDesc :many +<< << << < HEAD +SELECT * +FROM group_messages +WHERE group_id = $1 + AND id < $2 +ORDER BY id DESC +LIMIT $3; + +== == == = SELECT * FROM group_messages WHERE group_id = $1 AND id < $2 ORDER BY id DESC -LIMIT $3; \ No newline at end of file +LIMIT $3; + +>> >> >> > a99c43b ( + Set up sqlc +) \ No newline at end of file From 065a73c62c39adfff7b88e494c5a84908bba5bdf Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 25 Apr 2024 17:13:39 -0400 Subject: [PATCH 16/24] Add InsertLog Query (#383) * Add insertlog query * validation service * insert log * revocation for removed members * lint * remove unnecessary log * change test to use query from sqlc * remove comments * fix tests --- pkg/identity/api/v1/identity_service.go | 6 +-- pkg/identity/api/v1/identity_service_test.go | 22 +++++++- pkg/mls/store/queries.sql | 15 ++++++ pkg/mls/store/queries/db.go | 2 +- pkg/mls/store/queries/models.go | 2 +- pkg/mls/store/queries/queries.sql.go | 54 +++++++++++++++++++- pkg/mls/store/store.go | 45 ++++++++++++++-- pkg/mls/store/store_test.go | 39 ++++---------- 8 files changed, 142 insertions(+), 43 deletions(-) diff --git a/pkg/identity/api/v1/identity_service.go b/pkg/identity/api/v1/identity_service.go index 7f36b31d..8c1459be 100644 --- a/pkg/identity/api/v1/identity_service.go +++ b/pkg/identity/api/v1/identity_service.go @@ -7,8 +7,6 @@ import ( "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" api "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type Service struct { @@ -78,7 +76,7 @@ Start transaction (SERIALIZABLE isolation level) End transaction */ func (s *Service) PublishIdentityUpdate(ctx context.Context, req *api.PublishIdentityUpdateRequest) (*api.PublishIdentityUpdateResponse, error) { - return s.store.PublishIdentityUpdate(ctx, req) + return s.store.PublishIdentityUpdate(ctx, req, s.validationService) } func (s *Service) GetIdentityUpdates(ctx context.Context, req *api.GetIdentityUpdatesRequest) (*api.GetIdentityUpdatesResponse, error) { @@ -97,5 +95,5 @@ func (s *Service) GetInboxIds(ctx context.Context, req *api.GetInboxIdsRequest) for the address where revocation_sequence_id is lower or NULL 2. Return the value of the 'inbox_id' column */ - return nil, status.Errorf(codes.Unimplemented, "unimplemented") + return s.store.GetInboxIds(ctx, req) } diff --git a/pkg/identity/api/v1/identity_service_test.go b/pkg/identity/api/v1/identity_service_test.go index d0a7d2c4..24d49a4c 100644 --- a/pkg/identity/api/v1/identity_service_test.go +++ b/pkg/identity/api/v1/identity_service_test.go @@ -20,7 +20,27 @@ type mockedMLSValidationService struct { } func (m *mockedMLSValidationService) GetAssociationState(ctx context.Context, oldUpdates []*associations.IdentityUpdate, newUpdates []*associations.IdentityUpdate) (*mlsvalidate.AssociationStateResult, error) { - return nil, nil + + member_map := make([]*associations.MemberMap, 0) + member_map = append(member_map, &associations.MemberMap{ + Key: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "key_address"}}, + Value: &associations.Member{ + Identifier: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "ident"}}, + AddedByEntity: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "added_by_entity"}}, + }, + }) + + new_members := make([]*associations.MemberIdentifier, 0) + + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x01"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x02"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x03"}}) + + out := mlsvalidate.AssociationStateResult{ + AssociationState: &associations.AssociationState{InboxId: "test_inbox", Members: member_map, RecoveryAddress: "recovery", SeenSignatures: [][]byte{[]byte("seen"), []byte("sig")}}, + StateDiff: &associations.AssociationStateDiff{NewMembers: new_members, RemovedMembers: nil}, + } + return &out, nil } func (m *mockedMLSValidationService) ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]mlsvalidate.IdentityValidationResult, error) { diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 8b1e6a4d..b516916b 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -30,6 +30,11 @@ FROM address_log a ) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; +-- name: InsertAddressLog :one +INSERT INTO address_log (address, inbox_id, association_sequence_id, revocation_sequence_id) +VALUES ($1, $2, $3, $4) +RETURNING *; + -- name: InsertInboxLog :one INSERT INTO inbox_log ( inbox_id, @@ -39,6 +44,16 @@ INSERT INTO inbox_log ( VALUES ($1, $2, $3) RETURNING sequence_id; +-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, inbox_id, MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 AND a.inbox_id = $3 + GROUP BY address, inbox_id +); + -- name: CreateInstallation :exec INSERT INTO installations ( id, diff --git a/pkg/mls/store/queries/db.go b/pkg/mls/store/queries/db.go index fa785733..ef8b0c29 100644 --- a/pkg/mls/store/queries/db.go +++ b/pkg/mls/store/queries/db.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package queries diff --git a/pkg/mls/store/queries/models.go b/pkg/mls/store/queries/models.go index cc2ae9d3..711ac5b8 100644 --- a/pkg/mls/store/queries/models.go +++ b/pkg/mls/store/queries/models.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package queries diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 614bf469..090c1a4e 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 // source: queries.sql package queries @@ -256,6 +256,36 @@ func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessa return items, nil } +const insertAddressLog = `-- name: InsertAddressLog :one +INSERT INTO address_log (address, inbox_id, association_sequence_id, revocation_sequence_id) +VALUES ($1, $2, $3, $4) +RETURNING address, inbox_id, association_sequence_id, revocation_sequence_id +` + +type InsertAddressLogParams struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +func (q *Queries) InsertAddressLog(ctx context.Context, arg InsertAddressLogParams) (AddressLog, error) { + row := q.db.QueryRowContext(ctx, insertAddressLog, + arg.Address, + arg.InboxID, + arg.AssociationSequenceID, + arg.RevocationSequenceID, + ) + var i AddressLog + err := row.Scan( + &i.Address, + &i.InboxID, + &i.AssociationSequenceID, + &i.RevocationSequenceID, + ) + return i, err +} + const insertGroupMessage = `-- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3) @@ -513,6 +543,28 @@ func (q *Queries) QueryGroupMessagesWithCursorDesc(ctx context.Context, arg Quer return items, nil } +const revokeAddressFromLog = `-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, inbox_id, MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 AND a.inbox_id = $3 + GROUP BY address, inbox_id +) +` + +type RevokeAddressFromLogParams struct { + RevocationSequenceID sql.NullInt64 + Address string + InboxID string +} + +func (q *Queries) RevokeAddressFromLog(ctx context.Context, arg RevokeAddressFromLogParams) error { + _, err := q.db.ExecContext(ctx, revokeAddressFromLog, arg.RevocationSequenceID, arg.Address, arg.InboxID) + return err +} + const revokeInstallation = `-- name: RevokeInstallation :exec UPDATE installations SET revoked_at = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index db2300da..172579fd 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -13,6 +13,7 @@ import ( "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" + "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -30,7 +31,7 @@ type Store struct { } type IdentityStore interface { - PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) + PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } @@ -99,7 +100,7 @@ func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsReques }, nil } -func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { +func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { return nil, errors.New("IdentityUpdate is required") @@ -125,23 +126,57 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish } _ = append(updates, new_update) - // TODO: Validate the updates, and abort transaction if failed + state, err := validationService.GetAssociationState(ctx, updates, []*associations.IdentityUpdate{new_update}) + if err != nil { + return err + } + s.log.Info("Got association state", zap.Any("state", state)) protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + sequence_id, err := txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), IdentityUpdateProto: protoBytes, }) + s.log.Info("Inserted inbox log", zap.Any("sequence_id", sequence_id)) + if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id + + for _, new_member := range state.StateDiff.NewMembers { + s.log.Info("New member", zap.Any("member", new_member)) + if address, ok := new_member.Kind.(*associations.MemberIdentifier_Address); ok { + _, err = txQueries.InsertAddressLog(ctx, queries.InsertAddressLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + AssociationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + RevocationSequenceID: sql.NullInt64{Valid: false}, + }) + if err != nil { + return err + } + } + } + + for _, removed_member := range state.StateDiff.RemovedMembers { + s.log.Info("New member", zap.Any("member", removed_member)) + if address, ok := removed_member.Kind.(*associations.MemberIdentifier_Address); ok { + err = txQueries.RevokeAddressFromLog(ctx, queries.RevokeAddressFromLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + RevocationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + }) + if err != nil { + return err + } + } + } return nil }); err != nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 0f74996e..112776b9 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -2,11 +2,13 @@ package store import ( "context" + "database/sql" "sort" "testing" "time" "github.com/stretchr/testify/require" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" @@ -27,38 +29,18 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } -func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { - - entry := AddressLogEntry{ - Address: address, - InboxId: inboxId, - AssociationSequenceId: associationSequenceId, - RevocationSequenceId: nil, - } - ctx := context.Background() - - _, err := store.db.NewInsert(). - Model(&entry). - Exec(ctx) - - return err -} - func TestInboxIds(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() + ctx := context.Background() - seq, rev := uint64(1), uint64(5) - err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err := store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 1}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(2), uint64(8) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 2}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(3), uint64(9) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 3}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(4), uint64(1) - err = InsertAddressLog(store, "address", "correct", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 4}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) reqs := make([]*identity.GetInboxIdsRequest_Request, 0) @@ -69,12 +51,10 @@ func TestInboxIds(t *testing.T) { Requests: reqs, } resp, _ := store.GetInboxIds(context.Background(), req) - t.Log(resp) require.Equal(t, "correct", *resp.Responses[0].InboxId) - seq = uint64(5) - err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct_inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 5}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) @@ -83,8 +63,7 @@ func TestInboxIds(t *testing.T) { req = &identity.GetInboxIdsRequest{ Requests: reqs, } - seq, rev = uint64(8), uint64(2) - err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address2", InboxID: "inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 8}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "inbox2", *resp.Responses[1].InboxId) From e3ee7a13576df3900b175aedf9c3793498a91de7 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:27:54 -0700 Subject: [PATCH 17/24] Migrate first store methods to sqlc --- pkg/mls/store/queries.sql | 56 +++----------------- pkg/mls/store/queries/queries.sql.go | 78 ++++++++-------------------- 2 files changed, 28 insertions(+), 106 deletions(-) diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index f0a039ae..7bd43e35 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -62,94 +62,50 @@ ORDER BY created_at ASC; -- name: RevokeInstallation :exec UPDATE installations SET revoked_at = @revoked_at -WHERE id = @installation_id << << << < HEAD +WHERE id = @installation_id AND revoked_at IS NULL; -== == == = -AND revoked_at IS NULL; - ->> >> >> > a99c43b ( - Set up sqlc -) -- name: InsertGroupMessage :one +-- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3) RETURNING *; -- name: InsertWelcomeMessage :one -<< << << < HEAD INSERT INTO welcome_messages ( installation_key, data, installation_key_data_hash, hpke_public_key - ) == == == = -INSERT INTO welcome_messages ( - installation_key, - data, - installation_key_data_hash, - hpke_public_key - ) >> >> >> > a99c43b ( - Set up sqlc ) VALUES ($1, $2, $3, $4) RETURNING *; -- name: QueryGroupMessagesAsc :many -<< << << < HEAD -SELECT * -FROM group_messages == == == = SELECT * -FROM group_messages >> >> >> > a99c43b ( - Set up sqlc - ) +FROM group_messages WHERE group_id = @group_id ORDER BY id ASC LIMIT @numrows; -- name: QueryGroupMessagesDesc :many -<< << << < HEAD -SELECT * -FROM group_messages == == == = SELECT * -FROM group_messages >> >> >> > a99c43b ( - Set up sqlc - ) +FROM group_messages WHERE group_id = @group_id ORDER BY id DESC LIMIT @numrows; -- name: QueryGroupMessagesWithCursorAsc :many -<< << << < HEAD SELECT * FROM group_messages WHERE group_id = $1 - AND id > $2 == == == = -SELECT * -FROM group_messages -WHERE group_id = $1 - AND id > $2 >> >> >> > a99c43b ( - Set up sqlc - ) + AND id > $2 ORDER BY id ASC LIMIT $3; -- name: QueryGroupMessagesWithCursorDesc :many -<< << << < HEAD -SELECT * -FROM group_messages -WHERE group_id = $1 - AND id < $2 -ORDER BY id DESC -LIMIT $3; - -== == == = SELECT * FROM group_messages WHERE group_id = $1 AND id < $2 ORDER BY id DESC -LIMIT $3; - ->> >> >> > a99c43b ( - Set up sqlc -) \ No newline at end of file +LIMIT $3; \ No newline at end of file diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 8a2d795d..c9556056 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -14,15 +14,7 @@ import ( ) const createInstallation = `-- name: CreateInstallation :exec -INSERT INTO installations ( - id, - wallet_address, - created_at, - updated_at, - credential_identity, - key_package, - expiration - ) +INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) VALUES ($1, $2, $3, $3, $4, $5, $6) ` @@ -48,10 +40,8 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation } const fetchKeyPackages = `-- name: FetchKeyPackages :many -SELECT id, - key_package -FROM installations -WHERE id = ANY ($1::bytea []) +SELECT id, key_package FROM installations +WHERE id = ANY ($1::bytea[]) ` type FetchKeyPackagesRow struct { @@ -83,11 +73,9 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte } const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto -FROM inbox_log +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR -UPDATE +ORDER BY sequence_id ASC FOR UPDATE ` func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { @@ -119,13 +107,9 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL } const getIdentityUpdates = `-- name: GetIdentityUpdates :many -SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration -FROM installations -WHERE wallet_address = ANY ($1::text []) - AND ( - created_at > $2 - OR revoked_at > $2 - ) +SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations +WHERE wallet_address = ANY ($1::text[]) +AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` @@ -167,13 +151,10 @@ func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdates } const getInboxLogFiltered = `-- name: GetInboxLogFiltered :many -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto -FROM inbox_log AS a - JOIN ( - SELECT inbox_id, sequence_id - FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) - ) as b on b.inbox_id = a.inbox_id - AND a.sequence_id > b.sequence_id +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log AS a +JOIN ( + SELECT inbox_id, sequence_id FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) +) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC ` @@ -231,11 +212,7 @@ func (q *Queries) InsertGroupMessage(ctx context.Context, arg InsertGroupMessage } const insertInboxLog = `-- name: InsertInboxLog :one -INSERT INTO inbox_log ( - inbox_id, - server_timestamp_ns, - identity_update_proto - ) +INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) VALUES ($1, $2, $3) RETURNING sequence_id ` @@ -254,12 +231,7 @@ func (q *Queries) InsertInboxLog(ctx context.Context, arg InsertInboxLogParams) } const insertWelcomeMessage = `-- name: InsertWelcomeMessage :one -INSERT INTO welcome_messages ( - installation_key, - data, - installation_key_data_hash, - hpke_public_key - ) +INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) VALUES ($1, $2, $3, $4) RETURNING id, created_at, installation_key, data, installation_key_data_hash, hpke_public_key ` @@ -291,8 +263,7 @@ func (q *Queries) InsertWelcomeMessage(ctx context.Context, arg InsertWelcomeMes } const queryGroupMessagesAsc = `-- name: QueryGroupMessagesAsc :many -SELECT id, created_at, group_id, data, group_id_data_hash -FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages WHERE group_id = $1 ORDER BY id ASC LIMIT $2 @@ -333,8 +304,7 @@ func (q *Queries) QueryGroupMessagesAsc(ctx context.Context, arg QueryGroupMessa } const queryGroupMessagesDesc = `-- name: QueryGroupMessagesDesc :many -SELECT id, created_at, group_id, data, group_id_data_hash -FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages WHERE group_id = $1 ORDER BY id DESC LIMIT $2 @@ -375,10 +345,9 @@ func (q *Queries) QueryGroupMessagesDesc(ctx context.Context, arg QueryGroupMess } const queryGroupMessagesWithCursorAsc = `-- name: QueryGroupMessagesWithCursorAsc :many -SELECT id, created_at, group_id, data, group_id_data_hash -FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages WHERE group_id = $1 - AND id > $2 +AND id > $2 ORDER BY id ASC LIMIT $3 ` @@ -419,10 +388,9 @@ func (q *Queries) QueryGroupMessagesWithCursorAsc(ctx context.Context, arg Query } const queryGroupMessagesWithCursorDesc = `-- name: QueryGroupMessagesWithCursorDesc :many -SELECT id, created_at, group_id, data, group_id_data_hash -FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages WHERE group_id = $1 - AND id < $2 +AND id < $2 ORDER BY id DESC LIMIT $3 ` @@ -466,7 +434,7 @@ const revokeInstallation = `-- name: RevokeInstallation :exec UPDATE installations SET revoked_at = $1 WHERE id = $2 - AND revoked_at IS NULL +AND revoked_at IS NULL ` type RevokeInstallationParams struct { @@ -481,9 +449,7 @@ func (q *Queries) RevokeInstallation(ctx context.Context, arg RevokeInstallation const updateKeyPackage = `-- name: UpdateKeyPackage :execrows UPDATE installations -SET key_package = $1, - updated_at = $2, - expiration = $3 +SET key_package = $1, updated_at = $2, expiration = $3 WHERE id = $4 ` From f420c3989f962e54cadc3385ee710fce04059de5 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:28:09 -0700 Subject: [PATCH 18/24] Migrate MLS DB To SQLC (#380) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bun has been bothering me for a while, so I've been working on a migration that will get rid of our ORM altogether and just use boring SQL queries for everything. [`sqlc`](https://sqlc.dev/) is a very slick tool to generate code based on plain SQL queries using placeholders for arguments. It's not perfect...I had to do some gymnastics to make a few of the query types work. But the fact that there is no runtime other than the standard SQL driver and some generated code outweighs its limitations IMO. There's no fancy ORM library to worry about mangling your queries, and the learning curve is basically just "how well do you know SQL". - No support for serializable transactions - The SQL driver is not as well maintained as PGX - High learning curve to build complex queries, even if you know SQL well - Relations system is not very powerful and ends up doing N+1 queries a lot of the time. - Configuring the database with struct tags is errorprone, and there aren't great checks to make sure the struct tags actually match the schema. - I can't find a good way to have dynamic ORDER BY expressions. So I literally have separate queries for ASC and DESC versions. It's not the end of the world, but it's very frustrating. There's an [issue to fix it](https://github.com/sqlc-dev/sqlc/issues/2061), and some hacky workarounds using CASE statements, but it's not great. - Making the filters play nice with `json_populate_recordset` is a bit of a pain. Switching to the `pgx` driver helped, since I think there was a bug in Bun's pgdriver. We use Bun in a lot of places and for a lot of things today. - It powers the `authz` database and all the migrations there - It powers the migrations for the `message` database (but not the queries) - It powers the `mls` database and all the queries in the `mlsstore`. The priority right now is to remove it from the `mlsstore`. We will still use it for migrations (`sqlc` can read Bun migrations just fine). This involves replacing the bun `pgdriver` with `pgx` (done in this PR) and replacing all the Bun ORM queries with `sqlc` queries. I have most of the queries written, but I'll split up the actual migration over several PRs. This can be done incrementally, but once the process is complete we can delete the Bun models. We aren't using any of the fancy `sqlc` cloud features and have no plans to. Ummmm. 😬. That was me. --- pkg/mls/store/queries/queries.sql.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index c9556056..337eebd8 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -9,8 +9,6 @@ import ( "context" "database/sql" "encoding/json" - - "github.com/lib/pq" ) const createInstallation = `-- name: CreateInstallation :exec @@ -41,7 +39,7 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation const fetchKeyPackages = `-- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE id = ANY ($1::bytea[]) +WHERE ID IN ($1) ` type FetchKeyPackagesRow struct { @@ -49,8 +47,8 @@ type FetchKeyPackagesRow struct { KeyPackage []byte } -func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]FetchKeyPackagesRow, error) { - rows, err := q.db.QueryContext(ctx, fetchKeyPackages, pq.Array(installationIds)) +func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) if err != nil { return nil, err } @@ -108,18 +106,18 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL const getIdentityUpdates = `-- name: GetIdentityUpdates :many SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address = ANY ($1::text[]) +WHERE wallet_address IN ($1) AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` type GetIdentityUpdatesParams struct { - WalletAddresses []string + WalletAddresses string StartTime int64 } func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { - rows, err := q.db.QueryContext(ctx, getIdentityUpdates, pq.Array(arg.WalletAddresses), arg.StartTime) + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) if err != nil { return nil, err } From f87e45c2a346f41eab3fd87c7cd861669fed5c6f Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:27:54 -0700 Subject: [PATCH 19/24] Migrate first store methods to sqlc --- pkg/mls/store/queries/queries.sql.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 337eebd8..c9556056 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -9,6 +9,8 @@ import ( "context" "database/sql" "encoding/json" + + "github.com/lib/pq" ) const createInstallation = `-- name: CreateInstallation :exec @@ -39,7 +41,7 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation const fetchKeyPackages = `-- name: FetchKeyPackages :many SELECT id, key_package FROM installations -WHERE ID IN ($1) +WHERE id = ANY ($1::bytea[]) ` type FetchKeyPackagesRow struct { @@ -47,8 +49,8 @@ type FetchKeyPackagesRow struct { KeyPackage []byte } -func (q *Queries) FetchKeyPackages(ctx context.Context, ids []byte) ([]FetchKeyPackagesRow, error) { - rows, err := q.db.QueryContext(ctx, fetchKeyPackages, ids) +func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte) ([]FetchKeyPackagesRow, error) { + rows, err := q.db.QueryContext(ctx, fetchKeyPackages, pq.Array(installationIds)) if err != nil { return nil, err } @@ -106,18 +108,18 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL const getIdentityUpdates = `-- name: GetIdentityUpdates :many SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address IN ($1) +WHERE wallet_address = ANY ($1::text[]) AND (created_at > $2 OR revoked_at > $2) ORDER BY created_at ASC ` type GetIdentityUpdatesParams struct { - WalletAddresses string + WalletAddresses []string StartTime int64 } func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdatesParams) ([]Installation, error) { - rows, err := q.db.QueryContext(ctx, getIdentityUpdates, arg.WalletAddresses, arg.StartTime) + rows, err := q.db.QueryContext(ctx, getIdentityUpdates, pq.Array(arg.WalletAddresses), arg.StartTime) if err != nil { return nil, err } From 40b36b02a7f26352569ad5b10ed839802347bfde Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 25 Apr 2024 17:13:39 -0400 Subject: [PATCH 20/24] Add InsertLog Query (#383) * Add insertlog query * validation service * insert log * revocation for removed members * lint * remove unnecessary log * change test to use query from sqlc * remove comments * fix tests --- pkg/identity/api/v1/identity_service.go | 6 +- pkg/identity/api/v1/identity_service_test.go | 22 ++++- pkg/mls/store/queries.sql | 24 ++++++ pkg/mls/store/queries/queries.sql.go | 89 ++++++++++++++++---- pkg/mls/store/store.go | 45 ++++++++-- pkg/mls/store/store_test.go | 39 ++------- 6 files changed, 168 insertions(+), 57 deletions(-) diff --git a/pkg/identity/api/v1/identity_service.go b/pkg/identity/api/v1/identity_service.go index 7f36b31d..8c1459be 100644 --- a/pkg/identity/api/v1/identity_service.go +++ b/pkg/identity/api/v1/identity_service.go @@ -7,8 +7,6 @@ import ( "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" api "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type Service struct { @@ -78,7 +76,7 @@ Start transaction (SERIALIZABLE isolation level) End transaction */ func (s *Service) PublishIdentityUpdate(ctx context.Context, req *api.PublishIdentityUpdateRequest) (*api.PublishIdentityUpdateResponse, error) { - return s.store.PublishIdentityUpdate(ctx, req) + return s.store.PublishIdentityUpdate(ctx, req, s.validationService) } func (s *Service) GetIdentityUpdates(ctx context.Context, req *api.GetIdentityUpdatesRequest) (*api.GetIdentityUpdatesResponse, error) { @@ -97,5 +95,5 @@ func (s *Service) GetInboxIds(ctx context.Context, req *api.GetInboxIdsRequest) for the address where revocation_sequence_id is lower or NULL 2. Return the value of the 'inbox_id' column */ - return nil, status.Errorf(codes.Unimplemented, "unimplemented") + return s.store.GetInboxIds(ctx, req) } diff --git a/pkg/identity/api/v1/identity_service_test.go b/pkg/identity/api/v1/identity_service_test.go index d0a7d2c4..24d49a4c 100644 --- a/pkg/identity/api/v1/identity_service_test.go +++ b/pkg/identity/api/v1/identity_service_test.go @@ -20,7 +20,27 @@ type mockedMLSValidationService struct { } func (m *mockedMLSValidationService) GetAssociationState(ctx context.Context, oldUpdates []*associations.IdentityUpdate, newUpdates []*associations.IdentityUpdate) (*mlsvalidate.AssociationStateResult, error) { - return nil, nil + + member_map := make([]*associations.MemberMap, 0) + member_map = append(member_map, &associations.MemberMap{ + Key: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "key_address"}}, + Value: &associations.Member{ + Identifier: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "ident"}}, + AddedByEntity: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "added_by_entity"}}, + }, + }) + + new_members := make([]*associations.MemberIdentifier, 0) + + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x01"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x02"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x03"}}) + + out := mlsvalidate.AssociationStateResult{ + AssociationState: &associations.AssociationState{InboxId: "test_inbox", Members: member_map, RecoveryAddress: "recovery", SeenSignatures: [][]byte{[]byte("seen"), []byte("sig")}}, + StateDiff: &associations.AssociationStateDiff{NewMembers: new_members, RemovedMembers: nil}, + } + return &out, nil } func (m *mockedMLSValidationService) ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]mlsvalidate.IdentityValidationResult, error) { diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 8b1e6a4d..a63937ce 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -30,6 +30,16 @@ FROM address_log a ) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; +-- name: InsertAddressLog :one +INSERT INTO address_log ( + address, + inbox_id, + association_sequence_id, + revocation_sequence_id + ) +VALUES ($1, $2, $3, $4) +RETURNING *; + -- name: InsertInboxLog :one INSERT INTO inbox_log ( inbox_id, @@ -39,6 +49,20 @@ INSERT INTO inbox_log ( VALUES ($1, $2, $3) RETURNING sequence_id; +-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, + inbox_id, + MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 + AND a.inbox_id = $3 + GROUP BY address, + inbox_id + ); + -- name: CreateInstallation :exec INSERT INTO installations ( id, diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 614bf469..db14c010 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -83,25 +83,19 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte } const getAddressLogs = `-- name: GetAddressLogs :many -SELECT - a.address, +SELECT a.address, a.inbox_id, a.association_sequence_id -FROM - address_log a -INNER JOIN ( - SELECT - address, - MAX(association_sequence_id) AS max_association_sequence_id - FROM - address_log - WHERE - address = ANY ($1::text[]) - AND - revocation_sequence_id IS NULL - GROUP BY - address -) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +FROM address_log a + INNER JOIN ( + SELECT address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM address_log + WHERE address = ANY ($1::text []) + AND revocation_sequence_id IS NULL + GROUP BY address + ) b ON a.address = b.address + AND a.association_sequence_id = b.max_association_sequence_id ` type GetAddressLogsRow struct { @@ -256,6 +250,41 @@ func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessa return items, nil } +const insertAddressLog = `-- name: InsertAddressLog :one +INSERT INTO address_log ( + address, + inbox_id, + association_sequence_id, + revocation_sequence_id + ) +VALUES ($1, $2, $3, $4) +RETURNING address, inbox_id, association_sequence_id, revocation_sequence_id +` + +type InsertAddressLogParams struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +func (q *Queries) InsertAddressLog(ctx context.Context, arg InsertAddressLogParams) (AddressLog, error) { + row := q.db.QueryRowContext(ctx, insertAddressLog, + arg.Address, + arg.InboxID, + arg.AssociationSequenceID, + arg.RevocationSequenceID, + ) + var i AddressLog + err := row.Scan( + &i.Address, + &i.InboxID, + &i.AssociationSequenceID, + &i.RevocationSequenceID, + ) + return i, err +} + const insertGroupMessage = `-- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3) @@ -513,6 +542,32 @@ func (q *Queries) QueryGroupMessagesWithCursorDesc(ctx context.Context, arg Quer return items, nil } +const revokeAddressFromLog = `-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, + inbox_id, + MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 + AND a.inbox_id = $3 + GROUP BY address, + inbox_id + ) +` + +type RevokeAddressFromLogParams struct { + RevocationSequenceID sql.NullInt64 + Address string + InboxID string +} + +func (q *Queries) RevokeAddressFromLog(ctx context.Context, arg RevokeAddressFromLogParams) error { + _, err := q.db.ExecContext(ctx, revokeAddressFromLog, arg.RevocationSequenceID, arg.Address, arg.InboxID) + return err +} + const revokeInstallation = `-- name: RevokeInstallation :exec UPDATE installations SET revoked_at = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index db2300da..172579fd 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -13,6 +13,7 @@ import ( "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" + "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -30,7 +31,7 @@ type Store struct { } type IdentityStore interface { - PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) + PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } @@ -99,7 +100,7 @@ func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsReques }, nil } -func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { +func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { return nil, errors.New("IdentityUpdate is required") @@ -125,23 +126,57 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish } _ = append(updates, new_update) - // TODO: Validate the updates, and abort transaction if failed + state, err := validationService.GetAssociationState(ctx, updates, []*associations.IdentityUpdate{new_update}) + if err != nil { + return err + } + s.log.Info("Got association state", zap.Any("state", state)) protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + sequence_id, err := txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), IdentityUpdateProto: protoBytes, }) + s.log.Info("Inserted inbox log", zap.Any("sequence_id", sequence_id)) + if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id + + for _, new_member := range state.StateDiff.NewMembers { + s.log.Info("New member", zap.Any("member", new_member)) + if address, ok := new_member.Kind.(*associations.MemberIdentifier_Address); ok { + _, err = txQueries.InsertAddressLog(ctx, queries.InsertAddressLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + AssociationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + RevocationSequenceID: sql.NullInt64{Valid: false}, + }) + if err != nil { + return err + } + } + } + + for _, removed_member := range state.StateDiff.RemovedMembers { + s.log.Info("New member", zap.Any("member", removed_member)) + if address, ok := removed_member.Kind.(*associations.MemberIdentifier_Address); ok { + err = txQueries.RevokeAddressFromLog(ctx, queries.RevokeAddressFromLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + RevocationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + }) + if err != nil { + return err + } + } + } return nil }); err != nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 0f74996e..112776b9 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -2,11 +2,13 @@ package store import ( "context" + "database/sql" "sort" "testing" "time" "github.com/stretchr/testify/require" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" @@ -27,38 +29,18 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } -func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { - - entry := AddressLogEntry{ - Address: address, - InboxId: inboxId, - AssociationSequenceId: associationSequenceId, - RevocationSequenceId: nil, - } - ctx := context.Background() - - _, err := store.db.NewInsert(). - Model(&entry). - Exec(ctx) - - return err -} - func TestInboxIds(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() + ctx := context.Background() - seq, rev := uint64(1), uint64(5) - err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err := store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 1}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(2), uint64(8) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 2}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(3), uint64(9) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 3}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(4), uint64(1) - err = InsertAddressLog(store, "address", "correct", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 4}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) reqs := make([]*identity.GetInboxIdsRequest_Request, 0) @@ -69,12 +51,10 @@ func TestInboxIds(t *testing.T) { Requests: reqs, } resp, _ := store.GetInboxIds(context.Background(), req) - t.Log(resp) require.Equal(t, "correct", *resp.Responses[0].InboxId) - seq = uint64(5) - err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct_inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 5}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) @@ -83,8 +63,7 @@ func TestInboxIds(t *testing.T) { req = &identity.GetInboxIdsRequest{ Requests: reqs, } - seq, rev = uint64(8), uint64(2) - err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address2", InboxID: "inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 8}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "inbox2", *resp.Responses[1].InboxId) From 7f6a1d6d20b8191aa1acd2fcc94ca9f4bb1a915d Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 08:32:07 -0700 Subject: [PATCH 21/24] Add GetAddressLog SQL --- pkg/mls/store/models.go | 9 ++++ pkg/mls/store/queries.sql | 15 +++++++ pkg/mls/store/queries/queries.sql.go | 51 ++++++++++++++++++++++ pkg/mls/store/store.go | 32 ++++++++++++++ pkg/mls/store/store_test.go | 64 ++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+) diff --git a/pkg/mls/store/models.go b/pkg/mls/store/models.go index 4ac6342f..47d7145b 100644 --- a/pkg/mls/store/models.go +++ b/pkg/mls/store/models.go @@ -6,6 +6,15 @@ import ( "github.com/uptrace/bun" ) +type AddressLogEntry struct { + bun.BaseModel `bun:"table:address_log"` + + Address string `bun:",notnull"` + InboxId string `bun:",notnull"` + AssociationSequenceId *uint64 `bun:","` + RevocationSequenceId *uint64 `bun:","` +} + type InboxLogEntry struct { bun.BaseModel `bun:"table:inbox_log"` diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 7bd43e35..8b1e6a4d 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -15,6 +15,21 @@ FROM inbox_log AS a AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC; +-- name: GetAddressLogs :many +SELECT a.address, + a.inbox_id, + a.association_sequence_id +FROM address_log a + INNER JOIN ( + SELECT address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM address_log + WHERE address = ANY (@addresses::text []) + AND revocation_sequence_id IS NULL + GROUP BY address + ) b ON a.address = b.address + AND a.association_sequence_id = b.max_association_sequence_id; + -- name: InsertInboxLog :one INSERT INTO inbox_log ( inbox_id, diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index c9556056..b2ef7b4d 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -72,6 +72,57 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte return items, nil } +const getAddressLogs = `-- name: GetAddressLogs :many +SELECT + a.address, + a.inbox_id, + a.association_sequence_id +FROM + address_log a +INNER JOIN ( + SELECT + address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM + address_log + WHERE + address = ANY ($1::text[]) + AND + revocation_sequence_id IS NULL + GROUP BY + address +) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +` + +type GetAddressLogsRow struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 +} + +func (q *Queries) GetAddressLogs(ctx context.Context, addresses []string) ([]GetAddressLogsRow, error) { + rows, err := q.db.QueryContext(ctx, getAddressLogs, pq.Array(addresses)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GetAddressLogsRow + for rows.Next() { + var i GetAddressLogsRow + if err := rows.Scan(&i.Address, &i.InboxID, &i.AssociationSequenceID); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getAllInboxLogs = `-- name: GetAllInboxLogs :many SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log WHERE inbox_id = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index 9e5f6da5..db2300da 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -32,6 +32,7 @@ type Store struct { type IdentityStore interface { PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) + GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } type MlsStore interface { @@ -67,6 +68,37 @@ func New(ctx context.Context, config Config) (*Store, error) { return s, nil } +func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) { + + addresses := []string{} + for _, request := range req.Requests { + addresses = append(addresses, request.GetAddress()) + } + + addressLogEntries, err := s.queries.GetAddressLogs(ctx, addresses) + if err != nil { + return nil, err + } + + out := make([]*identity.GetInboxIdsResponse_Response, len(addresses)) + + for index, address := range addresses { + resp := identity.GetInboxIdsResponse_Response{} + resp.Address = address + + for _, log_entry := range addressLogEntries { + if log_entry.Address == address { + resp.InboxId = &log_entry.InboxID + } + } + out[index] = &resp + } + + return &identity.GetInboxIdsResponse{ + Responses: out, + }, nil +} + func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 379584f0..0f74996e 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" + identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" ) @@ -26,6 +27,69 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } +func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { + + entry := AddressLogEntry{ + Address: address, + InboxId: inboxId, + AssociationSequenceId: associationSequenceId, + RevocationSequenceId: nil, + } + ctx := context.Background() + + _, err := store.db.NewInsert(). + Model(&entry). + Exec(ctx) + + return err +} + +func TestInboxIds(t *testing.T) { + store, cleanup := NewTestStore(t) + defer cleanup() + + seq, rev := uint64(1), uint64(5) + err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(2), uint64(8) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(3), uint64(9) + err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + require.NoError(t, err) + seq, rev = uint64(4), uint64(1) + err = InsertAddressLog(store, "address", "correct", &seq, &rev) + require.NoError(t, err) + + reqs := make([]*identity.GetInboxIdsRequest_Request, 0) + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{ + Address: "address", + }) + req := &identity.GetInboxIdsRequest{ + Requests: reqs, + } + resp, _ := store.GetInboxIds(context.Background(), req) + t.Log(resp) + + require.Equal(t, "correct", *resp.Responses[0].InboxId) + + seq = uint64(5) + err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) + + reqs = append(reqs, &identity.GetInboxIdsRequest_Request{Address: "address2"}) + req = &identity.GetInboxIdsRequest{ + Requests: reqs, + } + seq, rev = uint64(8), uint64(2) + err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + require.NoError(t, err) + resp, _ = store.GetInboxIds(context.Background(), req) + require.Equal(t, "inbox2", *resp.Responses[1].InboxId) +} + func TestCreateInstallation(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() From 31dbc3aae720ee555e3f0b0567e0b4d9049e9c28 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 25 Apr 2024 07:36:38 -0700 Subject: [PATCH 22/24] Merge branch '04-24-migrate_first_store_methods_to_sqlc' of github.com:xmtp/xmtp-node-go into 04-24-migrate_first_store_methods_to_sqlc From 64d8d5277dad710d55681e02c723bed9eb876252 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 25 Apr 2024 17:13:39 -0400 Subject: [PATCH 23/24] Add InsertLog Query (#383) * Add insertlog query * validation service * insert log * revocation for removed members * lint * remove unnecessary log * change test to use query from sqlc * remove comments * fix tests --- pkg/identity/api/v1/identity_service.go | 6 +- pkg/identity/api/v1/identity_service_test.go | 22 ++++- pkg/mls/store/queries.sql | 24 ++++++ pkg/mls/store/queries/queries.sql.go | 89 ++++++++++++++++---- pkg/mls/store/store.go | 45 ++++++++-- pkg/mls/store/store_test.go | 39 ++------- 6 files changed, 168 insertions(+), 57 deletions(-) diff --git a/pkg/identity/api/v1/identity_service.go b/pkg/identity/api/v1/identity_service.go index 7f36b31d..8c1459be 100644 --- a/pkg/identity/api/v1/identity_service.go +++ b/pkg/identity/api/v1/identity_service.go @@ -7,8 +7,6 @@ import ( "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" api "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type Service struct { @@ -78,7 +76,7 @@ Start transaction (SERIALIZABLE isolation level) End transaction */ func (s *Service) PublishIdentityUpdate(ctx context.Context, req *api.PublishIdentityUpdateRequest) (*api.PublishIdentityUpdateResponse, error) { - return s.store.PublishIdentityUpdate(ctx, req) + return s.store.PublishIdentityUpdate(ctx, req, s.validationService) } func (s *Service) GetIdentityUpdates(ctx context.Context, req *api.GetIdentityUpdatesRequest) (*api.GetIdentityUpdatesResponse, error) { @@ -97,5 +95,5 @@ func (s *Service) GetInboxIds(ctx context.Context, req *api.GetInboxIdsRequest) for the address where revocation_sequence_id is lower or NULL 2. Return the value of the 'inbox_id' column */ - return nil, status.Errorf(codes.Unimplemented, "unimplemented") + return s.store.GetInboxIds(ctx, req) } diff --git a/pkg/identity/api/v1/identity_service_test.go b/pkg/identity/api/v1/identity_service_test.go index d0a7d2c4..24d49a4c 100644 --- a/pkg/identity/api/v1/identity_service_test.go +++ b/pkg/identity/api/v1/identity_service_test.go @@ -20,7 +20,27 @@ type mockedMLSValidationService struct { } func (m *mockedMLSValidationService) GetAssociationState(ctx context.Context, oldUpdates []*associations.IdentityUpdate, newUpdates []*associations.IdentityUpdate) (*mlsvalidate.AssociationStateResult, error) { - return nil, nil + + member_map := make([]*associations.MemberMap, 0) + member_map = append(member_map, &associations.MemberMap{ + Key: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "key_address"}}, + Value: &associations.Member{ + Identifier: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "ident"}}, + AddedByEntity: &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "added_by_entity"}}, + }, + }) + + new_members := make([]*associations.MemberIdentifier, 0) + + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x01"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x02"}}) + new_members = append(new_members, &associations.MemberIdentifier{Kind: &associations.MemberIdentifier_Address{Address: "0x03"}}) + + out := mlsvalidate.AssociationStateResult{ + AssociationState: &associations.AssociationState{InboxId: "test_inbox", Members: member_map, RecoveryAddress: "recovery", SeenSignatures: [][]byte{[]byte("seen"), []byte("sig")}}, + StateDiff: &associations.AssociationStateDiff{NewMembers: new_members, RemovedMembers: nil}, + } + return &out, nil } func (m *mockedMLSValidationService) ValidateKeyPackages(ctx context.Context, keyPackages [][]byte) ([]mlsvalidate.IdentityValidationResult, error) { diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 8b1e6a4d..a63937ce 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -30,6 +30,16 @@ FROM address_log a ) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; +-- name: InsertAddressLog :one +INSERT INTO address_log ( + address, + inbox_id, + association_sequence_id, + revocation_sequence_id + ) +VALUES ($1, $2, $3, $4) +RETURNING *; + -- name: InsertInboxLog :one INSERT INTO inbox_log ( inbox_id, @@ -39,6 +49,20 @@ INSERT INTO inbox_log ( VALUES ($1, $2, $3) RETURNING sequence_id; +-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, + inbox_id, + MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 + AND a.inbox_id = $3 + GROUP BY address, + inbox_id + ); + -- name: CreateInstallation :exec INSERT INTO installations ( id, diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index b2ef7b4d..36d40044 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -73,25 +73,19 @@ func (q *Queries) FetchKeyPackages(ctx context.Context, installationIds [][]byte } const getAddressLogs = `-- name: GetAddressLogs :many -SELECT - a.address, +SELECT a.address, a.inbox_id, a.association_sequence_id -FROM - address_log a -INNER JOIN ( - SELECT - address, - MAX(association_sequence_id) AS max_association_sequence_id - FROM - address_log - WHERE - address = ANY ($1::text[]) - AND - revocation_sequence_id IS NULL - GROUP BY - address -) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id +FROM address_log a + INNER JOIN ( + SELECT address, + MAX(association_sequence_id) AS max_association_sequence_id + FROM address_log + WHERE address = ANY ($1::text []) + AND revocation_sequence_id IS NULL + GROUP BY address + ) b ON a.address = b.address + AND a.association_sequence_id = b.max_association_sequence_id ` type GetAddressLogsRow struct { @@ -237,6 +231,41 @@ func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessa return items, nil } +const insertAddressLog = `-- name: InsertAddressLog :one +INSERT INTO address_log ( + address, + inbox_id, + association_sequence_id, + revocation_sequence_id + ) +VALUES ($1, $2, $3, $4) +RETURNING address, inbox_id, association_sequence_id, revocation_sequence_id +` + +type InsertAddressLogParams struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +func (q *Queries) InsertAddressLog(ctx context.Context, arg InsertAddressLogParams) (AddressLog, error) { + row := q.db.QueryRowContext(ctx, insertAddressLog, + arg.Address, + arg.InboxID, + arg.AssociationSequenceID, + arg.RevocationSequenceID, + ) + var i AddressLog + err := row.Scan( + &i.Address, + &i.InboxID, + &i.AssociationSequenceID, + &i.RevocationSequenceID, + ) + return i, err +} + const insertGroupMessage = `-- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3) @@ -481,6 +510,32 @@ func (q *Queries) QueryGroupMessagesWithCursorDesc(ctx context.Context, arg Quer return items, nil } +const revokeAddressFromLog = `-- name: RevokeAddressFromLog :exec +UPDATE address_log +SET revocation_sequence_id = $1 +WHERE (address, inbox_id, association_sequence_id) = ( + SELECT address, + inbox_id, + MAX(association_sequence_id) + FROM address_log AS a + WHERE a.address = $2 + AND a.inbox_id = $3 + GROUP BY address, + inbox_id + ) +` + +type RevokeAddressFromLogParams struct { + RevocationSequenceID sql.NullInt64 + Address string + InboxID string +} + +func (q *Queries) RevokeAddressFromLog(ctx context.Context, arg RevokeAddressFromLogParams) error { + _, err := q.db.ExecContext(ctx, revokeAddressFromLog, arg.RevocationSequenceID, arg.Address, arg.InboxID) + return err +} + const revokeInstallation = `-- name: RevokeInstallation :exec UPDATE installations SET revoked_at = $1 diff --git a/pkg/mls/store/store.go b/pkg/mls/store/store.go index db2300da..172579fd 100644 --- a/pkg/mls/store/store.go +++ b/pkg/mls/store/store.go @@ -13,6 +13,7 @@ import ( "github.com/uptrace/bun/migrate" migrations "github.com/xmtp/xmtp-node-go/pkg/migrations/mls" queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" + "github.com/xmtp/xmtp-node-go/pkg/mlsvalidate" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" "github.com/xmtp/xmtp-node-go/pkg/proto/identity/associations" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" @@ -30,7 +31,7 @@ type Store struct { } type IdentityStore interface { - PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) + PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) GetInboxLogs(ctx context.Context, req *identity.GetIdentityUpdatesRequest) (*identity.GetIdentityUpdatesResponse, error) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsRequest) (*identity.GetInboxIdsResponse, error) } @@ -99,7 +100,7 @@ func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsReques }, nil } -func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest) (*identity.PublishIdentityUpdateResponse, error) { +func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.PublishIdentityUpdateRequest, validationService mlsvalidate.MLSValidationService) (*identity.PublishIdentityUpdateResponse, error) { new_update := req.GetIdentityUpdate() if new_update == nil { return nil, errors.New("IdentityUpdate is required") @@ -125,23 +126,57 @@ func (s *Store) PublishIdentityUpdate(ctx context.Context, req *identity.Publish } _ = append(updates, new_update) - // TODO: Validate the updates, and abort transaction if failed + state, err := validationService.GetAssociationState(ctx, updates, []*associations.IdentityUpdate{new_update}) + if err != nil { + return err + } + s.log.Info("Got association state", zap.Any("state", state)) protoBytes, err := proto.Marshal(new_update) if err != nil { return err } - _, err = txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ + sequence_id, err := txQueries.InsertInboxLog(ctx, queries.InsertInboxLogParams{ InboxID: new_update.GetInboxId(), ServerTimestampNs: nowNs(), IdentityUpdateProto: protoBytes, }) + s.log.Info("Inserted inbox log", zap.Any("sequence_id", sequence_id)) + if err != nil { return err } - // TODO: Insert or update the address_log table using sequence_id + + for _, new_member := range state.StateDiff.NewMembers { + s.log.Info("New member", zap.Any("member", new_member)) + if address, ok := new_member.Kind.(*associations.MemberIdentifier_Address); ok { + _, err = txQueries.InsertAddressLog(ctx, queries.InsertAddressLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + AssociationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + RevocationSequenceID: sql.NullInt64{Valid: false}, + }) + if err != nil { + return err + } + } + } + + for _, removed_member := range state.StateDiff.RemovedMembers { + s.log.Info("New member", zap.Any("member", removed_member)) + if address, ok := removed_member.Kind.(*associations.MemberIdentifier_Address); ok { + err = txQueries.RevokeAddressFromLog(ctx, queries.RevokeAddressFromLogParams{ + Address: address.Address, + InboxID: state.AssociationState.InboxId, + RevocationSequenceID: sql.NullInt64{Valid: true, Int64: sequence_id}, + }) + if err != nil { + return err + } + } + } return nil }); err != nil { diff --git a/pkg/mls/store/store_test.go b/pkg/mls/store/store_test.go index 0f74996e..112776b9 100644 --- a/pkg/mls/store/store_test.go +++ b/pkg/mls/store/store_test.go @@ -2,11 +2,13 @@ package store import ( "context" + "database/sql" "sort" "testing" "time" "github.com/stretchr/testify/require" + queries "github.com/xmtp/xmtp-node-go/pkg/mls/store/queries" identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1" mlsv1 "github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1" test "github.com/xmtp/xmtp-node-go/pkg/testing" @@ -27,38 +29,18 @@ func NewTestStore(t *testing.T) (*Store, func()) { return store, dbCleanup } -func InsertAddressLog(store *Store, address string, inboxId string, associationSequenceId *uint64, revocationSequenceId *uint64) error { - - entry := AddressLogEntry{ - Address: address, - InboxId: inboxId, - AssociationSequenceId: associationSequenceId, - RevocationSequenceId: nil, - } - ctx := context.Background() - - _, err := store.db.NewInsert(). - Model(&entry). - Exec(ctx) - - return err -} - func TestInboxIds(t *testing.T) { store, cleanup := NewTestStore(t) defer cleanup() + ctx := context.Background() - seq, rev := uint64(1), uint64(5) - err := InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err := store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 1}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(2), uint64(8) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 2}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(3), uint64(9) - err = InsertAddressLog(store, "address", "inbox1", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "inbox1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 3}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) - seq, rev = uint64(4), uint64(1) - err = InsertAddressLog(store, "address", "correct", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 4}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) reqs := make([]*identity.GetInboxIdsRequest_Request, 0) @@ -69,12 +51,10 @@ func TestInboxIds(t *testing.T) { Requests: reqs, } resp, _ := store.GetInboxIds(context.Background(), req) - t.Log(resp) require.Equal(t, "correct", *resp.Responses[0].InboxId) - seq = uint64(5) - err = InsertAddressLog(store, "address", "correct_inbox2", &seq, nil) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address", InboxID: "correct_inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 5}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "correct_inbox2", *resp.Responses[0].InboxId) @@ -83,8 +63,7 @@ func TestInboxIds(t *testing.T) { req = &identity.GetInboxIdsRequest{ Requests: reqs, } - seq, rev = uint64(8), uint64(2) - err = InsertAddressLog(store, "address2", "inbox2", &seq, &rev) + _, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address2", InboxID: "inbox2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 8}, RevocationSequenceID: sql.NullInt64{Valid: false}}) require.NoError(t, err) resp, _ = store.GetInboxIds(context.Background(), req) require.Equal(t, "inbox2", *resp.Responses[1].InboxId) From 4472886dcd841d7b189267626666b7c8d725ef64 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 25 Apr 2024 17:13:39 -0400 Subject: [PATCH 24/24] Add InsertLog Query (#383) * Add insertlog query * validation service * insert log * revocation for removed members * lint * remove unnecessary log * change test to use query from sqlc * remove comments * fix tests --- pkg/mls/store/queries/queries.sql.go | 78 ++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index 36d40044..db14c010 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -14,7 +14,15 @@ import ( ) const createInstallation = `-- name: CreateInstallation :exec -INSERT INTO installations (id, wallet_address, created_at, updated_at, credential_identity, key_package, expiration) +INSERT INTO installations ( + id, + wallet_address, + created_at, + updated_at, + credential_identity, + key_package, + expiration + ) VALUES ($1, $2, $3, $3, $4, $5, $6) ` @@ -40,8 +48,10 @@ func (q *Queries) CreateInstallation(ctx context.Context, arg CreateInstallation } const fetchKeyPackages = `-- name: FetchKeyPackages :many -SELECT id, key_package FROM installations -WHERE id = ANY ($1::bytea[]) +SELECT id, + key_package +FROM installations +WHERE id = ANY ($1::bytea []) ` type FetchKeyPackagesRow struct { @@ -118,9 +128,11 @@ func (q *Queries) GetAddressLogs(ctx context.Context, addresses []string) ([]Get } const getAllInboxLogs = `-- name: GetAllInboxLogs :many -SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto FROM inbox_log +SELECT sequence_id, inbox_id, server_timestamp_ns, identity_update_proto +FROM inbox_log WHERE inbox_id = $1 -ORDER BY sequence_id ASC FOR UPDATE +ORDER BY sequence_id ASC FOR +UPDATE ` func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxLog, error) { @@ -152,9 +164,13 @@ func (q *Queries) GetAllInboxLogs(ctx context.Context, inboxID string) ([]InboxL } const getIdentityUpdates = `-- name: GetIdentityUpdates :many -SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration FROM installations -WHERE wallet_address = ANY ($1::text[]) -AND (created_at > $2 OR revoked_at > $2) +SELECT id, wallet_address, created_at, updated_at, credential_identity, revoked_at, key_package, expiration +FROM installations +WHERE wallet_address = ANY ($1::text []) + AND ( + created_at > $2 + OR revoked_at > $2 + ) ORDER BY created_at ASC ` @@ -196,10 +212,13 @@ func (q *Queries) GetIdentityUpdates(ctx context.Context, arg GetIdentityUpdates } const getInboxLogFiltered = `-- name: GetInboxLogFiltered :many -SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto FROM inbox_log AS a -JOIN ( - SELECT inbox_id, sequence_id FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) -) as b on b.inbox_id = a.inbox_id AND a.sequence_id > b.sequence_id +SELECT a.sequence_id, a.inbox_id, a.server_timestamp_ns, a.identity_update_proto +FROM inbox_log AS a + JOIN ( + SELECT inbox_id, sequence_id + FROM json_populate_recordset(null::inbox_filter, $1) as b(inbox_id, sequence_id) + ) as b on b.inbox_id = a.inbox_id + AND a.sequence_id > b.sequence_id ORDER BY a.sequence_id ASC ` @@ -292,7 +311,11 @@ func (q *Queries) InsertGroupMessage(ctx context.Context, arg InsertGroupMessage } const insertInboxLog = `-- name: InsertInboxLog :one -INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) +INSERT INTO inbox_log ( + inbox_id, + server_timestamp_ns, + identity_update_proto + ) VALUES ($1, $2, $3) RETURNING sequence_id ` @@ -311,7 +334,12 @@ func (q *Queries) InsertInboxLog(ctx context.Context, arg InsertInboxLogParams) } const insertWelcomeMessage = `-- name: InsertWelcomeMessage :one -INSERT INTO welcome_messages (installation_key, data, installation_key_data_hash, hpke_public_key) +INSERT INTO welcome_messages ( + installation_key, + data, + installation_key_data_hash, + hpke_public_key + ) VALUES ($1, $2, $3, $4) RETURNING id, created_at, installation_key, data, installation_key_data_hash, hpke_public_key ` @@ -343,7 +371,8 @@ func (q *Queries) InsertWelcomeMessage(ctx context.Context, arg InsertWelcomeMes } const queryGroupMessagesAsc = `-- name: QueryGroupMessagesAsc :many -SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash +FROM group_messages WHERE group_id = $1 ORDER BY id ASC LIMIT $2 @@ -384,7 +413,8 @@ func (q *Queries) QueryGroupMessagesAsc(ctx context.Context, arg QueryGroupMessa } const queryGroupMessagesDesc = `-- name: QueryGroupMessagesDesc :many -SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash +FROM group_messages WHERE group_id = $1 ORDER BY id DESC LIMIT $2 @@ -425,9 +455,10 @@ func (q *Queries) QueryGroupMessagesDesc(ctx context.Context, arg QueryGroupMess } const queryGroupMessagesWithCursorAsc = `-- name: QueryGroupMessagesWithCursorAsc :many -SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash +FROM group_messages WHERE group_id = $1 -AND id > $2 + AND id > $2 ORDER BY id ASC LIMIT $3 ` @@ -468,9 +499,10 @@ func (q *Queries) QueryGroupMessagesWithCursorAsc(ctx context.Context, arg Query } const queryGroupMessagesWithCursorDesc = `-- name: QueryGroupMessagesWithCursorDesc :many -SELECT id, created_at, group_id, data, group_id_data_hash FROM group_messages +SELECT id, created_at, group_id, data, group_id_data_hash +FROM group_messages WHERE group_id = $1 -AND id < $2 + AND id < $2 ORDER BY id DESC LIMIT $3 ` @@ -540,7 +572,7 @@ const revokeInstallation = `-- name: RevokeInstallation :exec UPDATE installations SET revoked_at = $1 WHERE id = $2 -AND revoked_at IS NULL + AND revoked_at IS NULL ` type RevokeInstallationParams struct { @@ -555,7 +587,9 @@ func (q *Queries) RevokeInstallation(ctx context.Context, arg RevokeInstallation const updateKeyPackage = `-- name: UpdateKeyPackage :execrows UPDATE installations -SET key_package = $1, updated_at = $2, expiration = $3 +SET key_package = $1, + updated_at = $2, + expiration = $3 WHERE id = $4 `