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

order transactions announcements in the order they are received #1435

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

charithabandi
Copy link
Contributor

@charithabandi charithabandi commented Mar 3, 2025

This PR ensures the FIFO consistency to the outgoing transaction announcements to maintain the nonce ordering. So all the transaction announcements are routed through a TxQueue to enforce this order.

@charithabandi charithabandi linked an issue Mar 3, 2025 that may be closed by this pull request
@charithabandi charithabandi requested a review from jchappelow March 3, 2025 19:54
Copy link
Member

@jchappelow jchappelow left a comment

Choose a reason for hiding this comment

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

OK for a quick fix. In general we don't want to use a buffered channel as a queue. A channel buffer greater than 1 is meant for performance rather than a functional requirement.

Out of curiosity, we should also have a look at the heap profile (go tool pprof http://localhost:6060/debug/pprof/heap) to see just what kind of memory just make(chan orderedTxn, txQueueSize) will allocate on construction. It won't be a lot, but it might be surprisingly larger than expected.

Thoughts about what happens if the channel buffer fills? I think it'll hang CE, right? Perhaps it's better to make this a non-blocking channel send (select with a default case).

EDIT: I'm also wondering about, say, 10,000 x 100KB transactions. That's 1GB. When we get a mature solution, I bet we'll want this configurable.

node/nogossip.go Outdated
case <-ctx.Done():
return
case txn := <-n.txQueue:
n.announceRawTx(context.Background(), txn.txID, txn.rawtx, txn.from)
Copy link
Member

Choose a reason for hiding this comment

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

This should use ctx from caller I believe since it is now a system level context from Start instead of some other request context with a deadline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I probably don't need to store rawTx in this and pull it from a mempool instead

Copy link
Member

Choose a reason for hiding this comment

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

Maybe. I think this is alright as is. But if you can do that without wasteful reserialization, I guess so.

@charithabandi charithabandi force-pushed the ordertxns branch 4 times, most recently from 11b9312 to c0ed7aa Compare March 4, 2025 00:30
@jchappelow jchappelow merged commit 579b128 into kwilteam:main Mar 4, 2025
2 checks passed
@charithabandi charithabandi deleted the ordertxns branch March 4, 2025 15:27
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.

tx announcement can become out of order
2 participants