stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

`listunspent` issues

Open obycode opened this issue 1 year ago • 1 comments

There are two problems with the miners calls to listunspent: https://github.com/stacks-network/stacks-core/blob/b5250c60877fa3380b450a7b7e7e9d3e87da6112/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs#L2619-L2630

We added the maximumCount option to ensure that the response is not too large, because the HTTP library can only handle messages up to 16MB.

Problem 1

If we hit this limit, the bitcoind will return UTXOs oldest first. A miner's block commit needs to use the output of the previous block commit, so this will be a very recent UTXO, so it may be pruned from the results. This is a problem.

Problem 2

It seems that this option will not actually make it return maximumCount UTXOs. In a test in the nakamoto-3 network, if I call listunspent without this limit, it returns 2513 UTXOs, but then when I call it with the maximumCount set to 1024, it returns 365 UTXOs.

obycode avatar Sep 23 '24 00:09 obycode

To avoid problem 1, @kantai's suggestion:

Yeah, realistically, the miner should always spend its last commit’s UTXO And add another input if necessary

We can make this change with low priority.

obycode avatar Sep 23 '24 15:09 obycode