Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

1 - upgrade facets #268

Merged
merged 40 commits into from
Nov 21, 2023
Merged

1 - upgrade facets #268

merged 40 commits into from
Nov 21, 2023

Conversation

snissn
Copy link
Contributor

@snissn snissn commented Oct 31, 2023

use hardhat to upgrade facets attached to the gateway

snissn added 30 commits October 26, 2023 16:06
…pe interspection to the gateway diamond so that we can know the current available functions
…compiled contracts, also gets the active facets on the gw diamond and prints out their bytecode from the chain. todo diff and run replace on any extra
…hipyard/ipc-solidity-actors into mikers/hardhatDiamondUpgrade
…hipyard/ipc-solidity-actors into mikers/hardhatDiamondUpgrade
…hipyard/ipc-solidity-actors into mikers/hardhatDiamondUpgrade
@snissn
Copy link
Contributor Author

snissn commented Nov 1, 2023

https://filecoinproject.slack.com/files/U042VH0A17Y/F063PUS8HB5/diamond_gateway_upgrade_2.mov

here's a demo of how the hardhat command npx hardhat upgrade-gw-diamond works - i simulate making a change to some of the code in a function in the GatewayRouterFacet to simulate a bugfix, run the hardhat command and deploy the function changes, then I revert the changes locally, run the command again and it updates it again. i also show that it does nothing when called without any changes

@snissn snissn marked this pull request as ready for review November 1, 2023 20:26
@snissn snissn marked this pull request as draft November 1, 2023 21:49
@snissn snissn marked this pull request as ready for review November 1, 2023 22:32
@snissn snissn requested review from aakoshh and adlrocha November 1, 2023 22:32
* initial work on upgrade sa diamond

* refactor code to util

* bugfix

* clean up upgrade subnet actor script
* large hardhat.config.js change due to prettier 

* add feature to update deployments.json file when you upgrade facets

* sed fix for accepting multi-line json
@snissn snissn changed the base branch from dev to dev_prettier_config November 3, 2023 03:41
@snissn snissn changed the base branch from dev_prettier_config to dev November 3, 2023 03:50
Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

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

Amazing job! I left a few suggestions. Also, would you mind adding a description of how the upgrade process works in the README? It would be useful to share some context of what the scripts do for someone coming new into the code base. Thanks!

// Function to upgrade the Subnet Actor Diamond
async function upgradeGatewayActorDiamond(deployments) {
// Get the Gateway Diamond address from the deployments
const gatewayDiamondAddress = deployments.Gateway
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the one upgrading is not the one that originally deployed the gateway? (this may definitely be the case). Could we add a way to optionally pass the gateway address as an argument and try to fetch from the deployments if nothing is provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we would need to pass the deployment.json around. It should just be public addresses! We need a lot of information to automatically do Diamond cut upgrades. We need to know the libs that the gateway and each facet was compiled with in order to determine the appropriate byte code on chain. At that point we are replicating the entire deployments json into command lines and it seems a lot easier to use the deployments json file!

}

export async function getRuntimeBytecode(bytecode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so in order to compare the bytecode deployed to the one locally, you do a test deployment using ganache. Do you mind adding a description of the process of upgrading in updade-sa-diamond and upgrade-gw-diamond, or even better, add a description in the README? I feel this could really help someone coming in the future to edit these scripts. Thanks 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Could I set that up in a follow on PR or do you want the readme blocking the merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is fine if we add it to a follow-up PR, let me know if you want me to open an issue for this. Mainly, it would be really useful to document:

  • How upgrades work.
  • The process of performing a specific upgrades.
  • And the basic assets (like the deployment.json) that needs to be provided if we want someone else to perform the upgrade.

Thanks! 🙏

scripts/upgrade-gw-diamond.ts Show resolved Hide resolved
scripts/util.ts Show resolved Hide resolved
@snissn snissn changed the title upgrade facets 1 - upgrade facets Nov 9, 2023
Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

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

Feel free to merge :) Just bear in mind to address my comment here: #268 (comment) in a follow-up PR if possible. Thanks!

@snissn
Copy link
Contributor Author

snissn commented Nov 21, 2023

follow up issue here: consensus-shipyard/ipc#126

@snissn snissn merged commit 088b307 into dev Nov 21, 2023
6 checks passed
@snissn snissn deleted the mikers/hardhatDiamondUpgrade branch November 21, 2023 21:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants