-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-54q9-r92x-944r
Harden the `L2WormholeGateway` minting flow
- Loading branch information
Showing
6 changed files
with
321 additions
and
98 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
cross-chain/arbitrum/deploy_l2/32_manual_upgrade_arbitrum_wormhole_gateway.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction, Deployment } from "hardhat-deploy/types" | ||
import { ContractFactory } from "ethers" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, helpers, deployments } = hre | ||
|
||
const { deployer } = await helpers.signers.getNamedSigners() | ||
|
||
const proxyDeployment: Deployment = await deployments.get( | ||
"ArbitrumWormholeGateway" | ||
) | ||
const implementationContractFactory: ContractFactory = | ||
await ethers.getContractFactory("L2WormholeGateway", { | ||
signer: deployer, | ||
}) | ||
|
||
// Deploy new implementation contract | ||
const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( | ||
proxyDeployment, | ||
implementationContractFactory, | ||
{ | ||
kind: "transparent", | ||
} | ||
)) as string | ||
|
||
deployments.log( | ||
`new implementation contract deployed at: ${newImplementationAddress}` | ||
) | ||
|
||
// Assemble proxy upgrade transaction. | ||
const proxyAdmin = await hre.upgrades.admin.getInstance() | ||
const proxyAdminOwner = await proxyAdmin.owner() | ||
|
||
const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( | ||
"upgrade", | ||
[proxyDeployment.address, newImplementationAddress] | ||
) | ||
|
||
deployments.log( | ||
`proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + | ||
`\t\tfrom: ${proxyAdminOwner}\n` + | ||
`\t\tto: ${proxyAdmin.address}\n` + | ||
`\t\tdata: ${upgradeTxData}` | ||
) | ||
|
||
// Update Deployment Artifact | ||
const gatewayArtifact: Artifact = | ||
hre.artifacts.readArtifactSync("L2WormholeGateway") | ||
|
||
await deployments.save("ArbitrumWormholeGateway", { | ||
...proxyDeployment, | ||
abi: gatewayArtifact.abi, | ||
implementation: newImplementationAddress, | ||
}) | ||
|
||
// Contracts can be verified on L2 Arbiscan in a similar way as we do it on | ||
// L1 Etherscan | ||
if (hre.network.tags.arbiscan) { | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation | ||
// contract, the proxy itself and any proxy-related contracts, as well as | ||
// link the proxy to the implementation contract’s ABI on (Ether)scan. | ||
await hre.run("verify", { | ||
address: newImplementationAddress, | ||
constructorArgsParams: proxyDeployment.args, | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["ManualUpgradeArbitrumWormholeGateway"] | ||
|
||
// Comment this line when running an upgrade. | ||
// yarn deploy --tags ManualUpgradeArbitrumWormholeGateway --network <network> | ||
func.skip = async () => true |
77 changes: 77 additions & 0 deletions
77
cross-chain/base/deploy_l2/24_manual_upgrade_base_wormhole_gateway.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction, Deployment } from "hardhat-deploy/types" | ||
import { ContractFactory } from "ethers" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, helpers, deployments } = hre | ||
|
||
const { deployer } = await helpers.signers.getNamedSigners() | ||
|
||
const proxyDeployment: Deployment = await deployments.get( | ||
"BaseWormholeGateway" | ||
) | ||
const implementationContractFactory: ContractFactory = | ||
await ethers.getContractFactory("L2WormholeGateway", { | ||
signer: deployer, | ||
}) | ||
|
||
// Deploy new implementation contract | ||
const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( | ||
proxyDeployment, | ||
implementationContractFactory, | ||
{ | ||
kind: "transparent", | ||
} | ||
)) as string | ||
|
||
deployments.log( | ||
`new implementation contract deployed at: ${newImplementationAddress}` | ||
) | ||
|
||
// Assemble proxy upgrade transaction. | ||
const proxyAdmin = await hre.upgrades.admin.getInstance() | ||
const proxyAdminOwner = await proxyAdmin.owner() | ||
|
||
const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( | ||
"upgrade", | ||
[proxyDeployment.address, newImplementationAddress] | ||
) | ||
|
||
deployments.log( | ||
`proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + | ||
`\t\tfrom: ${proxyAdminOwner}\n` + | ||
`\t\tto: ${proxyAdmin.address}\n` + | ||
`\t\tdata: ${upgradeTxData}` | ||
) | ||
|
||
// Update Deployment Artifact | ||
const gatewayArtifact: Artifact = | ||
hre.artifacts.readArtifactSync("L2WormholeGateway") | ||
|
||
await deployments.save("BaseWormholeGateway", { | ||
...proxyDeployment, | ||
abi: gatewayArtifact.abi, | ||
implementation: newImplementationAddress, | ||
}) | ||
|
||
// Contracts can be verified on L2 Basescan in a similar way as we do it on | ||
// L1 Etherscan | ||
if (hre.network.tags.basescan) { | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation | ||
// contract, the proxy itself and any proxy-related contracts, as well as | ||
// link the proxy to the implementation contract’s ABI on (Ether)scan. | ||
await hre.run("verify", { | ||
address: newImplementationAddress, | ||
constructorArgsParams: proxyDeployment.args, | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["ManualUpgradeBaseWormholeGateway"] | ||
|
||
// Comment this line when running an upgrade. | ||
// yarn deploy --tags ManualUpgradeBaseWormholeGateway --network <network> | ||
func.skip = async () => true |
77 changes: 77 additions & 0 deletions
77
cross-chain/optimism/deploy_l2/32_manual_upgrade_optimism_wormhole_gateway.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction, Deployment } from "hardhat-deploy/types" | ||
import { ContractFactory } from "ethers" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, helpers, deployments } = hre | ||
|
||
const { deployer } = await helpers.signers.getNamedSigners() | ||
|
||
const proxyDeployment: Deployment = await deployments.get( | ||
"OptimismWormholeGateway" | ||
) | ||
const implementationContractFactory: ContractFactory = | ||
await ethers.getContractFactory("L2WormholeGateway", { | ||
signer: deployer, | ||
}) | ||
|
||
// Deploy new implementation contract | ||
const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( | ||
proxyDeployment, | ||
implementationContractFactory, | ||
{ | ||
kind: "transparent", | ||
} | ||
)) as string | ||
|
||
deployments.log( | ||
`new implementation contract deployed at: ${newImplementationAddress}` | ||
) | ||
|
||
// Assemble proxy upgrade transaction. | ||
const proxyAdmin = await hre.upgrades.admin.getInstance() | ||
const proxyAdminOwner = await proxyAdmin.owner() | ||
|
||
const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( | ||
"upgrade", | ||
[proxyDeployment.address, newImplementationAddress] | ||
) | ||
|
||
deployments.log( | ||
`proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + | ||
`\t\tfrom: ${proxyAdminOwner}\n` + | ||
`\t\tto: ${proxyAdmin.address}\n` + | ||
`\t\tdata: ${upgradeTxData}` | ||
) | ||
|
||
// Update Deployment Artifact | ||
const gatewayArtifact: Artifact = | ||
hre.artifacts.readArtifactSync("L2WormholeGateway") | ||
|
||
await deployments.save("OptimismWormholeGateway", { | ||
...proxyDeployment, | ||
abi: gatewayArtifact.abi, | ||
implementation: newImplementationAddress, | ||
}) | ||
|
||
// Contracts can be verified on L2 Optimism Etherscan in a similar way as we do it on | ||
// L1 Etherscan | ||
if (hre.network.tags.optimism_etherscan) { | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation | ||
// contract, the proxy itself and any proxy-related contracts, as well as | ||
// link the proxy to the implementation contract’s ABI on (Ether)scan. | ||
await hre.run("verify", { | ||
address: newImplementationAddress, | ||
constructorArgsParams: proxyDeployment.args, | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["ManualUpgradeOptimismWormholeGateway"] | ||
|
||
// Comment this line when running an upgrade. | ||
// yarn deploy --tags ManualUpgradeOptimismWormholeGateway --network <network> | ||
func.skip = async () => true |
83 changes: 83 additions & 0 deletions
83
cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction, Deployment } from "hardhat-deploy/types" | ||
import { ContractFactory } from "ethers" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { ethers, helpers, deployments } = hre | ||
|
||
const { deployer } = await helpers.signers.getNamedSigners() | ||
|
||
const proxyDeployment: Deployment = await deployments.get( | ||
"PolygonWormholeGateway" | ||
) | ||
const implementationContractFactory: ContractFactory = | ||
await ethers.getContractFactory("L2WormholeGateway", { | ||
signer: deployer, | ||
}) | ||
|
||
// Deploy new implementation contract | ||
const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( | ||
proxyDeployment, | ||
implementationContractFactory, | ||
{ | ||
kind: "transparent", | ||
} | ||
)) as string | ||
|
||
deployments.log( | ||
`new implementation contract deployed at: ${newImplementationAddress}` | ||
) | ||
|
||
// Assemble proxy upgrade transaction. | ||
const proxyAdmin = await hre.upgrades.admin.getInstance() | ||
const proxyAdminOwner = await proxyAdmin.owner() | ||
|
||
const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( | ||
"upgrade", | ||
[proxyDeployment.address, newImplementationAddress] | ||
) | ||
|
||
deployments.log( | ||
`proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + | ||
`\t\tfrom: ${proxyAdminOwner}\n` + | ||
`\t\tto: ${proxyAdmin.address}\n` + | ||
`\t\tdata: ${upgradeTxData}` | ||
) | ||
|
||
// Update Deployment Artifact | ||
const gatewayArtifact: Artifact = | ||
hre.artifacts.readArtifactSync("L2WormholeGateway") | ||
|
||
await deployments.save("PolygonWormholeGateway", { | ||
...proxyDeployment, | ||
abi: gatewayArtifact.abi, | ||
implementation: newImplementationAddress, | ||
}) | ||
|
||
// Contracts can be verified on L2 Polygonscan in a similar way as we do it on | ||
// L1 Etherscan | ||
if (hre.network.tags.polygonscan) { | ||
if (hre.network.name === "mumbai") { | ||
// Polygonscan might not include the recently added proxy transaction right | ||
// after deployment. We need to wait some time so that transaction is | ||
// visible on Polygonscan. | ||
await new Promise((resolve) => setTimeout(resolve, 10000)) // 10sec | ||
} | ||
// We use `verify` instead of `verify:verify` as the `verify` task is defined | ||
// in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation | ||
// contract, the proxy itself and any proxy-related contracts, as well as | ||
// link the proxy to the implementation contract’s ABI on (Ether)scan. | ||
await hre.run("verify", { | ||
address: newImplementationAddress, | ||
constructorArgsParams: proxyDeployment.args, | ||
}) | ||
} | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["ManualUpgradePolygonWormholeGateway"] | ||
|
||
// Comment this line when running an upgrade. | ||
// yarn deploy --tags ManualUpgradePolygonWormholeGateway --network <network> | ||
func.skip = async () => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.