Is your feature request related to a problem? Please describe.
This issue asks for better ability to verify that the mempool walk algorithm is correct.
It is motivated originally by the fact that I ran the stacks-inspect try-mine tool on the chain state saved at (https://storage.googleapis.com/hiro-public/mainnet.tar.gz). I got a block with only 2 transactions from 44 candidates:
This led to me to wonder if there might be a bug in the candidate selection algorithm. I don't know if there is. Maybe there is or maybe this was the size of the mempool at the relevant time. I haven't had a chance to cross-reference what the mempool might have been then.
However, this request is based on the experience I had trying to figure out if the mempool walk might have a bug.
We noticed in the Friday meeting that none of us could describe this algorithm at a high level. But, this is a very central algorithm for the chain!
Describe the solution you'd like
I propose the following set of changes:
1) Separate out the creation of a mempool traversal from the processing of transactions. This way, the entire traversal can be accomplished quickly, and then analyzed.
2) Develop pseudo-code for this traversal algorithm, so that we can verify whether the implemented algorithm is correct with respect to the intended algorithm.
2) Add tests and/or other ways to verify (e.g., #3188) that the traversal is actually correct.
Additional context
Part of debugging and fixing transaction throughput.
Is your feature request related to a problem? Please describe. This issue asks for better ability to verify that the mempool walk algorithm is correct.
It is motivated originally by the fact that I ran the
stacks-inspect try-mine
tool on the chain state saved at (https://storage.googleapis.com/hiro-public/mainnet.tar.gz). I got a block with only 2 transactions from 44 candidates:This led to me to wonder if there might be a bug in the candidate selection algorithm. I don't know if there is. Maybe there is or maybe this was the size of the mempool at the relevant time. I haven't had a chance to cross-reference what the mempool might have been then.
However, this request is based on the experience I had trying to figure out if the mempool walk might have a bug.
Currently, the candidate selection algorithm is coupled with the processing of transactions. That is, they can't be separated. Processing a transaction is relatively slow (e.g., 1 transaction per second). Thus, most times there is not time to walk the entire mempool, while processing transactions along the way: https://github.com/stacks-network/stacks-blockchain/blob/08c163bab484954b3934515ee7bf60848f52ed4a/src/core/mempool.rs#L1013
Thus:
Also, from the documentation we have, it is not actually clear what the algorithm that we are running is: https://github.com/stacks-network/stacks-blockchain/blob/08c163bab484954b3934515ee7bf60848f52ed4a/src/core/mempool.rs#L892
We noticed in the Friday meeting that none of us could describe this algorithm at a high level. But, this is a very central algorithm for the chain!
Describe the solution you'd like I propose the following set of changes:
1) Separate out the creation of a mempool traversal from the processing of transactions. This way, the entire traversal can be accomplished quickly, and then analyzed. 2) Develop pseudo-code for this traversal algorithm, so that we can verify whether the implemented algorithm is correct with respect to the intended algorithm. 2) Add tests and/or other ways to verify (e.g., #3188) that the traversal is actually correct.
Additional context Part of debugging and fixing transaction throughput.