revault / revaultd

The "wallet" daemon for participants under the Revault architecture
BSD 3-Clause "New" or "Revised" License
49 stars 21 forks source link

Panic on negative value in listsinceblock #422

Open darosior opened 2 years ago

darosior commented 2 years ago
[1661944671][revaultd::sigfetcher][DEBUG] Polling signatures took 0 seconds.                                                                                                                                                                                                                                                                                               
[1661944672][revaultd][ERROR] panic occurred at line 1176 of file src/bitcoind/interface.rs: Some("Could not convert 'listsinceblock' entry's 'amount' to an Amount: Negative")                                                                                                                                                                                            
   0: revaultd::setup_panic_hook::{{closure}}                                                                                                                                                                                                                                                                                                                              
             at src/revaultd/src/lib.rs:50:18                                                                                                                                                                                                                                                                                                                              
   1: std::panicking::rust_panic_with_hook                                                                                                                                                                                                                                                                                                                                 
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:702:17                                                                                                                                                                                                                                                                        
   2: std::panicking::begin_panic_handler::{{closure}}                                                                                                                                                                                                                                                                                                                     
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:588:13                                                                                                                                                                                                                                                                        
   3: std::sys_common::backtrace::__rust_end_short_backtrace                                                                                                                                                                                                                                                                                                               
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:138:18                                                                                                                                                                                                                                                             
   4: rust_begin_unwind                                                                                                                                                                                                                                                                                                                                                    
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5                                                                                                                                                                                                                                                                         
   5: core::panicking::panic_fmt                                                                                                                                                                                                                                                                                                                                           
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14                                                                                                                                                                                                                                                                       
   6: core::result::unwrap_failed                                                                                                                                                                                                                                                                                                                                          
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5                                                                                                                                                                                                                                                                          
   7: core::result::Result<T,E>::expect                                                                                                                                                                                                                                                                                                                                    
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1035:23                                                                                                                                                                                                                                                                         
   8: <revaultd::bitcoind::interface::ListSinceBlockTransaction as core::convert::From<&serde_json::value::Value>>::from                                                                                                                                                                                                                                                   
             at src/revaultd/src/bitcoind/interface.rs:1175:21                                                                                                                                                                                                                                                                                                             
   9: revaultd::bitcoind::interface::BitcoinD::list_since_block::{{closure}}                                                                                                                                                                                                                                                                                               
             at src/revaultd/src/bitcoind/interface.rs:567:25                                                                                                                                                                                                                                                                                                              
  10: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut                                                                                                                                                                                                                                                                                
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:290:13                                                                                                                                                                                                                                                                    
  11: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::find_map                                                                                                                                                                                                                                                                                     
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/slice/iter/macros.rs:276:38                                                                                                                                                                                                                                                               
  12: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next                                                                                                                                                                                                                                                                   
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/iter/adapters/filter_map.rs:61:9                                                                                                                                                                                                                                                          
  13: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter                                                                                                                                                                                                                                                                        
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/vec/spec_from_iter_nested.rs:26:32                                                                                                                                                                                                                                                       
  14: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter                                                                                                                                                                                                                                                                                     
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/vec/spec_from_iter.rs:33:9                                                                                                                                                                                                                                                               
  15: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter                                                                                                                                                                                                                                                                                      
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/vec/mod.rs:2612:9                                                                                                                                                                                                                                                                        
  16: core::iter::traits::iterator::Iterator::collect                                                                                                                                                                                                                                                                                                                      
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/iter/traits/iterator.rs:1788:9                                                                                                                                                                                                                                                            
  17: revaultd::bitcoind::interface::BitcoinD::list_since_block                                                                                                                                                                                                                                                                                                            
             at src/revaultd/src/bitcoind/interface.rs:560:12                                                                                                                                                                                                                                                                                                              
  18: revaultd::bitcoind::interface::BitcoinD::list_deposits_since_block                                                                                                                                                                                                                                                                                                   
             at src/revaultd/src/bitcoind/interface.rs:581:9                                                                                                                                                                                                                                                                                                               
  19: revaultd::bitcoind::interface::BitcoinD::sync_deposits                                                                                                                                                                                                                                                                                                               
             at src/revaultd/src/bitcoind/interface.rs:635:21                                                                                                                                                                                                                                                                                                              
  20: revaultd::bitcoind::poller::update_utxos                                                                                                                                                                                                                                                                                                                             
             at src/revaultd/src/bitcoind/poller.rs:1554:9                                                                                                                                                                                                                                                                                                                 
  21: revaultd::bitcoind::poller::poller_main                                                                                                                                        
             at src/revaultd/src/bitcoind/poller.rs:1938:25                                                                                                                          
  22: revaultd::bitcoind::bitcoind_main_loop::{{closure}}                                                                                                                            
             at src/revaultd/src/bitcoind/mod.rs:211:17                                                                                                                              
  23: std::sys_common::backtrace::__rust_begin_short_backtrace                                                                                                                       
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:122:18                                                                       
  24: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}                                                                                                               
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/thread/mod.rs:501:17                                                                                 
  25: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once                                                                                  
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panic/unwind_safe.rs:271:9                                                                          
  26: std::panicking::try::do_call                                                                                                                                                   
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:492:40
darosior commented 2 years ago

Repro on aquarium:

darosior commented 2 years ago

Alright, it's because of generating block to a deposit address. https://github.com/revault/revaultd/blob/7cd856d5a345319cebc815aa61f3b66cebb48b86/src/bitcoind/interface.rs#L1161 https://github.com/revault/revaultd/blob/7cd856d5a345319cebc815aa61f3b66cebb48b86/src/bitcoind/interface.rs#L1183-L1189

This above does not take into account the "immature" category.