ETH POA Clique

Setup

1. Create genesis.json

  1. Configure genesis

    • Run puppeth
    • Specify network name (eg. forwardchain)
    • Type 2,1,2 to create new POA genesis
    • Choose blocktime
    • Specify the address of a signer
    • Specify the address to pre-fund
    • Choose chain ID

configure

  1. Export genesis.json

    • Type 2,2 to export genesis configs
    • Specify output directory

export 3. Edit the genesis.json file to your liking

2. Initialize the Geth database with genesis.json

geth --datadir data0 init genesis.json

3. Run nodes

Running the first node

Run

geth --datadir data0 --nat extip:<NODE_EXTERNAL_IP> --networkid <network_id> --unlock <address> --mine
# eg
geth --datadir data0 --nat extip:192.168.1.107 --networkid 33044 --unlock 0xCDD14b1EC1788BBDf74b4529B9b09f236E05bA0f --mine

Getting bootstrap node record

geth --datadir account0 attach
# then run this in console
admin.nodeInfo.enr

You will get something like this

enode://ddc07b91551141016411dc93b5a86c0a3ac2c60335847b396e58e6371af87ec919323ad7822be86ca152d2a3dcdbb1d9dc05915923916883c579a2d51baf9475@192.168.1.107:30303

Run member nodes

Use --unlock <address> --mine flag when running signer node

geth --datadir data1 --networkid <network_id> --port 30305 --bootnodes <NODE_ENR> --unlock 58139b41271e0a6abc9dc4eb229509a7a304b3ca --mine

# eg
## signer
geth --datadir data1 --networkid 33044 --port 30305 --bootnodes "enode://ddc07b91551141016411dc93b5a86c0a3ac2c60335847b396e58e6371af87ec919323ad7822be86ca152d2a3dcdbb1d9dc05915923916883c579a2d51baf9475@192.168.1.107:30303" --unlock 58139b41271e0a6abc9dc4eb229509a7a304b3ca --mine

## non-signer
geth --datadir data2 --networkid 33044 --port 30306 --bootnodes "enode://ddc07b91551141016411dc93b5a86c0a3ac2c60335847b396e58e6371af87ec919323ad7822be86ca152d2a3dcdbb1d9dc05915923916883c579a2d51baf9475@192.168.1.107:30303"

Consensus - Clique

Signer algorithm

Clique command docs

Example of Clique command (run this in Geth console)

# Get current chain status and signer list
clique.getSnapshot(<block_number>)

# Get signer and list 64 block signer stats
clique.status()

# Vote to add new signer (need n/2+1 votes)
clique.propose('0x9cc4d50e252a19b2a6d1141a45ccf6ff13646ade', true)


# Vote to remove signer (need n/2+1 votes)
clique.propose('0x9cc4d50e252a19b2a6d1141a45ccf6ff13646ade', false)

References

Call eth

https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.call