btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.29k stars 2.38k forks source link

Client asks for txs during IBD #1984

Open kcalvinalvin opened 1 year ago

kcalvinalvin commented 1 year ago

While I was syncing a node built from master 98e3c495442f08315e324e55fa235edb6ed28c98, I got the following error:

2023-05-22 08:40:06.677 [INF] SYNC: Processed 12 blocks in the last 10.19s (34673 transactions, height 759506, 2022-10-20 20:49:29 +0900 KST)                                                                                                                                                                                                      
2023-05-22 08:40:17.668 [INF] SYNC: Processed 16 blocks in the last 10.99s (26070 transactions, height 759522, 2022-10-20 22:45:27 +0900 KST)                                                                                                                                                                                                      
2023-05-22 08:40:27.794 [INF] SYNC: Processed 18 blocks in the last 10.12s (30749 transactions, height 759540, 2022-10-21 00:43:34 +0900 KST)                                                                                                                                                                                                      
2023-05-22 08:40:38.125 [INF] SYNC: Processed 16 blocks in the last 10.33s (38287 transactions, height 759556, 2022-10-21 03:46:21 +0900 KST)                                                                                                                                                                                                      
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 60                                                                                                                                                                                                               
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 70                                                                                                                                                                                                               
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 80                                                                                                                                                                                                               
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 90                                                                                                                                                                                                               
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 100                                                                                                                                                                                                              
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound): 1 transaction not found -- ban score increased to 110                                                                                                                                                                                                              
2023-05-22 08:40:44.681 [WRN] PEER: Misbehaving peer 127.0.0.1:8333 (outbound) -- banning and disconnecting                                                                                                                                                                                                                                        
2023-05-22 08:40:44.681 [INF] SYNC: Lost peer 127.0.0.1:8333 (outbound)                                                                                                                                                                                                                                                                            
2023-05-22 08:40:44.682 [WRN] SYNC: No sync peer candidates available                                                                                                                                                                                                                                                                              
2023-05-22 08:40:44.681 [INF] SRVR: Banned peer 127.0.0.1 (outbound) for 24h0m0s                                                                                                                                                                                                                                                                   
2023-05-22 08:40:49.689 [WRN] SYNC: Received done peer message for unknown peer 127.0.0.1:8333 (outbound)                                                                                                                                                                                                                                          
2023-05-22 08:40:54.694 [WRN] SYNC: Received done peer message for unknown peer 127.0.0.1:8333 (outbound)                                                                                                                                                                                                                            

I ran the binary with the following command:

btcd --datadir=. --logdir=. --connect=127.0.0.1 --norpc --cpuprofile=cpuprof-master --profile=8081 --nocfilters

The node that it connects to on 127.0.0.1 is Bitcoin Core v24.0.1

During ibd it shouldn't be asking for any txs so not sure where in the code getdata for a tx is being triggered.

Roasbeef commented 1 year ago

Is is that the bitcoind node is asking for transactions during IBD, or that we are?

cec489 commented 5 months ago

I'm getting the same errors trying to sync a utreexo compact state node. What seems to be happening (note: newbie here):

  1. I'm syncing a CSN, connecting to a single utreexo peer
  2. My node is getting a lot of tx inventories from the peer. These are unsolicited. I think the peer is sending all the mempool transaction to my node.
  3. My node does a getdata for each tx.
  4. Sometimes the tx is no longer in peer's mempool, resulting in a NotFound error. This could be due to trickle design. I've noticed that these tx's are usually in recently confirmed blocks at error time.

I tried this hack, which seems to avoid the NotFound errors, with no other side effects (again, newbie here) patch.txt