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

Deploy/Upgrade mechanism for QGB contract #178

Open
rach-id opened this issue Aug 21, 2023 · 2 comments
Open

Deploy/Upgrade mechanism for QGB contract #178

rach-id opened this issue Aug 21, 2023 · 2 comments
Assignees
Labels
contracts enhancement New feature or request

Comments

@rach-id
Copy link
Member

rach-id commented Aug 21, 2023

Context

This PR #177 implements the UUPS pattern in the QGB smart contract.

This changes how the QGB contract will be deployed from now on.

Previously, we were using a deploy command from the orchestrator-relayer to deploy the contract as it was straightforward.

Now that it's upgradable, to deploy it, we need to do the following:

  • Deploy the implementation
  • Deploy the proxy
  • Link the proxy to the implementation

Doing these steps, when deploying, and also when upgrading doing something similar, can be a bit tricky to implement/maintain correctly.

Proposals:

Hardhat project

Create a deploy folder inside the QGB repo, which would contain a hardhat project and a Makefile. This project will have already implemented scripts for deploying/upgrading, and will use the contracts in the root QGB repo.

This would allow keeping using foundry as a dev environment, and hardhat for deployment/upgrades.
The Makefile and a few scripts will help automate the whole process.

Also, we can incorporate some static code analyzers to be executed to check for known issues.

The upside is that we will use the hardhat abstractions directly, and not have to maintain them:

  const qgb = await hre.ethers.getContractFactory("QuantumGravityBridge");
  let qgbInstance = await hre.upgrades.deployProxy(qgb, [12443, 12344, "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"], {
    initializer: 'initialize',
    kind: 'uups'
  });
  await qgbInstance.waitForDeployment();

  console.log(
      `deployed to ${await qgbInstance.getAddress()}`
  );

  const qgbV2 = await hre.ethers.getContractFactory("QuantumGravityBridgeV2");
  console.log("Upgrading QGB...");
  await hre.upgrades.upgradeProxy(await qgbInstance.getAddress(), qgbV2);
  console.log("QGB upgraded successfully");

Note: we will still have a go command to deploy so that we use it in E2E tests and others. However, it will contain an experimental implementation not advised for production.

Maintain our own implementation

Update the deploy go command to do all the steps done by hardhat deployProxy and also provide an upgrade command to perform the upgrades. And then having to maintain them for any changes, etc.

Decision

TBD.

@rach-id rach-id added enhancement New feature or request contracts labels Aug 21, 2023
@rach-id rach-id self-assigned this Aug 21, 2023
@rach-id
Copy link
Member Author

rach-id commented Aug 21, 2023

cc @adlerjohn @evan-forbes

@rach-id
Copy link
Member Author

rach-id commented Sep 13, 2023

This can investigated: https://book.getfoundry.sh/config/hardhat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant