Skip to content

Commit

Permalink
Merge branch 'release' into merge-release-into-master
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Dec 6, 2024
2 parents fa19e22 + 1c6a92f commit 02dc11d
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 44 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
pos: [pos, no-pos]
l3node: [l3node, l3node-token-6, no-l3node]
tokenbridge: [tokenbridge, no-tokenbridge]
simple: [simple, no-simple]

steps:
- name: Checkout
Expand All @@ -34,8 +35,25 @@ jobs:
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }}
run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} --simple ${{ (matrix.simple == 'simple' && '--simple') || (matrix.simple == 'no-simple' && '--no-simple') || '' }}

bold_upgrade:
runs-on: ubuntu-8

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host

- name: Startup Nitro testnode
run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force --bold-upgrade --simple --detach
2 changes: 1 addition & 1 deletion .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

./test-node.bash "$@"
./test-node.bash "$@" --ci

if [ $? -ne 0 ]; then
echo "test-node.bash failed"
Expand Down
14 changes: 14 additions & 0 deletions boldupgrader/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:18-bullseye-slim
RUN apt-get update && \
apt-get install -y git docker.io python3 make gcc g++ curl jq
ARG BOLD_CONTRACTS_BRANCH=bold-merge-script
WORKDIR /workspace
RUN git clone --no-checkout https://github.com/OffchainLabs/nitro-contracts.git ./
RUN git checkout ${BOLD_CONTRACTS_BRANCH}
RUN yarn install && yarn cache clean
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="${PATH}:/root/.foundry/bin"
RUN foundryup
RUN touch scripts/config.ts
RUN yarn build:all
ENTRYPOINT ["yarn"]
48 changes: 48 additions & 0 deletions docker-compose-ci-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"target": {
"scripts": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"rollupcreator": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"boldupgrader": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"tokenbridge": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
}
}
}
23 changes: 22 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
- "127.0.0.1:6379:6379"

geth:
image: ethereum/client-go:latest
image: ethereum/client-go:stable
ports:
- "127.0.0.1:8545:8545"
- "127.0.0.1:8551:8551"
Expand Down Expand Up @@ -354,6 +354,26 @@ services:
- "tokenbridge-data:/workspace"
- /var/run/docker.sock:/var/run/docker.sock

boldupgrader:
depends_on:
- geth
- sequencer
pid: host
build:
context: boldupgrader/
args:
BOLD_CONTRACTS_BRANCH: ${BOLD_CONTRACTS_BRANCH:-}
environment:
- L1_RPC_URL=http://geth:8545
- L1_PRIV_KEY=0xdc04c5399f82306ec4b4d654a342f40e2e0620fe39950d967e1e574b32d4dd36
- CONFIG_NETWORK_NAME=local
- DEPLOYED_CONTRACTS_DIR=./scripts/files/
- DISABLE_VERIFICATION=true
volumes:
- "config:/config"
- "boldupgrader-data:/workspace"
- /var/run/docker.sock:/var/run/docker.sock

rollupcreator:
depends_on:
- geth
Expand Down Expand Up @@ -434,3 +454,4 @@ volumes:
das-committee-a-data:
das-committee-b-data:
das-mirror-data:
boldupgrader-data:
6 changes: 3 additions & 3 deletions rollupcreator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM node:18-bullseye-slim
ARG NITRO_CONTRACTS_BRANCH=main
RUN apt-get update && \
apt-get install -y git docker.io python3 build-essential curl jq
apt-get install -y git docker.io python3 make gcc g++ curl jq
ARG NITRO_CONTRACTS_BRANCH=main
WORKDIR /workspace
RUN git clone --no-checkout https://github.com/OffchainLabs/nitro-contracts.git ./
RUN git checkout ${NITRO_CONTRACTS_BRANCH}
RUN yarn install && yarn cache clean
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="${PATH}:/root/.foundry/bin"
RUN foundryup
RUN touch scripts/config.ts
RUN yarn install
RUN yarn build:all
ENTRYPOINT ["yarn"]
86 changes: 68 additions & 18 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { namedAccount, namedAddress } from "./accounts";
import * as L1GatewayRouter from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol/L1GatewayRouter.json";
import * as L1AtomicTokenBridgeCreator from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json";
import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json";
import * as TestWETH9 from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/test/TestWETH9.sol/TestWETH9.json";
import * as fs from "fs";
import { ARB_OWNER } from "./consts";
const path = require("path");
Expand Down Expand Up @@ -139,6 +140,14 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr
return token.address;
}

async function deployWETHContract(deployerWallet: Wallet): Promise<string> {
const wethFactory = new ContractFactory(TestWETH9.abi, TestWETH9.bytecode, deployerWallet);
const weth = await wethFactory.deploy("Wrapped Ether", "WETH");
await weth.deployTransaction.wait();

return weth.address;
}

export const bridgeFundsCommand = {
command: "bridge-funds",
describe: "sends funds from l1 to l2",
Expand Down Expand Up @@ -299,6 +308,10 @@ export const createERC20Command = {
boolean: true,
describe: "if true, deploy on L1 and bridge to L2",
},
l1: {
boolean: true,
describe: "if true, deploy on L1 only",
},
decimals: {
string: true,
describe: "number of decimals for token",
Expand All @@ -308,26 +321,26 @@ export const createERC20Command = {
handler: async (argv: any) => {
console.log("create-erc20");

if (argv.bridgeable) {
// deploy token on l1 and bridge to l2
const l1l2tokenbridge = JSON.parse(
fs
.readFileSync(path.join(consts.tokenbridgedatapath, "l1l2_network.json"))
.toString()
);
if (argv.bridgeable || argv.l1) {

// deploy token on l1
const l1provider = new ethers.providers.WebSocketProvider(argv.l1url);
const l2provider = new ethers.providers.WebSocketProvider(argv.l2url);

const deployerWallet = new Wallet(
ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)),
l1provider
);
const deployerWallet = namedAccount(argv.deployer).connect(l1provider);

const tokenAddress = await deployERC20Contract(deployerWallet, argv.decimals);
const token = new ethers.Contract(tokenAddress, ERC20.abi, deployerWallet);
console.log("Contract deployed at L1 address:", token.address);

if (!argv.bridgeable) return;

// bridge to l2
const l2provider = new ethers.providers.WebSocketProvider(argv.l2url);
const l1l2tokenbridge = JSON.parse(
fs
.readFileSync(path.join(consts.tokenbridgedatapath, "l1l2_network.json"))
.toString()
);

const l1GatewayRouter = new ethers.Contract(l1l2tokenbridge.l2Network.tokenBridge.l1GatewayRouter, L1GatewayRouter.abi, deployerWallet);
await (await token.functions.approve(l1l2tokenbridge.l2Network.tokenBridge.l1ERC20Gateway, ethers.constants.MaxUint256)).wait();
const supply = await token.totalSupply();
Expand Down Expand Up @@ -361,10 +374,7 @@ export const createERC20Command = {

// no l1-l2 token bridge, deploy token on l2 directly
argv.provider = new ethers.providers.WebSocketProvider(argv.l2url);
const deployerWallet = new Wallet(
ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)),
argv.provider
);
const deployerWallet = namedAccount(argv.deployer).connect(argv.provider);
const tokenAddress = await deployERC20Contract(deployerWallet, argv.decimals);
console.log("Contract deployed at address:", tokenAddress);

Expand Down Expand Up @@ -411,11 +421,19 @@ export const transferERC20Command = {
string: true,
describe: "address (see general help)",
},
l1: {
boolean: true,
describe: "if true, transfer on L1",
},
},
handler: async (argv: any) => {
console.log("transfer-erc20");

argv.provider = new ethers.providers.WebSocketProvider(argv.l2url);
if (argv.l1) {
argv.provider = new ethers.providers.WebSocketProvider(argv.l1url);
} else {
argv.provider = new ethers.providers.WebSocketProvider(argv.l2url);
}
const account = namedAccount(argv.from).connect(argv.provider);
const tokenContract = new ethers.Contract(argv.token, ERC20.abi, account);
const tokenDecimals = await tokenContract.decimals();
Expand All @@ -425,6 +443,38 @@ export const transferERC20Command = {
},
};

export const createWETHCommand = {
command: "create-weth",
describe: "creates WETH on L1",
builder: {
deployer: {
string: true,
describe: "account (see general help)"
},
deposit: {
number: true,
describe: "amount of weth to deposit",
default: 100,
}
},
handler: async (argv: any) => {
console.log("create-weth");

const l1provider = new ethers.providers.WebSocketProvider(argv.l1url);
const deployerWallet = namedAccount(argv.deployer).connect(l1provider);

const wethAddress = await deployWETHContract(deployerWallet);
const weth = new ethers.Contract(wethAddress, TestWETH9.abi, deployerWallet);
console.log("WETH deployed at L1 address:", weth.address);

if (argv.deposit > 0) {
const amount = ethers.utils.parseEther(argv.deposit.toString());
const depositTx = await deployerWallet.sendTransaction({ to: wethAddress, value: amount, data:"0xd0e30db0" }); // deposit()
await depositTx.wait();
}
},
};

export const sendL1Command = {
command: "send-l1",
describe: "sends funds between l1 accounts",
Expand Down
2 changes: 2 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
bridgeNativeTokenToL3Command,
bridgeToL3Command,
createERC20Command,
createWETHCommand,
transferERC20Command,
sendL1Command,
sendL2Command,
Expand All @@ -40,6 +41,7 @@ async function main() {
.command(bridgeToL3Command)
.command(bridgeNativeTokenToL3Command)
.command(createERC20Command)
.command(createWETHCommand)
.command(transferERC20Command)
.command(sendL1Command)
.command(sendL2Command)
Expand Down
Loading

0 comments on commit 02dc11d

Please sign in to comment.