scroll-tech / stateless-block-verifier

20 stars 6 forks source link

opt: zktrie should not commit after each tx #2

Closed lispc closed 2 months ago

lispc commented 2 months ago
  1. i think you misunderstand the "DatabaseCommit" trait. It is not trie commitment, it is tx state diff commitment, committing diffs into another block-level cache db layer.

let us use revm::InMemoryDB to merge state diff of each tx, then apply them after block.

  1. it seems no good to re-build evm instance for each tx. try fix this. ref: https://github.com/paradigmxyz/reth/blob/199503531c4e66cba702844a5a8224620ee0e877/crates/ethereum/evm/src/execute.rs#L129

====== outdated below =====

it seems if we want block-level trie commitment we have to use crates/revm/src/db/states/cache.rs. bins/revme/src/cmd/statetest/runner.rs provides an example

we should use

revm::db::State::builder()
                    .with_bundle_update()
                    .build();

here is how reth evm is built https://github.com/paradigmxyz/reth/blob/14ed7196c258545992efa478739a361f2fde7f1e/crates/revm/src/processor.rs#L80

revm::State can be used?

lightsing commented 2 months ago

resolved by adding a cache layer