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

Stable cadence refactor #6

Merged
merged 40 commits into from
Jun 11, 2024
Merged

Conversation

sisyphusSmiling
Copy link
Contributor

@sisyphusSmiling sisyphusSmiling commented Sep 22, 2023

Related: #1

This PR updates repo contents for Cadence 1.0 compatibility. While the MigrationStagingContract won't be used after 1.0 migration, staging and updating the contract will enhance auditability and transparency post-migration, enabling the migrated contracts can be validated against the code as staged. Migrating the contract also allows us to clean up the account after some time if need be.

Refactors for StagedContractUpdates are also included. Although this contract was not used as a mechanism for migration as originally intended, others may still find it useful moving forward to coordinate updates to distributed contract system.

@sisyphusSmiling sisyphusSmiling marked this pull request as ready for review May 16, 2024 22:24
@sisyphusSmiling sisyphusSmiling requested a review from a team as a code owner May 16, 2024 22:24
@sisyphusSmiling
Copy link
Contributor Author

Update: As of this writing, MigrationStagingContract migrated successfully in a local migration and has been staged for inclusion in the subsequent Testnet migration.

@sisyphusSmiling sisyphusSmiling force-pushed the stable-cadence-refactor branch from 96be0ad to d00b755 Compare June 3, 2024 23:40
@sisyphusSmiling sisyphusSmiling force-pushed the stable-cadence-refactor branch from d00b755 to 876e7d9 Compare June 3, 2024 23:42
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 93.44262% with 4 lines in your changes missing coverage. Please review.

Please upload report for BASE (stable-cadence@735a84b). Learn more about missing BASE report.

Files Patch % Lines
contracts/DependencyAudit.cdc 93.02% 3 Missing ⚠️
.../staged-contract-updates/StagedContractUpdates.cdc 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             stable-cadence       #6   +/-   ##
=================================================
  Coverage                  ?   83.89%           
=================================================
  Files                     ?        6           
  Lines                     ?      298           
  Branches                  ?        0           
=================================================
  Hits                      ?      250           
  Misses                    ?       48           
  Partials                  ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joshuahannan joshuahannan left a comment

Choose a reason for hiding this comment

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

Seems pretty straightforward! Just had a couple questions

return self.delegatedUpdaters.keys
}

/// Allows for the delegation of contract updates as defined within the Updater resource
///
access(all) fun delegate(updaterCap: Capability<&Updater>) {
access(all) fun delegate(updaterCap: Capability<auth(UpdateContract) &Updater>) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming that the functions in this resource don't need entitlements since they require the capability to call, but I just wanted to flag just in case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right, only those that are currently entitled need to be privileged. delegate and removeAsUpdater can be public as they allow & remove delegation to this resource and those are necessarily called by the owner of the underyling Updater since the caps are entitled.

let updaterPrivatePath = PrivatePath(
identifier: "StagedContractUpdatesUpdater_".concat(
let updaterCapStoragePath = StoragePath(
identifier: "StagedContractUpdatesUpdaterCapability_".concat(
Copy link
Member

Choose a reason for hiding this comment

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

Why did this string change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So here I replaced the deprecated private path with storage path. Since we no longer have private paths by which to manage issued capabilities, I instead store the issued capability in storage for easy traceability and revocation. Ultimately, what's stored at that path is no longer and Updater but a capability on an Updater, hence the change in path identifier.

Does that capability management scheme make sense or see any problems with that change?

Also, FWIW this contract isn't deployed on TN or MN but updating it here to diminish any tech debt and because the contract may be useful as reference.

Copy link
Member

Choose a reason for hiding this comment

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

that all makes sense

@sisyphusSmiling sisyphusSmiling merged commit c99c1a9 into stable-cadence Jun 11, 2024
1 check passed
@sisyphusSmiling sisyphusSmiling deleted the stable-cadence-refactor branch June 11, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants