0xPolygonZero / zk_evm

Apache License 2.0
68 stars 20 forks source link

Cache `prev_hashes` input prover data #325

Open atanmarko opened 6 days ago

atanmarko commented 6 days ago

When proving consecutive blocks, we should reuse already retrieved data.

Nashtare commented 6 days ago

Isn't it what https://github.com/0xPolygonZero/zk_evm/issues/282 was supposed to do already? Or do you mean if you kick of a job proving blocks 1 to 10. And then a next job proving blocks 11 to 30, the latter should retrieve the previously fetched hashes?

atanmarko commented 6 days ago

@Nashtare #282 just halved the number of calls to retrieve the previous 256 hashes. We still call fetch_other_block_data for every block. We also call provider.get_block on multiple places for the same block. Everything should be cached.

Nashtare commented 6 days ago

Ah ok. I got confused because the linked issue in #282 wasn't about going from 256 to 128 RPC calls but really about caching previously fetched block hashes (effectively what this new issue wants to address). But thanks for clarifying.

atanmarko commented 6 days ago

@Nashtare aha, OK. I opened the #282 to port https://github.com/0xPolygonZero/zero-bin/pull/62 to alloy and it didn't implement cache.

EDIT: it did in some capacity. Anyway it has to be done with current zero-bin setup ASAP.