Commit f52c0752 authored by Maurelian's avatar Maurelian

feat(ctb): Print tenderly simulation URLs during deployment

parent 7617117c
---
'@eth-optimism/contracts-bedrock': patch
---
Print tenderly simulation links during deployment
...@@ -3,3 +3,7 @@ L1_RPC= ...@@ -3,3 +3,7 @@ L1_RPC=
# Private key for the deployer account # Private key for the deployer account
PRIVATE_KEY_DEPLOYER= PRIVATE_KEY_DEPLOYER=
# Optional Tenderly details for a simulation link during deployment
TENDERLY_PROJECT=
TENDERLY_USERNAME=
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
getDeploymentAddress, getDeploymentAddress,
doStep, doStep,
jsonifyTransaction, jsonifyTransaction,
getTenderlySimulationLink,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
...@@ -97,6 +98,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -97,6 +98,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
// Wait for the ownership transfer to complete. // Wait for the ownership transfer to complete.
...@@ -133,6 +135,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -133,6 +135,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
// Wait for the ownership transfer to complete. // Wait for the ownership transfer to complete.
...@@ -169,6 +172,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -169,6 +172,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
// Wait for the ownership transfer to complete. // Wait for the ownership transfer to complete.
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
jsonifyTransaction, jsonifyTransaction,
isStep, isStep,
doStep, doStep,
getTenderlySimulationLink,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
...@@ -193,6 +194,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -193,6 +194,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
await awaitCondition( await awaitCondition(
...@@ -303,6 +305,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -303,6 +305,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`OptimismPortal address: ${OptimismPortal.address}`) console.log(`OptimismPortal address: ${OptimismPortal.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
await awaitCondition( await awaitCondition(
...@@ -331,6 +334,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -331,6 +334,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
await awaitCondition( await awaitCondition(
......
import assert from 'assert' import assert from 'assert'
import { URLSearchParams } from 'url'
import { ethers, Contract } from 'ethers' import { ethers, Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider' import { Provider } from '@ethersproject/abstract-provider'
...@@ -293,6 +294,7 @@ export const getDeploymentAddress = async ( ...@@ -293,6 +294,7 @@ export const getDeploymentAddress = async (
export const jsonifyTransaction = (tx: ethers.PopulatedTransaction): string => { export const jsonifyTransaction = (tx: ethers.PopulatedTransaction): string => {
return JSON.stringify( return JSON.stringify(
{ {
from: tx.from,
to: tx.to, to: tx.to,
data: tx.data, data: tx.data,
value: tx.value, value: tx.value,
...@@ -354,6 +356,9 @@ export const doStep = async (opts: { ...@@ -354,6 +356,9 @@ export const doStep = async (opts: {
console.log(`MSD address: ${opts.SystemDictator.address}`) console.log(`MSD address: ${opts.SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(
await getTenderlySimulationLink(opts.SystemDictator.provider, tx)
)
} }
// Wait for the step to complete. // Wait for the step to complete.
...@@ -368,3 +373,26 @@ export const doStep = async (opts: { ...@@ -368,3 +373,26 @@ export const doStep = async (opts: {
// Perform post-step checks. // Perform post-step checks.
await opts.checks() await opts.checks()
} }
/**
* Returns a direct link to a Tenderly simulation.
*
* @param provider Ethers Provider.
* @param tx Ethers transaction object.
* @returns the url of the tenderly simulation.
*/
export const getTenderlySimulationLink = async (
provider: ethers.providers.Provider,
tx: ethers.PopulatedTransaction
): Promise<string> => {
if (process.env.TENDERLY_PROJECT && process.env.TENDERLY_USERNAME) {
return `https://dashboard.tenderly.co/${process.env.TENDERLY_PROJECT}/${
process.env.TENDERLY_USERNAME
}/simulator/new?${new URLSearchParams({
network: (await provider.getNetwork()).chainId.toString(),
contractAddress: tx.to,
rawFunctionInput: tx.data,
from: tx.from,
}).toString()}`
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment