Repository: paritytech/parity-bitcoin (language: rust)

Issue:
Regtests are broken
https://gitlab.parity.io/parity/parity-bitcoin/-/jobs/133185


Discussion / hints:

Fix patch:
diff --git a/miner/src/memory_pool.rs b/miner/src/memory_pool.rs
index e58d25c03..7ff1e7549 100644
--- a/miner/src/memory_pool.rs
+++ b/miner/src/memory_pool.rs
@@ -45,6 +45,8 @@ pub struct Information {
 pub struct MemoryPool {
 	/// Transactions storage
 	storage: Storage,
+	/// Do we accept zero fee transactions?
+	accept_zero_fee_transactions: bool,
 }
 
 /// Single entry
@@ -637,16 +639,22 @@ impl HeapSizeOf for OrderedReferenceStorage {
 
 impl Default for MemoryPool {
 	fn default() -> Self {
-		MemoryPool {
-			storage: Storage::new(),
-		}
+		MemoryPool::new()
 	}
 }
 
 impl MemoryPool {
 	/// Creates new memory pool
 	pub fn new() -> Self {
-		MemoryPool::default()
+		MemoryPool {
+			storage: Storage::new(),
+			accept_zero_fee_transactions: false,
+		}
+	}
+
+	/// Accept zero fee transactions.
+	pub fn accept_zero_fee_transactions(&mut self) {
+		self.accept_zero_fee_transactions = true;
 	}
 
 	/// Insert verified transaction to the `MemoryPool`
@@ -757,7 +765,7 @@ impl MemoryPool {
 		let miner_fee = fc.calculate(self, &t.raw);
 
 		// do not accept any transactions that have negative OR zero fee
-		if miner_fee == 0 {
+		if !self.accept_zero_fee_transactions && miner_fee == 0 {
 			return None;
 		}
 		
diff --git a/sync/src/lib.rs b/sync/src/lib.rs
index 76dc3f5dd..26923991b 100644
--- a/sync/src/lib.rs
+++ b/sync/src/lib.rs
@@ -106,8 +106,13 @@ pub fn create_local_sync_node(consensus: ConsensusParams, db: storage::SharedSto
 		// during regtests, peer is providing us with bad blocks => we shouldn't close connection because of this
 		close_connection_on_bad_block: network != Network::Regtest,
 	};
+	let mut memory_pool = MemoryPool::new();
+	if network == Network::Regtest {
+		// during regtests, peer is providing us with zero fee transactions => we shouldn't ignore these
+		memory_pool.accept_zero_fee_transactions();
+	}
 
-	let memory_pool = Arc::new(RwLock::new(MemoryPool::new()));
+	let memory_pool = Arc::new(RwLock::new(memory_pool));
 	let sync_state = SynchronizationStateRef::new(SynchronizationState::with_storage(db.clone()));
 	let sync_chain = SyncChain::new(db.clone(), consensus.clone(), memory_pool.clone());
 	if sync_chain.is_segwit_possible() {


Test patch: