dpow_haveutxo: fix bug if only one "iguana" UTXO#186
Merged
ca333 merged 1 commit intoKomodoPlatform:devfrom Aug 24, 2020
Merged
dpow_haveutxo: fix bug if only one "iguana" UTXO#186ca333 merged 1 commit intoKomodoPlatform:devfrom
ca333 merged 1 commit intoKomodoPlatform:devfrom
Conversation
I had a bug on the main Notary Node (NN) but it didn't happen on the 3P NN on KMD. If there is only one "iguana" UTXO and no other UTXO (*), no notarization happens and the following error happens: ```no (%s -> %s) utxo: need to fund address.(%s) or wait for splitfund to confirm\n``` (*) Such case can be encountered if the node is running out of assetchain balance and there is only one "iguana" UTXO left. it can also happens if playing with distant coin split and/or advanced use of wallet filters. In such a case, the loop inside dpow_haveutxo will have ``n = cJSON_GetArraySize(unspents) = 1`` because listunspent returns only one UTXO. As ``j`` variable is initialized at 0 before the loop and incremented at the beginning of the loop, j = 1 at the first iteration of the loop so j = n and the loop will exit. By moving the j incrementation at the end of the loop, it will execute the code within the loop if there is only one UTXO. To test/analyse: - add more logs and analyze iguana TV on main NN and 3P NN. To test: - Test with different coinsplit scripts, - Test with distant coinsplit (e.g. with https://github.com/DeckerSU/komodo_scripts/blob/master/split_nn_sapling.sh) with/without wallet filters - Test on main NN and 3P NN in different situations (no coin left, only one big utxo not splitted, same tests without sapling (OOT)). Changelog for NN operators: The number of the chosen UTXO will be decreased by 1, meaning the UTXO "numbering" in the log will start at UTXO 0 instead of starting from UTXO 1: [%s] : chosen = %d out of %d loop.(%d)\n
DeckerSU
approved these changes
Aug 21, 2020
Contributor
DeckerSU
left a comment
There was a problem hiding this comment.
LGTM. This commit really should fix "only one" utxo issue, despite the fact that this issue is kind of rarely met edge case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This code change is not consensus change, it is a utxo selection improvement.
It was tested prior to the Bible rules existence.
I hope that enhancing iguana during S4 is not forbidden, can you clarify about how to test code improvements/changes without breaking Bible rules?
This code change was discussed on discord with blackjok3r who said that it will fix one problem of this loop but the utxo selection loop needs a complete rewrite.
I had a bug on the main Notary Node (NN) but it didn't happen on the 3P NN on KMD.
If there is only one "iguana" UTXO and no other UTXO (*), no notarization happens and the following error happens:
no (%s -> %s) utxo: need to fund address.(%s) or wait for splitfund to confirm\n(*) Such case can be encountered if the node is running out of assetchain balance and there is only one "iguana" UTXO left. it can also happens if playing with distant coin split and/or advanced use of wallet filters.
In such a case, the loop inside dpow_haveutxo will have
n = cJSON_GetArraySize(unspents) = 1because listunspent returns only one UTXO. Asjvariable is initialized at 0 before the loop and incremented at the beginning of the loop, j = 1 at the first iteration of the loop so j = n and the loop will exit. By moving the j incrementation at the end of the loop, it will execute the code within the loop if there is only one UTXO.To test/analyse:
To test:
Changelog for NN operators:
The number of the chosen UTXO will be decreased by 1, meaning the UTXO "numbering" in the log will start at UTXO 0 instead of starting from UTXO 1:
[%s] : chosen = %d out of %d loop.(%d)\n