Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
bcd1ca2 to
bce73a1
Compare
frankomosh
left a comment
There was a problem hiding this comment.
I guess this is a continuation of #34707. Could you share what was added or left out compared to it?
| if (it->second.send_statuses.size() < m_max_send_attempts) return AddResult::AlreadyPresent; | ||
| auto& state{it->second}; | ||
|
|
||
| if (!IsFinished(state)) { // We are still trying |
There was a problem hiding this comment.
A tx that used all its send attempts, but never came back from the network, can no longer be sent again. Now Add() can only restarts a tx that is resolved. But GetStale() skips such a tx, so nothing marks it resolved.
Are we getting rid of the 'retry' feature..?
There was a problem hiding this comment.
No, that was not intentional. Fixed. Please double check again, this has become non-trivial.
There was a problem hiding this comment.
Related, what happens when a previously-finished transaction is requested to be private-broadcast again?
Add()sees it finished, and clearsreceived_by_usandresolved- It is sent out again (to 3 peers)
- It never gets re-added to our mempool, as it already there.
MarkResolvedis not called again. - The transaction may be taken as failed
- Final state reported in RPC:
attempts_remaining0 and noreceived_by_us
Is this intended this way?
There was a problem hiding this comment.
It never gets re-added to our mempool, as it already there.
MarkResolvedis not called again.
Note that MarkResolved() is called after we receive the transaction but before we try to put it in the mempool:
bitcoin/src/net_processing.cpp
Line 4734 in df0dc1e
bitcoin/src/net_processing.cpp
Line 4770 in df0dc1e
So, it will be marked as resolved if we receive it, even if it wouldn't enter the mempool because it is already there.
But... would we receive it (a second time)? After the initial receive we would send it to all peers. So all of them know we have it. They wouldn't INV it to us anymore and even if they do we wouldn't request it (with GETDATA) because we have it in our mempool already.
So, yes, there is no reliable way to know if the second broadcast succeeded. This is the same in master right now. There may be new peers in the meantime that are unaware that we have the transaction and they will INV it to us (if it even starts propagating a second time through the network). Something to consider, separately from this PR. I do not think this PR changes the behavior.
There was a problem hiding this comment.
True, upon a re-request there new new relay will happen. Other nodes and this node will have the TX already in their mempool. As a result, "received_by_us" will never be set, and it will be not possible to decide/observe the success of the second broadcast.
My point was, that if the TX is already in our mempool, and for some strange reason it is relayed back to us after the re-request, our node will not request GETDATA (because TX is in the mempool), the handler will not be called, and the "receive" flags will remain empty.
The behavior on master is the same, except that the "received_by_us" flag is a new addition.
I can see these cases:
- Already in the mempool, and no re-relay happens (the likely case): The "received_by_us" stays empty
- Already in the mempool, but re-relay happens: The "received_by_us" stays empty --
AlreadyHaveTxis true, so no GETDATA is sent, no TX arrives, and the TX handler (MarkResolved) is never called. - Not in the mempool and re-relay happens: "received_by_us" is set.
Case 2. could be argued about, but I think it's fine. The root of the issue is that upon re-request there will be no new relay.
One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts).
There was a problem hiding this comment.
No, that was not intentional. Fixed. Please double check again, this has become non-trivial.
Looks good now.
Also noticed a good side effect: a tx that used all its attempts can now be removed when the queue is full. Before, it blocked the queue.
There was a problem hiding this comment.
One idea that we could consider though: upon a re-request don't clean the "received" flag if the TX is already in the mempool (persist that info that we have received it previously; and do perform the new sendouts)
I like this. However there would be inconsistency between the rest of the statuses and received_by_us. For example it would look that we have sent it to nobody and we have received it. I imagine we could keep all statuses: original time added, all peers we have sent to and the received by us. Then we would replace the global m_max_send_attempts (1000) with a per-transaction one and whenever a transaction is re-added, bump its max from 1000 to 2000 and increment planned_sends with INITIAL_CONNECTION_COUNT (3) instead of resetting it to 3.
This way all the history from before and from after the re-add will be visible. Maybe an overkill?
There was a problem hiding this comment.
Maybe an overkill?
I tend to agree..., one cost to keep in mind: today, each tx keeps at most 1000 send records. In #35680 (comment) I measured the worst-case getprivatebroadcastinfo output at about 1.15 GiB.
With a limit that grows on every re-add, a tx that is re-sent many times would keep growing with no cap. So if we go this way, maybe we still need a cap on the history
There was a problem hiding this comment.
Ok, then what to do with received_by_us in the case of re-add? I tend to lean towards resetting it as it is now in this PR because not resetting it would leave it inconsistent with the other fields.
There was a problem hiding this comment.
After reconsidering, I'm also for keeping the current logic. My suggestion would add further complexity, and would not solve all inconsistencies. The root cause is that a submission can be repeated, but he hearing back will likely not. Resubmission is not a regular use case, but if it's done, the user has to know that the received info will only be valid since the resubmission.
So for me it's fine like this.
bce73a1 to
0aa8193
Compare
|
PS
I am unsure. Better review this one as a fresh new unrelated one. |
|
Concept ACK |
| if (it->second.send_statuses.size() < m_max_send_attempts) return AddResult::AlreadyPresent; | ||
| auto& state{it->second}; | ||
|
|
||
| if (!IsFinished(state)) { // We are still trying |
There was a problem hiding this comment.
Related, what happens when a previously-finished transaction is requested to be private-broadcast again?
Add()sees it finished, and clearsreceived_by_usandresolved- It is sent out again (to 3 peers)
- It never gets re-added to our mempool, as it already there.
MarkResolvedis not called again. - The transaction may be taken as failed
- Final state reported in RPC:
attempts_remaining0 and noreceived_by_us
Is this intended this way?
0aa8193 to
295c961
Compare
|
|
optout21
left a comment
There was a problem hiding this comment.
Reviewed again, left some nits. I'm happy to revisit soon!
Friendly reminder one previous question of mine has not been fully addressed yet.
For finished transactions, this allows the inspection of when and to whom the transaction was sent as well as when/if it was echoed from the network. Co-authored-by: Vasil Dimov <[email protected]>
295c961 to
95cc8ad
Compare
|
Still in discussion: #36477 (comment) |

For finished transactions, this allows the inspection of when and to whom the transaction was sent as well as when/if it was echoed from the network.