Infrastructure contracts for EnergyWeb Chain (EWC) live launch.
Primary: Adam Nagy (@ngyam)
Heiko Burkhardt (@hai-ko), Jonas Bentke (@jbentke)
- node 8
- npm
- Optional: python 3.6 environment for Slither
npm install -D
and code away. Dependencies are installed locally.
Important: all contracts go to the chainspec, deployed at the same time with their addresses known beforehans, so no deployment/migration scripts are written. The contracts are compiled and put into the chainspec by our Genesis/Chainspec generator: https://github.com/energywebfoundation/ewf-genesis-generator
Compiler version: 0.5.8 (reason)
Implements the Parity's reporting validator set interface. Relays all function calls to a worker "Relayed" contract. This pattern is chosen for upgradeability.
-
Deployment:
constructor(address _owner, address _relayedSet)
It expects the Relayed address and contract owner address in the constructor.
Implements the actual validator set logic and storage.
-
Deployment:
constructor(address _owner, address _relaySet, address[] memory _initial)
It expects the Relay address, contract owner and the initial validator addresses in the constructor.
Contains the reward logic. Rewards are issued upon new blocks. The contract implements Parity's BlockReward interface.
Rewarded entities:
- Block authors: rewarded for a total of 10 years with ~10 mil tokens based on a discrete S curve distribution. The S curve calculator can be found here.
- Community fund: A multisig wallet controlled by the community. Rewarded for a total of 10 years with ~37.9 mil tokens. A constant amount is paid out with each new block.
-
Deployment:
constructor(address _communityFundAddress, uint256 _communityFundAmount)
Expects the address of the community fund (ideally a mutltisig wallet) and the constant amount that is paid to the fund with each new block in wei.
Holds investor funds, which are available to withdraw after a certain time period has passed.
-
Deployment:
constructor()
No params needed. The initial holding records are hardcoded into the constructor.
EWF's node control system contracts. Consists of 3 contracts for upgradeability.
Serves as a lookup contract for the node control logic.
-
Deployment:
constructor(NodeControlDb _nodeControlDb, address _owner)
Constructor expects the address of the db and the owner.
Stores validator node state information.
-
Deployment:
constructor(NodeControlLookUp _lookUpContract, address _owner)
Constructor expects the address of the lookup contract and the owner.
On-chain node control logic. Can issue update commands to nodes.
-
Deployment:
constructor(NodeControlDb _nodeControlDb, address _owner)
Constructor expects the address of the db and the owner.
This contract is Parity's Registry contract. The minor modification is that the SimpleRegistry was made Ownable and the following functions are only allowed to be called by the owner:
reserve()
confirmReverseAs()
setFee()
drain()
Functionally, this contract is just a placeholer, giving possibilities for future use.
-
Deployment:
constructor(address _owner)
Constructor expects the address of the owner only.
With the locally installed truffle:
npx truffle compile
Expected warnings:
- ValidatorSetRelayed.sol:128:9:
Warning: Unused function parameter
. This function is according to Parity spec. but we are not using tthe_proof
param for anything right now. - NodeControl contracts ->
Warning: Experimental features are turned on.
Expected because ofABIEncoderV2
.
npm test
The test script starts a ganache instance and stops it afterwards.
2 linters are set up:
- Solhint:
npm run lint:solhint
- Solium
npm run lint:solium
Solidity coverage
npm run coverage
-
Slither by Trail of bits:
-
Make sure a python 3.6 env is active.
-
Install
pip install slither-analyzer
or sometimes
pip3 install slither-analyzer
-
Then run
npm run security
-
-
MythX security checker (truffle security plugin by ConsenSys):
Already installed with the other local deps. Note that for a full check you need to have a registered account (free). Pass in the account params as env vars.
MYTHX_ETH_ADDRESS=0xYOURADDRESS MYTHX_PASSWORD=yourpass npm run verify
Please read our CONTRIBUTING guide for our code of conduct and for the process of submitting pull requests to us.
We use SemVer for versioning.
This project is licensed under the GPLv3 License - see the LICENSE file for details.