Skip to content

Instantly share code, notes, and snippets.

@xeroc
Created April 7, 2016 08:09
Show Gist options
  • Save xeroc/2920cf96fef9e864c05414e5720ce1cb to your computer and use it in GitHub Desktop.
Save xeroc/2920cf96fef9e864c05414e5720ce1cb to your computer and use it in GitHub Desktop.

Introduction: Consensus Mechanisms

Core questions to answer:

  • When should a block be appended to the bockchain
  • In a P2P network, who should be allowed to do so?

Starting stuation:

  • need to organize people/players/network participants
  • over an untrusted, unrelaible network
  • with the expectation of malicous interferences during communication
  • Byzantine Generals Problem (unsolved until satoshi)

Goals

  • find consensus about anything (organization of a time, agreeing on a set of data, voting, ..)

Proof of Work

  • Goal: integer representation of hash of a block is smaller than target "difficulty".
  • Difficulty adjusted to regualte towards target block confirmation time of x minutes (BTC: 10 minutes)
  • Show BTC blocks and leading zeros
  • Hashes are one way function (irreversible operation)
  • Mining equipment / resource hungry
  • Different Hash algorithms (scrypt, sha256, sha512, groekel, combinations of multiple algos)
  • Different retargeting strategies
  • Optional: reward for finding a block
  • Drawbacks:
    • Energy hungry
    • decentralization due to pooled mining
    • Random (poisson distributed) block confirmation times
    • user consensus != miner consensus
    • participating in consensus require expensive hardware
  • Advantages
    • Easy to verify (due to high energy consumed)

Proof of Stake

  • Goal: integer representation of hash of a block is smaller than target "difficulty".
  • Every satoshi allows to derive one hash for a given time instant (time and token address included in hash calculation)
  • The more stake one has, the more hashes can be computed => higher probability to find a valid block
  • Optional: reward for finding a block
  • Drawbacks:
    • Nothing at stake
    • Stake grinding
    • Initial stake distribution(?)
    • Participation in "minting/staking" requires unlocked keys/wallet
    • Random (poisson distributed) block confirmation times
    • the rich get richer
  • Advantages:
    • Low use of resources (energy efficient) due to significantly less hashes

Combination of POW and POS

  • Randomized block selection: Nxt and BlackCoin use randomization to predict the following generator, by using a formula that looks for the lowest hash value in combination with the size of the stake.[4][5][6] Since the stakes are public, each node can predict - with reasonable accuracy - which account will next win the right to forge a block.
  • Coin age based selection Peercoin's proof-of-stake system combines randomization with the concept of "coin age," a number derived from the product of the number of coins times the number of days the coins have been held. Coins that have been unspent for at least 30 days begin competing for the next block. Older and larger sets of coins have a greater probability of signing the next block. However, once a stake of coins has been used to sign a block, they must start over with zero "coin age" and thus wait at least 30 more days before signing another block. Also, the probability of finding the next block reaches a maximum after 90 days in order to prevent very old or very large collections of stakes from dominating the blockchain.
  • Velocity based selection Reddcoin's proof-of-stake velocity (PoSV)[11] claims to encourage velocity i.e. movement of money between people, rather than hoarding.
  • Voting based selection Instead of only using the stake size, the block generators can be selected by votes. BitShares uses a system where stake is used to elect a total of 101 delegates, who are then ordered at random.[12] This has many of the advantages of shareholder voting (for example, the flexible accountability enhances the incentives of the generators to act responsibly), and yet it reintroduces the dangerous Sybil attack - as in one case where one user posed as the top five delegates.[13]

Delegated Proof of Stake

  • Blockchain voting of block producers
  • votes are weightes by stake (similar to shareholders)
  • Block producers are sorted by shareholder approval
  • Set of N producers are allowed to sign new blocks with their keys
  • Subsequent block producers are known a-priori
  • Disadvanages:
    • Requires shareholders to participate in votes (apathy)
    • initial distribution of shares(?)
  • Advantages:
    • Allows interpretation of a business with shareholders and accountants (block producers)
    • High efficient
    • allows significantly lower confirmations times
    • constant block confirmation times(!)
    • very high degree of decentralization
    • bad actors can be unapproved by shareholders
    • shareholder consensus = network consensus (sooner or later)
    • participating in consensus does not require expensive hardware, but shares in "company"

Training (2.py)

  • Implementation of basic Proof Of Work

  • Discussion about 'target' adjustment

  • Discussion about Poison statistics 99.999% after 6 confirms etc..

  • POS requires more work since Blocks get authenticated by the miner (pub/priv key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment