0xPolygon / kurtosis-cdk

A Kurtosis package that deploys a private, portable, and modular Polygon CDK devnet
https://docs.polygon.technology/cdk
Apache License 2.0
28 stars 43 forks source link

Deploy cdk stack on a private l1 chain. #152

Closed petertheprocess closed 3 weeks ago

petertheprocess commented 3 weeks ago

System information

Ubuntu 20.04, amd64

Commit id

6e1650c

Tools versions

Checking that you have the necessary tools to deploy the Kurtosis CDK package... ✅ kurtosis 0.89.10 is installed, meets the requirement (=0.89). ✅ docker 26.1.3 is installed, meets the requirement (>=24.7).

You might as well need the following tools to interact with the environment... ⚠️ jq is not installed. You can install jq at: https://jqlang.github.io/jq/download/ ⚠️ yq is not installed. You can install yq at: https://pypi.org/project/yq/ ✅ cast 0.2.0 is installed. ⚠️ polycli is not installed. You can install polycli at: https://github.com/maticnetwork/polygon-cli/releases

Description & steps to reproduce

I want to deploy on a testnet(which is maintained by our school), which support compiler of v0.8.18.

  1. I first modified some l1 config based on https://github.com/0xPolygon/kurtosis-cdk/blob/main/doc-drafts/deploy-sepolia-l1.md.
  2. And since I found my chain is not support EIP-1559, I also add --lagcy flag to all the cast send cmd, like that
    fund_account_on_l1() {
    name="$1"
    address="$2"
    echo_ts "Funding $name account"
    cast send \
        --legacy \
        --rpc-url "{{.l1_rpc_url}}" \
        --mnemonic "{{.l1_preallocated_mnemonic}}" \
        --value "{{.l1_funding_amount}}" \
        "$address"
    }
  3. Then I get an error in Step 1: Preparing tesnet
    
    [2024-06-13 11:38:30] Deploying zkevm contracts to L1
    [2024-06-13 11:38:30] Step 1: Preparing tesnet

@0xpolygonhermez/zkevm-contracts@3.0.0 npx hardhat run deployment/testnet/prepareTestnet.ts --network localhost

ProviderError: invalid opcode: PUSH0 at HttpProvider.request (/opt/zkevm-contracts/node_modules/hardhat/src/internal/core/providers/http.ts:88:21) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async HardhatEthersProvider.estimateGas (/opt/zkevm-contracts/node_modules/@nomicfoundation/hardhat-ethers/src/internal/hardhat-ethers-provider.ts:237:27) at async Wallet.populateTransaction (/opt/zkevm-contracts/node_modules/ethers/src.ts/providers/abstract-signer.ts:105:28) at async Wallet.sendTransaction (/opt/zkevm-contracts/node_modules/ethers/src.ts/providers/abstract-signer.ts:232:21) at async ContractFactory.deploy (/opt/zkevm-contracts/node_modules/ethers/src.ts/contract/factory.ts:111:24) at async main (/opt/zkevm-contracts/deployment/testnet/prepareTestnet.ts:100:30) [2024-06-13 11:38:32] Step 2: Creating genesis

@0xpolygonhermez/zkevm-contracts@3.0.0 npx ts-node deployment/v2/1_createGenesis.ts

Warning: Potentially unsafe deployment of contracts/PolygonZkEVMGlobalExitRootL2.sol:PolygonZkEVMGlobalExitRootL2

You are using the `unsafeAllow.state-variable-immutable` flag.

Warning: Potentially unsafe deployment of contracts/PolygonZkEVMGlobalExitRootL2.sol:PolygonZkEVMGlobalExitRootL2

You are using the `unsafeAllow.constructor` flag.

[2024-06-13 11:38:38] Step 3: Deploying PolygonZKEVMDeployer

@0xpolygonhermez/zkevm-contracts@3.0.0 npx hardhat run deployment/v2/2_deployPolygonZKEVMDeployer.ts --network localhost

ProviderError: err: insufficient funds for gas * price + value: address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970 have 10000000000000000 want 100000000000000000 (supplied gas 15010499) at HttpProvider.request (/opt/zkevm-contracts/node_modules/hardhat/src/internal/core/providers/http.ts:88:21) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async HardhatEthersProvider.estimateGas (/opt/zkevm-contracts/node_modules/@nomicfoundation/hardhat-ethers/src/internal/hardhat-ethers-provider.ts:237:27) at async Wallet.populateTransaction (/opt/zkevm-contracts/node_modules/ethers/src.ts/providers/abstract-signer.ts:105:28) at async Wallet.sendTransaction (/opt/zkevm-contracts/node_modules/ethers/src.ts/providers/abstract-signer.ts:232:21) at async deployPolygonZkEVMDeployer (/opt/zkevm-contracts/deployment/helpers/deployment-helpers.ts:67:12) at async main (/opt/zkevm-contracts/deployment/v2/2_deployPolygonZKEVMDeployer.ts:73:54) [2024-06-13 11:38:40] Step 4: Deploying contracts

@0xpolygonhermez/zkevm-contracts@3.0.0 npx hardhat run deployment/v2/3_deployContracts.ts --network localhost

Error: Missing parameter: zkEVMDeployerAddress at main (/opt/zkevm-contracts/deployment/v2/3_deployContracts.ts:86:19) at Object. (/opt/zkevm-contracts/deployment/v2/3_deployContracts.ts:552:1) at Module._compile (node:internal/modules/cjs/loader:1358:14) at Module.m._compile (/opt/zkevm-contracts/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) at Object.require.extensions. [as .ts] (/opt/zkevm-contracts/node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1208:32) at Function.Module._load (node:internal/modules/cjs/loader:1024:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) at node:internal/main/run_main_module:28:49 [2024-06-13 11:38:41] Step 5: Creating rollup

@0xpolygonhermez/zkevm-contracts@3.0.0 npx hardhat run deployment/v2/4_createRollup.ts --network localhost

Error: Cannot find module './deploy_output.json' Require stack:


Creating keystores for zkevm-node/cdk-validium components Command returned with exit code '0' with no output

Printing a message Skipping the deployment of helper service to retrieve rollup data

Printing a message Deploying zkevm node and cdk peripheral databases

Rendering a template to a files artifact with name 'init.sql-001' Templates artifact name 'init.sql-001' rendered with artifact UUID 'bc1c4060fddc41ee8ef9733b1862e2ce'

Starting Postgres Service Service 'postgres-001' added with service UUID '3625a2b16b2949bc85a102b6fe528e51'

Printing a message Getting genesis file...

Storing files from service 'contracts-001' at path '/opt/zkevm/genesis.json' to files artifact with name 'genesis' Files with artifact name 'genesis' uploaded with artifact UUID '705813c7ae8743e58c4e799153530e89'

Printing a message Deploying cdk central/trusted environment

Rendering a template to a files artifact with name 'prover-config-artifact' Templates artifact name 'prover-config-artifact' rendered with artifact UUID '85d0edb2865f41d994cd40bdbe081a21'

Determining CPU system architecture Command returned with exit code '0' and the following output: x86_64

Adding service with name 'zkevm-prover-001' and image 'hermeznetwork/zkevm-prover:v6.0.0' Service 'zkevm-prover-001' added with service UUID '4886acf543f64597a2a9c99a7e4e5750'

Rendering a template to a files artifact with name 'trusted-node-config' Templates artifact name 'trusted-node-config' rendered with artifact UUID '142f3ca17a87476badf02d51fb694ef0'

Adding service with name 'zkevm-node-synchronizer-001' and image '0xpolygon/cdk-validium-node:0.6.5-cdk' There was an error executing Starlark code An error occurred executing instruction (number 23) at github.com/0xPolygon/kurtosis-cdk/lib/zkevm_node.star[52:21]: add_service(name="zkevm-node-synchronizer-001", config=ServiceConfig(image="0xpolygon/cdk-validium-node:0.6.5-cdk", ports={"pprof": PortSpec(number=6060, application_protocol="http"), "prometheus": PortSpec(number=9091, application_protocol="http")}, files={"/etc/zkevm": Directory(artifact_names=["trusted-node-config", "genesis"])}, entrypoint=["/app/zkevm-node"], cmd=["run", "--cfg=/etc/zkevm/node-config.toml", "--network=custom", "--custom-network-file=/etc/zkevm/genesis.json", "--components=synchronizer"])) Caused by: Unexpected error occurred starting service 'zkevm-node-synchronizer-001' Caused by: An error occurred waiting for all TCP and UDP ports to be open for service 'zkevm-node-synchronizer-001' with private IP '172.16.0.8'; this is usually due to a misconfiguration in the service itself, so here are the logs: == SERVICE 'zkevm-node-synchronizer-001' LOGS =================================== panic: failed to load genesis configuration from file. Error: json: cannot unmarshal non-string into Go struct field L1Config.L1Config.polygonZkEVMGlobalExitRootAddress of type common.Address

goroutine 1 [running]: github.com/0xPolygonHermez/zkevm-node/config.(Config).loadNetworkConfig(0xc000635b00, 0x15ecc40?) /home/runner/work/cdk-validium-node/cdk-validium-node/config/network.go:74 +0x1d3 github.com/0xPolygonHermez/zkevm-node/config.Load(0x0?, 0x1) /home/runner/work/cdk-validium-node/cdk-validium-node/config/config.go:186 +0x432 main.start(0xc000148d80) /home/runner/work/cdk-validium-node/cdk-validium-node/cmd/run.go:52 +0x37 github.com/urfave/cli/v2.(Command).Run(0xc0001b0dc0, 0xc000148d80, {0xc000444230, 0x5, 0x5}) /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.26.0/command.go:277 +0x9d8 github.com/urfave/cli/v2.(Command).Run(0xc000156000, 0xc000148840, {0xc00003e1e0, 0x6, 0x6}) /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.26.0/command.go:270 +0xc25 github.com/urfave/cli/v2.(App).RunContext(0xc0004b65a0, {0x1d5c320?, 0x2b2b440}, {0xc00003e1e0, 0x6, 0x6}) /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.26.0/app.go:335 +0x5db github.com/urfave/cli/v2.(*App).Run(...) /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.26.0/app.go:309 main.main() /home/runner/work/cdk-validium-node/cdk-validium-node/cmd/main.go:198 +0xd3b

== FINISHED SERVICE 'zkevm-node-synchronizer-001' LOGS =================================== Caused by: An error occurred while waiting for all TCP and UDP ports to be open Caused by: Unsuccessful ports check for IP '172.16.0.8' and port spec '{privatePortSpec:0xc001cf77a0}', even after '240' retries with '500' milliseconds in between retries. Timeout '2m0s' has been reached Caused by: An error occurred while calling network address '172.16.0.8:6060' with port protocol 'TCP' and using time out '200ms' Caused by: dial tcp 172.16.0.8:6060: i/o timeout

Error encountered running Starlark code.



### Desired behavior

I asked ChatGPT, it said we need to modify the compiler version since PUSH0 is unsupported in my chain, but how?

### What is the severity of this bug?

Critical; I am blocked and Kurtosis CDK is unusable for me because of this bug.
petertheprocess commented 3 weeks ago

I found out Deploying zkevm contracts to L1 is using docker to run code in https://github.com/0xPolygonHermez/zkevm-contracts, and in the run-contract-setup.sh, all step catains a flag --network localhost, but should it be something like l1_rpc_url instead?

echo_ts "Step 1: Preparing tesnet"
npx hardhat run deployment/testnet/prepareTestnet.ts --network localhost | tee 01_prepare_testnet.out

echo_ts "Step 2: Creating genesis"
MNEMONIC="{{.l1_preallocated_mnemonic}}" npx ts-node deployment/v2/1_createGenesis.ts | tee 02_create_genesis.out

echo_ts "Step 3: Deploying PolygonZKEVMDeployer"
npx hardhat run deployment/v2/2_deployPolygonZKEVMDeployer.ts --network localhost | tee 03_zkevm_deployer.out

echo_ts "Step 4: Deploying contracts"
npx hardhat run deployment/v2/3_deployContracts.ts --network localhost | tee 04_deploy_contracts.out

echo_ts "Step 5: Creating rollup"
npx hardhat run deployment/v2/4_createRollup.ts --network localhost | tee 05_create_rollup.out
leovct commented 3 weeks ago

The error you are experiencing is linked to the fact that your test network does not support the PUSH0 opcode. It has been introduced in https://github.com/ethereum/solidity/releases/tag/v0.8.20. Screenshot 2024-06-14 at 15 32 52