Problem:
When start the witness generator the first time,it will cause an overflow bug.Because the verified block is 0 and NUMBER_OF_STORED_ACCOUNT_TREE_CACHE is 300 while BlockNumber is unsigned type, block - NUMBER_OF_STORED_ACCOUNT_TREE_CACHE will get an negative num.The code is located on function store_account_tree_cache in file database.rs.
connection
.chain()
.block_schema()
.remove_old_account_tree_cache(block - NUMBER_OF_STORED_ACCOUNT_TREE_CACHE)
.await?;
CodeBase:
branch: master
commit: f958bd54000c5203ed54b55dee073d5b03f192be
Call Stack:
thread 'prover_server_pool' panicked at 'attempt to subtract with overflow', core/lib/basic_types/src/lib.rs:27:1
stack backtrace:
0: rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
2: core::panicking::panic
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:48:5
3: <zksync_basic_types::BlockNumber as core::ops::arith::Sub>::sub
at ./core/lib/basic_types/src/macros.rs:56:22
4: <zksync_witness_generator::database::Database as zksync_witness_generator::database_interface::DatabaseInterface>::store_account_tree_cache::{{closure}}
at ./core/bin/zksync_witness_generator/src/database.rs:268:44
5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/mod.rs:84:19
6: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/future.rs:123:9
7: zksync_witness_generator::witness_generator::WitnessGenerator<DB>::load_account_tree::{{closure}}
at ./core/bin/zksync_witness_generator/src/witness_generator.rs:162:22
8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/mod.rs:84:19
9: zksync_witness_generator::witness_generator::WitnessGenerator<DB>::prepare_witness_and_save_it::{{closure}}
at ./core/bin/zksync_witness_generator/src/witness_generator.rs:217:86
10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/mod.rs:84:19
11: zksync_witness_generator::witness_generator::WitnessGenerator<DB>::maintain::{{closure}}
at ./core/bin/zksync_witness_generator/src/witness_generator.rs:274:74
12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/mod.rs:84:19
13: zksync_witness_generator::witness_generator::WitnessGenerator<DB>::start::{{closure}}::{{closure}}
at ./core/bin/zksync_witness_generator/src/witness_generator.rs:67:36
14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/future/mod.rs:84:19
15: tokio::park::thread::CachedParkThread::block_on::{{closure}}
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/park/thread.rs:263:54
16: tokio::coop::with_budget::{{closure}}
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/coop.rs:106:9
17: std::thread::local::LocalKey<T>::try_with
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/thread/local.rs:412:16
18: std::thread::local::LocalKey<T>::with
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/thread/local.rs:388:9
19: tokio::coop::with_budget
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/coop.rs:99:5
20: tokio::coop::budget
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/coop.rs:76:5
21: tokio::park::thread::CachedParkThread::block_on
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/park/thread.rs:263:31
22: tokio::runtime::enter::Enter::block_on
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/runtime/enter.rs:151:13
23: tokio::runtime::thread_pool::ThreadPool::block_on
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/runtime/thread_pool/mod.rs:77:9
24: tokio::runtime::Runtime::block_on
at /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/runtime/mod.rs:463:43
25: zksync_witness_generator::witness_generator::WitnessGenerator<DB>::start::{{closure}}
at ./core/bin/zksync_witness_generator/src/witness_generator.rs:66:17
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
It should check current block and NUMBER_OF_STORED_ACCOUNT_TREE_CACHE before remove old account tree cache.
Let me see if I can find out more for you.
Let me see if I can find out more for you.
Thanks and wait for your help.