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

add deployment script for Swellchain (modified copy of Optimism deployment) #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
90 changes: 90 additions & 0 deletions .env.wsteth.swe_mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
RPC_ETH_MAINNET=
RPC_ETH_GOERLI=

RPC_OPT_MAINNET=https://mainnet.optimism.io
RPC_OPT_GOERLI=https://goerli.optimism.io

RPC_ARB_MAINNET=https://arb1.arbitrum.io/rpc
RPC_ARB_GOERLI=https://goerli-rollup.arbitrum.io/rpc

# ############################
# Etherscan
# ############################

ETHERSCAN_API_KEY_ETH=
ETHERSCAN_API_KEY_ARB=
ETHERSCAN_API_KEY_OPT=

# ############################
# Bridge/Gateway Deployment
# ############################

# Address of the token to deploy the bridge/gateway for
TOKEN=

# Name of the network environments used by deployment scripts.
# Might be one of: "mainnet", "goerli".
NETWORK=mainnet

# Run deployment in the forking network instead of public ones
FORKING=true

# Private key of the deployer account used for deployment process
ETH_DEPLOYER_PRIVATE_KEY=
OPT_DEPLOYER_PRIVATE_KEY=
ARB_DEPLOYER_PRIVATE_KEY=

L1_DEV_MULTISIG= ?
L1_PROXY_ADMIN= 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c
L1_BRIDGE_ADMIN= 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c
L1_DEPOSITS_ENABLED=false
L1_WITHDRAWALS_ENABLED=true
L1_DEPOSITS_ENABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x3cd9F71F80AB08ea5a7Dca348B5e94BC595f26A0"]
L1_DEPOSITS_DISABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x73b047fe6337183A454c5217241D780a932777bD"]
L1_WITHDRAWALS_ENABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c"]
L1_WITHDRAWALS_DISABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x73b047fe6337183A454c5217241D780a932777bD"]

L2_PROXY_ADMIN=
L2_BRIDGE_ADMIN=
L2_DEPOSITS_ENABLED=true
L2_WITHDRAWALS_ENABLED=true
L2_DEPOSITS_ENABLERS=[]
L2_DEPOSITS_DISABLERS=[]
L2_WITHDRAWALS_ENABLERS=[]
L2_WITHDRAWALS_DISABLERS=[]

# ############################
# Integration Acceptance & E2E Testing
# ############################

TESTING_ARB_NETWORK=
TESTING_ARB_L1_TOKEN=0x7AEE39c46f20135114e85A03C02aB4FE73fB8127
TESTING_ARB_L2_TOKEN=0x775ede8029C117effce283b3391E420EacF3c85F
TESTING_ARB_L1_ERC20_TOKEN_GATEWAY=0x0A7e12b563Ba623646a31a09F0182e8aD45D6cfD
TESTING_ARB_L2_ERC20_TOKEN_GATEWAY=0x8c269989D839eE9DaEe64D57C8c41404DF87F722
TESTING_ARB_L1_GATEWAY_ROUTER=0xa2a8F940752aDc4A3278B63B96d56D72D2b075B1
TESTING_ARB_L2_GATEWAY_ROUTER=0x57f54f87C44d816f60b92864e23b8c0897D4d81D

TESTING_OPT_NETWORK=
TESTING_OPT_L1_TOKEN=0xaF8a2F0aE374b03376155BF745A3421Dac711C12
TESTING_OPT_L2_TOKEN=0xAED5F9aaF167923D34174b8E636aaF040A11f6F7
TESTING_OPT_L1_ERC20_TOKEN_BRIDGE=0x243b661276670bD17399C488E7287ea4D416115b
TESTING_OPT_L2_ERC20_TOKEN_BRIDGE=0x447CD1794d209Ac4E6B4097B34658bc00C4d0a51

# ############################
# Integration Testing
# ############################

TESTING_USE_DEPLOYED_CONTRACTS=false
TESTING_L1_TOKENS_HOLDER=

TESTING_ARB_GOV_BRIDGE_EXECUTOR=
TESTING_OPT_GOV_BRIDGE_EXECUTOR=

# ############################
# E2E Testing
# ############################

TESTING_PRIVATE_KEY=
TESTING_OPT_LDO_HOLDER_PRIVATE_KEY=
TESTING_ARB_LDO_HOLDER_PRIVATE_KEY=
7 changes: 7 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ const config: HardhatUserConfig = {
opt_sepolia_fork: {
url: "http://localhost:9545",
},

swe_mainnet: {
url: env.string("RPC_SWELL_MAINNET", ""),
},
swe_sepolia: {
url: env.string("RPC_SWELL_SEPOLIA", ""),
},
},
gasReporter: {
enabled: env.string("REPORT_GAS", "false") !== "false",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"optimism:test:integration": "hardhat test ./test/optimism/*.integration.test.ts",
"optimism:test:acceptance": "hardhat test ./test/optimism/*.acceptance.test.ts",
"optimism:test:executor": "hardhat test ./test/bridge-executor/optimism.integration.test.ts",
"optimism:test:launch": "REVERT=false hardhat test ./test/optimism/{_launch.test.ts,bridging.integration.test.ts}"
"optimism:test:launch": "REVERT=false hardhat test ./test/optimism/{_launch.test.ts,bridging.integration.test.ts}",
"swellchain:deploy": "ts-node --files ./scripts/swellchain/deploy-bridge.ts"
},
"keywords": [],
"author": "",
Expand Down
80 changes: 80 additions & 0 deletions scripts/swellchain/deploy-bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import env from "../../utils/env";
import prompt from "../../utils/prompt";
import network from "../../utils/network";
import deployment from "../../utils/deployment";
import { BridgingManagement } from "../../utils/bridging-management";
import swellchain from "../../utils/swellchain";


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

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

const deploymentConfig = deployment.loadMultiChainDeploymentConfig();

const [l1DeployScript, l2DeployScript] = await swellchain
.deployment(networkName, { logger: console })
.erc20TokenBridgeDeployScript(
deploymentConfig.token,
{
deployer: ethDeployer,
admins: {
proxy: deploymentConfig.l1.proxyAdmin,
bridge: ethDeployer.address,
},
},
{
deployer: sweDeployer,
admins: {
proxy: deploymentConfig.l2.proxyAdmin,
bridge: sweDeployer.address,
},
}
);

await deployment.printMultiChainDeploymentConfig(
"Deploy Swellchain Bridge",
ethDeployer,
sweDeployer,
deploymentConfig,
l1DeployScript,
l2DeployScript
);

await prompt.proceed();

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

const l1ERC20TokenBridgeProxyDeployStepIndex = 1;
const l1BridgingManagement = new BridgingManagement(
l1DeployScript.getContractAddress(l1ERC20TokenBridgeProxyDeployStepIndex),
ethDeployer,
{ logger: console }
);

const l2ERC20TokenBridgeProxyDeployStepIndex = 3;
const l2BridgingManagement = new BridgingManagement(
l2DeployScript.getContractAddress(l2ERC20TokenBridgeProxyDeployStepIndex),
sweDeployer,
{ logger: console }
);

await l1BridgingManagement.setup(deploymentConfig.l1);
await l2BridgingManagement.setup(deploymentConfig.l2);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
34 changes: 34 additions & 0 deletions scripts/swellchain/finalize-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk";
import env from "../../utils/env";
import network from "../../utils/network";

async function main() {
const networkName = env.network();
const [l1Signer, l2Signer] = network
.multichain(["eth", "swe"], networkName)
.getSigners(env.privateKey(), { forking: false });

const txHash = env.string("TX_HASH");

const crossDomainMessenger = new CrossChainMessenger({
l1ChainId: network.chainId("eth", networkName),
l2ChainId: network.chainId("swe", networkName),
l1SignerOrProvider: l1Signer,
l2SignerOrProvider: l2Signer,
});

const status = await crossDomainMessenger.getMessageStatus(txHash);

if (status !== MessageStatus.READY_FOR_RELAY) {
throw new Error(`Invalid tx status: ${status}`);
}

console.log("Finalizing the L2 -> L1 message");
await crossDomainMessenger.finalizeMessage(txHash);
console.log("Message successfully finalized!");
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
37 changes: 37 additions & 0 deletions scripts/swellchain/prove-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk";
import env from "../../utils/env";
import network from "../../utils/network";

async function main() {
const networkName = env.network();
const [l1Signer, l2Signer] = network
.multichain(["eth", "swe"], networkName)
.getSigners(env.privateKey(), { forking: false });

const txHash = env.string("TX_HASH");

const crossChainMessenger = new CrossChainMessenger({
l1ChainId: network.chainId("eth", networkName),
l2ChainId: network.chainId("swe", networkName),
l1SignerOrProvider: l1Signer,
l2SignerOrProvider: l2Signer,
bedrock: true,
});

const status = await crossChainMessenger.getMessageStatus(txHash);

if (status !== MessageStatus.READY_TO_PROVE) {
throw new Error(`Invalid tx status: ${status}`);
}

console.log("Prove the L2 -> L1 message");
const tx = await crossChainMessenger.proveMessage(txHash);
console.log(`Waiting for the prove tx ${tx.hash}...`);
await tx.wait();
console.log(`Message was proved successfully!`);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading