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

[draft] ZSA assets swap #116

Draft
wants to merge 37 commits into
base: zsa1
Choose a base branch
from
Draft

[draft] ZSA assets swap #116

wants to merge 37 commits into from

Conversation

ConstanceBeguier
Copy link

@ConstanceBeguier ConstanceBeguier commented Oct 10, 2024

This PR introduces the ability to create ActionGroup and SwapBundle for performing asset swaps.

This PR modifies the Builder:

  • A new reference_notes element has been added, which contains reference split notes. These notes can be used when creating actions.
  • A new build_action_group function allows the creation of an ActionGroup from a Builder. Like when creating a Bundle, the ActionGroup will initially be without proof and signatures. You will need to call create_proof and apply_signatures to add them.

This PR creates a new SwapBundle structure. A SwapBundle is created from a list of ActionGroups. During this creation, the following operations are performed

  • The evaluation of the value balance of the SwapBundle (by summing the value balances of each ActionGroup).
  • The evaluation of the binding signature key bsk of the SwapBundle (by summing the bsk of each ActionGroup).
  • The binding signature of the SwapBundle which is equal to the signature of the SwapBundle SIGHASH with the binding signature key bsk.

TODO

  • In this PR, burning is not allowed in an ActionGroup, but we would like to allow it and store burning into inside ActionGroup.
    • The SpecificBuilderParams struct, the BurnNotEmptyInActionGroup error, and the bundle method need to be updated accordingly.
  • A Bundle can now contain an ActionGroup. This modification must be implemented.
  • There are currently two functions for computing orchard_action_groups_digest. These should be merged into a single function for better maintainability.

@ConstanceBeguier ConstanceBeguier changed the title [WIP] ZSA assets swap ZSA assets swap Oct 18, 2024
src/builder.rs Outdated Show resolved Hide resolved
.iter()
.fold(
self.action_group
.prepare_for_action_group(&mut rng, action_group_digest),

Choose a reason for hiding this comment

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

Why do we get action_group_digest as parameter? Unlike sighash it is available via self, isn't it? This should be more fool-proof

Copy link
Author

Choose a reason for hiding this comment

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

It is exactly similar to the prepare function for Bundle.
It is inside the prepare_for_action_group function that you save the digest into self.

Choose a reason for hiding this comment

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

Yeah, yeah, I see where this design is coming from. It's just that in case of tx sighash it makes more sense because you don't have it inside the bundle

Anyway, given our conversations regarding signing sighash for action groups too unders some circumstances (e.g. when ther is only single action group inside tx) - it starts to be relevant for action group too

@ConstanceBeguier ConstanceBeguier changed the title ZSA assets swap [draft] ZSA assets swap Nov 25, 2024
@ConstanceBeguier ConstanceBeguier marked this pull request as draft November 25, 2024 09:14
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.

2 participants