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

use uint16 for treeArity in PollFactory.deploy #313

Conversation

exfinen
Copy link
Contributor

@exfinen exfinen commented Nov 28, 2021

In maci/contracts/contracts/Poll.sol,

since the type of treeArity is uint8,

        uint8 treeArity = 5;   // line 63

in

        require(   // line 73
            _maxValues.maxMessages <= treeArity ** _treeDepths.messageTreeDepth &&
            ...

treeArity ** _treeDepths.messageTreeDepth seems to overflow when _treeDepths.messageTreeDepth is greater than 3, i.e. 5^3 = 125 but 5^4 = 625 which is greater than 256, and that makes the require statement fail.

The type of treeArity should be a type that can store larger values without overflow.

@weijiekoh
Copy link
Contributor

Thanks @exfinen! I pushed a new commit that uses uint256 for treeArity and casts messageTreeDepth and voteOptionTreeDepth to uin256 instead.

@weijiekoh weijiekoh merged commit 0976d66 into privacy-scaling-explorations:v1 Dec 1, 2021
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