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

feat(deployment): fund L1 bridge #400

Merged
merged 5 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"generate:genesis": "ts-node ./utils/generate_genesis/main.ts",
"test:genesis": "./test/genesis/generate_genesis.test.sh",
"test:integration": "./test/test_integration.sh",
"deploy:hardhat": "LOG_LEVEL=debug pnpm hardhat deploy_L1 --network hardhat --dao-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --team-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --l2-genesis-block-hash 0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 --confirmations 1",
"deploy:hardhat": "LOG_LEVEL=debug pnpm hardhat deploy_L1 --network hardhat --dao-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --team-vault 0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39 --l2-genesis-block-hash 0xee1950562d42f0da28bd4550d88886bc90894c77c9c9eaefef775d4c8223f259 --bridge-funder-private-key ddbf12f72c946bb1e6de5eaf580c51db51828ba198d9b0dba9c7d48ec748dc04 --bridge-fund 0xff --confirmations 1",
"lint-staged": "lint-staged --allow-empty"
},
"lint-staged": {
Expand Down Expand Up @@ -81,4 +81,4 @@
"@openzeppelin/contracts": "^4.5.0",
"@openzeppelin/contracts-upgradeable": "^4.5.1"
}
}
}
41 changes: 41 additions & 0 deletions packages/protocol/tasks/deploy_L1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ task("deploy_L1")
ethers.constants.HashZero
)
.addOptionalParam("l2ChainId", "L2 chain id", config.K_CHAIN_ID, types.int)
.addOptionalParam(
"bridgeFunderPrivateKey",
"Private key of the L1 bridge funder",
"",
types.string
)
.addOptionalParam(
"bridgeFund",
"L1 bridge's initial fund in hex",
"",
types.string
)
.addOptionalParam(
"confirmations",
"Number of confirmations to wait for deploy transaction.",
Expand Down Expand Up @@ -51,6 +63,8 @@ export async function deployContracts(hre: any) {
const l2GenesisBlockHash = hre.args.l2GenesisBlockHash
const taikoL2Address = hre.args.taikoL2
const l2ChainId = hre.args.l2ChainId
const bridgeFunderPrivateKey = hre.args.bridgeFunderPrivateKey
const bridgeFund = hre.args.bridgeFund

log.debug(`network: ${network}`)
log.debug(`chainId: ${chainId}`)
Expand All @@ -59,6 +73,8 @@ export async function deployContracts(hre: any) {
log.debug(`l2GenesisBlockHash: ${l2GenesisBlockHash}`)
log.debug(`taikoL2Address: ${taikoL2Address}`)
log.debug(`l2ChainId: ${l2ChainId}`)
log.debug(`bridgeFunderPrivateKey: ${bridgeFunderPrivateKey}`)
log.debug(`bridgeFund: ${bridgeFund}`)
log.debug(`confirmations: ${hre.args.confirmations}`)
log.debug()

Expand Down Expand Up @@ -131,6 +147,31 @@ export async function deployContracts(hre: any) {
await AddressManager.setAddress(`${chainId}.bridge`, Bridge.address)
)

// Fund L1 bridge, which is necessary when there is a L2 faucet
if (
bridgeFunderPrivateKey.length &&
hre.ethers.utils.isHexString(bridgeFund)
) {
const funder = new hre.ethers.Wallet(
bridgeFunderPrivateKey,
hre.ethers.provider
)

await utils.waitTx(
hre,
await funder.sendTransaction({
to: Bridge.address,
value: hre.ethers.BigNumber.from(bridgeFund),
})
)

log.debug(
`L1 bridge balance: ${hre.ethers.utils.hexlify(
await hre.ethers.provider.getBalance(Bridge.address)
)}`
)
}

// save deployments
const deployments = {
network,
Expand Down
5 changes: 3 additions & 2 deletions packages/protocol/test/genesis/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"TokenVault": "0x0000777700000000000000000000000000000002",
"EtherVault": "0x0000777700000000000000000000000000000003",
"Bridge": "0x0000777700000000000000000000000000000004",
"TestERC20": "0x0000777700000000000000000000000000000005"
"TestERC20": "0x0000777700000000000000000000000000000005",
"AddressManager": "0x0000777700000000000000000000000000000006"
},
"predeployERC20": true
}
}