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

Add support for dependent transfers #1253

Closed
wants to merge 26 commits into from

Conversation

Br1ght0ne
Copy link
Member

@Br1ght0ne Br1ght0ne commented Jan 22, 2024

Close #1194.

Checklist

  • I have linked to any relevant issues.
  • I have updated the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary labels.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@Br1ght0ne Br1ght0ne marked this pull request as ready for review February 12, 2024 11:50
@Br1ght0ne Br1ght0ne changed the title (WIP) support for dependent transactions Add support for dependent transactions Feb 12, 2024
@Br1ght0ne Br1ght0ne changed the title Add support for dependent transactions Add support for dependent transfers Feb 12, 2024
Copy link
Contributor

@MujkicA MujkicA left a comment

Choose a reason for hiding this comment

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

It's a step in the right direction but we still need to refine it so that it helps with real issues like not being able to send multiple txs at once because our wallet owns only 1 coin.
For reference: https://github.com/FuelLabs/faucet/blob/35e7e12963b4259aa97577f3d2e0e88fea36b8b8/src/routes.rs#L206

the faucet has it's own makeshift implementation of dependant transactions to cover for this problem.

packages/fuels-accounts/src/coin_cache.rs Outdated Show resolved Hide resolved
let remaining_amount = available_amount - used_base_amount - transaction_fee.max_fee();

if remaining_amount == 0 {
return Err(error!(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a low level problem that we reveal to a high level API call.
The user is not explicitly aware that inputs are being chopped up to make this work under the hood.
If I used dependent_transfers and this error were to come up, It's not obvious how to fix it.

Also, I doubt there is a way to fix it. If the selected coin(s) fit so perfectly that they can't be split up I either have more coins to cover for the next tx or I don't, it's not a matter dependant transfers.

Maybe we should attempt to execute dependant txs on a best effort basis but not be explicit about it.

.await?;
}

let tx_status = provider.send_transaction_and_await_commit(tx).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we wait for each tx to be finalized there is no need to keep track of the output of previous tx. We can just ask the node to provide spendable coins at that point.

@Br1ght0ne Br1ght0ne closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide support for user-friendly creation of dependent transactions
3 participants