File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to the versioning scheme outlined in the [ README.md] ( README.md ) .
77
8+ ## [ 3.1.0.0.11]
9+
10+ - Hotfix for p2p stack misbehavior in mempool syncing conditions
11+
812## [ 3.1.0.0.10]
913
1014### Added
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ pub struct StacksMemPoolStream {
9797 pub corked : bool ,
9898 /// Did we run out of transactions to send?
9999 pub finished : bool ,
100+ num_bytes : u64 ,
100101 /// link to the mempool DB
101102 mempool_db : DBConn ,
102103}
@@ -118,6 +119,7 @@ impl StacksMemPoolStream {
118119 tx_query,
119120 last_randomized_txid,
120121 num_txs : 0 ,
122+ num_bytes : 0 ,
121123 max_txs,
122124 coinbase_height,
123125 corked : false ,
@@ -178,6 +180,14 @@ impl HttpChunkGenerator for StacksMemPoolStream {
178180 if !next_txs. is_empty ( ) {
179181 // have another tx to send
180182 let chunk = next_txs[ 0 ] . serialize_to_vec ( ) ;
183+ if u64:: try_from ( chunk. len ( ) )
184+ . unwrap ( )
185+ . saturating_add ( self . num_bytes )
186+ >= u64:: from ( MAX_MESSAGE_LEN ) / 2
187+ {
188+ self . corked = true ;
189+ return Ok ( self . last_randomized_txid . serialize_to_vec ( ) ) ;
190+ }
181191 if let Some ( next_last_randomized_txid) = next_last_randomized_txid_opt {
182192 // we have more after this
183193 self . last_randomized_txid = next_last_randomized_txid;
@@ -187,6 +197,9 @@ impl HttpChunkGenerator for StacksMemPoolStream {
187197 self . finished = true ;
188198 }
189199 self . num_txs += next_txs. len ( ) as u64 ;
200+ self . num_bytes = self
201+ . num_bytes
202+ . saturating_add ( u64:: try_from ( chunk. len ( ) ) . unwrap ( ) ) ;
190203 return Ok ( chunk) ;
191204 } else if let Some ( next_txid) = next_last_randomized_txid_opt {
192205 // no more txs to send
Original file line number Diff line number Diff line change @@ -937,7 +937,12 @@ impl<P: ProtocolFamily> ConnectionInbox<P> {
937937 ) ;
938938 self . inbox . push_back ( message) ;
939939 consumed_message = true ;
940- } ;
940+ } else {
941+ if bytes_consumed == 0 {
942+ warn ! ( "0 bytes consumed, but no message parsed" ) ;
943+ return Err ( net_error:: ConnectionBroken ) ;
944+ }
945+ }
941946
942947 bytes_consumed
943948 } else {
Original file line number Diff line number Diff line change 11# Update these values when a new release is created.
22# `stacks-common/build.rs` will automatically update `versions.rs` with these values.
3- stacks_node_version = " 3.1.0.0.10 "
4- stacks_signer_version = " 3.1.0.0.10 .0"
3+ stacks_node_version = " 3.1.0.0.11 "
4+ stacks_signer_version = " 3.1.0.0.11 .0"
You can’t perform that action at this time.
0 commit comments