-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase reorg cache timer limit #3489
Comments
I don't understand what you mean here by "add the mempool in the reorg cache". Can you clarify? |
Sorry if this was unclear. I meant to add each transaction from the mempool in the reorg cache as they become confirmed on the blockchain. We will "age them out" after x minutes (x : timer limit). And in case of large reorg with empty block, nodes will rebroadcast them automatically if the cached txs were not contained in the reorg. |
We actually add txs to the reorg cache at the same time as we add them to the mempool. A fork (or competing forks) will cause the mempool to be reconciled (every tx in the mempool is valid w.r.t current chain state). But txs remain in the reorg cache, independent of current chain state. This is by design, invalid txs may become valid, precisely so we can handle reorg like this.
We should check the current impl. I'm not entirely confident this happens today. Edit: Just checked and it does look like we simply add txs back to the mempool directly when reconciling the reorg cache. And this does not cause the node to (re)broadcast these txs to peers. This is probably a gap in our logic. For every tx in the reorg cache that is successfully added back to the mempool during reconciliation should also be (re)broadcast out to our peers. We should treat these txs as "new" in this scenario. |
A 24 hour period had been suggested in keybase for the reorg cache retention period (currently 30 minutes). In a reorg scenario we would also need to then iterate over this full 24 period of txs as part of the reorg cache reconciliation process. Each tx needs to be reprocessed, attempting to add it back to the mempool. |
I'm not sure we should set it to 24 hours by default. While it may seem fine now, it is likely because we have mostly empty blocks. A normal full block is 1.4MB so we have 1440 blocks per day which is Edit: actually, I think I was wrong above and it would be GBs of data of network traffic in any case Note: We need to be careful of full blocks case or when the reorg has more txs than fit in a block - full blocks is the simplest to think about. There's another parameter https://github.com/mimblewimble/grin/blob/master/pool/src/transaction_pool.rs#L106 which regulates the size of the tx pool. If we receive 2 GBs of txs, can we even fit them in our mempool? These two parameters seem related |
Then we should just increase it to 4-5 hours by default. Some Grin users will drastically increase the timer themselves. And nodes will (re)broadcast the transaction automatically once there's a fix for the txs when reorg cache is reconciled with the mempool . I believe also, as @phyro mentioned, we should also increase the default mempool size, which is set currently to 50 000 txs (~59 full blocks) to prevent especially reorg on stale full blocks in the future. |
One thing to consider here is who should be responsible for rebroadcasting txs. Common situation: A tx is relayed across majority of the network before being included in a block. On reorg, this tx is present in majority of reorg caches and will be replayed into majority of mempools (no rebroadcast required). This starts to change if we introduce a rebroadcast step - now the "reorg_cache" is being used to repopulate other pools. And in fact we now have a slightly undesirable situation where every node is now trying to repopulate every pool with everybody rebroadcasting every cached tx. This is likely to result in a lot of redundant network traffic. Tx participants may want to be responsible for any rebroadcast. If I sent funds a few hours ago, maybe my wallet or my node is able to monitor for reorg and proactively rebroadcast my tx to ensure it up back in the wider mempool. |
Right, then I believe we should make the broadcast of transactions issued from reorg cache configurable, and set by default to false. So just nodes that would like to maintain a massive reorg will broadcast transactions again. There should be only few people that might want to enable it (particularly those who drastically increased their reorg cache period). So the situation would come back to few node is now trying to repopulate pool peers. Edit : As you said everyone is responsible for their local pool and consequently we should just allow miners to increase reorg cache period in the config file if they want it. |
If we want to still investigate, I propose 2 strategies to re-broadcast transactions after a reorg, for both of them we'll have the option set to false by default in order to minimize network traffic, and have the following rules :
1st strategy :
2nd strategy :
|
@deevope this one can be closed now, correct? |
We should increase for every node the reorg_cache timer limit which is set by default to 30 minutes if it affects the mempool, so in case of future large reorg, nodes will rebroadcast automatically all unconfirmed transactions which were confirmed in the stale blocks.
If it only affects our local txs pool, we should consider to add the mempool in the reorg cache for the reason mentioned above.
The text was updated successfully, but these errors were encountered: