Skip to content

Commit

Permalink
Add logs for more information about chain-specific deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
shanefontaine committed Jul 20, 2021
1 parent 2839fae commit f0af915
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const DEFAULT_TIME_TO_WAIT: number = 0
export const TIMESTAMP_VARIANCE: number = 1000000

export const DEFAULT_ETHERS_OVERRIDES = {
gasLimit: 2500000,
gasLimit: 4500000,
gasPrice: 10000000000
}

Expand Down
16 changes: 12 additions & 4 deletions scripts/deployAndSetupHop/deployL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export async function deployL2 (config: Config) {
l2_canonicalToken,
l2_hopBridgeToken,
l2SwapLpTokenName,
l2SwapLpTokenSymbol
l2SwapLpTokenSymbol,
logger
))

logger.log('deploying L2 bridge and L2 amm wrapper')
Expand Down Expand Up @@ -254,7 +255,8 @@ const deployAmm = async (
l2_canonicalToken: Contract,
l2_hopBridgeToken: Contract,
l2SwapLpTokenName: string,
l2SwapLpTokenSymbol: string
l2SwapLpTokenSymbol: string,
logger: any
) => {

let decimalParams: any[] = []
Expand All @@ -267,7 +269,8 @@ const deployAmm = async (
const l2HopBridgeTokenDecimals = await l2_hopBridgeToken.decimals(...decimalParams)

// Deploy AMM contracts
const L2_SwapContractFactory: ContractFactory = await deployL2SwapLibs(deployer, ethers)
logger.log('Deploying L2 Swap Libs')
const L2_SwapContractFactory: ContractFactory = await deployL2SwapLibs(deployer, ethers, logger)
const l2_swap = await L2_SwapContractFactory.deploy(overrides)
await waitAfterTransaction(l2_swap, ethers)

Expand All @@ -286,6 +289,7 @@ const deployAmm = async (
initializeParams.push(overrides)
}

logger.log('Initializing Swap')
const tx = await l2_swap.initialize(...initializeParams)
await tx.wait()
await waitAfterTransaction()
Expand All @@ -297,9 +301,11 @@ const deployAmm = async (

const deployL2SwapLibs = async (
signer: Signer,
ethers: any
ethers: any,
logger: any
) => {
const L2_MathUtils: ContractFactory = await ethers.getContractFactory('MathUtils', { signer })
logger.log('Deploying L2 Math Utils')
const l2_mathUtils = await L2_MathUtils.deploy(overrides)
await waitAfterTransaction(l2_mathUtils, ethers)

Expand All @@ -312,6 +318,8 @@ const deployL2SwapLibs = async (
}
)

logger.log('Deploying L2 Swap Utils')
logger.log('IMPORTANT: This transaction needs 4.5 million gas to be deployed on Polygon')
const l2_swapUtils = await L2_SwapUtils.deploy(overrides)
await waitAfterTransaction(l2_swapUtils, ethers)

Expand Down
10 changes: 7 additions & 3 deletions scripts/deployAndSetupHop/setupL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ export async function setupL1 (config: Config) {
l1_messenger = L1_MessengerWrapper.attach(l1_messenger.address)
l2_messengerProxy = L2_MessengerProxy.attach(l2MessengerProxyAddress)

logger.log(
`IMPORTANT: this tx will fail if it is being called a second time (i.e. restarting a deployment halfway through).`,
`The value can only be set once.`
)
await updatePolygonState(l1ChainId, l1_messengerWrapper, l2_messengerProxy)
}

Expand Down Expand Up @@ -336,8 +340,8 @@ export async function setupL1 (config: Config) {

logger.log('sending token to L2')
logger.log(
`IF THIS TRANSACTION FAILS: it may be because you are using a patched OZ. Reinstall node modules & redeploy the L1 bridge.`,
`A failed transaction here will not show any internal calls and use very little gas.`
`IMPORTANT: if this transaction fails, it may be because you are using a patched OZ. Reinstall node modules &`,
`redeploy the L1 bridge. A failed transaction here will not show any internal calls and use very little gas.`
)
modifiedGasPrice = await getModifiedGasPrice(ethers, l1ChainId)
tx = await l1_bridge
Expand Down Expand Up @@ -382,7 +386,7 @@ const updatePolygonState = async (
}

const transaction = await l2EthersWallet.sendTransaction(setFxRootTunnelTransaction)
transaction.wait()
return transaction.wait()
}

if (require.main === module) {
Expand Down

0 comments on commit f0af915

Please sign in to comment.