hirosystems / ordhook

Build indexers, standards and protocols on top of Ordinals and Inscriptions (BRC20, etc).
Apache License 2.0
180 stars 55 forks source link

Repairing blocks results in panicking #260

Closed GuutBoy closed 6 months ago

GuutBoy commented 7 months ago

To deal with the issue in #258 I attempted to repair blocks using the ordhook db repair blocks command. However this only resulted in a main thread panic. See output below

RUST_BACKTRACE=1 ordhook db repair blocks --config-path=../Ordhook.toml
thread 'main' panicked at 'internal error: entered unreachable code', components/ordhook-cli/src/cli/mod.rs:259:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:117:5
   3: ordhook::cli::RepairStorageCommand::get_blocks
   4: ordhook::cli::handle_command::{{closure}}
   5: tokio::runtime::park::CachedParkThread::block_on
   6: tokio::runtime::context::runtime::enter_runtime
   7: hiro_system_kit::tokio_helpers::nestable_block_on
   8: ordhook::cli::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

With the full backtrace:

$ RUST_BACKTRACE=full ordhook db repair blocks --config-path=../Ordhook.toml
thread 'main' panicked at 'internal error: entered unreachable code', components/ordhook-cli/src/cli/mod.rs:259:18
stack backtrace:
   0:     0x55f9d1bb8601 - std::backtrace_rs::backtrace::libunwind::trace::he648b5c8dd376705
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55f9d1bb8601 - std::backtrace_rs::backtrace::trace_unsynchronized::h5da3e203eef39e9f
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55f9d1bb8601 - std::sys_common::backtrace::_print_fmt::h8d28d3f20588ae4c
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55f9d1bb8601 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd9a5b0c9c6b058c0
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55f9d1be634f - core::fmt::rt::Argument::fmt::h0afc04119f252b53
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/fmt/rt.rs:138:9
   5:     0x55f9d1be634f - core::fmt::write::h50b1b3e73851a6fe
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/fmt/mod.rs:1094:21
   6:     0x55f9d1bb42d7 - std::io::Write::write_fmt::h184eaf275e4484f0
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/io/mod.rs:1714:15
   7:     0x55f9d1bb8415 - std::sys_common::backtrace::_print::hf58c3a5a25090e71
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x55f9d1bb8415 - std::sys_common::backtrace::print::hb9cf0a7c7f077819
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x55f9d1bb9b83 - std::panicking::default_hook::{{closure}}::h066adb2e3f3e2c07
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:269:22
  10:     0x55f9d1bb9914 - std::panicking::default_hook::h277fa2776900ff14
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:288:9
  11:     0x55f9d1bba109 - std::panicking::rust_panic_with_hook::hceaf38da6d9db792
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:705:13
  12:     0x55f9d1bb9fc1 - std::panicking::begin_panic_handler::{{closure}}::h2bce3ed2516af7df
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:595:13
  13:     0x55f9d1bb8a66 - std::sys_common::backtrace::__rust_end_short_backtrace::h090f3faf8f98a395
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:151:18
  14:     0x55f9d1bb9d52 - rust_begin_unwind
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
  15:     0x55f9d0b2f5f3 - core::panicking::panic_fmt::h4ec8274704d163a3
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
  16:     0x55f9d0b2f683 - core::panicking::panic::hee69a8315e4031d6
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:117:5
  17:     0x55f9d0b821cb - ordhook::cli::RepairStorageCommand::get_blocks::h29c12d735110ab7a
  18:     0x55f9d0bc2361 - ordhook::cli::handle_command::{{closure}}::hffd2933123f2bf92
  19:     0x55f9d0bb3c60 - tokio::runtime::park::CachedParkThread::block_on::h7ed6674745d3e0fd
  20:     0x55f9d0c2bbf1 - tokio::runtime::context::runtime::enter_runtime::h3d60315c990817fa
  21:     0x55f9d0bf7870 - hiro_system_kit::tokio_helpers::nestable_block_on::he8eb20fb8f092ea2
  22:     0x55f9d0b82f1f - ordhook::cli::main::h4941a6c610afc492
  23:     0x55f9d0beeb43 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd48e853c417060d3
  24:     0x55f9d0c06c19 - std::rt::lang_start::{{closure}}::h1c4f3596ad18214d
  25:     0x55f9d1bac29b - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h75ba4244a1c7bb54
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:284:13
  26:     0x55f9d1bac29b - std::panicking::try::do_call::h0a2baa36dea975a1
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
  27:     0x55f9d1bac29b - std::panicking::try::h0e42aa233d4224d4
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
  28:     0x55f9d1bac29b - std::panic::catch_unwind::hefdfd8f482606434
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
  29:     0x55f9d1bac29b - std::rt::lang_start_internal::{{closure}}::h457959f0f91da23b
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/rt.rs:148:48
  30:     0x55f9d1bac29b - std::panicking::try::do_call::h112cfd1acb38183b
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
  31:     0x55f9d1bac29b - std::panicking::try::ha64f15b20cec18ca
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
  32:     0x55f9d1bac29b - std::panic::catch_unwind::hbacc2b68ee2c119e
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
  33:     0x55f9d1bac29b - std::rt::lang_start_internal::h5f408694586c2a05
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/rt.rs:148:20
  34:     0x55f9d0c0e435 - main
  35:     0x7f50bbe697e5 - __libc_start_main
  36:     0x55f9d0b5e8fe - _start
  37:                0x0 - <unknown>
smcclellan commented 7 months ago

@GuutBoy Could you try running this in the latest on develop? This may be fixed there.

GuutBoy commented 7 months ago

@smcclellan I can confirm this is on the latest develop. I wonder if I may be missing some arguments? Even so, this probably should not result in a panic. I am simply running

ordhook db repair blocks
lgalabru commented 6 months ago

@GuutBoy how about now?

GuutBoy commented 6 months ago

Still the same

$ ordhook db repair blocks --config-path Ordhook.toml
thread 'main' panicked at 'internal error: entered unreachable code', components/ordhook-cli/src/cli/mod.rs:259:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I am guessing it is because I need to add options like --blocks or something.

lgalabru commented 6 months ago

correct. if you don't know which blocks to repair, you can use the command

$ ordhook service start --config-path Ordhook.toml

the new version should run some integrity checks and auto-repair broken states.

lgalabru commented 6 months ago

Feel free to re-open this issue with more logs if you're still having some trouble.