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

Allow dependent tx issuance over the wallet API #1413

Merged
merged 2 commits into from
Apr 25, 2023
Merged

Conversation

StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Apr 25, 2023

Why this should be merged

The X-chain mempool post Cortina does not allow dependent transactions to be included. For example:

  • Tx A consumes UTXO A and produces UTXO B.
  • Tx B consumes UTXO B and produces UTXO C.

The mempool disallows this to avoid mempool DoSes. However, the wallet API is explicitly designed to enable issuance of dependent txs.

How this works

Honors the mempool requirement of only having no dependent txs while making the API seem like there are dependent txs in the mempool. In the example above, Tx A will be issued into the mempool. If Tx B is then issued while Tx A is still processing, Tx B will be enqueued until Tx A is accepted. After Tx A is accepted, Tx B will be issued into the mempool.

This is a fairly minimal implementation that does not attempt to parallelize independent txs.

How this was tested

Issued many concurrent txs onto Fuji

@StephenButtolph StephenButtolph self-assigned this Apr 25, 2023
@StephenButtolph StephenButtolph added the vm This involves virtual machines label Apr 25, 2023
@StephenButtolph StephenButtolph added this to the v1.10.1 milestone Apr 25, 2023
w.pendingTxs.Delete(txID)

for {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we document or just help me understand, why pop off oldest transaction only once, and exit the for-loop on success? Trying to understand how decided function relates to this operation.

Copy link
Contributor

Choose a reason for hiding this comment

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

To rephrase my question,

Allow dependent tx issuance

In what cases, dependent tx failed to be issued, so we need another tx issuance to trigger the tx issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the user is issuing virtuous txs - verification will never fail. However, I didn't want to just have the node crash (or fall into an infinite loop) in this situation... So instead I dropped the tx and logged a warning.

In all likelihood - if one tx is dropped they all will be.

Copy link
Contributor

Choose a reason for hiding this comment

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

... didn't want .. or fall into an infinite loop

Oh makes sense.

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

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

the wallet API is explicitly designed to enable issuance of dependent txs

Now makes sense. Thanks for the context.

@StephenButtolph StephenButtolph merged commit f382d84 into dev Apr 25, 2023
@StephenButtolph StephenButtolph deleted the patch-wallet-api branch April 25, 2023 16:58
joshua-kim pushed a commit to joshua-kim/avalanchego that referenced this pull request Apr 28, 2023
Co-authored-by: abenegia <alberto.benegiamo@gmail.com>
Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: Manthan Dave <manthanhd@live.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vm This involves virtual machines
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants