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

Refactor backend #144

Closed
enricobottazzi opened this issue Aug 29, 2023 · 2 comments · Fixed by #152
Closed

Refactor backend #144

enricobottazzi opened this issue Aug 29, 2023 · 2 comments · Fixed by #152
Assignees

Comments

@enricobottazzi
Copy link
Member

enricobottazzi commented Aug 29, 2023

As described in the blogpost, the AddressOwnership part and the Round part should be two separate (and asynchronous) steps.

pub struct Snapshot<const LEVELS: usize, const N_ASSETS: usize, const N_BYTES: usize> {
mst: MerkleSumTree<N_ASSETS, N_BYTES>,
proof_of_address_ownership: AddressOwnershipProof,
trusted_setup: [SetupArtifcats; 2], // the first trusted setup relates to MstInclusionCircuit, the second related to SolvencyCircuit
}

In particular, proof_of_address_ownership should be independent from a Snapshot.

EDIT: As I was reviewing #141 I noticed that Snapshot and SummaSigner are completely independent and do not talk to each other. Snapshot APIs was originally planned to be the entry point for a user of the backend, but actually, they cannot do much with that as they cannot interact with the contract!

Following the description and the naming in the blogpost, I think we should have two high-level classes: AddressOwnership and Round.

AddressOwnership should be used to submit proof of solvency to the Smart Contract

Round should be used to:

  • Build a Snapshot (which is only composed by a Merkle Sum Tree and Assets)
  • Submit proof of solvency to the Smart Contract
  • Generate proof of inclusion to the user.

The goal should be to allow the user (exchange) of our library to fully complete the flow described in the blogpost

@enricobottazzi enricobottazzi added this to the Blog Post Release milestone Aug 29, 2023
@sifnoc
Copy link
Member

sifnoc commented Aug 30, 2023

EDIT: As I was reviewing #141 I noticed that Snapshot and SummaSigner are completely independent and do not talk to each other. Snapshot APIs was originally planned to be the entry point for a user of the backend, but actually, they cannot do much with that as they cannot interact with the contract!

Yes, you are correct. The Snapshot API that follows the original plan largely mirrors the CLI app from the PoC - summa-playground.
Most of the functions in the CLI app can be used for the Snapshot API. Therefore, we can reshape those functions for the Snapshot API while renaming the current Snapshot to SnapshotData.

Following the description and the naming in the blogpost, I think we should have two high-level classes: AddressOwnership and Round.

Separating AddressOwnership makes sense to me, especially the optimistic approach that eliminates the need for verifying solvency based on addresses in the contract.

The term Round reminds me of its usage in the early design - Design Core components for API - Round.
However, I believe you're referring to something different: a single Snapshot instance existing within the Round like one below:

struct Round {
	snapshot: Snapshot,
	signer: SummaSigner,
}

struct Snapshot {
	mst: MerkleSumTree,
    trusted_setup: [SetupArtifcats; 2],
}

generic consts are ignored in above.

@enricobottazzi
Copy link
Member Author

enricobottazzi commented Aug 30, 2023

struct Round {
	snapshot: Snapshot,
	signer: SummaSigner,
}

struct Snapshot {
	mst: MerkleSumTree,
    trusted_setup: [SetupArtifcats; 2],
}

I like this. We can go ahead. Also, all the core methods run by the CEX should be on Round namely:

  • build_snapshot
  • submit_proof_of_solvency
  • generate_proof_of_inclusion

AddressOwnership struct should also leverage the SummaSigner and expose the API submit_proof_of_address_ownership

@enricobottazzi enricobottazzi moved this to Backlog in ∑ Summa Aug 31, 2023
@enricobottazzi enricobottazzi removed this from the Blog Post Release milestone Aug 31, 2023
@sifnoc sifnoc moved this from Backlog to In Progress in ∑ Summa Sep 4, 2023
@enricobottazzi enricobottazzi moved this from In Progress to Under Review in ∑ Summa Sep 8, 2023
@enricobottazzi enricobottazzi linked a pull request Sep 12, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from Under Review to Merged in ∑ Summa Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging a pull request may close this issue.

2 participants