Skip to content

Commit

Permalink
Merge pull request #254 from SurfingNerd/i204-README
Browse files Browse the repository at this point in the history
I204 readme
  • Loading branch information
SurfingNerd authored Oct 22, 2024
2 parents 62cfc4b + f01ffc1 commit f3a9f96
Show file tree
Hide file tree
Showing 3 changed files with 1,705 additions and 8 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# HBBFT - POSDAO Smart Contracts

Implementation of the HBBFT-POSDAO consensus algorithm in [Solidity](https://solidity.readthedocs.io).
Implementation of the HBBFT-POSDAO consensus algorithm in [Solidity](https://solidity.readthedocs.io),
suited for the needs of the DMD Diamond Blockchain https://github.com/DMDcoin/whitepaper/wiki

## About

POSDAO is a Proof-of-Stake (POS) algorithm implemented as a decentralized autonomous organization (DAO). It is designed to provide a decentralized, fair, and energy efficient consensus for public chains. The algorithm works as a set of smart contracts written in Solidity. POSDAO can be implemented with any general purpose BFT consensus protocol. In the current version Honeybadger BFT (HBBFT) is chosen, which is leaderless and with instant finality. It incentivizes actors to behave in the best interests of a network.
POSDAO is a Proof-of-Stake (POS) algorithm implemented as a decentralized autonomous organization (DAO). It is designed to provide a decentralized, fair, and energy efficient consensus for public chains. The algorithm works as a set of smart contracts written in Solidity. It is designed to work together with a Honeybadger BFT (HBBFT) consensus algoritm, which is leaderless and with instant finality. It incentivizes actors to behave in the best interests of a network.

The algorithm provides a Sybil control mechanism for reporting malicious validators and adjusting their stake, distributing a block reward, and managing a set of validators.

## POSDAO Repositories and Resources

- White paper https://forum.poa.network/t/posdao-white-paper/2208
- Backported Open Ethereum client with all POSDAO features https://github.com/poanetwork/open-ethereum/tree/posdao-backport
- Original Open Ethereum client supporting POSDAO features https://github.com/OpenEthereum/open-ethereum starting from v2.7.2 (except [posdaoTransition spec option](https://github.com/OpenEthereum/open-ethereum/pull/11245) which waits to be released in the next version)
- White paper https://github.com/DMDcoin/whitepaper/wiki

## Smart Contract Summaries

Expand All @@ -28,8 +27,6 @@ Check also the [BlockRewardHbbft call graph](/docs/BlockRewardHbbft-call-graph.p
- KeyGenHistory.writeAck
- KeyGenHistory.writePart

- `InitializerHbbft`: used once on network startup and then destroyed. This contract is needed for initializing upgradable contracts since an upgradable contract can't have the constructor. The bytecode of this contract is written by the `scripts/make_spec_hbbft.js` into `spec.json` along with other contracts when initializing on genesis block.

- `RandomHbbft`: stores random numbers written by the HBBFT engine. Random numbers are used to form a new validator set at the beginning of each staking epoch by the `ValidatorSet` contract. There are two key functions:
- `setCurrentSeed`. This is a setter that can only be called by the HBBFT engine in order to set the newly generated random number that is gonna be used for the new validator set selection.
- `currentSeed`. This public getter is used by the `ValidatorSetHbbft` contract at a predefined block of each staking epoch to get the accumulated random seed for randomly choosing new validators among active pools. It can also be used by anyone who wants to use the network's random seed.
Expand All @@ -49,6 +46,14 @@ Check also the [StakingHbbft call graph](/docs/StakingHbbft-call-graph.png).
- `ValidatorSetHbbft`: stores the current validator set and contains the logic for choosing new validators at the beginning of each staking epoch. The logic uses a random seed stored in the `RandomHbbft` contract. Also, ValidatorSetHbbft is responsible for discovering and removing malicious validators. This contract is based on `reporting ValidatorSet` [described in Parity Wiki](https://wiki.parity.io/Validator-Set.html#reporting-contract).
Check also the [ValidatorSetHbbft call graph](/docs/ValidatorSetHbbft-call-graph.png).

- `BonusScoreSystem`: Handles the Bonus Scores that validators collect during their supportive phases.

- `ConnectivityTrackerHbbft`: Tracks the notifications of individual nodes in order to handle Early Epoch Ends if the network has to many nodes that became disconnected.

- `KeyGenHistory`: Manages the treshhold encryption shared key generation, required for epoch switches in order to pass the leadership to a new set of validators.

- `ValueGuards`: Manages valid ranges for changes of Ecosystem Parameter changes.

## Usage

### Install Dependencies
Expand Down
22 changes: 21 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const mnemonic: string = process.env.MNEMONIC ? process.env.MNEMONIC : ethers.Mn

const chainIds = {
hardhat: 31337,
alpha2: 777012
alpha2: 777012,
alpha4: 777018,
};

const config: HardhatUserConfig = {
Expand Down Expand Up @@ -71,6 +72,14 @@ const config: HardhatUserConfig = {
browserURL: "http://185.187.170.209:4000/",
},
},
{
network: "alpha4",
chainId: 777018,
urls: {
apiURL: "http://62.171.133.46:4400/api",
browserURL: "http://62.171.133.46:4400",
},
},
],
},
contractSizer: {
Expand Down Expand Up @@ -146,6 +155,17 @@ const config: HardhatUserConfig = {
},
gasPrice: 1000000000,
},
alpha4: {
url: "http://62.171.133.46:54100",
accounts: {
mnemonic: getMnemonic(),
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
passphrase: "",
},
gasPrice: 1000000000,
},
},
paths: {
artifacts: "./artifacts",
Expand Down
Loading

0 comments on commit f3a9f96

Please sign in to comment.