tx pool: fix backoff delay logic when re-relaying txs #8326
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.
It appears there is a logic error when calling
get_relay_delay()
. As a result, txs get stuck in the daemon if the daemon happens to fail the first submission, and don't re-relay as expected.Examples of submission failures: #6938, #6929, #8251
The following sample numbers should hopefully help make it clear what the issue was, and how this PR implements a backoff delay as expected. Took me a bit to wrap my head around it -- it looks simple but it's deceptively tricky.
Before this PR
now - last_relayed_time
now - received_time
get_relay_delay
Notice how
now - last_relayed_time
is always <=get_relay_delay
. This causes txs to get stuck right here, preventing them from being re-relayed (edit: until theMAX_RELAY_TIME
of 4 hours).This PR
now - last_relayed_time
last_relayed_time - received_time
get_relay_delay
Re-relays occur in the bolded rows, since
now - last_relayed_time > get_relay_delay
.