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

[circuits] [cli] create production-friendly tree depth combinations #100

Closed
weijiekoh opened this issue May 8, 2020 · 0 comments
Closed
Assignees

Comments

@weijiekoh
Copy link
Contributor

weijiekoh commented May 8, 2020

The larger the state and message tree depths, the more gas that a user (or relayer) has to pay to sign up or publish a message. The larger the vote option tree, state tree, and message tree depths, the longer it will take for the coordinator to generate proofs.

We can assume that the coordinator has more computational power than the average user, so it's okay to set the vote option tree to the maximum feasible size on consumer hardware (5 ^ 5 = 3125 leaves).

The message tree size should be large enough such that each user can cast 1 vote per vote option, plus an additional key-change message on top of that.

Let the depth of the state tree be s, the depth of the message tree be m, the depth of the vote option tree be v, and the number of voice credits as c.

Each user should be able to publish at least c + 1 messages, or 5 ** v + 1 messages, whichever is smaller. This is to let them either spend all their voice credits (1 credit per vote) or vote for up to all available vote options. Let this value be n.

The depth of the message tree should therefore be ceil(log2(2 ** s * n)).

E.g. Assuming that each user has 99 voice credits, the vote option tree depth is 4, and the state tree depth is 4:

n = 2 ** 4 + 1 = 17
ceil(log2(2 ** 4 * 17)) = 9

Predefined tree depths

State tree depth Message tree depth Vote option tree depth Deployment gas Signup gas Publish message gas
10 17 5 9136375 551133 1055361
4 4 2 7274945 333357 583713

Ultimately, whoever builds upon MACI has to decide exactly which tree depths works for their use case, and they have to be responsible for its specific trusted setup.

That said, if we use a Quadtree (see #101), we can support larger trees.

CC: we should just use Large because the gas savings are not that large

@weijiekoh weijiekoh created this issue from a note in Minimum Viable MACI (Backlog) May 8, 2020
@weijiekoh weijiekoh moved this from Backlog to In progress in Minimum Viable MACI May 12, 2020
@weijiekoh weijiekoh moved this from In progress to Sprint 6 in Minimum Viable MACI May 12, 2020
@weijiekoh weijiekoh self-assigned this May 12, 2020
@weijiekoh weijiekoh moved this from Sprint 6 to In progress in Minimum Viable MACI Sep 6, 2020
@weijiekoh weijiekoh moved this from In progress to Needs review in Minimum Viable MACI Sep 18, 2020
@weijiekoh weijiekoh moved this from Needs review to Done in Minimum Viable MACI Sep 18, 2020
@ctrlc03 ctrlc03 closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants