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

Subnet registry to deploy upgradeable subnet actors #822

Merged
merged 15 commits into from
Mar 20, 2024

Conversation

snissn
Copy link
Contributor

@snissn snissn commented Mar 19, 2024

Change subnet registry so that subnet actors the registry deploys have the diamondcut and diamondLoupe Factes on them

  • Blocker: ENG-29 RegisterSubnetFacet diamond constructor missing Loupe and DiamondCut

    • add code from test createSubnetActorDiamondWithFaucets to subnet registry function newSubnetActor
    • update SubnetRegistryDiamond.sol for 2 more facets
      • add to constructorParams
        • bytes4[] subnetActorDiamondCutSelectors;
        • bytes4[] subnetActorLoupeSelectors;
        • address diamondCutFacet;
        • address loupeFacet;
      • in constructor
        • assert both addresses != 0
      • set state variable "s" with the four values above
      • update ./lib/LibSubnetRegistryStorage.sol
        • address SUBNET_ACTOR_DIAMOND_CUT_FACET;
        • address SUBNET_ACTOR_LOUPE_FACET;
        • bytes4[] subnetActorDiamondCutSelectors;
        • bytes4[] subnetActorLoupeSelectors;
  • deploy-registry.ts needs to deploy DiamondCut and Loupe facets

Upgrade Code

  • Use registry config and after upgrading create a config for each subnet actor that is upgraded in the format subnet.actor-{address.}json
  • Update subnet actor upgrade scripts to accept an address for the subnet actor

Testing plan

  1. Deploy a new gateway and registry combo
  2. update ~/.ipc/config with latest gateway and registry info
  3. create a new subnet using the command ipc-cli subnet create --parent /r1337 --min-validators 3 --min-validator-stake 1 --bottomup-check-period 30 --permission-mode collateral --supply-source-kind native --from 0xAddress
  4. modify one of the subnet actor facets, such as deleting or adding a function, or editing a function and run this command to perform an upgrade: ipc/contracts$ make upgrade-sa-diamond SUBNET_ACTOR_ADDRESS=0xed27b8e0f2f382195d1a71d55edccb9acccb6daf
  5. The subnet actor should be upgraded on chain with an output similar to:
make upgrade-sa-diamond SUBNET_ACTOR_ADDRESS=0xed27b8e0f2f382195d1a71d55edccb9acccb6daf
./ops/upgrade-sa-diamond.sh auto 0xed27b8e0f2f382195d1a71d55edccb9acccb6daf
[*] Automatically getting chainID for network
[*] Target network Chain ID: 0x539
Generating typings for: 1 artifacts in dir: typechain for target: ethers-v5
Successfully generated 56 typings!
Compiled 1 Solidity file successfully (evm target: paris).

Facet Bytecode Not Found:
---------------------------------
Facet Name: SubnetActorManagerFacet
Libraries:

Address: 0x5172193b895876021684E8b20323Ac0C7467351c


Diamond Facet Upgrade:
-----------------------------------
Diamond Address: 0xed27b8e0f2f382195d1a71d55edccb9acccb6daf
Replacement Facet Name: SubnetActorManagerFacet


Deployment Status:
-------------------------
New replacement facet (SubnetActorManagerFacet) deployed.
  1. confirm a new file is created subnet.actor-0xed27b8e0f2f382195d1a71d55edccb9acccb6daf.json and archive that information for the future because subsequent upgrades from this make file will expect that to be there

@raulk raulk requested a review from cryptoAtwill March 19, 2024 02:21
@@ -20,7 +20,7 @@ upgrade-gw-diamond:
./ops/upgrade-gw-diamond.sh $(NETWORK)

upgrade-sa-diamond:
./ops/upgrade-sa-diamond.sh $(NETWORK)
./ops/upgrade-sa-diamond.sh $(NETWORK) $(SUBNET_ACTOR_ADDRESS)

upgrade-sr-diamond:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @snissn, just a quick question for upgrading subnet-registry, if the subnet actor code has updated, and an we want the registry to deploy new version of SubnetActor, after an upgrade of SubnetRegistry, will the registry start deploying the newer version of the Subnet Actor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey will! The answer should be yes. Using the upgrade code to upgrade src/subnetregistry/RegisterSubnetFacet.sol in the registry should change the deploy path for new subnets.

@snissn snissn marked this pull request as ready for review March 19, 2024 03:11
@jsoares jsoares requested review from cryptoAtwill and raulk March 19, 2024 09:23
@raulk raulk added the Fluence label Mar 19, 2024
Comment on lines +67 to +78
EthFacet {
name: "DiamondLoupeFacet",
abi: ia::diamond_loupe_facet::DIAMONDLOUPEFACET_ABI.to_owned(),
},
EthFacet {
name: "DiamondCutFacet",
abi: ia::diamond_cut_facet::DIAMONDCUTFACET_ABI.to_owned(),
},
EthFacet {
name: "OwnershipFacet",
abi: ia::ownership_facet::OWNERSHIPFACET_ABI.to_owned(),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

We were missing these facets from the gateway. Although the owner address will be f01 (Init actor), as that's the actor that creates the gateway and the registry during genesis:

from: init::INIT_ACTOR_ADDR, // asserted by the constructor

Which means that we anyway can't upgrade the gateway and registry actors inside a subnet without a hard fork.

cc @fridrik01 @cryptoAtwill

@raulk raulk force-pushed the mikers/upgradeSubnetActor branch from 295202b to c16789e Compare March 20, 2024 02:03
@raulk raulk merged commit f2d8744 into main Mar 20, 2024
22 checks passed
@raulk raulk deleted the mikers/upgradeSubnetActor branch March 20, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants