Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee committed May 23, 2024
2 parents 7b85cfe + 6c23d79 commit c334820
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

# TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var
./test-node.bash --init-force --detach

START=$(date +%s)
Expand Down
18 changes: 17 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,30 @@ services:
- geth
- sequencer
pid: host
build: tokenbridge/
build:
context: tokenbridge/
args:
TOKEN_BRIDGE_BRANCH: ${TOKEN_BRIDGE_BRANCH:-}
environment:
- ARB_URL=http://sequencer:8547
- ETH_URL=http://geth:8545
volumes:
- "tokenbridge-data:/workspace"
- /var/run/docker.sock:/var/run/docker.sock

rollupcreator:
depends_on:
- geth
- sequencer
pid: host
build:
context: rollupcreator/
args:
NITRO_CONTRACTS_BRANCH: ${NITRO_CONTRACTS_BRANCH:-}
volumes:
- "config:/config"
- /var/run/docker.sock:/var/run/docker.sock

volumes:
l1data:
consensus:
Expand Down
14 changes: 14 additions & 0 deletions rollupcreator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:16-bullseye-slim
ARG NITRO_CONTRACTS_BRANCH=main
RUN apt-get update && \
apt-get install -y git docker.io python3 build-essential curl jq
WORKDIR /workspace
RUN git clone --no-checkout https://github.com/OffchainLabs/nitro-contracts.git ./
RUN git checkout ${NITRO_CONTRACTS_BRANCH}
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"]
32 changes: 32 additions & 0 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,38 @@ export const createERC20Command = {
},
};

export const transferERC20Command = {
command: "transfer-erc20",
describe: "transfers ERC20 token",
builder: {
token: {
string: true,
describe: "token address",
},
amount: {
string: true,
describe: "amount to transfer",
},
from: {
string: true,
describe: "account (see general help)",
},
to: {
string: true,
describe: "address (see general help)",
},
},
handler: async (argv: any) => {
console.log("transfer-erc20");

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 decimals = await tokenContract.decimals();
await(await tokenContract.transfer(namedAccount(argv.to).address, ethers.utils.parseUnits(argv.amount, decimals))).wait();
argv.provider.destroy();
},
};

export const sendL1Command = {
command: "send-l1",
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,
transferERC20Command,
sendL1Command,
sendL2Command,
sendL3Command,
Expand All @@ -35,6 +36,7 @@ async function main() {
.command(bridgeToL3Command)
.command(bridgeNativeTokenToL3Command)
.command(createERC20Command)
.command(transferERC20Command)
.command(sendL1Command)
.command(sendL2Command)
.command(sendL3Command)
Expand Down
33 changes: 26 additions & 7 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ set -e
NITRO_NODE_VERSION=offchainlabs/nitro-node:v2.3.3-6a1c1a7-dev
BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1

# This commit matches the v1.2.1 contracts, with additional fixes for rollup deployment script.
# Once v1.2.2 is released, we can switch to that version.
DEFAULT_NITRO_CONTRACTS_VERSION="a00d2faac01e050339ff7b0ac5bc91df06e8dbff"
DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.1"

# Set default versions if not overriden by provided env vars
: ${NITRO_CONTRACTS_BRANCH:=$DEFAULT_NITRO_CONTRACTS_VERSION}
: ${TOKEN_BRIDGE_BRANCH:=$DEFAULT_TOKEN_BRIDGE_VERSION}
export NITRO_CONTRACTS_BRANCH
export TOKEN_BRIDGE_BRANCH

echo "Using NITRO_CONTRACTS_BRANCH: $NITRO_CONTRACTS_BRANCH"
echo "Using TOKEN_BRIDGE_BRANCH: $TOKEN_BRIDGE_BRANCH"

mydir=`dirname $0`
cd "$mydir"

Expand Down Expand Up @@ -259,7 +273,8 @@ if $force_build; then
docker build blockscout -t blockscout -f blockscout/docker/Dockerfile
fi
fi
LOCAL_BUILD_NODES=scripts

LOCAL_BUILD_NODES="scripts rollupcreator"
if $tokenbridge || $l3_token_bridge; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
Expand Down Expand Up @@ -344,9 +359,12 @@ if $force_init; then

sequenceraddress=`docker compose run scripts print-address --account sequencer | tail -n 1 | tr -d '\r\n'`
l2ownerAddress=`docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n'`
l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'`
wasmroot=`docker compose run --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"`

docker compose run --entrypoint /usr/local/bin/deploy sequencer --l1conn ws://geth:8546 --l1keystore /home/user/l1keystore --sequencerAddress $sequenceraddress --ownerAddress $l2ownerAddress --l1DeployAccount $l2ownerAddress --l1deployment /config/deployment.json --authorizevalidators 10 --wasmrootpath /home/user/target/machines --l1chainid=$l1chainid --l2chainconfig /config/l2_chain_config.json --l2chainname arb-dev-test --l2chaininfo /config/deployed_chain_info.json
docker compose run --entrypoint sh sequencer -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json"
echo == Deploying L2 chain
docker compose run -e PARENT_CHAIN_RPC="http://geth:8545" -e DEPLOYER_PRIVKEY=$l2ownerKey -e PARENT_CHAIN_ID=$l1chainid -e CHILD_CHAIN_NAME="arb-dev-test" -e MAX_DATA_SIZE=117964 -e OWNER_ADDRESS=$l2ownerAddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l2_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_chain_info.json" rollupcreator create-rollup-testnode
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json"

if $simple; then
echo == Writing configs
Expand All @@ -369,7 +387,6 @@ if $force_init; then
echo == Deploying L1-L2 token bridge
sleep 10 # no idea why this sleep is needed but without it the deploy fails randomly
rollupAddress=`docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_chain_info.json | tail -n 1 | tr -d '\r\n'"`
l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'`
docker compose run -e ROLLUP_OWNER_KEY=$l2ownerKey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_KEY=$devprivkey -e PARENT_RPC=http://geth:8545 -e CHILD_KEY=$devprivkey -e CHILD_RPC=http://sequencer:8547 tokenbridge deploy:local:token-bridge
docker compose run --entrypoint sh tokenbridge -c "cat network.json && cp network.json l1l2_network.json && cp network.json localNetwork.json"
echo
Expand Down Expand Up @@ -398,15 +415,17 @@ if $force_init; then
if $l3_custom_fee_token; then
echo == Deploying custom fee token
nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer --bridgeable $tokenbridge | tail -n 1 | awk '{ print $NF }'`
EXTRA_L3_DEPLOY_FLAG="--nativeTokenAddress $nativeTokenAddress"
docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_token_bridge_deployer --to l3owner
EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress"
fi

echo == Deploying L3
l3owneraddress=`docker compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n'`
l3ownerkey=`docker compose run scripts print-private-key --account l3owner | tail -n 1 | tr -d '\r\n'`
l3sequenceraddress=`docker compose run scripts print-address --account l3sequencer | tail -n 1 | tr -d '\r\n'`
docker compose run --entrypoint /usr/local/bin/deploy sequencer --l1conn ws://sequencer:8548 --l1keystore /home/user/l1keystore --sequencerAddress $l3sequenceraddress --ownerAddress $l3owneraddress --l1DeployAccount $l3owneraddress --l1deployment /config/l3deployment.json --authorizevalidators 10 --wasmrootpath /home/user/target/machines --l1chainid=412346 --l2chainconfig /config/l3_chain_config.json --l2chainname orbit-dev-test --l2chaininfo /config/deployed_l3_chain_info.json --maxDataSize 104857 $EXTRA_L3_DEPLOY_FLAG
docker compose run --entrypoint sh sequencer -c "jq [.[]] /config/deployed_l3_chain_info.json > /config/l3_chain_info.json"

docker compose run -e DEPLOYER_PRIVKEY=$l3ownerkey -e PARENT_CHAIN_RPC="http://sequencer:8547" -e PARENT_CHAIN_ID=412346 -e CHILD_CHAIN_NAME="orbit-dev-test" -e MAX_DATA_SIZE=104857 -e OWNER_ADDRESS=$l3owneraddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$l3sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l3_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/l3deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_l3_chain_info.json" $EXTRA_L3_DEPLOY_FLAG rollupcreator create-rollup-testnode
docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_l3_chain_info.json > /config/l3_chain_info.json"

echo == Funding l3 funnel and dev key
docker compose up --wait l3node sequencer
Expand Down
4 changes: 3 additions & 1 deletion tokenbridge/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM node:16-bullseye-slim
ARG TOKEN_BRIDGE_BRANCH=main
RUN apt-get update && \
apt-get install -y git docker.io python3 build-essential
WORKDIR /workspace
RUN git clone https://github.com/OffchainLabs/token-bridge-contracts.git ./
RUN git clone --no-checkout https://github.com/OffchainLabs/token-bridge-contracts.git ./
RUN git checkout ${TOKEN_BRIDGE_BRANCH}
RUN yarn install
RUN yarn build
ENTRYPOINT ["yarn"]

0 comments on commit c334820

Please sign in to comment.