stratum-mining / stratum

stratum
https://stratumprotocol.org
Other
221 stars 127 forks source link

Custom transactions from JDC removed from mempool during update #840

Open lorbax opened 7 months ago

lorbax commented 7 months ago

The declared transaction in declared mining job are stored as a whole in the JDS mempool. The transactions in in declared jobs are recognized because they have this form (like txid: Txid <-- Some(Transaction) in the hashmap). In JDsMemppol::update_mempool() we create a new hashmap mempool_ordered. Inside the task spawned, the node's mempool is stored in in the variable mempool: Vec<Txid>. For every entry txid of this vector, if there was a transaction in the mutex mempool of the form txid: Txid <-- Some(Transaction), then the whole transaction is stored in mempool_ordered. The other transactions in mempool are stored in mempool_ordered as txid: Txid <-- None. Then JDS mempool is updated with mempool_ordered https://github.com/stratum-mining/stratum/pull/833 As a consequence of that, if the downstream declares a transaction which is unknown to the node, then it gets lost during the update of the JDS mempool. If the mempool is updated frequently this may prevent to the block propagation for the JDS, which is not good.

If this is fixed, we must also remove the transactions of old declared jobs, otherwise the there is (very remote) risk of overflow.

Fix this issue after merging of PR833.

NonsoAmadi10 commented 7 months ago

Alright @lorbax i will take this issue up. Let me make the requested changes on #833