stakwork/sphinx-key

Signer's chain tracker advances by one block, but broker times out, and remains on the current block.

Closed this issue · 1 comments

This is a rare bug, but it's a showstopper when it does occur.

Best explanation so far:

Broker sends an AddBlock message to the signer, signer takes longer than the broker timeout to respond, but nonetheless responds, and advances its state.

Broker though, timed out, and is now trying the AddBlock message again.

At this point, the signer complains like this:

I (14948) vls_protocol_signer::handler: Restore node 03db6da1e6a91f8c716e57ecc8029d452e9506016b17f47fd920ae7f04712775b0                                       
I (15968) lightning_signer::node:   Restore channel 0379bb7397a354dc8bfb07d3d8a0d24d88d84c0eae2c6a68fd15149aaafbbaca950400000000000000 outpoint Some(OutPoint 
{ txid: 5c12978335d47b1a8e9edd3d5d47d7a9a3b241f1b8db7e4b75aaaf1aaf74c3a9, vout: 0 })                                                                          
I (16258) lightning_signer::node: Restore node 03db6da1e6a91f8c716e57ecc8029d452e9506016b17f47fd920ae7f04712775b0 on bitcoin                                  
I (16258) vls_protocol_signer::handler: vls_protocol_signer::handler::RootHandlerBuilder::do_build:: NodeState::summary 03db: 0 invoices, 0 issued_invoices, 0
 payments, excess_amount 0                                                                                                                                    
I (16288) sphinx_key::core::events: => starting the main signing loop...                                                                                      
I (23328) sphinx_key::core::events: new event loop!                                                                                                           
I (23338) sphinx_key::core::events: Available DRAM: 117740, Max block: 75776                                                                                  
I (23338) sphinx_signer::root: => handler sequence: 37                                                                                                        
I (23348) sphinx_signer::root: VLS: => AddBlock                                                                                                               
E (23358) lightning_signer::chain::tracker: InvalidChain: header.prev_blockhash 00000000000000000000ced82a9fb1bfb6629d4e237fb303c7a79643a11619e4 != self.tip.b
lock_hash 0000000000000000000228bd014a349ab728faba7a8124cce03b67f29d5ed458                                                                                    
thread 'main' panicked at 'add_block: InvalidChain', /home/flow/.cargo/git/checkouts/validating-lightning-signer-a73a90f948bef2fd/19447b1/vls-protocol-signer/
src/handler.rs:641:22

Broker is sending AddBlock for block at height 815524, but the tip of the signer's tracker is already at 815524, so we get this complaint.