# Zuzalu Workshop ### Machines #### Verify files r6a.8xlarge #### Mock prover r6a.8xlarge #### Full prover r6a.24xlarge ### Basic OS preparation ````bash= sudo apt update && sudo \ apt install -y tmux git curl cargo build-essential \ libomp-dev libgmp-dev nlohmann-json3-dev libpqxx-dev \ nasm libgrpc++-dev libprotobuf-dev grpc-proto libsodium-dev \ uuid-dev libsecp256k1-dev unzip ```` #### Nodejs (NVM) ```bash $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash $ source ~/.bashrc $ nvm install 16 $ node -v v16.20.0 ``` #### Download mainnet files (tmux) ``` $ tmux $ wget https://de012a78750e59b808d922b39535e862.s3.eu-west-1.amazonaws.com/v1.1.0-rc.1-fork.4.tgz ctrl + d ... tar xzvf v1.1.0-rc.1-fork.4.tgz ``` #### Install docker ``` $ sudo apt-get -y install docker.io $ sudo usermod -aG docker $USER $ newgrp docker && newgrp ubuntu ``` ### Deploy contracts * commit: b1cefea1431e59b2121e543b786b93af99e859f4 ```bash= $ git clone https://github.com/0xPolygonHermez/zkevm-contracts.git $ cd zkevm-contracts $ npm i $ cp .env.example .env ``` #### Create wallets ##### create wallets.js file: ```js const ethers = require("ethers"); async function main() { const arrayNames = ["## Deployment Address", "\n\n## Trusted sequencer", "\n\n## Trusted aggregator"]; for (let i = 0; i < arrayNames.length; i++) { const wallet = ethers.Wallet.createRandom(); console.log(arrayNames[i]); console.log(`Address: ${wallet.address}`); console.log(`PrvKey: ${wallet._signingKey().privateKey}`); console.log(`mnemonic: "${wallet._mnemonic().phrase}"`); const keystoreJson = await wallet.encrypt("password"); console.log(`keystore: ${keystoreJson}`); } } main().catch((e) => { console.error(e); process.exit(1); }); ``` ##### Run wallets.js ```bash! $ node wallets.js | tee wallets.txt ``` #### edit .env ``` $ nano .env MNEMONIC="..." (from wallets.txt Deployment Address) INFURA_PROJECT_ID="..." (your infura project ID) ETHERSCAN_API_KEY="..." (your etherscan API key) ``` #### Edit deploy_parameters.json ```bash= $ cd deployment $ cp deploy_parameters.json.example deploy_parameters.json ``` * edit deploy_parameters.json ```js "realVerifier": true "trustedSequencerURL": "http://54.83.84.85:8545", (your machine ip) "trustedSequencer" (from wallets.txt Trusted sequencer ) "chainID": 42069 (a chainid) "trustedAggregator" (from wallets.txt aggregator sequencer), "forkID": 4, "admin":"",(from wallets.txt Deployment Address) "zkEVMOwner": "",(from wallets.txt Deployment Address) "timelockAddress": "", (from wallets.txt Deployment Address), "initialZkEVMDeployerOwner": "" (from wallets.txt Deployment Address) "zkEVMDeployerAddress":"" (leave empty) "maticTokenAddress":"", (leave empty, it's deployed) ``` * Send ether to Deployment address (15 GöETH) * Edit deployment/helpers/deployment-helpers.js to adjust the gasPrice according to network status ``` const gasPriceKeylessDeployment = '200'; // 100 gweis ``` #### Make the deployment ```bash= $ npm run deploy:deployer:ZkEVM:goerli $ npm run verify:deployer:ZkEVM:goerli $ npm run deploy:testnet:ZkEVM:goerli $ npm run verify:ZkEVM:goerli ``` if you see errors you can run it again, although is normal to see an error on the last step ```bash= $ npm run verify:ZkEVM:goerli > @0xpolygonhermez/zkevm-contracts@0.6.0.0 verify:ZkEVM:goerli > npx hardhat run deployment/verifyContracts.js --network goerli The contract 0x7B57AB2fadea6e08A9db517aE8508802614Db4c3 has already been verified The contract 0x2b8c728f7Ec1C31D67610e9025E8769E9E99F039 has already been verified The contract 0x5F08d8E4520cDbF0dcE070036C402E98a30d94C2 has already been verified The contract 0x75676c695427f6a6682C45591aA3bc4364730b33 has already been verified Verifying implementation: 0x1f908EDa752727BA0Fcce8f306aD165e67C8ecED The contract 0x1f908EDa752727BA0Fcce8f306aD165e67C8ecED has already been verified Verifying proxy: 0x7C4dB19d2E90a859A23587361A25697937D57A32 AssertionError: expected false to equal true at main (/home/ubuntu/zkevm-contracts/deployment/verifyContracts.js:102:74) at processTicksAndRejections (node:internal/process/task_queues:96:5) { showDiff: true, actual: false, expected: true, operator: 'strictEqual' } ``` ##### aprove Matic token for sequencer ``` $ npx hardhat console --network goerli ``` ```javascript! const provider = ethers.getDefaultProvider("https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io") const privateKey = 'From wallet.txt Trusted sequencer' const wallet = new ethers.Wallet(privateKey, provider); const maticTokenFactory = await ethers.getContractFactory('ERC20PermitMock', provider); maticTokenContract = maticTokenFactory.attach("From deployments/goerly_***/deploy_output.json maticTokenAddress") maticTokenContractWallet = maticTokenContract.connect(wallet) await maticTokenContractWallet.approve("From deployments/goerly_***/deploy_output.json polygonZkEVMAddress", ethers.utils.parseEther("100.0")) ``` ### zkNode deployment ```bash # DOWNLOAD ARTIFACTS $ mkdir -p ~/data/{statedb,pooldb} ~/zkevm-config ~/zkevm-node echo 'export ZKEVM_NET=mainnet' >> ~/.profile echo 'export ZKEVM_DIR=~/zkevm-node' >> ~/.profile echo 'export ZKEVM_CONFIG_DIR=~/zkevm-config' >> ~/.profile source ~/.profile curl -L https://github.com/0xPolygonHermez/zkevm-node/releases/latest/download/$ZKEVM_NET.zip > $ZKEVM_NET.zip && unzip -o $ZKEVM_NET.zip -d $ZKEVM_DIR && rm $ZKEVM_NET.zip cp $ZKEVM_DIR/$ZKEVM_NET/example.env $ZKEVM_CONFIG_DIR/.env ```` #### EDIT .env file ``` # EDIT THIS env file: nano $ZKEVM_CONFIG_DIR/.env # URL of a JSON RPC for Ethereum mainnet ZKEVM_NODE_ETHERMAN_URL = "https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io" # PATH WHERE THE STATEDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA ZKEVM_NODE_STATEDB_DATA_DIR = "~/data/statedb" # PATH WHERE THE POOLDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA ZKEVM_NODE_POOLDB_DATA_DIR = "~/data/pooldb" # OPTIONAL, UNCOMENT IF YOU WANT TO DO ADVANCED CONFIG # ZKEVM_ADVANCED_CONFIG_DIR = "/should/be/same/path/as/ZKEVM_CONFIG_DIR" ```` #### Change genesis * copy genesis from contracts zkevm-contracts/deplyoments/goerli_***/genesis.json into zkevm-node/mainnet/config/environments/public/public.genesis.config.json ##### Edit genesis file zkevm-node/mainnet/config/environments/public/public.genesis.config.json ``` { "l1Config" : { "chainId": 5, "polygonZkEVMAddress": "...", "maticTokenAddress": "...", "polygonZkEVMGlobalExitRootAddress": "..." }, "genesisBlockNumber": 9050589, "root": "....", "genesis": [ { ``` The chainId parameter is the L1 network, which in this deployment is goerli (5). The other values are obtained from the file ~/zkevm-contracts/deployments/goerli_***/deploy_output.json Just take into account that polygonZkEVMGlobalExitRootAddress is called deploymentBlockNumber in the file. #### Change config edit ~/zkevm-node/mainnet/config/environments/public/public.node.config.toml ```yml IsTrustedSequencer = true [Log] Environment = "development" # "production" or "development" Level = "info" Outputs = ["stderr"] [StateDB] User = "state_user" Password = "state_password" Name = "state_db" Host = "zkevm-state-db" Port = "5432" EnableLog = false MaxConns = 200 [Pool] FreeClaimGasLimit = 1500000 MaxTxBytesSize=30132 MaxTxDataBytesSize=30000 DefaultMinGasPriceAllowed = 1000000000 MinAllowedGasPriceInterval = "5m" PollMinAllowedGasPriceInterval = "15s" [Pool.DB] User = "pool_user" Password = "pool_password" Name = "pool_db" Host = "zkevm-pool-db" Port = "5432" EnableLog = false MaxConns = 200 [Etherman] URL = "https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io" MultiGasProvider = false L1URL = "https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io" L2URLs = ["http://zkevm-rpc:8545"] [Etherman.Etherscan] ApiKey = "IT8717TY59FYRJYVS859SJ3V2ITI45STGW" [RPC] Host = "0.0.0.0" Port = 8545 ReadTimeoutInSec = 60 WriteTimeoutInSec = 60 MaxRequestsPerIPAndSecond = 5000 SequencerNodeURI = "" EnableL2SuggestedGasPricePolling = true [RPC.WebSockets] Enabled = true Port = 8546 [Synchronizer] SyncInterval = "2s" SyncChunkSize = 100 trustedSequencerURL = "" [MTClient] URI = "zkevm-executor:50061" [Executor] URI = "zkevm-executor:50071" [Metrics] Host = "0.0.0.0" Port = 9091 Enabled = true ProfilingHost = "0.0.0.0" ProfilingPort = 6060 ProfilingEnabled = false [Sequencer] WaitPeriodPoolIsEmpty = "1s" WaitPeriodSendSequence = "15s" LastBatchVirtualizationTimeMaxWaitPeriod = "10s" BlocksAmountForTxsToBeDeleted = 100 FrequencyToCheckTxsForDelete = "12h" MaxTxsPerBatch = 150 MaxBatchBytesSize = 129848 MaxCumulativeGasUsed = 30000000 MaxKeccakHashes = 468 MaxPoseidonHashes = 279620 MaxPoseidonPaddings = 149796 MaxMemAligns = 262144 MaxArithmetics = 262144 MaxBinaries = 262144 MaxSteps = 8388608 WeightBatchBytesSize = 1 WeightCumulativeGasUsed = 1 WeightKeccakHashes = 1 WeightPoseidonHashes = 1 WeightPoseidonPaddings = 1 WeightMemAligns = 1 WeightArithmetics = 1 WeightBinaries = 1 WeightSteps = 1 TxLifetimeCheckTimeout = "10m" MaxTxLifetime = "3h" MaxTxSizeForL1 = 131072 [Sequencer.Finalizer] GERDeadlineTimeoutInSec = "2s" ForcedBatchDeadlineTimeoutInSec = "60s" SendingToL1DeadlineTimeoutInSec = "20s" SleepDurationInMs = "100ms" ResourcePercentageToCloseBatch = 10 GERFinalityNumberOfBlocks = 0 ClosingSignalsManagerWaitForCheckingL1Timeout = "10s" ClosingSignalsManagerWaitForCheckingGER = "10s" ClosingSignalsManagerWaitForCheckingForcedBatches = "10s" ForcedBatchesFinalityNumberOfBlocks = 0 TimestampResolution = "15s" [Sequencer.DBManager] PoolRetrievalInterval = "500ms" [Sequencer.Worker] ResourceCostMultiplier = 1000 [SequenceSender] WaitPeriodSendSequence = "5s" LastBatchVirtualizationTimeMaxWaitPeriod = "5s" MaxTxSizeForL1 = 131072 SenderAddress = "0x225c96B7dB4223f0244DcfC833e0bB9f40a948E4" PrivateKeys = [{Path = "/pk/sequencer.keystore", Password = "password"}] [Aggregator] Host = "0.0.0.0" Port = 50081 ForkId = 4 RetryTime = "5s" VerifyProofInterval = "30s" TxProfitabilityCheckerType = "acceptall" TxProfitabilityMinReward = "1.1" ProofStatePollingInterval = "5s" SenderAddress = "0xC44e94B84C6b021a90a3946404cF30d3aF921437" CleanupLockedProofsInterval = "2m" GeneratingProofCleanupThreshold = "10m" [EthTxManager] ForcedGas = 0 PrivateKeys = [ {Path = "/pk/sequencer.keystore", Password = "password"}, {Path = "/pk/aggregator.keystore", Password = "password"} ] [Database] Database = "postgres" User = "test_user" Password = "test_password" Name = "test_db" Host = "zkevm-bridge-db" Port = "5435" MaxConns = 20 [BridgeController] Store = "postgres" Height = 32 [BridgeServer] GRPCPort = "9090" HTTPPort = "8080" [NetworkConfig] GenBlockNumber = 9050589 PolygonZkEVMAddress = "0x85cc56a5d329AB0ACE1D419A89cFcbfE006f1E67" PolygonBridgeAddress = "0xBe36B148797a3CB52b0818c2a357E7CF35474B98" PolygonZkEVMGlobalExitRootAddress = "0xc13f0e85326666b12705A81e8BE5e7d7D97A1c31" MaticTokenAddress = "0x0487999Df59BD3a0C6A2BFc13b31b8EA766289F6" L2PolygonBridgeAddresses = ["0xBe36B148797a3CB52b0818c2a357E7CF35474B98"] L1ChainID = 5 [L2GasPriceSuggester] Type = "default" DefaultGasPriceWei = 100000000 [ClaimTxManager] FrequencyToMonitorTxs = "1s" PrivateKey = {Path = "/pk/sequencer.keystore", Password = "password"} Enabled = true ``` and change: ```yml [Etherman] URL = "https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io" L1URL ="https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io" [Etherman.Etherscan] ApiKey = "..." [Aggregator] SenderAddress = "" (trustedAggregator from deploy_output.json) [NetworkConfig] GenBlockNumber = (deploymentBlockNumber from deploy_output.json) PolygonZkEVMAddress = (polygonZkEVMAddress from deploy_output.json) PolygonBridgeAddress = (PolygonZkEVMBridge from genesis.json) PolygonZkEVMGlobalExitRootAddress = (polygonZkEVMGlobalExitRootAddress from deploy_output.json) MaticTokenAddress = (maticTokenAddress from deploy_output.json) L2PolygonBridgeAddresses = [""] (PolygonZkEVMBridge from genesis.json) ``` #### Add wallets * nano zkevm-config/sequencer.keystore (from wallets.txt) * nano zkevm-config/aggregator.keystore (from wallets.txt) #### edit init_prover_db.sql got to ~/zkevm-node/mainnet/db/scripts and edit init_prover_db.sql to match this: ``` CREATE DATABASE prover_db; \connect prover_db; CREATE SCHEMA state; CREATE TABLE state.nodes (hash BYTEA PRIMARY KEY, data BYTEA NOT NULL); CREATE TABLE state.program (hash BYTEA PRIMARY KEY, data BYTEA NOT NULL); CREATE USER prover_user with password 'prover_pass'; GRANT CONNECT ON DATABASE prover_db TO prover_user; ALTER USER prover_user SET SEARCH_PATH=state; GRANT ALL PRIVILEGES ON SCHEMA state TO prover_user; GRANT ALL PRIVILEGES ON TABLE state.nodes TO prover_user; GRANT ALL PRIVILEGES ON TABLE state.program TO prover_user; ``` #### Start services remove zkevm-node/mainnet/docker-compose.yml content ##### start databases ```yml= version: "3.5" networks: default: name: zkevm services: zkevm-state-db: container_name: zkevm-state-db restart: unless-stopped image: postgres healthcheck: test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ] ports: - 5432:5432 volumes: - ./db/scripts/init_prover_db.sql:/docker-entrypoint-initdb.d/init.sql - ${ZKEVM_NODE_STATEDB_DATA_DIR}:/var/lib/postgresql/data - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/postgresql.conf:/etc/postgresql.conf environment: - POSTGRES_USER=state_user - POSTGRES_PASSWORD=state_password - POSTGRES_DB=state_db command: - "postgres" - "-N" - "500" - "-c" - "config_file=/etc/postgresql.conf" zkevm-pool-db: container_name: zkevm-pool-db restart: unless-stopped image: postgres healthcheck: test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ] deploy: resources: limits: memory: 2G reservations: memory: 1G ports: - 5433:5432 volumes: - ${ZKEVM_NODE_POOLDB_DATA_DIR}:/var/lib/postgresql/data environment: - POSTGRES_USER=pool_user - POSTGRES_PASSWORD=pool_password - POSTGRES_DB=pool_db command: - "postgres" - "-N" - "500" ``` ```bash $ sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml up -d ## Check status $ sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS zkevm-pool-db postgres "docker-entrypoint.s…" zkevm-pool-db 38 seconds ago Up 36 seconds (healthy) 0.0.0.0:5433->5432/tcp, :::5433->5432/tcp zkevm-state-db postgres "docker-entrypoint.s…" zkevm-state-db 38 seconds ago Up 36 seconds (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp ``` ##### Executor add: ``` zkevm-executor: container_name: zkevm-executor restart: unless-stopped image: hermeznetwork/zkevm-prover:v1.1.4-RC2-fork.4 depends_on: zkevm-state-db: condition: service_healthy ports: - 50061:50061 # MT - 50071:50071 # Executor volumes: - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.prover.config.json:/usr/src/app/config.json command: > zkProver -c /usr/src/app/config.json ``` ```bash $ sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml up -d ## Check status $ sudo docker compose --env-file $ZKEVM_CONFIG_DIR/.env -f $ZKEVM_DIR/$ZKEVM_NET/docker-compose.yml ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS zkevm-executor hermeznetwork/zkevm-prover:c231382 "zkProver -c /usr/sr…" zkevm-executor 12 seconds ago Up 7 seconds 0.0.0.0:50061->50061/tcp, :::50061->50061/tcp, 0.0.0.0:50071->50071/tcp, :::50071->50071/tcp zkevm-pool-db postgres "docker-entrypoint.s…" zkevm-pool-db 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:5433->5432/tcp, :::5433->5432/tcp zkevm-state-db postgres "docker-entrypoint.s…" zkevm-state-db 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp ```` ##### syncronizer ```yml= zkevm-sync: container_name: zkevm-sync restart: unless-stopped depends_on: zkevm-state-db: condition: service_healthy zkevm-executor: condition: service_started image: hermeznetwork/zkevm-node:v0.1.2-RC1 environment: - ZKEVM_NODE_ETHERMAN_URL=${ZKEVM_NODE_ETHERMAN_URL} volumes: - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components synchronizer" ``` ##### l2-gas-pricer ``` zkevm-l2gaspricer: container_name: zkevm-l2gaspricer image: hermeznetwork/zkevm-node:v0.1.2-RC1 depends_on: zkevm-pool-db: condition: service_healthy environment: - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db volumes: - /home/ubuntu/zkevm-config/sequencer.keystore:/pk/keystore - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components l2gaspricer" ``` ##### zkevm-eth-tx-manager ```yml zkevm-eth-tx-manager: container_name: zkevm-eth-tx-manager image: hermeznetwork/zkevm-node:v0.1.2-RC1 depends_on: zkevm-state-db: condition: service_healthy ports: - 9094:9091 # needed if metrics enabled environment: - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db volumes: - ${ZKEVM_CONFIG_DIR}/sequencer.keystore:/pk/sequencer.keystore - ${ZKEVM_CONFIG_DIR}/aggregator.keystore:/pk/aggregator.keystore - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components eth-tx-manager" ``` ##### rpc ``` zkevm-rpc: container_name: zkevm-rpc restart: unless-stopped depends_on: zkevm-pool-db: condition: service_healthy zkevm-state-db: condition: service_healthy zkevm-sync: condition: service_started image: hermeznetwork/zkevm-node:v0.1.2-RC1 ports: - 8545:8545 - 9091:9091 # needed if metrics enabled environment: - ZKEVM_NODE_ETHERMAN_URL=${ZKEVM_NODE_ETHERMAN_URL} volumes: - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components rpc --http.api eth,net,debug,zkevm,txpool,web3" ``` ##### sequencer ``` zkevm-sequencer: container_name: zkevm-sequencer image: hermeznetwork/zkevm-node:v0.1.2-RC1 depends_on: zkevm-pool-db: condition: service_healthy zkevm-state-db: condition: service_healthy zkevm-executor: condition: service_started ports: - 9092:9091 # needed if metrics enabled - 6060:6060 environment: - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db - ZKEVM_NODE_SEQUENCER_SENDER_ADDRESS=__CHANGE_ADDRESS__ volumes: - ${ZKEVM_CONFIG_DIR}/sequencer.keystore:/pk/sequencer.keystore - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components sequencer,sequence-sender" ``` ##### aggregator ```` zkevm-aggregator: container_name: zkevm-aggregator image: hermeznetwork/zkevm-node:v0.1.2-RC1 depends_on: zkevm-pool-db: condition: service_healthy zkevm-state-db: condition: service_healthy ports: - 50081:50081 - 9093:9091 # needed if metrics enabled environment: - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db - ZKEVM_NODE_AGGREGATOR_SENDER_ADDRESS=__CHANGE_ADDRESS__ volumes: - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.genesis.config.json:/app/genesis.json command: - "/bin/sh" - "-c" - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components aggregator" ```` ##### zkevm-explorer ``` zkevm-explorer-l2: container_name: zkevm-explorer-l2 image: hermeznetwork/zkevm-explorer:latest ports: - 4004:4004 environment: - PORT=4004 - NETWORK=POE - SUBNETWORK=Polygon zkEVM - CHAIN_ID=4269 - COIN=ETH - ETHEREUM_JSONRPC_VARIANT=geth - ETHEREUM_JSONRPC_HTTP_URL=http://zkevm-rpc:8545 - DATABASE_URL=postgres://l2_explorer_user:l2_explorer_password@zkevm-explorer-l2-db:5432/explorer - ECTO_USE_SSL=false - MIX_ENV=prod - LOGO=/images/blockscout_logo.svg - LOGO_FOOTER=/images/blockscout_logo.svg - SUPPORTED_CHAINS=[] - SHOW_OUTDATED_NETWORK_MODAL=false command: ["/bin/sh", "-c", "mix do ecto.create, ecto.migrate; mix phx.server"] zkevm-explorer-l2-db: container_name: zkevm-explorer-l2-db image: postgres ports: - 5436:5432 environment: - POSTGRES_USER=l2_explorer_user - POSTGRES_PASSWORD=l2_explorer_password - POSTGRES_DB=l2_explorer_db command: [ "postgres", "-N", "500" ] ``` ##### bridge ``` zkevm-bridge-db: container_name: zkevm-bridge-db image: postgres healthcheck: test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ] expose: - 5435 ports: - 5435:5432 environment: - POSTGRES_USER=test_user - POSTGRES_PASSWORD=test_password - POSTGRES_DB=test_db command: ["postgres", "-N", "500"] zkevm-bridge-service: container_name: zkevm-bridge-service image: hermeznetwork/zkevm-bridge-service:v0.1.0 depends_on: zkevm-bridge-db: condition: service_healthy ports: - 9090:9090 - 8081:8080 environment: - ZKEVM_BRIDGE_DATABASE_USER=test_user - ZKEVM_BRIDGE_DATABASE_PASSWORD=test_password - ZKEVM_BRIDGE_DATABASE_NAME=test_db - ZKEVM_BRIDGE_DATABASE_HOST=zkevm-bridge-db - ZKEVM_BRIDGE_DATABASE_PORT=5432 volumes: - ${ZKEVM_CONFIG_DIR}/sequencer.keystore:/pk/sequencer.keystore - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/public}/public.node.config.toml:/app/config.toml command: - "/bin/sh" - "-c" - "/app/zkevm-bridge run --cfg /app/config.toml" zkevm-bridge-ui: container_name: zkevm-bridge-ui image: hermeznetwork/zkevm-bridge-ui:latest ports: - 8080:80 environment: - ETHEREUM_RPC_URL=https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io - ETHEREUM_EXPLORER_URL=https://goerli.etherscan.io - ETHEREUM_BRIDGE_CONTRACT_ADDRESS=... - ETHEREUM_FORCE_UPDATE_GLOBAL_EXIT_ROOT=true - ETHEREUM_PROOF_OF_EFFICIENCY_CONTRACT_ADDRESS=... - POLYGON_ZK_EVM_RPC_URL=http://IP:8545 - POLYGON_ZK_EVM_EXPLORER_URL=http://IP:4004 - POLYGON_ZK_EVM_BRIDGE_CONTRACT_ADDRESS=... - POLYGON_ZK_EVM_NETWORK_ID=1 - BRIDGE_API_URL=http://IP:8081 - ENABLE_FIAT_EXCHANGE_RATES=false - ENABLE_OUTDATED_NETWORK_MODAL=false - ENABLE_DEPOSIT_WARNING=true - ENABLE_REPORT_FORM=false ``` ##### Prover config on ~/config.json ```json { "runExecutorServer": false, "runExecutorClient": false, "runExecutorClientMultithread": false, "runStateDBServer": false, "runStateDBTest": false, "runAggregatorServer": false, "runAggregatorClient": true, "proverName": "static_prover", "runFileGenBatchProof": false, "runFileGenAggregatedProof": false, "runFileGenFinalProof": false, "runFileProcessBatch": false, "runFileProcessBatchMultithread": false, "runFileExecutor": false, "runKeccakScriptGenerator": false, "runKeccakTest": false, "runStorageSMTest": false, "runBinarySMTest": false, "runMemAlignSMTest": false, "runSHA256Test": false, "runBlakeTest": false, "executeInParallel": true, "useMainExecGenerated": true, "useProcessBatchCache": true, "saveRequestToFile": false, "saveInputToFile": true, "saveDbReadsToFile": true, "saveDbReadsToFileOnChange": false, "saveOutputToFile": true, "saveFilesInSubfolders": false, "saveProofToFile": true, "saveResponseToFile": false, "loadDBToMemCache": true, "loadDBToMemCacheInParallel": false, "dbMTCacheSize": 16384, "dbProgramCacheSize": 16384, "dbMultiWrite": true, "dbFlushInParallel": true, "opcodeTracer": false, "logRemoteDbReads": false, "logExecutorServerResponses": false, "executorServerPort": 50071, "executorROMLineTraces": false, "executorClientPort": 50071, "executorClientHost": "127.0.0.1", "stateDBServerPort": 5432, "stateDBURL": "local", "aggregatorServerPort": 50081, "aggregatorClientPort": 50081, "aggregatorClientHost": "YOUR-PUBLIC-IP-ADDRESS", "aggregatorClientMockTimeout": 10000000, "mapConstPolsFile": false, "mapConstantsTreeFile": false, "inputFile": "testvectors/aggregatedProof/recursive1.zkin.proof_0.json", "inputFile2": "testvectors/aggregatedProof/recursive1.zkin.proof_1.json", "outputPath": "/output/", "configPath": "/mnt/prover/config/", "zkevmCmPols_disabled": "/mnt/prover/runtime/zkevm.commit", "c12aCmPols": "runtime/c12a.commit", "recursive1CmPols_disabled": "runtime/recursive1.commit", "recursive2CmPols_disabled": "runtime/recursive2.commit", "recursivefCmPols_disabled": "runtime/recursivef.commit", "finalCmPols_disabled": "runtime/final.commit", "publicsOutput": "public.json", "proofFile": "proof.json", "databaseURL": "postgresql://prover_user:prover_pass@zkevm-state-db:5432/prover_db", "databaseURL_disabled": "local", "dbNodesTableName": "state.nodes", "dbProgramTableName": "state.program", "dbConnectionsPool": true, "cleanerPollingPeriod": 600, "requestsPersistence": 3600, "maxExecutorThreads": 20, "maxProverThreads": 8, "maxStateDBThreads": 8 } ``` In "aggregatorClientHost" set your public IP address. ##### prover ``` zkevm-prover-server: container_name: zkevm-prover-server image: hermeznetwork/zkevm-prover:v1.1.4-RC2-fork.4 ports: - 50051:50051 volumes: - ~/v1.1.0-rc.1-fork.4/config:/mnt/prover/config:ro - ~/config.json:/app/config.json command: "zkProver -c /app/config.json" ``` #### Open Ports * 22 * 8081 * 8080 * 50081 * 5432 * 8545 * 4004 * 61090 #### Activate forced tx ``` $ npx hardhat console --network goerli const zkevm = await ethers.getContractFactory('PolygonZkEVM') const zkevmContract = zkevm.attach("_polygonZkEVMAddress_") const provider = ethers.getDefaultProvider("https://erigon-goerli-erigon.b0231289064888c3.dyndns.dappnode.io") const privateKey = 'From wallet.txt Deployment Address' const wallet = new ethers.Wallet(privateKey, provider); const zkevmContractWallet = zkevm.connect(wallet) await zkevmContract.activateForceBatches() ``` ### Install go ``` wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile source .profile go version ``` ### Provide L1 Ether to the bridge We are going to create a bridge transaction to send L1 Ether to the bridge. ``` mkdir -p ~/initial-bridge cd initial-bridge wget https://raw.githubusercontent.com/0xPolygonHermez/zkevm-bridge-service/develop/test/scripts/deposit/main.go nano main.go l1BridgeAddr = "0x5567fAbF3B17F320BA3906d2f6CD43021d27A8AB" // zkevm-contracts/deployments/goerli_*/deploy_output.json: polygonZkEVMBridgeAddress l1AccHexAddress = "0x593A083125Dc0f6E50c0DAe8689ece7E22987450" // zkevm-contracts/wallets.txt: sequencer address l1AccHexPrivateKey = "0x438f372ac8cdfa13493cab7d0155e4f4c24f98664edf8a3139cfae6967a48c33" // zkevm-contracts/wallets.txt: sequencer prvkey l1NetworkURL = "http://147.83.40.37:8545" // public IP go mod init example.com/deposit go mod tidy go run main.go 2023-06-07T06:28:58.739Z INFO initial-bridge/main.go:41 Sending bridge tx... {"pid": 776268, "version": "v0.1.0"} 2023-06-07T06:29:14.211Z DEBUG operations/wait.go:99 Transaction successfully mined: 0x9dfe6006dc01ccd350e63d31547fd562ed3ccd7d572d96d5e24d138f83371864 {"pid": 776268, "version": "v0.1.0"} 2023-06-07T06:29:14.211Z INFO initial-bridge/main.go:46 Success! {"pid": 776268, "version": "v0.1.0"} https://goerli.etherscan.io/tx/0x9dfe6006dc01ccd350e63d31547fd562ed3ccd7d572d96d5e24d138f83371864 ``` ### Claim our L2 zkEther Create a forzed claim to get the zkEther in L2. ``` mkdir -p ~/initial-claim cd initial-claim wget https://raw.githubusercontent.com/0xPolygonHermez/zkevm-bridge-service/develop/test/scripts/initialClaim/main.go ``` Open main.go and modify the following parameters: ``` const ( l2BridgeAddr = "0x5567fAbF3B17F320BA3906d2f6CD43021d27A8AB" // zkevm-contracts/deployments/goerli_*/deploy_output.json: polygonZkEVMBridgeAddress zkevmAddr = "0x12c3e0CC1d4619deaC19014a72C98c129448Cfd7" // zkevm-contracts/deployments/goerli_*/deploy_output.json: polygonZkEVMAddress accHexAddress = "0x593A083125Dc0f6E50c0DAe8689ece7E22987450" // zkevm-contracts/wallets.txt: sequencer address accHexPrivateKey = "0x438f372ac8cdfa13493cab7d0155e4f4c24f98664edf8a3139cfae6967a48c33" // zkevm-contracts/wallets.txt: sequencer prvkey l1NetworkURL = "http://147.83.40.37:8545" // public IP l2NetworkURL = "http://147.83.40.37:8123" // public IP bridgeURL = "http://147.83.40.37:8080" // public IP l2GasLimit = 1000000 mtHeight = 32 miningTimeout = 180 ) ``` go go get github.com/0xPolygonHermez/zkevm-bridge-service@4e1ca558144cac00fe0762329aaf7b3e9482b57a go run main.go 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:69 bridge: orig_addr:"0x0000000000000000000000000000000000000000" amount:"90000000000000000" dest_net:1 dest_addr:"0x593A083125Dc0f6E50c0DAe8689ece7E22987450" block_num:9136803 tx_hash:"0x9dfe6006dc01ccd350e63d31547fd562ed3ccd7d572d96d5e24d138f83371864" metadata:"0x" ready_for_claim:true {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:70 mainnetExitRoot: 0x2f980da5486db6393ea8bacd68a3e68286eaa8c217fcf4eccaf68fe17746d55b {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:71 rollupExitRoot: 0x0000000000000000000000000000000000000000000000000000000000000000 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x0000000000000000000000000000000000000000000000000000000000000000 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xe58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xf9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xf8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xb46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xc65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xf4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xcdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0xb8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z DEBUG initial-claim/main.go:75 smt: 0x8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.723Z INFO initial-claim/main.go:81 Sending claim tx... {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:105 L2 tx.Nonce: 0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:106 L2 tx.GasPrice: 0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:107 L2 tx.Gas: 1000000 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:108 L2 tx.Hash: 0x8de2d20ee06e1dcb6d195625ca4e9e9cd45205b9a824f20d23b2c0696185705d {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:114 tx encoded: 0xf905a98080830f4240945567fabf3b17f320ba3906d2f6cd43021d27a8ab80b905442cffd02e0000000000000000000000000000000000000000000000000000000000000000ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d3021ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a193440eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f839867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf8923490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99cc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8beccda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d22733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981fe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618db8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea32293237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d7358448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a900000000000000000000000000000000000000000000000000000000000000002f980da5486db6393ea8bacd68a3e68286eaa8c217fcf4eccaf68fe17746d55b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000593a083125dc0f6e50c0dae8689ece7e22987450000000000000000000000000000000000000000000000000013fbe85edc9000000000000000000000000000000000000000000000000000000000000000005200000000000000000000000000000000000000000000000000000000000000000830148cda0a754008042998fa9efaf836ec05b2da654ff0bd915cafa6749735f12d32db6aba01ccd2215559aab1ec5951d649ad51a2cafd9f9402dc4f30779aa0a6ba15cac42 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z DEBUG state/helper.go:29 0 0 1000000 0x5567fAbF3B17F320BA3906d2f6CD43021d27A8AB 0 1348 42069 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:119 forcedBatch content: 0xf905688080830f4240945567fabf3b17f320ba3906d2f6cd43021d27a8ab80b905442cffd02e0000000000000000000000000000000000000000000000000000000000000000ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d3021ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a193440eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f839867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf8923490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99cc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8beccda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d22733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981fe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618db8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea32293237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d7358448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a900000000000000000000000000000000000000000000000000000000000000002f980da5486db6393ea8bacd68a3e68286eaa8c217fcf4eccaf68fe17746d55b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000593a083125dc0f6e50c0dae8689ece7e22987450000000000000000000000000000000000000000000000000013fbe85edc900000000000000000000000000000000000000000000000000000000000000000520000000000000000000000000000000000000000000000000000000000000000082a4558080a754008042998fa9efaf836ec05b2da654ff0bd915cafa6749735f12d32db6ab1ccd2215559aab1ec5951d649ad51a2cafd9f9402dc4f30779aa0a6ba15cac421b {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:45.724Z INFO initial-claim/main.go:121 Using address: 0x593A083125Dc0f6E50c0DAe8689ece7E22987450 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:46.058Z INFO initial-claim/main.go:146 Number of forceBatches in the smc: 0 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:46.569Z DEBUG initial-claim/main.go:152 currentBlock.Time(): 1686120096 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:47.061Z INFO initial-claim/main.go:165 TxHash: 0x1ab11947011f9c2edcf341a2900e33c0b5a511406944c34cdf5ad89fe6beb837 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.127Z DEBUG operations/wait.go:99 Transaction successfully mined: 0x1ab11947011f9c2edcf341a2900e33c0b5a511406944c34cdf5ad89fe6beb837 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.191Z DEBUG initial-claim/main.go:185 log decoded: &{ForceBatchNum:1 LastGlobalExitRoot:[16 237 230 159 3 176 133 128 210 131 176 252 112 62 157 197 14 20 224 230 228 59 198 115 13 253 176 18 80 178 250 204] Sequencer:0x593A083125Dc0f6E50c0DAe8689ece7E22987450 Transactions:[] Raw:{Address:0x12c3e0CC1d4619deaC19014a72C98c129448Cfd7 Topics:[0xf94bb37db835f1ab585ee00041849a09b12cd081d77fa15ca070757619cbc931 0x0000000000000000000000000000000000000000000000000000000000000001] Data:[16 237 230 159 3 176 133 128 210 131 176 252 112 62 157 197 14 20 224 230 228 59 198 115 13 253 176 18 80 178 250 204 0 0 0 0 0 0 0 0 0 0 0 0 89 58 8 49 37 220 15 110 80 192 218 232 104 158 206 126 34 152 116 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] BlockNumber:9136851 TxHash:0x1ab11947011f9c2edcf341a2900e33c0b5a511406944c34cdf5ad89fe6beb837 TxIndex:43 BlockHash:0xd03c597d947ea87cf72ea69455e088488c2bd6a52f3de974a80f7b4d51e4c61f Index:109 Removed:false}} {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.191Z INFO initial-claim/main.go:187 GlobalExitRoot: 0x10ede69f03b08580d283b0fc703e9dc50e14e0e6e43bc6730dfdb01250b2facc {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.191Z INFO initial-claim/main.go:188 Transactions: {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.730Z INFO initial-claim/main.go:193 MinForcedTimestamp: 1686120108 {"pid": 783804, "version": "v0.1.0"} 2023-06-07T06:41:50.731Z INFO initial-claim/main.go:196 Success!!!! {"pid": 783804, "version": "v0.1.0"} #### brid ``` ``` ``` package main import ( "context" "math/big" "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" clientUtils "github.com/0xPolygonHermez/zkevm-bridge-service/test/client" "github.com/0xPolygonHermez/zkevm-bridge-service/utils" "github.com/0xPolygonHermez/zkevm-node/log" "github.com/ethereum/go-ethereum/common" ) const ( l2BridgeAddr = "0xcCAb59a3D6Ca0E945D7807Aea48EE1aBf85dA316" l2AccHexAddress = "0x88dAA5DB47afc13ade1d8F2a8E102788251454a5" l2AccHexPrivateKey = "0xcf09fc0001da715d53aa8208c16dca1f325a8c1e90d6dbe314dbcb43a92f5875" l2NetworkURL = "http://54.227.78.48:8545" bridgeURL = "http://54.227.78.48:8080" mtHeight = 32 ) func main() { ctx := context.Background() c, err := utils.NewClient(ctx, l2NetworkURL, common.HexToAddress(l2BridgeAddr)) if err != nil { log.Fatal("Error: ", err) } auth, err := c.GetSigner(ctx, l2AccHexPrivateKey) if err != nil { log.Fatal("Error: ", err) } // Get Claim data cfg := clientUtils.Config{ L1NodeURL: l2NetworkURL, L2NodeURL: l2NetworkURL, BridgeURL: bridgeURL, L2BridgeAddr: common.HexToAddress(l2BridgeAddr), } client, err := clientUtils.NewClient(ctx, cfg) if err != nil { log.Fatal("Error: ", err) } deposits, _, err := client.GetBridges(l2AccHexAddress, 0, 10) //nolint if err != nil { log.Fatal("Error: ", err) } bridgeData := deposits[0] proof, err := client.GetMerkleProof(deposits[0].NetworkId, deposits[0].DepositCnt) if err != nil { log.Fatal("error: ", err) } log.Debug("bridge: ", bridgeData) log.Debug("mainnetExitRoot: ", proof.MainExitRoot) log.Debug("rollupExitRoot: ", proof.RollupExitRoot) var smt [mtHeight][32]byte for i := 0; i < len(proof.MerkleProof); i++ { log.Debug("smt: ", proof.MerkleProof[i]) smt[i] = common.HexToHash(proof.MerkleProof[i]) } globalExitRoot := &etherman.GlobalExitRoot{ ExitRoots: []common.Hash{common.HexToHash(proof.MainExitRoot), common.HexToHash(proof.RollupExitRoot)}, } log.Info("Sending claim tx...") a, _ := big.NewInt(0).SetString(bridgeData.Amount, 0) e := etherman.Deposit { LeafType: uint8(bridgeData.LeafType), OriginalNetwork: uint(bridgeData.OrigNet), OriginalAddress: common.HexToAddress(bridgeData.OrigAddr), Amount: a, DestinationNetwork: uint(bridgeData.DestNet), DestinationAddress: common.HexToAddress(bridgeData.DestAddr), DepositCount: uint(bridgeData.DepositCnt), BlockNumber: bridgeData.BlockNum, NetworkID: uint(bridgeData.NetworkId), TxHash: common.HexToHash(bridgeData.TxHash), Metadata: []byte(bridgeData.Metadata), ReadyForClaim: bridgeData.ReadyForClaim, } to, data, err := c.BuildSendClaim(ctx, &e, smt, globalExitRoot, auth) if err != nil { log.Fatal("error: ", err) } log.Info("to: ", to) log.Info("data: ", data) log.Info("data hex: ", common.Bytes2Hex(data)) log.Info("Success!") balance, err := c.Client.BalanceAt(ctx, common.HexToAddress(l2AccHexAddress), nil) if err != nil { log.Fatal("error getting balance: ", err) } log.Info("L2 balance: ", balance) } ``` edit: * l2BridgeAddr * l2AccHexAddress (sequencer address) * l2AccHexPrivateKey (sequencer private key) * l2NetworkURL ("http://54.227.78.48:8545") * bridgeURL ("http://54.227.78.48:8080") ``` go mod init example.com/claim go mod tidy go get github.com/0xPolygonHermez/zkevm-bridge-service/utils@dcb8177036017af5f9eeee650a67a5be436f867d go run main.go ```