Skip to content

Instantly share code, notes, and snippets.

@holiman
Last active September 20, 2022 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holiman/5e021b24a7bfec95c8cc84b97e44e45a to your computer and use it in GitHub Desktop.
Save holiman/5e021b24a7bfec95c8cc84b97e44e45a to your computer and use it in GitHub Desktop.

Background

In EIP-255 , @karalabe proposes a PoA-scheme which reuses the current header-fields. The PoA-scheme has the following scheme to handle forks (caused by malicious minters or general latency):

If the number of authorized signers are N, and we allow each signer to mint 1 block out of K, then at any point in time N-K miners are allowed to mint. To avoid these racing for blocks, every signer would add a small random "offset" to the time it releases a new block. This ensures that small forks are rare, but occasionally still happen (as on the main net). If a signer is caught abusing it's authority and causing chaos, it can be voted out.

This gist outlines another scheme, by using the difficulty header.

Description

The difficulty field in a block header is unused in a PoA scheme. Traditionally, the difficulty is used to define what blocks are preferred, in the case of a fork. Two competing blocks/chains are effectively judged by difficulty, and the 'best' is chosen as the canon one. Thus, difficulty (and total difficulty) is a metric of the quality of the chain.

In a PoA-scheme, the same semantic meaning (quality of chain) can be reused on the same field.

Scheme:

  • With N minters,
  • any minter is allowed to mine a block at any height
  • A block mined by minter K at height ( h % N == K ) is considered in-turn
  • A block mined by minter K at any other height is considered out-of-turn.
  • An in-turn block must have difficulty set to 2 * X
  • An out-of-turn block must have difficulty set to X.
  • X is some constant, e.g. the genesis difficulty.

With this scheme, the 'best' chain will be the one where most minters mine in-turn, but if any minter(s) goes offline, remaining minters can continue to mine the chain.

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