Skip to content

kaiax/builder: set timeout for bundle tx #309

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

Merged
merged 49 commits into from
Apr 11, 2025

Conversation

ulbqb
Copy link
Contributor

@ulbqb ulbqb commented Apr 3, 2025

Proposed changes

This PR solves the dangling transaction problem.

Problem

Nodes have kept to hold potentially failed bundle transactions in the pending because they don't have any way to know if they succeed or fail and nodes haven't remove any transactions without results. Usually, nodes can know tx result through propagated created blocks but the results of the transactions in failed bundle aren't in any blocks.

Solution

  • PendingTimeout - All nodes remove the builder module transactions from the pending in certain period. Timeout is 10s.
  • KnownTxTimeout - All nodes reject the builder module transactions for certain period after they are received. Timeout is 30s.

How it works

The below image shows how a tx is propagated and is removed from pending if tx is failed bundle tx against before and after this pr.

[as-is]

time\pending EN0 EN1 PN0 PN1 CN0 CN1 desc
0s tx EN0 receives bundle tx.
0.5s tx tx tx tx tx tx tx is propagated.
1s tx tx tx tx tx CN0 is proposer and tx fail.
1.5s tx tx tx tx tx tx tx is propagated.
2s tx tx tx tx tx CN1 is proposer and tx fail.
... tx tx tx tx tx loop

[to-be]

time\pending EN0 EN1 PN0 PN1 C01 CN1 desc
0s tx EN0 receives bundle tx.
0.5s tx tx tx tx tx tx tx is propagated.
1s tx tx tx tx tx CN0 is proposer and tx fail.
1.5s tx tx tx tx tx tx is propagated but rejected by knownTxTimeout.
2s tx tx tx tx CN1 is proposer and tx fail.
7s tx tx tx tx tx is propagated but rejected by knownTxTimeout.
10s tx is marked with unexecutable by pendingTimeout and will be removed.
20s tx is rejected by knownTxTime even if tx is left in network.
40s tx nodes can get to receive the same bundle tx after knownTxTimeout.

(PS I had AI create most of the test. That's awesome😎)

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have read the CLA and signed by comment I have read the CLA Document and I hereby sign the CLA in first time contribute
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@ulbqb ulbqb marked this pull request as draft April 3, 2025 09:36
@ulbqb ulbqb force-pushed the fix/mitigate_dangling branch from ce10da6 to af8c4dd Compare April 3, 2025 09:54
@ulbqb ulbqb self-assigned this Apr 3, 2025
@ulbqb ulbqb marked this pull request as ready for review April 4, 2025 07:11
@ulbqb ulbqb requested review from shiki-tak and Mdaiki0730 April 4, 2025 07:11
Copy link
Contributor

@hyeonLewis hyeonLewis left a comment

Choose a reason for hiding this comment

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

Just a quick thought: The EN and PN don't include module tx in txpool but only broadcast them. So after broadcasting tx, no EN and PN has module tx, but only CN will have it. (CN only broadcasts tx to CNs)

It'll have side effects by not storing tx in txpool (Tx might be missing before reaching to CNs)

@ulbqb ulbqb requested review from yoomee1313 and hyeonLewis April 11, 2025 01:16
@Mdaiki0730
Copy link
Contributor

Mdaiki0730 commented Apr 11, 2025

If one tx is a module tx, is there a need to have a builder module?
https://github.com/kaiachain/kaia/pull/309/files#diff-1372f977fe5a5f233ec6a55693c89acccaac3244936d3896a51b1dba6ace8757R33

I misunderstood, please don't care.

@ulbqb
Copy link
Contributor Author

ulbqb commented Apr 11, 2025

I changed pending timeout (30s to 10s) and known tx timeout (60s to 30s) for optimization.

@ulbqb ulbqb merged commit 833964c into kaiachain:feat/gasless Apr 11, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants