Poll
A Poll contract allows voters to submit encrypted messages which can be either votes or key change 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
stateMerged
bool stateMerged
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
maxVoteOptions
uint256 maxVoteOptions
Max vote options for the poll
treeDepths
struct Params.TreeDepths treeDepths
Depths of the merkle trees
messageBatchSize
uint8 messageBatchSize
Message batch size for the poll
extContracts
struct Params.ExtContracts extContracts
The contracts used by the Poll
batchHashes
uint256[] batchHashes
The array for chain hash checkpoints
chainHash
uint256 chainHash
Current chain hash
isBatchHashesPadded
bool isBatchHashesPadded
@notice flag for batch padding
VotingPeriodOver
error VotingPeriodOver()
VotingPeriodNotOver
error VotingPeriodNotOver()
PollAlreadyInit
error PollAlreadyInit()
TooManyMessages
error TooManyMessages()
InvalidPubKey
error InvalidPubKey()
StateAlreadyMerged
error StateAlreadyMerged()
InvalidBatchLength
error InvalidBatchLength()
BatchHashesAlreadyPadded
error BatchHashesAlreadyPadded()
PublishMessage
event PublishMessage(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey)
MergeMaciState
event MergeMaciState(uint256 _stateRoot, uint256 _numSignups)
constructor
constructor(uint256 _duration, uint256 _maxVoteOptions, struct Params.TreeDepths _treeDepths, uint8 _messageBatchSize, 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 |
_maxVoteOptions | uint256 | The maximum number of vote options |
_treeDepths | struct Params.TreeDepths | The depths of the merkle trees |
_messageBatchSize | uint8 | The message batch size |
_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.
isNotPadded
modifier isNotPadded()
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
getBatchHashes
function getBatchHashes() external view returns (uint256[])
Get all message batch hashes
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256[] | betchHashes array containing all batch hashes |
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. |
updateChainHash
function updateChainHash(uint256 messageHash) internal
compute and update current message chain hash
Parameters
Name | Type | Description |
---|---|---|
messageHash | uint256 | hash of the current message |
padLastBatch
function padLastBatch() external
pad last unclosed batch
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 |
mergeMaciState
function mergeMaciState() public
The second step of merging the MACI state. This allows the ProcessMessages circuit to access the latest state tree and ballots via currentSbCommitment.
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 |