0xPolygonHermez / cdk-erigon

Ethereum implementation on the efficiency frontier
GNU Lesser General Public License v3.0
35 stars 38 forks source link

Recovering Erigon sequencer data form zkNode is too slow. #1113

Closed zjg555543 closed 2 weeks ago

zjg555543 commented 2 months ago

On the X Layer testnet, to upgrade the Erigon Sequencer, data from zkNode needs to be recovered into the Erigon Sequencer by performing the following two steps:

# xlayer step 1
./build/bin/cdk-erigon --zkevm.sync-limit=12524591 --config="xlayerconfig-testnet.yaml"

# xlayer step 2
# CDK_ERIGON_SEQUENCER=1 ./build/bin/cdk-erigon --zkevm.l1-sync-start-block=4648290 --config="xlayerconfig-testnet.yaml"

# specific erigon branch for step1
git clone -b zjg/recover-test https://github.com/okx/xlayer-erigon.git
cd xlayer-erigon;  make cdk-erigon
DIFF: https://github.com/okx/xlayer-erigon/pull/135

# da service for step2
git clone -b zjg/sync-from-rpc https://github.com/okx/xlayer-data-availability.git
cd xlayer-data-availability;make build-docker; cd test; make run; 
xlayerconfig-testnet.yaml
zkevm.da-url: http://127.0.0.1:8444

However, during the execution of the step2, the process is extremely slow. In one day, blocks are processed from 12,531,103 to 12,764,260, with an average of 0.3987 seconds per block. There are still 4,614,653 blocks remaining, which would take approximately 21.29 days to complete.

Is there a way to optimize this process?

V-Staykov commented 1 month ago

L1 Recovery should be a bit faster than what you say and there might be some space for optimization, but it is still processing everything block by block and calculating the SMT for each block, so it can't be as fast.

Why don't you sync as an RPC to the latest batch though? I don't see a reason to stop so far behind.

zjg555543 commented 1 month ago

L1 Recovery should be a bit faster than what you say and there might be some space for optimization, but it is still processing everything block by block and calculating the SMT for each block, so it can't be as fast.

Why don't you sync as an RPC to the latest batch though? I don't see a reason to stop so far behind.

@V-Staykov Thanks for you sharing. About two months ago, I tried using RPC to sync to the latest block and then using the sequencer, but it gave an error after starting. So recently, I've been using the steps mentioned above.

So, should the correct steps be like this?

# Step 1, as a RPC to sync the latest block.
./build/bin/cdk-erigon --config="xlayerconfig-testnet.yaml"

# Step 2, as a sequencer to recover the data
# CDK_ERIGON_SEQUENCER=1 ./build/bin/cdk-erigon --zkevm.l1-sync-start-block=4648290 --config="xlayerconfig-testnet.yaml"

# Step 3, start the sequencer to product blocks.
# CDK_ERIGON_SEQUENCER=1 ./build/bin/cdk-erigon --config="xlayerconfig-testnet.yaml"
V-Staykov commented 1 month ago

@zjg555543 actually on step 1 you should sync up to a last block in batch. Can be last block in latest batch.

You can do that with the flag that limits execution: zkevm.sync-limit: 6872180

revitteth commented 2 weeks ago

Can reopen if the issue is still a problem, but believe RPC sync should solve this!