5

If one calls the API function getTransactionsToApprove() one expects to receive 2 tips. To this end it calls the randomWalk() method two times. However I noticed that the randomWalk() routine contains some stop-conditions (like !checkSolidity or belowMaxDepth) where it terminates the random walk and returns the latest visited tail (which is not necessary a tip).

So if I am not mistaken the API call can end up with 1 or 2 tx which could be non-tips. To me this seems not desirable, since as a new tx you want exclusively to approve tips. I might be wrong here but can someone confirm/explain this?

For convenience I show here the code-flow:

enter image description here

3

First of all, the property of a transaction being a tip is volatile and can change before the walk even finishes. So even if the function was guaranteed to find a tip, by the time it returned it could already be a non-tip (as somebody else approved it). Also keep in mind that the property of a transaction being a tip is not the same in the whole network, a tip on your node may already be approved multiple times on another node.

That being said, the conditions that you found are there to prevent choosing a transaction that it could not verify - for example a non-solid one, which is a transaction where its second approved transaction is not yet present on your node, or a transaction that approves two conflicting transactions. In those cases it is better to stop before that transaction and approve this other transaction, which technically is no longer a tip but better to choose that non-tip than throwing away all the random walk so far.

Another point to keep in mind: Users/Nodes on the IOTA network may be hostile and deliberately introduce transactions that approve double spends or approve non-existing transactions. Usually the best way to take care of these users is ignoring that they are there, i. e. stop the walks before their invalid transactions and approve the previous transactions even if they are no longer tips.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.