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

Add upgrade_and_call #1148

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

andrew-fleming
Copy link
Collaborator

@andrew-fleming andrew-fleming commented Sep 14, 2024

Fixes #694.

This PR proposes to add upgrade_and_call to UpgradeableComponent's InternalImpl. This PR also proposes to add IUpgradeAndCall interface which includes both upgrade and upgrade_and_call.

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

Looking good Andrew. Left some comments.

packages/upgrades/src/upgradeable.cairo Outdated Show resolved Hide resolved
packages/upgrades/src/interface.cairo Outdated Show resolved Hide resolved

Replaces the contract's class hash with `new_class_hash` and then calls `selector`
from the upgraded context.

Copy link
Member

Choose a reason for hiding this comment

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

I would add a note mentioning that should be kept in mind that the call is executed from the upgraded contract itself, and not the calling account, since they may have some implications in the setup.

Also, another note that could be helpful is that with native account abstraction, and multicall being part of SNIP6, this behavior could be achieved by using just upgraded and putting the extra call in the second element of the list of calls. Then the call would be executed from the account itself, and can't be front-runned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

docs/modules/ROOT/pages/api/upgrades.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/upgrades.adoc Show resolved Hide resolved
Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

Good job, Andrew!
I've left a couple of comments

packages/upgrades/src/upgradeable.cairo Show resolved Hide resolved
packages/upgrades/src/tests/test_upgradeable.cairo Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/upgrades.adoc Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.90%. Comparing base (bf5d02c) to head (e30d6b1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1148      +/-   ##
==========================================
+ Coverage   88.87%   88.90%   +0.03%     
==========================================
  Files          57       57              
  Lines        1375     1379       +4     
==========================================
+ Hits         1222     1226       +4     
  Misses        153      153              
Files with missing lines Coverage Δ
packages/upgrades/src/upgradeable.cairo 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf5d02c...e30d6b1. Read the comment docs.

Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

Left a couple of minor suggestions. Apart from that, I think we are ready to go

docs/modules/ROOT/pages/api/upgrades.adoc Show resolved Hide resolved
packages/upgrades/src/tests/test_upgradeable.cairo Outdated Show resolved Hide resolved
}

#[test]
#[ignore] // REASON:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not forget to add a reason or un-ignore the test

packages/upgrades/src/upgradeable.cairo Outdated Show resolved Hide resolved
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.

Add upgrade_and_call as utility
3 participants