Skip to content

Add a public bundle-builder function as an alternative to the mutable builder.#404

Merged
str4d merged 4 commits intozcash:mainfrom
nuttycom:builder_functions
Dec 19, 2023
Merged

Add a public bundle-builder function as an alternative to the mutable builder.#404
str4d merged 4 commits intozcash:mainfrom
nuttycom:builder_functions

Conversation

@nuttycom
Copy link
Contributor

An alternative/extension to #403

nuttycom and others added 2 commits December 14, 2023 15:56
The term `recipient` is commonly used to refer to the address to which a
note is sent; however, a bundle may include multiple outputs to the same
recipient. This change is intended to clarify this usage.

Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
@codecov-commenter
Copy link

codecov-commenter commented Dec 18, 2023

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (003619b) 81.07% compared to head (422c5e3) 80.99%.

Files Patch % Lines
src/builder.rs 73.78% 27 Missing ⚠️
src/bundle.rs 25.00% 3 Missing ⚠️
src/tree.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
- Coverage   81.07%   80.99%   -0.08%     
==========================================
  Files          31       31              
  Lines        3112     3141      +29     
==========================================
+ Hits         2523     2544      +21     
- Misses        589      597       +8     

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

@nuttycom nuttycom requested a review from str4d December 18, 2023 19:02
@nuttycom nuttycom requested a review from str4d December 19, 2023 16:07
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed as of 2e2c161.

///
/// [orcharddummynotes]: https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes
fn dummy(rng: &mut impl RngCore) -> Self {
pub fn dummy(rng: &mut impl RngCore) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need to be public? SpendInfo::dummy is not public (so there's an API asymmetry now), and the builder is responsible for applying padding internally.

Suggested change
pub fn dummy(rng: &mut impl RngCore) -> Self {
fn dummy(rng: &mut impl RngCore) -> Self {

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 want it to be possible for callers to add dummy actions beyond the two required padding; they can already do so by manually sending zero value to a random address, so exposing this convenience method doesn't add any capability that they don't already have, and I don't see there as being a substantive maintenance burden.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed as of 422c5e3.

Comment on lines +494 to +500
let num_actions = bundle_type
.num_actions(num_requested_spends, num_requested_outputs)
.map_err(|_| BuildError::BundleTypeNotSatisfiable)?;
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 now a bit unintuitive, because it can potentially include both real spends and outputs, and dummies beyond what the bundle type's padding requires. This opens up the API to user-defined extra padding that can potentially make their transactions distinguishable from network transactions.

That being said, the way that BundleType::num_actions works means that this doesn't prevent the BundleType's padding rule from being applied, so this is a hazard that should be documented, not a bug per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The users can already add padding by just sending zeros to arbitrary addresses, so it doesn't change anything.

str4d
str4d previously approved these changes Dec 19, 2023
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK 74ba740

Co-authored-by: str4d <thestr4d@gmail.com>
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Re-utACK 938b203

@str4d str4d merged commit 78f5986 into zcash:main Dec 19, 2023
@nuttycom nuttycom deleted the builder_functions branch December 19, 2023 20:05
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.

3 participants