Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove inbox validation for uploading key packages #400

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

neekolas
Copy link
Collaborator

@neekolas neekolas commented Aug 14, 2024

tl;dr

  • Implements part of Phase 1 of Tracking: Loosen Key Package Upload Validation #399
  • Goal here is to loosen the validations on uploading key packages so that uploads can happen before PublishIdentityUpdate is called
  • Begins the process of cleaning up these APIs and simplifying things

AI Assisted Summary

This pull request includes several changes to the project, primarily focused on refactoring the installation registration process and updating the database schema. The key changes made are:

  1. Removed inbox_id and expiration columns from the installations table.
  2. Updated SQL queries to reflect the schema changes, including the removal of UpdateKeyPackage query and the addition of CreateOrUpdateInstallation query with upsert logic.
  3. Deprecated the RegisterInstallation method in favor of UploadKeyPackage.
  4. Updated test cases to align with the new schema and methods.
  5. Simplified the ValidateInboxIdKeyPackages method by removing intermediate validation requests and leveraging direct validation responses.

These changes aim to streamline the installation registration process, reduce database schema complexity, and improve overall code maintainability.


Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @neekolas and the rest of your teammates on Graphite Graphite

@neekolas neekolas force-pushed the 08-13-loosen_validations_for_key_package_uploads branch from 2404937 to 49ddb76 Compare August 14, 2024 04:04
@@ -2,5 +2,5 @@
set -e

function docker_compose() {
docker-compose -f dev/docker/docker-compose.yml -p xmtpd "$@"
docker compose -f dev/docker/docker-compose.yml -p xmtpd "$@"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently our Github runners have been upgraded to a new version where docker-compose no longer exists as a separate command. You must use docker compose instead.

@neekolas neekolas force-pushed the 08-13-loosen_validations_for_key_package_uploads branch from 49ddb76 to a816114 Compare August 14, 2024 04:08
@@ -130,17 +130,17 @@ func (s *Service) Publish(ctx context.Context, req *proto.PublishRequest) (*prot
log.Debug("received message")

if len(env.ContentTopic) > MaxContentTopicNameSize {
return nil, status.Errorf(codes.InvalidArgument, "topic length too big")
return nil, status.Error(codes.InvalidArgument, "topic length too big")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our linter has apparently become more fussy with some version upgrade and this old code was causing lint fails

@neekolas neekolas force-pushed the 08-13-loosen_validations_for_key_package_uploads branch 2 times, most recently from 81914f6 to 8fdef23 Compare August 14, 2024 04:16
@@ -96,17 +96,17 @@ func (wa *WalletAuthorizer) requiresAuthorization(req interface{}) bool {
func (wa *WalletAuthorizer) getWallet(ctx context.Context) (types.WalletAddr, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return "", status.Errorf(codes.Unauthenticated, "metadata is not provided")
return "", status.Error(codes.Unauthenticated, "metadata is not provided")
Copy link
Collaborator Author

@neekolas neekolas Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stricter linting updates again

@neekolas neekolas force-pushed the 08-13-loosen_validations_for_key_package_uploads branch from 8fdef23 to ec2480f Compare August 14, 2024 04:29
@neekolas neekolas marked this pull request as ready for review August 14, 2024 04:39
*
DEPRECATED: Use UploadKeyPackage instead
*
*/
func (s *Service) RegisterInstallation(ctx context.Context, req *mlsv1.RegisterInstallationRequest) (*mlsv1.RegisterInstallationResponse, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need a separate endpoint for registering an installation and updating the key package. Can just do a "create or update" query and have one endpoint for everything.

Copy link
Contributor

@richardhuaaa richardhuaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, this is so much cleaner

InstallationId []byte
Expiration uint64
}

func (s *MLSValidationServiceImpl) ValidateInboxIdKeyPackages(ctx context.Context, keyPackages [][]byte) ([]InboxIdValidationResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be ValidateKeyPackages now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some items further down in the tracking issue for cleaning up dead code and renaming things. Didn't want to do too much at once

@neekolas neekolas merged commit f7a54a0 into main Aug 14, 2024
4 checks passed
@neekolas neekolas deleted the 08-13-loosen_validations_for_key_package_uploads branch August 14, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants