Skip to content

Commit

Permalink
p2p: Remove the assertion for the filter height
Browse files Browse the repository at this point in the history
It is not clear to me when this happens, but based on how
the sync function is written, there doesn't seem to be a reason to assert and fail.

Additionally, when starting a new negotiation with a new peer, it appears to be quite common to receive a peer with a different height, which may be the incorrect one.

The crash that I observe on my system is:

```
thread '<unnamed>' panicked at 'assertion failed: filter_height <= block_height', /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/p2p/src/fsm/cbfmgr.rs:853:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/core/src/panicking.rs:117:5
   3: nakamoto_p2p::fsm::cbfmgr::FilterManager<F,U,C>::sync
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/p2p/src/fsm/cbfmgr.rs:853:9
   4: nakamoto_p2p::fsm::cbfmgr::FilterManager<F,U,C>::idle
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/p2p/src/fsm/cbfmgr.rs:900:13
   5: nakamoto_p2p::fsm::cbfmgr::FilterManager<F,U,C>::initialize
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/p2p/src/fsm/cbfmgr.rs:329:9
   6: <nakamoto_p2p::fsm::StateMachine<T,F,P,C> as nakamoto_net::StateMachine>::initialize
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/p2p/src/fsm.rs:782:9
   7: <nakamoto_client::service::Service<T,F,P,C> as nakamoto_net::StateMachine>::initialize
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/client/src/service.rs:86:9
   8: <nakamoto_net_poll::reactor::Reactor<std::net::tcp::TcpStream,Id> as nakamoto_net::Reactor<Id>>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/net/poll/src/reactor.rs:156:9
   9: nakamoto_client::client::ClientRunner<R>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/client/src/client.rs:183:9
  10: nakamoto_client::client::Client<R>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/client/src/client.rs:402:9
  11: satoshi_nakamoto::Nakamoto::new::{{closure}}
             at /home/vincent/Github/coffee/satoshi/satoshi-nakamoto/src/lib.rs:41:45
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2023-04-06T16:54:52.509Z DEBUG   plugin-satoshi_plugin: Err(PluginError { code: -1, msg: \"command channel disconnected\", data: None })

```

Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Jun 25, 2023
1 parent 5ffebc6 commit 3c546e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion p2p/src/fsm/cbfmgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,12 @@ impl<F: Filters, U: Wire<Event> + SetTimer + Disconnect, C: Clock> FilterManager
let filter_height = self.filters.height();
let block_height = tree.height();

assert!(filter_height <= block_height);
if filter_height > block_height {
log::info!(
"filter height (`{filter_height}`) grater than the block height (`{block_height}`)"
);
return;
}

// Don't start syncing filter headers until block headers are synced passed the last
// checkpoint. BIP 157 states that we should sync the full block header chain before
Expand Down

0 comments on commit 3c546e6

Please sign in to comment.