How to start a RPC node for Cardona testnet:
Repo branch: `https://github.com/0xPolygonHermez/cdk-erigon`
Build node: `make cdk-erigon`
Run the node as a RPC for cardona testnet: `build/bin/cdk-erigon --config="/path/to/hermezconfig-cardona.yaml" --maxpeers 0`
The content of hermezconfig-cardona.yaml (need to change datadir):
```
datadir : '/path/to/cardona/data'
chain : "hermez-cardona"
http : true
private.api.addr : "localhost:9093"
zkevm.l2-chain-id: 2442
zkevm.l2-sequencer-rpc-url: "https://rpc.cardona.zkevm-rpc.com/"
zkevm.l2-datastreamer-url: "datastream.cardona.zkevm-rpc.com:6900"
zkevm.l1-chain-id: 11155111
zkevm.l1-rpc-url: "https://rpc.sepolia.org"
zkevm.l1-polygon-rollup-manager: "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff"
zkevm.l1-rollup: "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff"
zkevm.l1-matic-contract-address: "0x1850Dd35dE878238fb1dBa7aF7f929303AB6e8E4"
zkevm.l1-ger-manager-contract-address: "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF"
zkevm.l1-topic-verification: "0xcb339b570a7f0b25afa7333371ff11192092a0aeace12b671f4c212f2815c6fe"
zkevm.l1-topic-sequence: "0x303446e6a8cb73c83dff421c0b1d5e5ce0719dab1bff13660fc254e58cc17fce"
zkevm.l1-block-range: 20000
zkevm.l1-query-delay: 6000
zkevm.l1-first-block: 4789190
zkevm.rpc-ratelimit: 250
txpool.disable: true
torrent.port: 42071
zkevm.datastream-version: 2
externalcl: true
http.api : ["eth","debug","net","trace","web3","erigon","zkevm"]
```
Also, for faster testing, we can sync only the first few hundred blocks by changing execution stage file like this:
```
diff --git a/eth/stagedsync/stage_execute_zkevm.go b/eth/stagedsync/stage_execute_zkevm.go
index b8c3f1f1cf..a4d8527b69 100644
--- a/eth/stagedsync/stage_execute_zkevm.go
+++ b/eth/stagedsync/stage_execute_zkevm.go
@@ -121,6 +121,9 @@ func SpawnExecuteBlocksStageZk(s *StageState, u Unwinder, tx kv.RwTx, toBlock ui
eridb := erigon_db.NewErigonDb(tx)
Loop:
for blockNum := stageProgress + 1; blockNum <= to; blockNum++ {
+ if blockNum > 500 {
+ break
+ }
stageProgress = blockNum
if stoppedErr = common.Stopped(quit); stoppedErr != nil {
```
Sample queries for data required by prover:
Get witness for a block:
`curl http://127.0.0.1:8545 -X POST -H "Content-Type: application/json" --data '{"method":"zkevm_getWitness","params":["0x1"],"id": "block-3","jsonrpc":"2.0"}'`
Get witness for a range of blocks:
`curl http://127.0.0.1:8545 -X POST -H "Content-Type: application/json" --data '{"method":"zkevm_getBlockRangeWitness","params":["0x1", "0x1f3"],"id": "block-0x1_0x1f3","jsonrpc":"2.0"}'`
Get witness for a batch (batch is essentially a range of blocks):
`curl http://127.0.0.1:8545 -X POST -H "Content-Type: application/json" --data '{"method":"zkevm_getBatchWitness","params":[88],"id": "batch-88","jsonrpc":"2.0"}'`
Get block trace:
`curl http://127.0.0.1:8545 -X POST -H "Content-Type: application/json" --data '{"method":"debug_traceBlockByNumber","params":["0x100", {"tracer": "zeroTracer"}],"id":1,"jsonrpc":"2.0"}'`
One important thing to note is that the behavior of debug_traceBlockByNumber in cdk-erigon is different from jerigon. The output of debug_traceBlockByNumber doesn’t contain the block witness as the last element in the result. Therefore, in order to get the witness for the same block, one will need to call zkevm_getWitness. The reason of this divergence is mostly because the module structure is different in cdk-erigon (we couldn’t import function that calculates witness in debug_traceBlockByNumber ).