Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mempool v1 records which peer it has sent the tx #1089

Merged
merged 1 commit into from Sep 22, 2023

Conversation

cmwaters
Copy link
Contributor

This PR records that we have sent the peer the transaction to avoid doing it a second time

Copy link
Contributor

@rootulp rootulp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

[question] do we want to do something similar for the CAT pool around here?

Comment on lines +272 to +275
} else {
// record that we have sent the peer the transaction
// to avoid doing it a second time
memTx.SetPeer(peerID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol what a simple change! makes sense to me.

the old mechanism seems so weird! Like, why even both setting the peer if they send you a transaction that you already have if they are setting the peer for original sender? Is the sole purpose to attempt to keep txs in the mempool for longer? are there other tradeoffs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original idea was to stop the transaction from being sent back to the peer who originally sent it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that part makes sense, but this one specifically

// Check for the transaction in the cache.
if !txmp.cache.Push(tx) {
// If the cached transaction is also in the pool, record its sender.
if elt, ok := txmp.txByKey[txKey]; ok {
txmp.metrics.AlreadySeenTxs.Add(1)
w := elt.Value.(*WrappedTx)
w.SetPeer(txInfo.SenderID)

why do this at all?

@cmwaters
Copy link
Contributor Author

[question] do we want to do something similar for the CAT pool around here?

We do do it. See

memR.mempool.PeerHasTx(peerID, txKey)

@cmwaters cmwaters merged commit 43db8d0 into main Sep 22, 2023
15 checks passed
@cmwaters cmwaters deleted the cal/record-sent-txs branch September 22, 2023 07:38
cmwaters added a commit that referenced this pull request Sep 25, 2023
This PR records that we have sent the peer the transaction to avoid
doing it a second time
cmwaters added a commit that referenced this pull request Sep 25, 2023
This PR records that we have sent the peer the transaction to avoid
doing it a second time
@faddat faddat mentioned this pull request Feb 22, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants