blobstream-contracts
blobstream-contracts copied to clipboard
Deploy/Upgrade mechanism for QGB contract
Context
This PR https://github.com/celestiaorg/quantum-gravity-bridge/pull/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.
cc @adlerjohn @evan-forbes
This can investigated: https://book.getfoundry.sh/config/hardhat