Skip to content

Commit

Permalink
deploy all script, refactor other deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalgek committed Apr 8, 2024
1 parent 06d00c7 commit 0b22b0f
Show file tree
Hide file tree
Showing 13 changed files with 829 additions and 553 deletions.
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ TOKEN=
# Address of the rebasable token to deploy the bridge/gateway for
REBASABLE_TOKEN=

# Address of token rate notifier. Connects Lido core protocol.
TOKEN_RATE_NOTIFIER=

# Address of token rate pusher
L1_OP_STACK_TOKEN_RATE_PUSHER=

# Gas limit required to complete pushing token rate on L2.
L2_GAS_LIMIT_FOR_PUSHING_TOKEN_RATE=

# A time period when token rate can be considered outdated.
RATE_OUTDATED_DELAY=

# Address of L1 token bridge proxy.
L1_TOKEN_BRIDGE=

# Address of L2 token bridge proxy.
L2_TOKEN_BRIDGE=

# Address of the non-rebasable token proxy on L2.
L2_TOKEN=

# Address of token rate oracle on L2
L2_TOKEN_RATE_ORACLE=

# Address of bridge executor.
GOV_BRIDGE_EXECUTOR=

# Name of the network environments used by deployment scripts.
# Might be one of: "mainnet", "goerli".
NETWORK=mainnet
Expand Down
4 changes: 2 additions & 2 deletions scripts/optimism/deploy-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function main() {
const [l1DeployScript, l2DeployScript] = await optimism
.deployment(networkName, { logger: console })
.erc20TokenBridgeDeployScript(
deploymentConfig.token,
deploymentConfig.rebasableToken,
deploymentConfig.l1Token,
deploymentConfig.l1RebasableToken,
deploymentConfig.l2TokenRateOracle,
{
deployer: ethDeployer,
Expand Down
73 changes: 73 additions & 0 deletions scripts/optimism/deploy-new-impls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import env from "../../utils/env";
import prompt from "../../utils/prompt";
import network from "../../utils/network";
import deployment from "../../utils/deployment";

import deploymentNewImplementations from "../../utils/optimism/deploymentNewImplementations";

async function main() {
const networkName = env.network();
const ethOptNetwork = network.multichain(["eth", "opt"], networkName);

const [ethDeployer] = ethOptNetwork.getSigners(env.privateKey(), {
forking: env.forking(),
});
const [, optDeployer] = ethOptNetwork.getSigners(
env.string("OPT_DEPLOYER_PRIVATE_KEY"),
{
forking: env.forking(),
}
);

const deploymentConfig = deployment.loadMultiChainDeploymentConfig();

const [l1DeployScript, l2DeployScript] = await deploymentNewImplementations(
networkName,
{ logger: console }
)
.deployScript(
{
deployer: ethDeployer,
admins: {
proxy: deploymentConfig.l1.proxyAdmin,
bridge: ethDeployer.address
},
contractsShift: 0,
tokenProxyAddress: deploymentConfig.l1Token,
tokenRebasableProxyAddress: deploymentConfig.l1RebasableToken,
opStackTokenRatePusherImplAddress: deploymentConfig.l1OpStackTokenRatePusher,
tokenBridgeProxyAddress: deploymentConfig.l1TokenBridge,
},
{
deployer: optDeployer,
admins: {
proxy: deploymentConfig.l2.proxyAdmin,
bridge: optDeployer.address,
},
contractsShift: 0,
tokenBridgeProxyAddress: deploymentConfig.l2TokenBridge,
tokenProxyAddress: deploymentConfig.l2Token,
tokenRateOracleProxyAddress: deploymentConfig.l2TokenRateOracle,
tokenRateOracleRateOutdatedDelay: deploymentConfig.rateOutdatedDelay,
}
);

await deployment.printMultiChainDeploymentConfig(
"Deploy new implementations: bridges, wstETH, stETH",
ethDeployer,
optDeployer,
deploymentConfig,
l1DeployScript,
l2DeployScript
);

await prompt.proceed();

await l1DeployScript.run();
await l2DeployScript.run();
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
112 changes: 57 additions & 55 deletions scripts/optimism/deploy-oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,74 @@ import env from "../../utils/env";
import prompt from "../../utils/prompt";
import network from "../../utils/network";
import optimism from "../../utils/optimism";
import deploymentOracle from "../../utils/deployment";
import deployment from "../../utils/deployment";
import { TokenRateNotifier__factory } from "../../typechain";

async function main() {
const networkName = env.network();
const ethOptNetwork = network.multichain(["eth", "opt"], networkName);
const networkName = env.network();
const ethOptNetwork = network.multichain(["eth", "opt"], networkName);

const [ethDeployer] = ethOptNetwork.getSigners(env.privateKey(), {
forking: env.forking(),
});
const [, optDeployer] = ethOptNetwork.getSigners(
env.string("OPT_DEPLOYER_PRIVATE_KEY"),
{
forking: env.forking(),
}
);
const [ethDeployer] = ethOptNetwork.getSigners(env.privateKey(), {
forking: env.forking(),
});
const [, optDeployer] = ethOptNetwork.getSigners(
env.string("OPT_DEPLOYER_PRIVATE_KEY"),
{
forking: env.forking(),
}
);

const l1Token = env.address("TOKEN")
const l1Admin = env.address("L1_PROXY_ADMIN");
const l2Admin = env.address("L2_PROXY_ADMIN");
const deploymentConfig = deployment.loadMultiChainDeploymentConfig();

const [l1DeployScript, l2DeployScript] = await optimism
.deploymentOracle(networkName, { logger: console })
.oracleDeployScript(
l1Token,
{
deployer: ethDeployer,
admins: {
proxy: l1Admin,
bridge: ethDeployer.address,
},
},
{
deployer: optDeployer,
admins: {
proxy: l2Admin,
bridge: optDeployer.address,
},
}
);
const [l1DeployScript, l2DeployScript] = await optimism
.deploymentOracle(networkName, { logger: console })
.oracleDeployScript(
deploymentConfig.l1Token,
deploymentConfig.l2GasLimitForPushingTokenRate,
deploymentConfig.rateOutdatedDelay,
{
deployer: ethDeployer,
admins: {
proxy: deploymentConfig.l1.proxyAdmin,
bridge: ethDeployer.address,
},
contractsShift: 0
},
{
deployer: optDeployer,
admins: {
proxy: deploymentConfig.l2.proxyAdmin,
bridge: optDeployer.address,
},
contractsShift: 0
}
);

// await deploymentOracle.printMultiChainDeploymentConfig(
// "Deploy Token Rate Oracle",
// ethDeployer,
// optDeployer,
// deploymentConfig,
// l1DeployScript,
// l2DeployScript
// );
await deployment.printMultiChainDeploymentConfig(
"Deploy Token Rate Oracle",
ethDeployer,
optDeployer,
deploymentConfig,
l1DeployScript,
l2DeployScript
);

await prompt.proceed();
await prompt.proceed();

await l1DeployScript.run();
await l2DeployScript.run();
await l1DeployScript.run();
await l2DeployScript.run();

/// setup, add observer
const tokenRateNotifier = TokenRateNotifier__factory.connect(
l1DeployScript.tokenRateNotifierImplAddress,
ethDeployer
);
await tokenRateNotifier
.connect(ethDeployer)
.addObserver(l1DeployScript.opStackTokenRatePusherImplAddress);
/// setup by adding observer
const tokenRateNotifier = TokenRateNotifier__factory.connect(
l1DeployScript.tokenRateNotifierImplAddress,
ethDeployer
);
await tokenRateNotifier
.connect(ethDeployer)
.addObserver(l1DeployScript.opStackTokenRatePusherImplAddress);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
console.error(error);
process.exitCode = 1;
});
4 changes: 2 additions & 2 deletions test/bridge-executor/optimism.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { BridgingManagerRole } from "../../utils/bridging-management";
import env from "../../utils/env";
import network from "../../utils/network";
import { getBridgeExecutorParams } from "../../utils/bridge-executor";
import deploymentAll from "../../utils/optimism/deploymentAll";
import deploymentAll from "../../utils/optimism/deploymentAllFromScratch";

scenario("Optimism :: Bridge Executor integration test", ctxFactory)
.step("Activate L2 bridge", async (ctx) => {
Expand Down Expand Up @@ -239,7 +239,7 @@ async function ctxFactory() {

const [, optDeployScript] = await deploymentAll(
networkName
).erc20TokenBridgeDeployScript(
).deployAllScript(
l1Token.address,
l1TokenRebasable.address,
{
Expand Down
28 changes: 21 additions & 7 deletions utils/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,32 @@ interface ChainDeploymentConfig extends BridgingManagerSetupConfig {
}

interface MultiChainDeploymentConfig {
token: string;
rebasableToken: string;
l1Token: string;
l1RebasableToken: string;
l1OpStackTokenRatePusher: string;
l2GasLimitForPushingTokenRate: number;
rateOutdatedDelay: number;
l1TokenBridge: string;
l2TokenBridge: string;
l2Token: string;
l2TokenRateOracle: string;
govBridgeExecutor: string;
l1: ChainDeploymentConfig;
l2: ChainDeploymentConfig;
}

export function loadMultiChainDeploymentConfig(): MultiChainDeploymentConfig {
return {
token: env.address("TOKEN"),
rebasableToken: env.address("REBASABLE_TOKEN"),
l2TokenRateOracle: env.address("TOKEN_RATE_ORACLE"),
l1Token: env.address("TOKEN"),
l1RebasableToken: env.address("REBASABLE_TOKEN"),
l1OpStackTokenRatePusher: env.address("L1_OP_STACK_TOKEN_RATE_PUSHER"),
l2GasLimitForPushingTokenRate: Number(env.string("L2_GAS_LIMIT_FOR_PUSHING_TOKEN_RATE")),
rateOutdatedDelay: Number(env.string("RATE_OUTDATED_DELAY")),
l1TokenBridge: env.address("L1_TOKEN_BRIDGE"),
l2TokenBridge: env.address("L2_TOKEN_BRIDGE"),
l2Token: env.address("L2_TOKEN"),
l2TokenRateOracle: env.address("L2_TOKEN_RATE_ORACLE"),
govBridgeExecutor: env.address("GOV_BRIDGE_EXECUTOR"),
l1: {
proxyAdmin: env.address("L1_PROXY_ADMIN"),
bridgeAdmin: env.address("L1_BRIDGE_ADMIN"),
Expand Down Expand Up @@ -53,8 +67,8 @@ export async function printMultiChainDeploymentConfig(
l1DeployScript: DeployScript,
l2DeployScript: DeployScript
) {
const { token, stETHToken, l1, l2 } = deploymentParams;
console.log(chalk.bold(`${title} :: ${chalk.underline(token)} :: ${chalk.underline(stETHToken)}\n`));
const { l1Token, l1RebasableToken, l1, l2 } = deploymentParams;
console.log(chalk.bold(`${title} :: ${chalk.underline(l1Token)} :: ${chalk.underline(l1RebasableToken)}\n`));
console.log(chalk.bold(" · L1 Deployment Params:"));
await printChainDeploymentConfig(l1Deployer, l1);
console.log();
Expand Down
Loading

0 comments on commit 0b22b0f

Please sign in to comment.