• Stars
    star
    169
  • Rank 217,387 (Top 5 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Partial Lock Commit Reveal Voting System that utilizes ERC20 Tokens

Partial-Lock Commit-Reveal Voting

Codeship Status for ConsenSys/PLCRVoting

Detailed walkthrough

Mainnet factory: 0xdf9c10e2e9bb8968b908261d38860b1a038cc2ef

Rinkeby factory: 0x5edd7268c6a0d2f171789d8385e95cdbb16ab735

EPM: plcr-revival

Summary

PLCR voting is an efficient system for token-weighted voting on the Ethereum blockchain

PLCR voting enables a user to participate in multiple polls simultaneously with their tokens while preventing double-voting of tokens within polls

PLCR voting allows users to withdraw (at any time) the maximum number of tokens which are not actively used in voting

PLCR voting (in it's current implementation) does not stake tokens -- voting in the losing party of a poll does not result in a loss of one's tokens


Core terminology / variables

voting rights: tokens controlled by the voting contract; either active or available to be used in PLCR voting

commit-reveal: voting takes place in 2 separate chronologic time periods. this prevents the voting process itself from influencing vote results

  • commit stage: time period where a user can submit a secret token-weighted vote, locking those tokens. committed votes are concealed using a salted hash of (1) the user's vote option and (2) a random number
  • reveal stage: time period where a user can unlock their secret vote, confirming the vote's token-weight and option

locked tokens: during a poll's commit stage, committed tokens are "locked" (not-withdrawable) until the user either (1) reveals their vote or (2) rescues their tokens (more on this later)

partial-lock: although committed tokens are locked, you are able to and are highly encouraged to use those same "locked" tokens to commit votes in multiple polls at the same time

majority bloc: the group of voters who voted with a greater aggregate number of tokens

minority bloc: the group of voters who voted with a lesser aggregate number of tokens

  • note: the total number of locked tokens is equivalent to the greatest number of tokens that a user committed (in any poll) which have not been unlocked

voteTokenBalance: mapping of user addresses: voting rights

voteOption: voter's choice for (binary) dispute resolution. in token-curated registries, references the candidate (applicant)

  • votesFor: represents tokens voted in support for the candidate
  • votesAgainst: represents tokens voted in opposition to the candidate

Core steps / general flow / pseudocode

  1. acquire voting contract's intrinsic token

  2. plcr.startPoll(details): create a new poll and emit details about the poll to the network

    • note: if using a token-curated registry, startPoll is a message sent via tcr.challenge(listing)
  3. token.approve(voting): approve the voting contract, setting an allowance and enabling ERC20 transactions with the voting contract

  4. plcr.requestVotingRights(tokens): transfer tokens from the user to the voting contract, increasing the user's voteTokenBalance (voting rights). in order to be able to lock and unlock tokens during periods, the voting contract must have control over voting tokens

    • note: PLCRVoting v1.1 inlines requestVotingRights(tokens - votingRights) the commitVote function
  5. plcr.commitVote(poll, secret, tokens): submit a secret token-weighted vote to a poll. the vote choice is hidden and submitted as a secret

  6. plcr.revealVote(poll, keys): reveal the hidden contents of a committed vote. this confirms the secret commit's validity and increases the number of total votes toward the user's vote option

  7. tcr.updateStatus(poll): ping the contract that initiated the poll. tally the votesFor and votesAgainst, resolve the challenge, and transfer tokens accordingly

    • if the applicant won, challenger is auto-transferred the challenge reward
    • if the applicant won, the challenge reward is added to the Listing's deposit stake, available to be withdrawn using tcr.withdraw()
    • voter reward is made available to be claimed
    • NOTICE: challenge reward is different from voter reward. challenge reward goes to either: the applicant or the challenger, and is equal to the special dispensation percentage * staked deposit of the opponent (min deposit). voter reward goes to the majority bloc of voters who voted for a poll
  8. tcr.claimReward(poll, key): claim reward tokens for voting with the winning side (the majority bloc of voters for that poll's ruling). increasing the user's voteTokenBalance (voting rights)

  9. plcr.withdrawVotingRights(tokens): transfer tokens from the voting contract to the user, decreasing the user's voteTokenBalance (voting rights)


Tools, tips, strategies, idiosyncrasies

Forget to reveal and locked your tokens?

  • if you do not reveal a committed vote within the reveal stage (perhaps by forgetting to send the transaction or by losing the vote's salt key), you can still rescue and unlock those tokens by invoking plcr.rescueTokens(). those tokens will not count toward the poll's outcome, as the reveal stage must have ended by this point to proceed. they are unlocked and made available to be withdrawn if/when you desire to do so

Saving money & time

  • PLCRVoting v1.1 supports multi-commit and multi-reveal. if you have more than 1 poll you wish to commit/reveal for, you can collect the values of the multiple votes and send the consolidated data in a single transaction

  • since v1.1 requests voting rights within the commitVote function, you can save an additional tx by NOT calling requestVotingRights, and solely invoking commitVote with the maximum number of tokens you are willing to actively use (i.e. lock) for voting. TLDR: don't bother with requestVotingRights, just call commitVote

Things to be aware of

  • during the commit stage: although users' vote options are hidden (using a random salt), the number of tokens with which the user voted in the poll is emitted with the transaction and available to other users

  • a user can only have 1 valid commit per poll. a re-committed vote will effectively delete the former commit

  • voting in polls does not risk losing voting rights. if you vote in the minority bloc of a poll, you do not lose any tokens. yes, PLCR voting (in it's current implementation) does not stake tokens!

Goals

Tactical goal: increase the number of tokens one owns

  • vote in every poll, vote with the majority

Strategic goal: increase the value of those tokens one owns

  • vote judiciously to make the system more valuable

More Repositories

1

smart-contract-best-practices

A guide to smart contract security best practices
HTML
7,296
star
2

ethereum-developer-tools-list

A guide to available tools and platforms for developing on Ethereum.
5,172
star
3

quorum

A permissioned implementation of Ethereum supporting data privacy
Go
4,581
star
4

mythril

Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
Python
3,683
star
5

Tokens

Ethereum Token Contracts
JavaScript
2,020
star
6

eth-lightwallet

Lightweight JS Wallet for Node and the browser
JavaScript
1,418
star
7

gnark

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license
Go
1,265
star
8

surya

A set of utilities for exploring Solidity contracts
JavaScript
1,027
star
9

ethql

A GraphQL interface to Ethereum πŸ”₯
TypeScript
623
star
10

abi-decoder

Nodejs and Javascript library for decoding data params and events from ethereum transactions
JavaScript
605
star
11

vscode-solidity-auditor

Solidity language support and visual security auditor for Visual Studio Code
JavaScript
560
star
12

teku

Java Implementation of the Ethereum 2.0 Beacon Chain
Java
557
star
13

cakeshop

An integrated development environment and SDK for Ethereum-like ledgers
JavaScript
510
star
14

Token-Factory

Basic Token Factory dapp.
JavaScript
477
star
15

gnark-crypto

gnark-crypto provides elliptic curve and pairing-based cryptography on BN, BLS12, BLS24 and BW6 curves. It also provides various algorithms (algebra, crypto) of particular interest to zero knowledge proof systems.
Go
452
star
16

constellation

Peer-to-peer encrypted message exchange
Haskell
379
star
17

UniversalToken

Implementation of Universal Token for Assets and Payments
JavaScript
337
star
18

quorum-examples

Examples for Quorum
Shell
316
star
19

scribble

Scribble instrumentation tool
TypeScript
310
star
20

anonymous-zether

A private payment system for Ethereum-based blockchains, with no trusted setup.
Solidity
283
star
21

defi-score

DeFi Score: An open framework for evaluating DeFi protocols
Python
279
star
22

EthOn

EthOn - The Ethereum Ontology
HTML
245
star
23

Mahuta

IPFS Storage service with search capability
Java
230
star
24

doc.zk-evm

Linea documentation
JavaScript
224
star
25

solidity-metrics

Solidity Code Metrics
JavaScript
207
star
26

tessera

Tessera - Enterprise Implementation of Quorum's transaction manager
Java
169
star
27

ethjsonrpc

Python JSON-RPC client for the Ethereum blockchain
Python
156
star
28

zero-knowledge-proofs

Zero Knowledge Proofs and how they can be implemented in Quorum
C++
128
star
29

python-solidity-parser

An experimental Solidity parser for Python built on top of a robust ANTLR4 grammar πŸ“š
Python
125
star
30

truffle-security

MythX smart contract security verification plugin for Truffle Framework
JavaScript
124
star
31

web3signer

Web3Signer is an open-source signing service capable of signing on multiple platforms (Ethereum1 and 2, Filecoin) using private keys stored in an external vault, or encrypted on a disk.
Java
122
star
32

btcrelay-fetchd

Just the fetchd script of btcrelay
Python
116
star
33

evm-dafny

An EVM interpreter in Dafny
Dafny
113
star
34

ethereum-dissectors

πŸ”Wireshark dissectors for Ethereum devp2p protocols
C
109
star
35

quorum-dev-quickstart

The Quorum Developer Quickstart utility can be used to rapidly generate local Quorum blockchain networks for development and demo purposes using Besu, GoQuorum, and Codefi Orchestrate.
Solidity
108
star
36

ethsigner

A transaction signing application to be used with a web3 provider.
Java
107
star
37

daedaluzz

Benchmark Generator for Smart-Contract Fuzzers
Solidity
106
star
38

solc-typed-ast

A TypeScript package providing a normalized typed Solidity AST along with the utilities necessary to generate the AST (from Solc) and traverse/manipulate it.
TypeScript
105
star
39

truffle-webpack-demo

A demo Webpack + React App using truffle-solidity-loader
JavaScript
95
star
40

orion

Orion is a PegaSys component for doing private transactions
Java
92
star
41

blockchainSecurityDB

JavaScript
88
star
42

quorum-kubernetes

Helm charts for Hyperledger Besu and GoQuorum
Mustache
85
star
43

gpact

General Purpose Atomic Crosschain Transaction Protocol
Java
84
star
44

quorum-docs

Documentation assets for Quorum
84
star
45

linea-attestation-registry

Verax is a shared registry for storing attestations of public interest on EVM chains, designed to enhance data discoverability and consumption for dApps across the network.
TypeScript
82
star
46

mythx-cli

A command line interface for the MythX smart contract security analysis API
Python
81
star
47

bytecode-verifier

Compile Solidity source code and verify its bytecode matches the blockchain
JavaScript
80
star
48

goff

goff (go finite field) is a unix-like tool that generates fast field arithmetic in Go.
Go
76
star
49

zsl-q

ZSL on Quorum
C++
71
star
50

security-workshop-for-devs

Secure smart contract development workshop hosted by ConsenSys Diligence and MythX.
70
star
51

Legions

Ethereum/EVM Node Security Toolkit
Python
69
star
52

eth2.0-dafny

Eth2.0 spec in Dafny
Dafny
67
star
53

starknet-snap

The MetaMask Snap for Starknet
TypeScript
65
star
54

quorum-docker-Nnodes

Run a bunch of Quorum nodes, each in a separate Docker container.
Shell
65
star
55

Project-Alchemy

Ethereum-Zcash Integration effort
63
star
56

handel

Multi-Signature Aggregation in a Large Byzantine Committees
Go
52
star
57

qubernetes

Quorum on Kubernetes.
Go
52
star
58

Uniswap-audit-report-2018-12

50
star
59

quorum-tools

Tools for running Quorum clusters and integration tests
Haskell
50
star
60

doc.teku

ConsenSys Ethereum 2.0 client
CSS
47
star
61

vscode-solidity-metrics

Generate Solidity Source Code Metrics, Complexity and Risk profile reports for your project.
JavaScript
46
star
62

private-networks-deployment-scripts

This repository contains out-of-the-box deployment scripts for private PoA networks
Shell
45
star
63

awesome-quorum

A curated list of awesome softwares, libraries, tools, articles, educational resources, discussion channels and more to build on ConsenSys Quorum.
45
star
64

wittgenstein

Simulator for some PoS or consensus algorithms. Includes dfinity, casper IMD and others
Java
45
star
65

vscode-ethover

Ethereum Account Address Hover Info and Actions
JavaScript
42
star
66

permissioning-smart-contracts

Smart contracts for the Besu permissioning system
TypeScript
41
star
67

besu-sample-networks

Hyperledger Besu Ethereum client quick-start makes you able to simply test all Besu features.
40
star
68

0x-review

Security review of 0x smart contracts
HTML
39
star
69

mythx-playground

Exercises to go along with smart contract security workshops by MythX and ConsenSys Diligence
Solidity
39
star
70

linea-tutorials

An EVM-equivalent zk-rollup for scaling Ethereum dapps
Shell
38
star
71

kubernetes-action

GitHub Action to run kubectl
Dockerfile
38
star
72

evm-analyzer-benchmark-suite

A benchmark suite for evaluating the precision of EVM code analysis tools.
HTML
38
star
73

quorum-key-manager

A universal Key & Account Management solution for blockchain applications.
Go
37
star
74

quorum-cloud

Deploy Quorum network in a cloud provider of choice
HCL
36
star
75

quorum.js

Quorum.js is an extension to web3.js providing support for JP Morgan's Quorum API
JavaScript
36
star
76

web3js-eea

EEA JavaScript libraries.
JavaScript
35
star
77

truffle-solidity-loader

A Webpack loader that will parse and provision Solidity files to Javascript using Truffle for compilation
JavaScript
35
star
78

rimble-app-demo

React Ethereum dApp demonstrating onboarding and transaction UX
JavaScript
35
star
79

secureum-diligence-bootcamp

Solidity
34
star
80

linea-contracts

Linea smart-contracts
Solidity
33
star
81

pythx

A Python library for the MythX smart contract security analysis platform
Python
33
star
82

react-metamask

JavaScript
32
star
83

infura-sdk

Infura NFT SDK
TypeScript
32
star
84

diligence-fuzzing

Python
32
star
85

quorum-aws

Tools for deploying Quorum clusters to AWS
HCL
32
star
86

web3studio-soy

Static Websites on the Distributed Web
JavaScript
31
star
87

boilerplate-react

React app boilerplate by ConsenSys France
JavaScript
29
star
88

hellhound

HellHound is a decentralized blind computation platform.
Go
29
star
89

aragraph

Visualize your Aragon DAO Templates
JavaScript
29
star
90

quorum-wizard

Quorum Wizard is a command line tool that allow users to set up a development Quorum network on their local machine in less than 2 minutes.
JavaScript
28
star
91

doc.goquorum

Documentation site for GoQuorum, the ConsenSys Enterprise Ethereum client
CSS
27
star
92

mythxjs

TypeScript
26
star
93

linea-token-list

Linea Token List
TypeScript
25
star
94

web3js-quorum

JavaScript
24
star
95

0x_audit_report_2018-07-23

0x Protocol v2 Audit
HTML
24
star
96

hackathon-2021-dapp-workshop

JavaScript
24
star
97

so101_canon

Resources on self-management/organization
24
star
98

quorum-explorer

A light-weight front-end explorer for Besu and GoQuorum to visualise private networks and deploy smart contracts
TypeScript
24
star
99

sidechains-samples

Sample code for Atomic Crosschain Transactions
Java
22
star
100

deposit-sc-dafny

Deposit smart contract in Dafny
Dafny
20
star