Poll
A Poll contract allows voters to submit encrypted messages which can be either votes, key change messages or topup messages.
Do not deploy this directly. Use PollFactory.deploy() which performs some checks on the Poll constructor arguments.
isInit
bool isInit
Whether the Poll has been initialized
coordinatorPubKey
struct DomainObjs.PubKey coordinatorPubKey
The coordinator's public key
coordinatorPubKeyHash
uint256 coordinatorPubKeyHash
Hash of the coordinator's public key
mergedStateRoot
uint256 mergedStateRoot
the state root of the state merkle tree
deployTime
uint256 deployTime
duration
uint256 duration
stateAqMerged
bool stateAqMerged
Whether the MACI contract's stateAq has been merged by this contract
currentSbCommitment
uint256 currentSbCommitment
Get the commitment to the state leaves and the ballots. This is hash3(stateRoot, ballotRoot, salt). Its initial value should be hash(maciStateRootSnapshot, emptyBallotRoot, 0) Each successful invocation of processMessages() should use a different salt to update this value, so that an external observer cannot tell in the case that none of the messages are valid.
numMessages
uint256 numMessages
The number of messages that have been published
numSignups
uint256 numSignups
The number of signups that have been processed before the Poll ended (stateAq merged)
actualStateTreeDepth
uint8 actualStateTreeDepth
The actual depth of the state tree to be used as public input for the circuit
maxValues
struct Params.MaxValues maxValues
Max values for the poll
treeDepths
struct Params.TreeDepths treeDepths
Depths of the merkle trees
extContracts
struct Params.ExtContracts extContracts
The contracts used by the Poll
VotingPeriodOver
error VotingPeriodOver()
VotingPeriodNotOver
error VotingPeriodNotOver()
PollAlreadyInit
error PollAlreadyInit()
TooManyMessages
error TooManyMessages()
InvalidPubKey
error InvalidPubKey()
StateAqAlreadyMerged
error StateAqAlreadyMerged()
StateAqSubtreesNeedMerge
error StateAqSubtreesNeedMerge()
InvalidBatchLength
error InvalidBatchLength()
PublishMessage
event PublishMessage(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey)
TopupMessage
event TopupMessage(struct DomainObjs.Message _message)
MergeMaciStateAqSubRoots
event MergeMaciStateAqSubRoots(uint256 _numSrQueueOps)
MergeMaciStateAq
event MergeMaciStateAq(uint256 _stateRoot, uint256 _numSignups)
MergeMessageAqSubRoots
event MergeMessageAqSubRoots(uint256 _numSrQueueOps)
MergeMessageAq
event MergeMessageAq(uint256 _messageRoot)
constructor
constructor(uint256 _duration, struct Params.MaxValues _maxValues, struct Params.TreeDepths _treeDepths, struct DomainObjs.PubKey _coordinatorPubKey, struct Params.ExtContracts _extContracts) public payable
Each MACI instance can have multiple Polls. When a Poll is deployed, its voting period starts immediately.
Parameters
Name | Type | Description |
---|---|---|
_duration | uint256 | The duration of the voting period, in seconds |
_maxValues | struct Params.MaxValues | The maximum number of messages and vote options |
_treeDepths | struct Params.TreeDepths | The depths of the merkle trees |
_coordinatorPubKey | struct DomainObjs.PubKey | The coordinator's public key |
_extContracts | struct Params.ExtContracts | The external contracts |
isAfterVotingDeadline
modifier isAfterVotingDeadline()
A modifier that causes the function to revert if the voting period is not over.
isWithinVotingDeadline
modifier isWithinVotingDeadline()
A modifier that causes the function to revert if the voting period is over
init
function init() public
The initialization function.
Should be called immediately after Poll creation and messageAq ownership transferred
topup
function topup(uint256 stateIndex, uint256 amount) public virtual
Allows to publish a Topup message
Parameters
Name | Type | Description |
---|---|---|
stateIndex | uint256 | The index of user in the state queue |
amount | uint256 | The amount of credits to topup |
publishMessage
function publishMessage(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey) public virtual
Allows anyone to publish a message (an encrypted command and signature). This function also enqueues the message.
Parameters
Name | Type | Description |
---|---|---|
_message | struct DomainObjs.Message | The message to publish |
_encPubKey | struct DomainObjs.PubKey | An epheremal public key which can be combined with the coordinator's private key to generate an ECDH shared key with which to encrypt the message. |
publishMessageBatch
function publishMessageBatch(struct DomainObjs.Message[] _messages, struct DomainObjs.PubKey[] _encPubKeys) external
submit a message batch
Can only be submitted before the voting deadline
Parameters
Name | Type | Description |
---|---|---|
_messages | struct DomainObjs.Message[] | the messages |
_encPubKeys | struct DomainObjs.PubKey[] | the encrypted public keys |
mergeMaciStateAq
function mergeMaciStateAq(uint256 _pollId) public
The second step of merging the MACI state AccQueue. This allows the ProcessMessages circuit to access the latest state tree and ballots via currentSbCommitment.
Parameters
Name | Type | Description |
---|---|---|
_pollId | uint256 | The ID of the active Poll |
mergeMessageAqSubRoots
function mergeMessageAqSubRoots(uint256 _numSrQueueOps) public
The first step in merging the message AccQueue so that the ProcessMessages circuit can access the message root.
Parameters
Name | Type | Description |
---|---|---|
_numSrQueueOps | uint256 | The number of subroot queue operations to perform |
mergeMessageAq
function mergeMessageAq() public
The second step in merging the message AccQueue so that the ProcessMessages circuit can access the message root.
getDeployTimeAndDuration
function getDeployTimeAndDuration() public view returns (uint256 pollDeployTime, uint256 pollDuration)
Returns the Poll's deploy time and duration
Return Values
Name | Type | Description |
---|---|---|
pollDeployTime | uint256 | |
pollDuration | uint256 |
numSignUpsAndMessages
function numSignUpsAndMessages() public view returns (uint256 numSUps, uint256 numMsgs)
The number of messages which have been processed and the number of signups
Return Values
Name | Type | Description |
---|---|---|
numSUps | uint256 | |
numMsgs | uint256 | The number of messages sent by voters |