-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Identity DB ready for prod (#394)
* Deal with transaction serialization issues * Revert schema change * Use pg_advisory_xact_lock * Check return value of lock * Add random sleep * Add initial migration * Remove unused line * Update code to use new schema * Remove unused file * Fix failing tests * Remove unused functions * Move hex encoding to the db
- Loading branch information
Showing
33 changed files
with
1,378 additions
and
1,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
with-expecter: true | ||
packages: | ||
github.com/xmtp/xmtp-node-go/pkg/proto/mls/api/v1: | ||
config: | ||
dir: ./pkg/mocks | ||
outpkg: mocks | ||
interfaces: | ||
MlsApi_SubscribeGroupMessagesServer: | ||
config: | ||
MlsApi_SubscribeWelcomeMessagesServer: | ||
config: | ||
github.com/xmtp/xmtp-node-go/pkg/mlsvalidate: | ||
config: | ||
dir: ./pkg/mocks | ||
outpkg: mocks | ||
interfaces: | ||
MLSValidationService: | ||
config: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ if ! which golangci-lint &>/dev/null; then brew install golangci-lint; fi | |
if ! which shellcheck &>/dev/null; then brew install shellcheck; fi | ||
if ! which protoc &>/dev/null; then brew install protobuf; fi | ||
if ! which protoc-gen-go &>/dev/null; then go install google.golang.org/protobuf/cmd/protoc-gen-go@latest; fi | ||
if ! which mockgen &>/dev/null || [ `mockgen --version` != "v0.4.0" ]; then go install go.uber.org/mock/[email protected]; fi | ||
if ! which mockery &>/dev/null; then brew install mockery; fi | ||
if ! which protolint &>/dev/null; then go install github.com/yoheimuta/protolint/cmd/protolint@latest; fi | ||
|
||
dev/generate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
.../mls/20240109001927_add-messages.down.sql → ...tions/mls/20240528181822_wipe-db.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
SET statement_timeout = 0; | ||
|
||
--bun:split | ||
DROP TABLE IF EXISTS messages; | ||
|
||
SELECT 1 | ||
|
||
--bun:split | ||
|
||
SELECT 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SET statement_timeout = 0; | ||
|
||
--bun:split | ||
DROP TABLE IF EXISTS installations, group_messages, welcome_messages, inbox_log, address_log; | ||
|
||
--bun:split | ||
DROP TYPE IF EXISTS inbox_filter; | ||
|
6 changes: 5 additions & 1 deletion
6
...20240425021053_add-inbox-filters.down.sql → ...s/mls/20240528181851_init-schema.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
SET statement_timeout = 0; | ||
|
||
--bun:split | ||
DROP TYPE IF EXISTS inbox_filter; | ||
|
||
SELECT 1 | ||
|
||
--bun:split | ||
|
||
SELECT 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
SET statement_timeout = 0; | ||
|
||
--bun:split | ||
CREATE TABLE installations( | ||
id BYTEA PRIMARY KEY, | ||
created_at BIGINT NOT NULL, | ||
updated_at BIGINT NOT NULL, | ||
inbox_id BYTEA NOT NULL, | ||
key_package BYTEA NOT NULL, | ||
expiration BIGINT NOT NULL | ||
); | ||
|
||
--bun:split | ||
CREATE TABLE group_messages( | ||
id BIGSERIAL PRIMARY KEY, | ||
created_at TIMESTAMP NOT NULL DEFAULT NOW(), | ||
group_id BYTEA NOT NULL, | ||
data BYTEA NOT NULL, | ||
group_id_data_hash BYTEA NOT NULL | ||
); | ||
|
||
--bun:split | ||
CREATE INDEX idx_group_messages_group_id_id ON group_messages(group_id, id); | ||
|
||
--bun:split | ||
CREATE UNIQUE INDEX idx_group_messages_group_id_data_hash ON group_messages(group_id_data_hash); | ||
|
||
--bun:split | ||
CREATE TABLE welcome_messages( | ||
id BIGSERIAL PRIMARY KEY, | ||
created_at TIMESTAMP NOT NULL DEFAULT NOW(), | ||
installation_key BYTEA NOT NULL, | ||
data BYTEA NOT NULL, | ||
hpke_public_key BYTEA NOT NULL, | ||
installation_key_data_hash BYTEA NOT NULL | ||
); | ||
|
||
--bun:split | ||
CREATE INDEX idx_welcome_messages_installation_key_id ON welcome_messages(installation_key, id); | ||
|
||
--bun:split | ||
CREATE UNIQUE INDEX idx_welcome_messages_group_key_data_hash ON welcome_messages(installation_key_data_hash); | ||
|
||
--bun:split | ||
CREATE TABLE inbox_log( | ||
sequence_id BIGSERIAL PRIMARY KEY, | ||
inbox_id BYTEA NOT NULL, | ||
server_timestamp_ns BIGINT NOT NULL, | ||
identity_update_proto BYTEA NOT NULL | ||
); | ||
|
||
--bun:split | ||
CREATE INDEX idx_inbox_log_inbox_id_sequence_id ON inbox_log(inbox_id, sequence_id); | ||
|
||
--bun:split | ||
CREATE TABLE address_log( | ||
address TEXT NOT NULL, | ||
inbox_id BYTEA NOT NULL, | ||
association_sequence_id BIGINT, | ||
revocation_sequence_id BIGINT | ||
); | ||
|
||
--bun:split | ||
CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id); | ||
|
||
--bun:split | ||
CREATE TYPE inbox_filter AS ( | ||
inbox_id TEXT, -- Because this is serialized as JSON, we can't use a BYTEA type | ||
sequence_id BIGINT | ||
); | ||
|
Oops, something went wrong.