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

Vectorize transfers #3356

Merged
merged 9 commits into from
Jul 5, 2024
Merged

Vectorize transfers #3356

merged 9 commits into from
Jul 5, 2024

Conversation

grarco
Copy link
Contributor

@grarco grarco commented Jun 3, 2024

Describe your changes

Closes #2596.
Required modification to enable #2597.

Modifies transparent and masp transactions to allow for multi-party transfers. Transparent transfers allow for multiple sources, targets token and amounts.

Shielding and unshielding masp transfers are instead vectorized in a slightly different way: shieldings are vectorized in a fan-in fashion: multiple sources, amounts and tokens but the target is a single PaymentAddress. Unshieldings are fan-out: multiple targets, tokens and amount but the source is a single SpendingKey.

Ibc shielded actions remain unchanged as I believe we can't vectorize them because of the way packets are designed.

This PR does NOT update the client to support vectorized transfers as at the moment it's unclear to me how to achieve that maintaining a decent UX: for now we only support these transactions via the SDK.

Indicate on which release or other PRs this topic is based on

v0.39.0

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 718 lines in your changes missing coverage. Please review.

Project coverage is 53.78%. Comparing base (879a326) to head (1e98403).

Files Patch % Lines
crates/sdk/src/masp.rs 0.00% 217 Missing ⚠️
crates/sdk/src/tx.rs 0.00% 189 Missing ⚠️
crates/sdk/src/signing.rs 0.00% 134 Missing ⚠️
crates/apps_lib/src/cli.rs 0.00% 64 Missing ⚠️
crates/light_sdk/src/transaction/transfer.rs 0.00% 30 Missing ⚠️
crates/token/src/lib.rs 0.00% 26 Missing ⚠️
crates/node/src/bench_utils.rs 0.00% 24 Missing ⚠️
crates/sdk/src/lib.rs 0.00% 18 Missing ⚠️
crates/apps_lib/src/client/tx.rs 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3356      +/-   ##
==========================================
- Coverage   53.92%   53.78%   -0.15%     
==========================================
  Files         317      317              
  Lines      107575   107837     +262     
==========================================
- Hits        58011    58001      -10     
- Misses      49564    49836     +272     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

grarco added a commit that referenced this pull request Jun 4, 2024
@grarco grarco marked this pull request as ready for review June 4, 2024 09:42
@cwgoes cwgoes mentioned this pull request Jun 4, 2024
@grarco grarco mentioned this pull request Jun 5, 2024
2 tasks
break;
} else {
sign(namada, &mut tx, &args.tx, signing_data).await?;
let cmt_hash = tx.first_commitments().unwrap().get_hash();
Copy link
Member

Choose a reason for hiding this comment

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

I guess this relates to your comment above that vectorization is not really supported in the cli atm.

Copy link
Contributor Author

@grarco grarco Jun 6, 2024

Choose a reason for hiding this comment

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

Actually this has to do with transaction batching

))
}

/// Build a shielded transfer transaction from the given parameters
pub fn shielded(
Copy link
Member

Choose a reason for hiding this comment

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

how out of data is our c bindings example?

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 fear very much 😢

@brentstone brentstone mentioned this pull request Jun 6, 2024
Copy link
Member

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

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

Did I miss or are the new wasms added to the whitelist?

}
// Load the current shielded context given the spending key we
// possess
let mut shielded = context.shielded_mut().await;
Copy link
Member

Choose a reason for hiding this comment

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

I think we only need to do this once. So we can move it outside of the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually want to load the context only if the source is a spending key, which we can know only from within the loop. But I've added a boolean in 937a972 to avoid loading the context more than once

crates/sdk/src/signing.rs Outdated Show resolved Hide resolved
crates/sdk/src/signing.rs Outdated Show resolved Hide resolved
@grarco grarco force-pushed the grarco/vectorize-transfers branch from 937a972 to 1e98403 Compare June 6, 2024 09:34
brentstone added a commit that referenced this pull request Jun 7, 2024
* grarco/vectorize-transfers:
  Changelog #3356
  Fmt
  Avoids reloading shielded context
  Misc improvements to signing for vectorized transfers
  Check no vectorized transfers in cli
  Fixes signature generation for vectorized transfers
  Fixes benchmarks
  Vectorizes masp transfers
  Vectorizes transparent transfers
brentstone added a commit that referenced this pull request Jun 7, 2024
* grarco/vectorize-transfers:
  Changelog #3356
  Fmt
  Avoids reloading shielded context
  Misc improvements to signing for vectorized transfers
  Check no vectorized transfers in cli
  Fixes signature generation for vectorized transfers
  Fixes benchmarks
  Vectorizes masp transfers
  Vectorizes transparent transfers
@grarco grarco mentioned this pull request Jun 13, 2024
2 tasks
@murisi
Copy link
Contributor

murisi commented Jun 26, 2024

@grarco Not sure if this is strictly necessary, but do any of the wasms in this PR allow a transfer with transparent inputs, transparent outputs, and shielded (inputs or outputs) all there simultaneously?

@grarco
Copy link
Contributor Author

grarco commented Jun 26, 2024

@grarco Not sure if this is strictly necessary, but do any of the wasms in this PR allow a transfer with transparent inputs, transparent outputs, and shielded (inputs or outputs) all there simultaneously?

Not really, it's more focused on vectorizing the 4 different types of transfers: so shielded transfers are already vectorized since they can contain multiple spend/output notes. Transparent transfers have been updated to support multiple sources/targets/tokens. Shielding has been updated to support multiple transparent sources and unshielding has been updated to support multiple transparent outputs, but there's no way yet to mix them in a single transaction.

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.

Allow multiple transfers in a single tx
6 participants