0xPolygonHermez / cdk-erigon

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

[RPC] generate witness locally during execution. #1458

Open hexoscott opened 1 week ago

hexoscott commented 1 week ago

Normally, witness generation requires an unwind of the chain to replay transactions and find touch points to put into the witness, but this process can be very slow if the network is producing a lot of blocks and the aggregator can't keep up.

The task is to add a new flag like zkevm.pre-populate-witness and if set, the RPC will generate a witness during the execution phase and store this in the table we use for caching witnesses (the sequencer already uses this so lets use the same table in the same way).

A call for the witness should then check if it is already in the cache before performing the usual steps.

If we don't have the witness in the cache then we should store it after generating it. This will allow this feature to work without needing a resync.

Bonus - can we do this without requiring the unwind to get the witness?