Skip to content

Commit

Permalink
support for user's chainID
Browse files Browse the repository at this point in the history
  • Loading branch information
lesterli authored Aug 9, 2023
2 parents 7a8d0c1 + bd8ff55 commit 213cdac
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 27 deletions.
16 changes: 16 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18-bullseye

# Set the working directory
WORKDIR /zkevm-contracts

# Copy package.json and package-lock.json to the container
COPY package*.json ./

# Install zkevm-contracts dependencies
RUN npm install

# Copy the entire zkevm-contracts
COPY . .

ENTRYPOINT ["/bin/bash"]
CMD ["./docker/scripts/deploy-contracts.sh"]
8 changes: 0 additions & 8 deletions docker/Dockerfile.geth

This file was deleted.

43 changes: 43 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.5"
networks:
default:
name: zkevm

services:
zkevm-mock-l1-network:
container_name: zkevm-mock-l1-network
image: ethereum/client-go
ports:
- 8545:8545
- 8546:8546
command:
- "--http"
- "--http.api"
- "admin,eth,debug,miner,net,txpool,personal,web3"
- "--http.addr"
- "0.0.0.0"
- "--http.corsdomain"
- "*"
- "--http.vhosts"
- "*"
- "--ws"
- "--ws.origins"
- "*"
- "--ws.addr"
- "0.0.0.0"
- "--dev"
- "--datadir"
- "/geth_data"
- "--syncmode"
- "full"
- "--rpc.allow-unprotected-txs"

zkevm-contracts:
container_name: zkevm-contracts
image: snapchain/zkevm-contracts
depends_on:
zkevm-mock-l1-network:
condition: service_started
environment:
- JSONRPC_HTTP_URL=http://zkevm-mock-l1-network:8545
- L2_CHAIN_ID=2955
2 changes: 2 additions & 0 deletions docker/scripts/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo docker build -t snapchain/zkevm-contracts -f docker/Dockerfile .
14 changes: 14 additions & 0 deletions docker/scripts/deploy-contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -eux

echo "JSONRPC_HTTP_URL: $JSONRPC_HTTP_URL"
node docker/scripts/fund-accounts.js
echo "Replace <chainID> with $L2_CHAIN_ID"
sed -i.bak "s/<chainID>/$L2_CHAIN_ID/g" docker/scripts/deploy_parameters_docker.json
cp docker/scripts/deploy_parameters_docker.json deployment/deploy_parameters.json
cp docker/scripts/genesis_docker.json deployment/genesis.json
npx hardhat run deployment/testnet/prepareTestnet.js --network zkevmMockL1Network
npx hardhat run deployment/2_deployPolygonZKEVMDeployer.js --network zkevmMockL1Network
npx hardhat run deployment/3_deployContracts.js --network zkevmMockL1Network
mkdir docker/deploymentOutput
mv deployment/deploy_output.json docker/deploymentOutput
16 changes: 0 additions & 16 deletions docker/scripts/deploy-docker.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker/scripts/deploy_parameters_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"networkName": "zkevm",
"version":"0.0.1",
"trustedSequencer":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"chainID": 1001,
"chainID": <chainID>,
"trustedAggregator":"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"trustedAggregatorTimeout": 604799,
"pendingStateTimeout": 604799,
Expand Down
3 changes: 2 additions & 1 deletion docker/scripts/fund-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const DEFAULT_NUM_ACCOUNTS = 20;

async function main() {
const MNEMONIC = process.env.MNEMONIC || DEFAULT_MNEMONIC;
const currentProvider = new ethers.providers.JsonRpcProvider('http://localhost:8545');
const JSONRPC_HTTP_URL = process.env.JSONRPC_HTTP_URL || 'http://zkevm-mock-l1-network:8545'
const currentProvider = new ethers.providers.JsonRpcProvider(JSONRPC_HTTP_URL);
const signerNode = await currentProvider.getSigner();
const numAccountsToFund = process.env.NUM_ACCOUNTS || DEFAULT_NUM_ACCOUNTS;

Expand Down
9 changes: 9 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ module.exports = {
count: 20,
},
},
zkevmMockL1Network: {
url: process.env.JSONRPC_HTTP_URL || 'http://zkevm-mock-l1-network:8545',
accounts: {
mnemonic: process.env.MNEMONIC || DEFAULT_MNEMONIC,
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
},
},
hardhat: {
initialDate: '0',
allowUnlimitedContractSize: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"eslint-plugin-mocha": "^9.0.0",
"ethereum-waffle": "^3.4.4",
"ffjavascript": "^0.2.57",
"hardhat": "^2.13.0",
"hardhat": "^2.17.0",
"hardhat-dependency-compiler": "^1.1.3",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^2.8.4",
Expand Down

0 comments on commit 213cdac

Please sign in to comment.