nervosnetwork / ckb-light-client

CKB light client reference implementation
MIT License
14 stars 16 forks source link

fix: unexpected total difficulty from storage #32

Closed TheWaWaR closed 2 years ago

TheWaWaR commented 2 years ago

The panic this PR aimed to fix:

[2022-07-06T01:26:36Z TRACE ckb_light_client::protocols::light_client::components::send_last_state] peer SessionId(19): update last state
thread 'GlobalRt-1' panicked at 'U256: attempt to subtract with overflow', xxx/src/github.com-1ecc6299db9ec823/numext-fixed-uint-core-0.1.6/src/lib.rs:21:1
stack backtrace:
   0:        0x10c493b81 - std::backtrace_rs::backtrace::libunwind::trace::h0b624e35bf84187c
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x10c493b81 - std::backtrace_rs::backtrace::trace_unsynchronized::h435d9bd636904605
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x10c493b81 - std::sys_common::backtrace::_print_fmt::h3ca407d645e7e73d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x10c493b81 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f26ffad025fdbe8
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:        0x10c4b647b - core::fmt::write::h0a9937d83d3944c1
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:        0x10c48c068 - std::io::Write::write_fmt::hfaf2e2e92eda8127
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:        0x10c4964b7 - std::sys_common::backtrace::_print::h11335bd900abe1ce
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:        0x10c4964b7 - std::sys_common::backtrace::print::hdf5291c87f745042
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:        0x10c4964b7 - std::panicking::default_hook::{{closure}}::hc11e9b8d348e68b0
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:        0x10c4960c5 - std::panicking::default_hook::h1d26ec4d0d63be04
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:        0x10c496b40 - std::panicking::rust_panic_with_hook::hef4f5e524db188b3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17
  11:        0x10c49686e - std::panicking::begin_panic_handler::{{closure}}::h6e8805ea2351af89
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  12:        0x10c493ff7 - std::sys_common::backtrace::__rust_end_short_backtrace::hd383ade987b76f63
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  13:        0x10c49655a - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  14:        0x10c4f19cf - core::panicking::panic_fmt::hb58956db718d5b79
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  15:        0x10bbdac21 - ckb_light_client::protocols::light_client::LightClientProtocol::build_prove_request_content::hcf324a62cb890034
  16:        0x10bbd8dfe - ckb_light_client::protocols::light_client::LightClientProtocol::get_block_samples::h7699b942413d6721
  17:        0x10bb54266 - ckb_light_client::protocols::light_client::components::send_last_state::SendLastStateProcess::execute::h6f6a3d8ae323a674
  18:        0x10bbd856a - <ckb_light_client::protocols::light_client::LightClientProtocol as ckb_network::protocols::CKBProtocolHandler>::received::h179d07dc922cb493