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

Entitlements Migration #2951

Merged
merged 56 commits into from
Jan 16, 2024
Merged

Entitlements Migration #2951

merged 56 commits into from
Jan 16, 2024

Conversation

dsainati1
Copy link
Contributor

Adds the entitlements migration as detailed in onflow/flips#95.

Part of #2709


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

…:onflow/cadence into sainati/entitlements-migration
@dsainati1 dsainati1 self-assigned this Nov 21, 2023
This was referenced Nov 21, 2023
@dsainati1
Copy link
Contributor Author

This is currently in a draft state, I need to add more tests, especially for the cases where contracts are being loaded from multiple different locations and addresses, and for the case where one or more contracts has not yet been updated and thus fails to typecheck.

migrations/migration.go Outdated Show resolved Hide resolved
migrations/entitlements/migration.go Show resolved Hide resolved
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Looks good! Just some last suggestions and questions

migrations/entitlements/migration.go Outdated Show resolved Hide resolved
migrations/entitlements/migration.go Show resolved Hide resolved
migrations/entitlements/migration.go Show resolved Hide resolved
migrations/entitlements/migration.go Show resolved Hide resolved
@turbolent
Copy link
Member

@SupunS Do we have to use the same "trick" that we used in the type value migration, which forces the re-hashing / removal + reinsertion, in this migration?

@SupunS
Copy link
Member

SupunS commented Jan 5, 2024

ah, that's a good flag. It is currently handled in the migration framework:

// Key was migrated.
// Remove the old value at the old key.
// This old value will be inserted again with the new key, unless the value is also migrated.
existingKey = legacyKey(existingKey)

But might need to make a small adjustment to return a 'legacy reference type' for the reference type:

case *interpreter.ReferenceStaticType:
legacyReferencedType := legacyType(typ.ReferencedType)
if legacyReferencedType != nil {
return interpreter.NewReferenceStaticType(nil, typ.Authorization, legacyReferencedType)
}

@dsainati1 A way to test this is to have a type-value as a dictionary key, and the inner type of that type-value should get migrated by the entitlement migrations.

@dsainati1
Copy link
Contributor Author

A way to test this is to have a type-value as a dictionary key, and the inner type of that type-value should get migrated by the entitlement migrations.

Added this test, which passes with no code changes.

@turbolent
Copy link
Member

Let's double check https://discord.com/channels/613813861610684416/1108479699732152503/1194054315644571750,
i.e. wait for https://discord.com/channels/613813861610684416/1194054315644571750/1194066844479393952

(sorry for being overly cautious with the migration code)

@SupunS
Copy link
Member

SupunS commented Jan 12, 2024

I think we can merge this one. Any changes required for re-hashing can/will be added in #3013

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great work! Sorry it took so long to get in

migrations/migration.go Outdated Show resolved Hide resolved
migrations/entitlements/migration_test.go Show resolved Hide resolved
@dsainati1 dsainati1 merged commit bf9973a into master Jan 16, 2024
11 of 12 checks passed
@dsainati1 dsainati1 deleted the sainati/entitlements-migration branch January 16, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants