Conversation
| const FLAG_OUTPUTS_ENABLED: u8 = 0b0000_0010; | ||
| const FLAG_ZSA_ENABLED: u8 = 0b0000_0100; | ||
| const FLAGS_EXPECTED_UNSET: u8 = !(FLAG_SPENDS_ENABLED | FLAG_OUTPUTS_ENABLED | FLAG_ZSA_ENABLED); | ||
| const FLAG_SWAPS_ENABLED: u8 = 0b0000_1000; |
There was a problem hiding this comment.
is this compliant with the Swaps zip?
There was a problem hiding this comment.
Flag for swaps is not mentioned in the zip, probably should ask Vivek to add it
| use super::{ | ||
| orchard_domain::OrchardDomainCommon, | ||
| zcash_note_encryption_domain::{ | ||
| build_base_note_plaintext_bytes, Memo, COMPACT_NOTE_SIZE_VANILLA, NOTE_VERSION_BYTE_V2, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Should not move existing imports
There was a problem hiding this comment.
- Preserve Import Order
Add this to your rustfmt.toml:
reorder_imports = falseThis prevents Rust from reordering imports.
(This is needed for everything we do.)
src/note.rs
Outdated
| /// | ||
| /// [orcharddummynotes]: https://zips.z.cash/protocol/nu5.pdf#orcharddummynotes | ||
| pub(crate) fn dummy( | ||
| pub fn dummy( |
There was a problem hiding this comment.
why?
generaly we do not want to expose this.
Consider a soution where the dummy padding is happaning inside orchard (add relevent function)
There was a problem hiding this comment.
I need dummy notes and keys to build a tx in librustzcash tests
There was a problem hiding this comment.
exposing an unneeded api publicly for the sake of external tests will not fly.
Can we reproduce the conntent of dummy() inside librustzcash?
There was a problem hiding this comment.
I would need to duplicate a lot, not sure its the best way. Perhaps we play with test-dependencies and features instead, what do you think?
There was a problem hiding this comment.
Dummy methods have been copied to librustzcash
There was a problem hiding this comment.
just make sure it is inside #[Test]
src/tree.rs
Outdated
| impl MerklePath { | ||
| /// Generates a dummy Merkle path for use in dummy spent notes. | ||
| pub(crate) fn dummy(mut rng: &mut impl RngCore) -> Self { | ||
| pub fn dummy(mut rng: &mut impl RngCore) -> Self { |
src/bundle.rs
Outdated
| } | ||
|
|
||
| /// Defines the authorization type of an Orchard bundle with a proof. | ||
| pub trait AuthorizedWithProof: Authorization<SpendAuth = redpallas::Signature<SpendAuth>> { |
There was a problem hiding this comment.
why do we need a new trait?
Why not add proof() to impl ActionGroupAuthorized { ?
There was a problem hiding this comment.
In serailization normal ZSA bundle and ZSA bundle that is inside ActionGroup are almost identical, except Authorization. It's Authorized and ActionGroupAuthorized. To depuplicate serialization I need them both to implement a trait that has a proof() method
There was a problem hiding this comment.
not sure I follow.
AuthorizedWithProof adds no new information to the content. There is already a proof inside ActionGroupAuthorized. Why do we need a new generic AuthorizedWithProof again?
There was a problem hiding this comment.
Both ActionGroup and OrchardZSA budnles are Bundle<A, V, D>. They are identical, but in first case A=Authorized, in second A=ActionGroupAuthorized. During serialization we need to write a proof which is a part of both, but it is not a part of any common trait, it is just 2 unrelated fields in 2 unrelated structures. So to deduplicate the code I added this common interface that describes something that is Authorized and has proof method
This reverts commit 07b94c8.
rustfmt.toml
Outdated
| @@ -0,0 +1 @@ | |||
| reorder_imports = false No newline at end of file | |||
There was a problem hiding this comment.
new line
(consider updating ide setup to be automatic)
src/domain/orchard_domain_vanilla.rs
Outdated
| zcash_note_encryption_domain::{ | ||
| build_base_note_plaintext_bytes, Memo, COMPACT_NOTE_SIZE_VANILLA, NOTE_VERSION_BYTE_V2, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
any reason moving the imports?
This PR contains a set of additions/changes that allow ZSA Swaps to be implemented in librustzcash: - Adds Swap BundleType and Flag - Adds AuthorizedWithProof trait that defines proof() method for both Authorized and ActionGroupAuthorized - Adds utility methods e.g. from_parts() for SwapBundle, is_empty() in Builder - Changes visibility of some methods e.g. dummy() for testing in librustzcash - Removes ActionGroup structure

This PR contains a set of additions/changes that allow ZSA Swaps to be implemented in librustzcash: