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

Intro Host resource to enhance contract account security & add test suite #7

Merged
merged 34 commits into from
Dec 8, 2023

Conversation

sisyphusSmiling
Copy link
Contributor

It was realized when reviewing a similar pattern that publishing unrestricted AuthAccount Capabilities introduces enough risk to be considered an anti-pattern.

This PR introduces changes to the (formerly named ContractUpdater) StagedContractUpdates contract that allow contract-hosting accounts to wrap their AuthAccount Capabilities in a Host resource before publishing to the account that will store the Updater resource defining their full update deployment. This restricts the access on the underlying account to the contract update API and nothing else from the time of transfer onward and is significantly safer than passing a full AuthAccount Capability.

Also introduced in this PR is a Cadence test suite as well as a testing workflow action on pull request and merge to main.

@sisyphusSmiling sisyphusSmiling self-assigned this Dec 1, 2023
@sisyphusSmiling sisyphusSmiling changed the title Wrap AuthAccount in Host resources & add test suite Wrap AuthAccount Capability in Host resource & add test suite Dec 1, 2023
@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Contributor Author

@sisyphusSmiling sisyphusSmiling Dec 6, 2023

Choose a reason for hiding this comment

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

Note this was renamed to StagedContractUpdates.cdc, but I think the GitHub UI is confused and is reflecting as a delete + new file. There are likely a number of other instances where renaming + changes cause this mixup in the UI - sorry for any confusion!

@sisyphusSmiling sisyphusSmiling requested review from a team and j1010001 December 7, 2023 00:47
@sisyphusSmiling sisyphusSmiling marked this pull request as ready for review December 7, 2023 00:52
@sisyphusSmiling sisyphusSmiling added the enhancement New feature or request label Dec 7, 2023
@sisyphusSmiling sisyphusSmiling changed the title Wrap AuthAccount Capability in Host resource & add test suite Intro Host resource to enhance contract account security & add test suite Dec 7, 2023
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.

It would be good to make sure each transaction has a comment at the top describing what it does

access(self) let failedDeployments: {Int: [String]}

init(
blockUpdateBoundary: UInt64,
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to validate the blockUpdateBoundary?

Copy link
Member

Choose a reason for hiding this comment

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

I guess we don't know when cadence 1.0 will be released yet, so we can't really choose a block yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's my thought. I figured we would pass that value on deployment once the boundary is known. The coordinator can also update the value as long as the updated value is advanced.

transactions/coordinator/set_block_update_boundary.cdc Outdated Show resolved Hide resolved
@sisyphusSmiling
Copy link
Contributor Author

Thanks for approving @joshuahannan, I'll update transactions missing comments shortly.

@sisyphusSmiling sisyphusSmiling merged commit 9384ccd into main Dec 8, 2023
@sisyphusSmiling sisyphusSmiling deleted the testnet-prep branch December 8, 2023 21:01
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
Development

Successfully merging this pull request may close these issues.

3 participants