-
Notifications
You must be signed in to change notification settings - Fork 56
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
chore: change Gateway contract to be upgradable #175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though we have the OZ docs, I think it would be great to add a test to show how the upgrade process would look like
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
added this one more thing in upgrade process on real networks would be to track network files in source control https://docs.openzeppelin.com/upgrades-plugins/1.x/network-files where things like storage layout, implementation contracts address etc would be stored, so when there is upgrade, plugin would validate that storage layout is not broken etc. but i guess we can discuss that once we move from PoC to livenet deployments |
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, we can look into have a contract upgrade workflow section in the specs
it("should upgrade and forward call to Receiver's receiveA function", async function () { | ||
// Upgrade Gateway contract | ||
const GatewayV2 = await ethers.getContractFactory("GatewayV2"); | ||
const gatewayV2 = await upgrades.upgradeProxy(gateway.address, GatewayV2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the deployProxy
caller become admin and can call upgradeProxy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this override in Gateway contract:
function _authorizeUpgrade(address newImplementation) internal override onlyOwner() {}
is to basically control who can upgrade, in this case I used simplest way to add authorization which is Ownable
but we can add more granular roles using role based access control in future:
https://docs.openzeppelin.com/contracts/2.x/access-control
i added this in unit test, to test if upgrade fails if not using owner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this requires a review since we're not merging into main
.
Using openzeppelin hardhat upgrades, and UUPS proxy.
Resources: https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable
UUPS vs Transparent Proxy: https://docs.openzeppelin.com/contracts/4.x/api/proxy#transparent-vs-uups
Had to go with lower package versions because ethers 5 is used. We should consider bumping ethers and other packages.