{"id":24247332,"url":"https://github.com/poanetwork/poa-network-consensus-contracts","last_synced_at":"2025-09-23T12:32:15.717Z","repository":{"id":42362677,"uuid":"112296895","full_name":"poanetwork/poa-network-consensus-contracts","owner":"poanetwork","description":"Main repository for POADAO consensus. Includes contracts for Initial Ceremony, Governance, Management of Validators","archived":false,"fork":false,"pushed_at":"2022-12-29T05:33:08.000Z","size":3598,"stargazers_count":67,"open_issues_count":28,"forks_count":64,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-09T21:51:26.902Z","etag":null,"topics":["consensus","governance","solidity"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poanetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audit/ChainSecurity/ChainSecurity_PoA.pdf","citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-28T06:42:33.000Z","updated_at":"2024-03-21T11:02:04.000Z","dependencies_parsed_at":"2023-01-31T08:00:29.289Z","dependency_job_id":null,"html_url":"https://github.com/poanetwork/poa-network-consensus-contracts","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poanetwork%2Fpoa-network-consensus-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poanetwork%2Fpoa-network-consensus-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poanetwork%2Fpoa-network-consensus-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poanetwork%2Fpoa-network-consensus-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poanetwork","download_url":"https://codeload.github.com/poanetwork/poa-network-consensus-contracts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233975968,"owners_count":18760032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consensus","governance","solidity"],"created_at":"2025-01-14T23:32:49.458Z","updated_at":"2025-09-23T12:32:10.252Z","avatar_url":"https://github.com/poanetwork.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# poa-network-consensus-contracts\n\n[![Build Status](https://travis-ci.org/poanetwork/poa-network-consensus-contracts.svg?branch=master)](https://travis-ci.org/poanetwork/poa-network-consensus-contracts)\n\n## Security Audit\n- [PoA Consensus Audit](https://github.com/poanetwork/poa-network-consensus-contracts/blob/master/audit/MixBytes/PoA%20Consensus%20Audit.pdf) by MixBytes\n- [PoA Consensus Audit](https://github.com/poanetwork/poa-network-consensus-contracts/blob/master/audit/ChainSecurity/ChainSecurity_PoA.pdf) by ChainSecurity\n\n## Start POA network\n\n- Install npm dependencies `npm i`\n- Generate flat sources of contracts with the script `./make_flat.sh`\n- We need a bytecode of `PoaNetworkConsensus` contract to add it to [`spec.json`](https://github.com/poanetwork/poa-chain-spec/blob/core/spec.json) of the network. \u003cbr /\u003e\nGo to `scripts` directory and run `poa-bytecode.js`: \u003cbr /\u003e\n```bash\n$ cd scripts\n$ npm i\n$ MASTER_OF_CEREMONY=0x0039F22efB07A647557C7C5d17854CFD6D489eF3 node poa-bytecode.js\n```\nIt will show the bytecode of `PoaNetworkConsensus` contract. Copy the bytecode and paste it into `spec.json`.\n\n## Add Contracts to Parity UI.\n\nStart Parity UI. In the contracts section press `Develop` button. \nSelect `0.4.24` Solidity compiler version. Set `Optimize` to `true`.\n\n- In Parity UI `Contracts` tab choose watch custom contract. Paste bytecode and ABI of `PoaNetworkConsensus` contract from Remix.\n\nCompile and deploy contracts in the next sequence:\n\n- `ProxyStorage_flat.sol` - Deploy `ProxyStorage` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - equal to zero,\n`_implementationAddress` - address of ProxyStorage contract.\n-  Make a call to `ProxyStorage init` with `_poaConsensus` parameter equal to the address of PoaNetworkConsensus contract, using the address of `EternalStorageProxy` and ABI of `ProxyStorage`.\n-  Select `PoaNetworkConsensus` contract and call `setProxyStorage` with the address of ProxyStorage contract.\n- `KeysManager_flat.sol` - Deploy `KeysManager` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of KeysManager contract.\n-  Make a call to `KeysManager init` with `_previousKeysManager` parameter equal to 0x0000000000000000000000000000000000000000, using the address of `EternalStorageProxy` and ABI of `KeysManager`.\n- `BallotsStorage_flat.sol` - Deploy `BallotsStorage` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of BallotsStorage contract.\n-  Make a call to `BallotsStorage init` with `_thresholds` parameter equal to [3, 2], using the address of `EternalStorageProxy` and ABI of `BallotsStorage`.\n- `VotingToChangeKeys_flat.sol` - Deploy `VotingToChangeKeys` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of VotingToChangeKeys contract.\n-  Make a call to `VotingToChangeKeys init` with `_minBallotDuration` parameter equal to `172800`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeKeys`.\n-  Make a call to `VotingToChangeKeys migrateDisable`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeKeys`.\n- `VotingToChangeMinThreshold_flat.sol` - Deploy `VotingToChangeMinThreshold` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of VotingToChangeMinThreshold contract.\n-  Make a call to `VotingToChangeMinThreshold init` with `_minBallotDuration` parameter equal to `172800` and `_minPossibleThreshold` parameter equal to `3`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeMinThreshold`.\n-  Make a call to `VotingToChangeMinThreshold migrateDisable`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeMinThreshold`.\n- `VotingToChangeProxyAddress_flat.sol` - Deploy `VotingToChangeProxyAddress` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of VotingToChangeProxyAddress contract.\n-  Make a call to `VotingToChangeProxyAddress init` with `_minBallotDuration` parameter equal to `172800`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeProxyAddress`.\n-  Make a call to `VotingToChangeProxyAddress migrateDisable`, using the address of `EternalStorageProxy` and ABI of `VotingToChangeProxyAddress`.\n- `ValidatorMetadata_flat.sol` - Deploy `ValidatorMetadata` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of ValidatorMetadata contract.\n- `VotingToManageEmissionFunds_flat.sol` - Deploy `VotingToManageEmissionFunds` contract.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of VotingToManageEmissionFunds contract.\n- `EmissionFunds_flat.sol` - Deploy `EmissionFunds` contract with constructor parameter `_votingToManageEmissionFunds` equal to `EternalStorageProxy` address of `VotingToManageEmissionFunds` contract.\n- `RewardByBlock_flat.sol` - Deploy `RewardByBlock` contract and replace `emissionFunds` constant value `0x00...` inside it with the address of deployed `EmissionFunds`. Then deploy `RewardByBlock`.\n- `EternalStorageProxy_flat.sol` - Deploy `EternalStorageProxy` contract with constructor parameters: \u003cbr /\u003e\n`_proxyStorage` - address of ProxyStorage contract,\n`_implementationAddress` - address of RewardByBlock contract.\n-  Make a call to `VotingToManageEmissionFunds init`, using the address of `EternalStorageProxy` and ABI of `VotingToManageEmissionFunds`, with the next parameters: \u003cbr /\u003e\n`_emissionFunds` - address of EmissionFunds contract,\n`_emissionReleaseTime` - your emission release unix timestamp,\n`_emissionReleaseThreshold` - your emission release threshold in seconds,\n`_distributionThreshold` - your distribution threshold in seconds.\n-  Select deployed `ProxyStorage` contract and make a call from MoC address to `initializeAddresses` with relevant addresses.\n\n## Unit tests\n[Full Test Report](https://poanetwork.github.io/poa-network-consensus-contracts/mochawesome.html)\u003cbr /\u003e\n\n```\n  Contract: BallotsStorage [all features]\n    #init\n      ✓ prevent from double init\n      ✓ thresholds are correct (40ms)\n    #migrate\n      ✓ should copy thresholds from an old contract (282ms)\n    #setThreshold\n      ✓ can only be called from votingToChangeThreshold address (66ms)\n      ✓ cannot be set for Invalid threshold (200ms)\n      ✓ new value cannot be equal to 0 (124ms)\n      ✓ sets new value for Keys threshold (57ms)\n      ✓ sets new value for MetadataChange threshold (71ms)\n    #getProxyThreshold\n      ✓ return value is correct (392ms)\n      ✓ return value is correct if MoC is removed (1286ms)\n    #getVotingToChangeThreshold\n      ✓ returns voting to change min threshold address (71ms)\n    #getBallotLimitPerValidator\n      ✓ returns correct limit (253ms)\n      ✓ returns correct limit if MoC is removed (1044ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (131ms)\n      ✓ should change implementation address (145ms)\n      ✓ should increment implementation version (125ms)\n      ✓ new implementation should work (156ms)\n      ✓ new implementation should use the same proxyStorage address (121ms)\n      ✓ new implementation should use the same storage (157ms)\n  Contract: BallotsStorage upgraded [all features]\n    #init\n      ✓ prevent from double init\n      ✓ thresholds are correct\n    #migrate\n      ✓ should copy thresholds from an old contract (222ms)\n    #setThreshold\n      ✓ can only be called from votingToChangeThreshold address (58ms)\n      ✓ cannot be set for Invalid threshold (181ms)\n      ✓ new value cannot be equal to 0 (138ms)\n      ✓ sets new value for Keys threshold (53ms)\n      ✓ sets new value for MetadataChange threshold (66ms)\n    #getProxyThreshold\n      ✓ return value is correct (370ms)\n      ✓ return value is correct if MoC is removed (1220ms)\n    #getVotingToChangeThreshold\n      ✓ returns voting to change min threshold address (51ms)\n    #getBallotLimitPerValidator\n      ✓ returns correct limit (243ms)\n      ✓ returns correct limit if MoC is removed (1079ms)\n  Contract: EmissionFunds [all features]\n    constructor\n      ✓ should save VotingToManageEmissionFunds address\n    #fallback\n      ✓ should receive funds (327ms)\n    #sendFundsTo\n      ✓ may only be called by VotingToManageEmissionFunds (39ms)\n      ✓ should send funds to receiver (332ms)\n      ✓ should send entire amount (339ms)\n      ✓ should not send funds if amount greater than balance (319ms)\n      ✓ should not send funds if amount is too much (312ms)\n      ✓ should be fulfilled if receiver is 0x0 (168ms)\n      ✓ should be fulfilled if amount is zero (328ms)\n      ✓ should fail if receiver address is not full (664ms)\n    #burnFunds\n      ✓ may only be called by VotingToManageEmissionFunds\n      ✓ should burn funds (163ms)\n      ✓ should burn entire amount (165ms)\n      ✓ should not burn funds if amount greater than balance (165ms)\n      ✓ should not burn funds if amount is too much (263ms)\n      ✓ should be fulfilled if amount is zero (159ms)\n    #freezeFunds\n      ✓ may only be called by VotingToManageEmissionFunds (45ms)\n      ✓ should freeze funds (168ms)\n      ✓ should be fulfilled if amount is zero (159ms)\n  Contract: EternalStorageProxy [all features]\n    constructor\n      ✓ should revert if implementation address is equal to 0x0\n      ✓ should allow ProxyStorage address equal to 0x0 (53ms)\n      ✓ should set ProxyStorage address (52ms)\n      ✓ should set implementation address (61ms)\n      ✓ should set owner (42ms)\n    #renounceOwnership\n      ✓ may only be called by an owner\n      ✓ should set owner to 0x0\n    #transferOwnership\n      ✓ may only be called by an owner (129ms)\n      ✓ should change owner\n      ✓ should not change owner if its address is 0x0\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (41ms)\n      ✓ should not change implementation address if it is the same\n      ✓ should not change implementation address if it is 0x0\n      ✓ should change implementation address\n      ✓ should increment version (53ms)\n  Contract: KeysManager [all features]\n    #constructor\n      ✓ sets masterOfCeremony, proxyStorage, poaConsensus (133ms)\n      ✓ adds masterOfCeremony to validators hash\n      ✓ cannot be called twice\n    #initiateKeys\n      ✓ can only be called by master of ceremony (104ms)\n      ✓ cannot allow 0x0 addresses (57ms)\n      ✓ should not allow to initialize already initialized key (74ms)\n      ✓ should not allow to initialize already initialized key after validator created mining key (172ms)\n      ✓ should not equal to master of ceremony\n      ✓ should not allow to initialize more than maxNumberOfInitialKeys (595ms)\n      ✓ should increment initialKeyCount by 1 (80ms)\n      ✓ should set initialKeys hash to activated status (103ms)\n    #createKeys\n      ✓ should only be called from initialized key (162ms)\n      ✓ params should not be equal to 0x0 (209ms)\n      ✓ params should not be equal to each other (138ms)\n      ✓ any of params should not be equal to initialKey (231ms)\n      ✓ should not allow passing the same key after it is already created (355ms)\n      ✓ should assign mining, voting, payout keys to relative mappings (184ms)\n      ✓ should assign voting \u003c-\u003e mining key and payout \u003c-\u003e mining key relationships (156ms)\n      ✓ adds validator to poaConsensus contract (156ms)\n      ✓ should set validatorKeys hash (149ms)\n      ✓ should set validatorKeys hash (148ms)\n    #addMiningKey\n      ✓ may only be called if KeysManager.init had been called before (85ms)\n      ✓ should only be called from votingToChangeKeys (111ms)\n      ✓ should not let add more than maxLimit (64ms)\n      ✓ should set validatorKeys hash (92ms)\n    #addVotingKey\n      ✓ may only be called if KeysManager.init had been called before (125ms)\n      ✓ may only be called if params are not the same (150ms)\n      ✓ should add VotingKey (165ms)\n      ✓ should only be called if mining is active (239ms)\n      ✓ swaps keys if voting already exists (236ms)\n    #addPayoutKey\n      ✓ may only be called if KeysManager.init had been called before (132ms)\n      ✓ may only be called if params are not the same (147ms)\n      ✓ should add PayoutKey (175ms)\n      ✓ should only be called if mining is active (321ms)\n      ✓ swaps keys if voting already exists (252ms)\n    #removeMiningKey\n      ✓ may only be called if KeysManager.init had been called before (183ms)\n      ✓ should remove miningKey (667ms)\n      ✓ removes validator from poaConsensus (331ms)\n      ✓ removes MoC from poaConsensus (1040ms)\n      ✓ should still enforce removal of votingKey to 0x0 even if voting key did not exist (299ms)\n    #removeVotingKey\n      ✓ may only be called if KeysManager.init had been called before (208ms)\n      ✓ should be successful only for active voting key (245ms)\n      ✓ should remove votingKey (283ms)\n    #removePayoutKey\n      ✓ may only be called if KeysManager.init had been called before (215ms)\n      ✓ should be successful only for active payout key (257ms)\n      ✓ should remove payoutKey (274ms)\n    #swapMiningKey\n      ✓ should swap mining key (702ms)\n      ✓ should swap MoC (352ms)\n      ✓ should keep voting and payout keys (531ms)\n    #swapVotingKey\n      ✓ should swap voting key (221ms)\n    #swapPayoutKey\n      ✓ should swap payout key (256ms)\n    #migrateInitialKey\n      ✓ can copy initial keys (390ms)\n    #migrateMiningKey\n      ✓ copies validator keys (1208ms)\n      ✓ throws when trying to copy invalid mining key (208ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (99ms)\n      ✓ should change implementation address (174ms)\n      ✓ should increment implementation version (89ms)\n      ✓ new implementation should work (123ms)\n      ✓ new implementation should use the same proxyStorage address (186ms)\n      ✓ new implementation should use the same storage (324ms)\n  Contract: KeysManager upgraded [all features]\n    #constructor\n      ✓ sets masterOfCeremony, proxyStorage, poaConsensus (169ms)\n      ✓ adds masterOfCeremony to validators hash\n      ✓ cannot be called twice\n    #initiateKeys\n      ✓ can only be called by master of ceremony (81ms)\n      ✓ cannot allow 0x0 addresses (64ms)\n      ✓ should not allow to initialize already initialized key (87ms)\n      ✓ should not allow to initialize already initialized key after validator created mining key (185ms)\n      ✓ should not equal to master of ceremony (44ms)\n      ✓ should not allow to initialize more than maxNumberOfInitialKeys (674ms)\n      ✓ should increment initialKeyCount by 1 (82ms)\n      ✓ should set initialKeys hash to activated status (100ms)\n    #createKeys\n      ✓ should only be called from initialized key (182ms)\n      ✓ params should not be equal to 0x0 (246ms)\n      ✓ params should not be equal to each other (149ms)\n      ✓ any of params should not be equal to initialKey (152ms)\n      ✓ should not allow passing the same key after it is already created (380ms)\n      ✓ should assign mining, voting, payout keys to relative mappings (171ms)\n      ✓ should assign voting \u003c-\u003e mining key and payout \u003c-\u003e mining key relationships (187ms)\n      ✓ adds validator to poaConsensus contract (154ms)\n      ✓ should set validatorKeys hash (165ms)\n      ✓ should set validatorKeys hash (247ms)\n    #addMiningKey\n      ✓ may only be called if KeysManager.init had been called before (88ms)\n      ✓ should only be called from votingToChangeKeys (122ms)\n      ✓ should not let add more than maxLimit (50ms)\n      ✓ should set validatorKeys hash (108ms)\n    #addVotingKey\n      ✓ may only be called if KeysManager.init had been called before (117ms)\n      ✓ may only be called if params are not the same (156ms)\n      ✓ should add VotingKey (179ms)\n      ✓ should only be called if mining is active (239ms)\n      ✓ swaps keys if voting already exists (238ms)\n    #addPayoutKey\n      ✓ may only be called if KeysManager.init had been called before (145ms)\n      ✓ may only be called if params are not the same (143ms)\n      ✓ should add PayoutKey (169ms)\n      ✓ should only be called if mining is active (344ms)\n      ✓ swaps keys if voting already exists (251ms)\n    #removeMiningKey\n      ✓ may only be called if KeysManager.init had been called before (181ms)\n      ✓ should remove miningKey (707ms)\n      ✓ removes validator from poaConsensus (348ms)\n      ✓ removes MoC from poaConsensus (1048ms)\n      ✓ should still enforce removal of votingKey to 0x0 even if voting key did not exist (308ms)\n    #removeVotingKey\n      ✓ may only be called if KeysManager.init had been called before (216ms)\n      ✓ should be successful only for active voting key (229ms)\n      ✓ should remove votingKey (377ms)\n    #removePayoutKey\n      ✓ may only be called if KeysManager.init had been called before (206ms)\n      ✓ should be successful only for active payout key (231ms)\n      ✓ should remove payoutKey (260ms)\n    #swapMiningKey\n      ✓ should swap mining key (737ms)\n      ✓ should swap MoC (384ms)\n      ✓ should keep voting and payout keys (523ms)\n    #swapVotingKey\n      ✓ should swap voting key (230ms)\n    #swapPayoutKey\n      ✓ should swap payout key (283ms)\n    #migrateInitialKey\n      ✓ can copy initial keys (445ms)\n    #migrateMiningKey\n      ✓ copies validator keys (1228ms)\n      ✓ throws when trying to copy invalid mining key (205ms)\n  Contract: ValidatorMetadata [all features]\n    #createMetadata\n      ✓ happy path (170ms)\n      ✓ should not let create metadata if fullAddress is too long (200ms)\n      ✓ should not let create metadata if called by non-voting key (86ms)\n      ✓ should not let create metadata if called second time (153ms)\n    #clearMetadata\n      ✓ happy path (770ms)\n    #moveMetadata\n      ✓ happy path (1142ms)\n    #initMetadata\n      ✓ happy path (441ms)\n    #changeRequest\n      ✓ happy path (248ms)\n      ✓ should not let call if there is no metadata\n      ✓ resets confirmations when changeRequest recreated (515ms)\n    #cancelPendingChange\n      ✓ happy path (473ms)\n      ✓ should not let delete records for someone else miningKey (490ms)\n    #confirmPendingChange\n      ✓ should not let confirm your own changes (236ms)\n      ✓ should confirm changes (316ms)\n      ✓ prevent from double voting (337ms)\n      ✓ should not exceed confirmations limit (577ms)\n    #finalize\n      ✓ happy path (758ms)\n    #getMinThreshold\n      ✓ returns default value\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (82ms)\n      ✓ should change implementation address (79ms)\n      ✓ should increment implementation version (80ms)\n      ✓ new implementation should work (120ms)\n      ✓ new implementation should use the same proxyStorage address (80ms)\n      ✓ new implementation should use the same storage (321ms)\n  Contract: ValidatorMetadata upgraded [all features]\n    #createMetadata\n      ✓ happy path (169ms)\n      ✓ should not let create metadata if fullAddress is too long (210ms)\n      ✓ should not let create metadata if called by non-voting key (88ms)\n      ✓ should not let create metadata if called second time (145ms)\n    #clearMetadata\n      ✓ happy path (677ms)\n    #moveMetadata\n      ✓ happy path (1014ms)\n    #initMetadata\n      ✓ happy path (553ms)\n    #changeRequest\n      ✓ happy path (165ms)\n      ✓ should not let call if there is no metadata\n      ✓ resets confirmations when changeRequest recreated (495ms)\n    #cancelPendingChange\n      ✓ happy path (586ms)\n      ✓ should not let delete records for someone else miningKey (490ms)\n    #confirmPendingChange\n      ✓ should not let confirm your own changes (415ms)\n      ✓ should confirm changes (310ms)\n      ✓ prevent from double voting (383ms)\n      ✓ should not exceed confirmations limit (608ms)\n    #finalize\n      ✓ happy path (760ms)\n    #getMinThreshold\n      ✓ returns default value\n  Contract: PoaNetworkConsensus [all features]\n    default values\n      ✓ finalized should be false\n      ✓ checks systemAddress\n      ✓ allows you to set current list of validators (87ms)\n      ✓ validators in the list must differ (129ms)\n    #finalizeChange\n      ✓ should only be called by systemAddress (79ms)\n      ✓ should set finalized to true (73ms)\n      ✓ should set currentValidators to pendingList (78ms)\n      ✓ set currentValidators to pendingList after addValidator call (301ms)\n    #addValidator\n      ✓ should only be called from keys manager (63ms)\n      ✓ should not allow to add already existing validator (78ms)\n      ✓ should not allow 0x0 addresses (74ms)\n      ✓ should set validatorsState for new validator (80ms)\n      ✓ should set finalized to false (72ms)\n      ✓ should emit InitiateChange with blockhash and pendingList as params (284ms)\n    #swapValidatorKey\n      ✓ should swap validator key (294ms)\n      ✓ should swap MoC (271ms)\n    #removeValidator\n      ✓ should remove validator (95ms)\n      ✓ should remove MoC (249ms)\n      ✓ should only be called from keys manager (112ms)\n      ✓ should only be allowed to remove from existing set of validators (46ms)\n      ✓ should decrease length of pendingList (258ms)\n      ✓ should change validatorsState (100ms)\n      ✓ should set finalized to false (114ms)\n    #setProxyStorage\n      ✓ can be called by MoC (62ms)\n      ✓ can be called by owner (67ms)\n      ✓ can only be called once\n      ✓ cannot be set to 0x0 address\n      ✓ sets proxyStorage (51ms)\n      ✓ sets wasProxyStorageSet (47ms)\n      ✓ emits MoCInitializedProxyStorage (38ms)\n      ✓ #getKeysManager (58ms)\n    #isValidator\n      ✓ returns true for validator\n    #isValidatorFinalized\n      ✓ returns true for finalized validator (1654ms)\n  Contract: ProxyStorage [all features]\n    #constructor\n      ✓ sets PoA\n    #initializeAddresses\n      ✓ sets all addresses (158ms)\n      ✓ prevents Moc to call it more than once (89ms)\n    #setContractAddress\n      ✓ can only be called from votingToChangeProxy address (93ms)\n      ✓ cannot be set to 0x0 address (69ms)\n      ✓ sets keysManager (142ms)\n      ✓ sets votingToChangeKeys (154ms)\n      ✓ sets votingToChangeMinThreshold (253ms)\n      ✓ sets ballotsStorage (142ms)\n      ✓ sets poaConsensus (81ms)\n      ✓ sets validatorMetadata (227ms)\n      ✓ changes proxyStorage (itself) implementation (205ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (itself) (119ms)\n      ✓ should change implementation address (115ms)\n      ✓ should increment implementation version (127ms)\n      ✓ new implementation should work (168ms)\n      ✓ new implementation should use the same storage (182ms)\n  Contract: ProxyStorage upgraded [all features]\n    #constructor\n      ✓ sets PoA\n    #initializeAddresses\n      ✓ sets all addresses (165ms)\n      ✓ prevents Moc to call it more than once (81ms)\n    #setContractAddress\n      ✓ can only be called from votingToChangeProxy address (180ms)\n      ✓ cannot be set to 0x0 address (67ms)\n      ✓ sets keysManager (158ms)\n      ✓ sets votingToChangeKeys (163ms)\n      ✓ sets votingToChangeMinThreshold (144ms)\n      ✓ sets ballotsStorage (253ms)\n      ✓ sets poaConsensus (81ms)\n      ✓ sets validatorMetadata (172ms)\n      ✓ changes proxyStorage (itself) implementation (145ms)\n  Contract: RewardByBlock [all features]\n    #reward\n      ✓ may only be called by system address (94ms)\n      ✓ should revert if input array contains more than one item\n      ✓ should revert if lengths of input arrays are not equal (38ms)\n      ✓ should revert if `kind` parameter is not 0\n      ✓ should revert if mining key does not exist (252ms)\n      ✓ should assign rewards to payout key and EmissionFunds (88ms)\n      ✓ should assign reward to mining key if payout key is 0 (143ms)\n      ✓ should assign rewards to extra receivers and clear extra receivers list (369ms)\n    #addExtraReceiver\n      ✓ may only be called by bridge contract (59ms)\n      ✓ should revert if receiver address is 0x0\n      ✓ should revert if amount is 0 (39ms)\n      ✓ can only be called once for the same recipient (79ms)\n      ✓ should add receivers (214ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (111ms)\n      ✓ should change implementation address (111ms)\n      ✓ should increment implementation version (116ms)\n      ✓ new implementation should work (154ms)\n      ✓ new implementation should use the same proxyStorage address (112ms)\n  Contract: RewardByBlock upgraded [all features]\n    #reward\n      ✓ may only be called by system address (89ms)\n      ✓ should revert if input array contains more than one item\n      ✓ should revert if lengths of input arrays are not equal (46ms)\n      ✓ should revert if `kind` parameter is not 0 (48ms)\n      ✓ should revert if mining key does not exist (246ms)\n      ✓ should assign rewards to payout key and EmissionFunds (81ms)\n      ✓ should assign reward to mining key if payout key is 0 (121ms)\n      ✓ should assign rewards to extra receivers and clear extra receivers list (421ms)\n    #addExtraReceiver\n      ✓ may only be called by bridge contract (68ms)\n      ✓ should revert if receiver address is 0x0 (45ms)\n      ✓ should revert if amount is 0 (47ms)\n      ✓ can only be called once for the same recipient (72ms)\n      ✓ should add receivers (199ms)\n  Contract: RewardByTime [all features]\n    #reward\n      ✓ may only be called by system address (152ms)\n      ✓ should assign rewards to payout keys and EmissionFunds (3292ms)\n      ✓ should work fine after some validators are removed and added (1355ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (108ms)\n      ✓ should change implementation address (111ms)\n      ✓ should increment implementation version (112ms)\n      ✓ new implementation should work (259ms)\n      ✓ new implementation should use the same proxyStorage address (113ms)\n  Contract: RewardByTime upgraded [all features]\n    #reward\n      ✓ may only be called by system address (150ms)\n      ✓ should assign rewards to payout keys and EmissionFunds (3160ms)\n      ✓ should work fine after some validators are removed and added (1459ms)\n  Contract: Voting to change keys [all features]\n    #createBallot\n      ✓ happy path (705ms)\n      ✓ should not let create voting with invalid duration (170ms)\n      ✓ should not let add votingKey for MoC (416ms)\n      ✓ should not let add votingKey for 0x0 (447ms)\n      ✓ should not let add payoutKey for 0x0 (588ms)\n      ✓ should not let create more ballots than the limit (10140ms)\n    #createBallotToAddNewValidator\n      ✓ happy path (296ms)\n      ✓ deny adding already existed voting key\n      ✓ deny adding already existed payout key (199ms)\n      ✓ should create validator with all keys after finalization (1282ms)\n      ✓ should allow removing new validator if finalizeChange did not happen (2249ms)\n    #vote\n      ✓ should let a validator to vote (194ms)\n      ✓ reject vote should be accepted (199ms)\n      ✓ should allow multiple voters to vote (875ms)\n      ✓ should not let vote nonVoting key (57ms)\n      ✓ should not let vote before startTime key (102ms)\n      ✓ should not let vote after endTime key (97ms)\n      ✓ should not let vote with already voted key (271ms)\n      ✓ should not let vote with invalid choice (267ms)\n      ✓ should not let vote with invalid id (170ms)\n    #finalize\n      ✓ happy path - no action since it did not meet minimum number of totalVoters (803ms)\n      ✓ finalize addition of payout key (933ms)\n      ✓ finalize addition of VotingKey (1027ms)\n      ✓ cannot create ballot for using previous mining key (2257ms)\n      ✓ finalize addition of MiningKey (1144ms)\n      ✓ finalize removal of MiningKey (2097ms)\n      ✓ finalize removal of VotingKey (1237ms)\n      ✓ finalize removal of PayoutKey (1178ms)\n      ✓ finalize swap of VotingKey (1216ms)\n      ✓ finalize swap of PayoutKey (1178ms)\n      ✓ finalize swap of MiningKey (1373ms)\n      ✓ prevent double finalize (1841ms)\n      ✓ allowed at once after all validators gave their votes (1730ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (2013ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (98ms)\n      ✓ should change implementation address (101ms)\n      ✓ should increment implementation version (98ms)\n      ✓ new implementation should work (148ms)\n      ✓ new implementation should use the same proxyStorage address (186ms)\n      ✓ new implementation should use the same storage (963ms)\n  Contract: Voting to change keys upgraded [all features]\n    #createBallot\n      ✓ happy path (782ms)\n      ✓ should not let create voting with invalid duration (187ms)\n      ✓ should not let add votingKey for MoC (624ms)\n      ✓ should not let add votingKey for 0x0 (518ms)\n      ✓ should not let add payoutKey for 0x0 (480ms)\n      ✓ should not let create more ballots than the limit (10430ms)\n    #createBallotToAddNewValidator\n      ✓ happy path (316ms)\n      ✓ deny adding already existed voting key\n      ✓ deny adding already existed payout key (227ms)\n      ✓ should create validator with all keys after finalization (1418ms)\n      ✓ should allow removing new validator if finalizeChange did not happen (2165ms)\n    #vote\n      ✓ should let a validator to vote (190ms)\n      ✓ reject vote should be accepted (196ms)\n      ✓ should allow multiple voters to vote (831ms)\n      ✓ should not let vote nonVoting key (57ms)\n      ✓ should not let vote before startTime key (93ms)\n      ✓ should not let vote after endTime key (94ms)\n      ✓ should not let vote with already voted key (191ms)\n      ✓ should not let vote with invalid choice (179ms)\n      ✓ should not let vote with invalid id (173ms)\n    #finalize\n      ✓ happy path - no action since it did not meet minimum number of totalVoters (830ms)\n      ✓ finalize addition of payout key (910ms)\n      ✓ finalize addition of VotingKey (1022ms)\n      ✓ cannot create ballot for using previous mining key (2234ms)\n      ✓ finalize addition of MiningKey (1023ms)\n      ✓ finalize removal of MiningKey (2017ms)\n      ✓ finalize removal of VotingKey (1237ms)\n      ✓ finalize removal of PayoutKey (1142ms)\n      ✓ finalize swap of VotingKey (1172ms)\n      ✓ finalize swap of PayoutKey (1155ms)\n      ✓ finalize swap of MiningKey (1503ms)\n      ✓ prevent double finalize (1828ms)\n      ✓ allowed at once after all validators gave their votes (1722ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (2024ms)\n  Contract: VotingToChangeMinThreshold [all features]\n    #createBallot\n      ✓ happy path (377ms)\n      ✓ proposed value should be more than or equal to 3\n      ✓ proposed value should not be equal to the same value\n      ✓ should not let create more ballots than the limit (10284ms)\n    #vote\n      ✓ should let a validator to vote (181ms)\n      ✓ reject vote should be accepted (407ms)\n      ✓ should allow multiple voters to vote (422ms)\n      ✓ should not let vote nonVoting key (69ms)\n      ✓ should not let vote before startTime key (91ms)\n      ✓ should not let vote after endTime key (95ms)\n      ✓ should not let vote with already voted key (209ms)\n      ✓ should not let vote with invalid choice (166ms)\n      ✓ should not let vote with invalid id (169ms)\n    #finalize\n      ✓ does not change if it did not pass minimum threshold (561ms)\n      ✓ should change to proposedValue when quorum is reached (1253ms)\n      ✓ prevents double finalize (1671ms)\n      ✓ allowed at once after all validators gave their votes (2039ms)\n      ✓ should decrease validator limit only once when calling finalize more than once (1589ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (1495ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (77ms)\n      ✓ should change implementation address (93ms)\n      ✓ should increment implementation version (91ms)\n      ✓ new implementation should work (120ms)\n      ✓ new implementation should use the same proxyStorage address (89ms)\n      ✓ new implementation should use the same storage (585ms)\n  Contract: VotingToChangeMinThreshold upgraded [all features]\n    #createBallot\n      ✓ happy path (271ms)\n      ✓ proposed value should be more than or equal to 3 (133ms)\n      ✓ proposed value should not be equal to the same value\n      ✓ should not let create more ballots than the limit (10305ms)\n    #vote\n      ✓ should let a validator to vote (194ms)\n      ✓ reject vote should be accepted (190ms)\n      ✓ should allow multiple voters to vote (481ms)\n      ✓ should not let vote nonVoting key (51ms)\n      ✓ should not let vote before startTime key (108ms)\n      ✓ should not let vote after endTime key (108ms)\n      ✓ should not let vote with already voted key (193ms)\n      ✓ should not let vote with invalid choice (182ms)\n      ✓ should not let vote with invalid id (262ms)\n    #finalize\n      ✓ does not change if it did not pass minimum threshold (560ms)\n      ✓ should change to proposedValue when quorum is reached (1312ms)\n      ✓ prevents double finalize (1806ms)\n      ✓ allowed at once after all validators gave their votes (2331ms)\n      ✓ should decrease validator limit only once when calling finalize more than once (1595ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (1508ms)\n  Contract: VotingToChangeProxyAddress [all features]\n    #createBallot\n      ✓ happy path (278ms)\n      ✓ proposed address should not be 0x0\n      ✓ can create multiple ballots (489ms)\n      ✓ should not let create more ballots than the limit (9893ms)\n    #vote\n      ✓ should let a validator to vote (183ms)\n      ✓ reject vote should be accepted (284ms)\n      ✓ should allow multiple voters to vote (852ms)\n      ✓ should not let vote nonVoting key (52ms)\n      ✓ should not let vote before startTime key (103ms)\n      ✓ should not let vote after endTime key (97ms)\n      ✓ should not let vote with already voted key (195ms)\n      ✓ should not let vote with invalid choice (181ms)\n      ✓ should not let vote with invalid id (180ms)\n    #finalize\n      ✓ does not change if it did not pass minimum threshold (598ms)\n      ✓ should change KeysManager implementation (920ms)\n      ✓ should change VotingToChangeKeys implementation (1053ms)\n      ✓ should change VotingToChangeMinThreshold implementation (995ms)\n      ✓ should change VotingToChangeProxy implementation (1083ms)\n      ✓ should change BallotsStorage implementation (1075ms)\n      ✓ should change ValidatorMetadata implementation (1062ms)\n      ✓ should change ProxyStorage implementation (1068ms)\n      ✓ prevents double finalize (1513ms)\n      ✓ allowed at once after all validators gave their votes (1768ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (1995ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (88ms)\n      ✓ should change implementation address (87ms)\n      ✓ should increment implementation version (113ms)\n      ✓ new implementation should work (139ms)\n      ✓ new implementation should use the same proxyStorage address (86ms)\n      ✓ new implementation should use the same storage (620ms)\n  Contract: VotingToChangeProxyAddress upgraded [all features]\n    #createBallot\n      ✓ happy path (395ms)\n      ✓ proposed address should not be 0x0 (119ms)\n      ✓ can create multiple ballots (394ms)\n      ✓ should not let create more ballots than the limit (10105ms)\n    #vote\n      ✓ should let a validator to vote (179ms)\n      ✓ reject vote should be accepted (194ms)\n      ✓ should allow multiple voters to vote (805ms)\n      ✓ should not let vote nonVoting key (55ms)\n      ✓ should not let vote before startTime key (103ms)\n      ✓ should not let vote after endTime key (213ms)\n      ✓ should not let vote with already voted key (224ms)\n      ✓ should not let vote with invalid choice (225ms)\n      ✓ should not let vote with invalid id (196ms)\n    #finalize\n      ✓ does not change if it did not pass minimum threshold (684ms)\n      ✓ should change KeysManager implementation (1177ms)\n      ✓ should change VotingToChangeKeys implementation (1182ms)\n      ✓ should change VotingToChangeMinThreshold implementation (1065ms)\n      ✓ should change VotingToChangeProxy implementation (1115ms)\n      ✓ should change BallotsStorage implementation (985ms)\n      ✓ should change ValidatorMetadata implementation (1082ms)\n      ✓ should change ProxyStorage implementation (1080ms)\n      ✓ prevents double finalize (1522ms)\n      ✓ allowed at once after all validators gave their votes (1686ms)\n    #migrate\n      ✓ should copy a ballot to the new contract (2022ms)\n  Contract: VotingToManageEmissionFunds [all features]\n    #init\n      ✓ should change state correctly (119ms)\n      ✓ cannot be called more than once\n    #createBallot\n      ✓ happy path (866ms)\n      ✓ may only be called by valid voting key (139ms)\n      ✓ endTime must be greater than startTime\n      ✓ startTime must be greater than current time (39ms)\n      ✓ cannot be called before emission release time (64ms)\n      ✓ ballot cannot last longer than distribution threshold (55ms)\n      ✓ receiver address should not be 0x0 (64ms)\n      ✓ cannot create multiple ballots during the same distribution period (435ms)\n      ✓ should allow creating new ballot after the next emission release threshold (490ms)\n    #cancelNewBallot\n      ✓ happy path (880ms)\n      ✓ cannot cancel nonexistent or finalized ballot (341ms)\n      ✓ may only be called by creator of a ballot (232ms)\n      ✓ may only be called within ballot canceling threshold (265ms)\n      ✓ cannot cancel already cancelled ballot (221ms)\n      ✓ should restore emission release time (493ms)\n    #refreshEmissionReleaseTime\n      ✓ should not update until the next threshold (130ms)\n      ✓ should update to the next threshold (72ms)\n      ✓ should update to the future threshold (86ms)\n    #vote\n      ✓ should let a validator to vote (959ms)\n      ✓ should allow multiple voters to vote (1497ms)\n      ✓ should not let vote by nonvoting key (57ms)\n      ✓ should not let vote before startTime (94ms)\n      ✓ should not let vote after endTime (260ms)\n      ✓ should not let vote with already voted key (207ms)\n      ✓ should not let vote with invalid choice (152ms)\n      ✓ should not let vote with invalid id (164ms)\n      ✓ should not let vote if already finalized (1535ms)\n      ✓ should not let vote with old miningKey (2431ms)\n      ✓ should not let vote if ballot is canceled (256ms)\n    #finalize\n      ✓ happy path (591ms)\n      ✓ freeze funds if it did not pass minimum voters count (1036ms)\n      ✓ freeze funds if there is no majority of 3 votes (1322ms)\n      ✓ freeze funds if there is no majority of 4 votes (1678ms)\n      ✓ send funds to receiver if most votes are for sending (2089ms)\n      ✓ send funds to receiver if most votes are for sending (1749ms)\n      ✓ burn funds if most votes are for burning (1704ms)\n      ✓ prevents finalize with invalid id (280ms)\n      ✓ do not let finalize if a ballot is active (189ms)\n      ✓ finalize immediately if the last validator gave his vote (1187ms)\n      ✓ does not finalize immediately until ballot canceling threshold is reached (1236ms)\n      ✓ prevents double finalize (279ms)\n      ✓ should refresh emission release time (256ms)\n      ✓ deny finalization if the voting key is a contract (703ms)\n      ✓ deny finalization within ballot canceling threshold (301ms)\n      ✓ deny finalization of canceled ballot (461ms)\n    #upgradeTo\n      ✓ may only be called by ProxyStorage (91ms)\n      ✓ should change implementation address (92ms)\n      ✓ should increment implementation version (91ms)\n      ✓ new implementation should work (129ms)\n      ✓ new implementation should use the same proxyStorage address (92ms)\n      ✓ new implementation should use the same storage (960ms)\n  Contract: VotingToManageEmissionFunds upgraded [all features]\n    #init\n      ✓ should change state correctly (111ms)\n      ✓ cannot be called more than once\n    #createBallot\n      ✓ happy path (835ms)\n      ✓ may only be called by valid voting key (142ms)\n      ✓ endTime must be greater than startTime (45ms)\n      ✓ startTime must be greater than current time (126ms)\n      ✓ cannot be called before emission release time (64ms)\n      ✓ ballot cannot last longer than distribution threshold (41ms)\n      ✓ receiver address should not be 0x0 (52ms)\n      ✓ cannot create multiple ballots during the same distribution period (467ms)\n      ✓ should allow creating new ballot after the next emission release threshold (464ms)\n    #cancelNewBallot\n      ✓ happy path (878ms)\n      ✓ cannot cancel nonexistent or finalized ballot (300ms)\n      ✓ may only be called by creator of a ballot (290ms)\n      ✓ may only be called within ballot canceling threshold (250ms)\n      ✓ cannot cancel already cancelled ballot (244ms)\n      ✓ should restore emission release time (601ms)\n    #refreshEmissionReleaseTime\n      ✓ should not update until the next threshold (129ms)\n      ✓ should update to the next threshold (273ms)\n      ✓ should update to the future threshold (72ms)\n    #vote\n      ✓ should let a validator to vote (842ms)\n      ✓ should allow multiple voters to vote (1572ms)\n      ✓ should not let vote by nonvoting key (60ms)\n      ✓ should not let vote before startTime (89ms)\n      ✓ should not let vote after endTime (253ms)\n      ✓ should not let vote with already voted key (202ms)\n      ✓ should not let vote with invalid choice (173ms)\n      ✓ should not let vote with invalid id (155ms)\n      ✓ should not let vote if already finalized (1404ms)\n      ✓ should not let vote with old miningKey (2283ms)\n      ✓ should not let vote if ballot is canceled (152ms)\n    #finalize\n      ✓ happy path (569ms)\n      ✓ freeze funds if it did not pass minimum voters count (1142ms)\n      ✓ freeze funds if there is no majority of 3 votes (1393ms)\n      ✓ freeze funds if there is no majority of 4 votes (1872ms)\n      ✓ send funds to receiver if most votes are for sending (2304ms)\n      ✓ send funds to receiver if most votes are for sending (1816ms)\n      ✓ burn funds if most votes are for burning (1898ms)\n      ✓ prevents finalize with invalid id (209ms)\n      ✓ do not let finalize if a ballot is active (211ms)\n      ✓ finalize immediately if the last validator gave his vote (1281ms)\n      ✓ does not finalize immediately until ballot canceling threshold is reached (1316ms)\n      ✓ prevents double finalize (292ms)\n      ✓ should refresh emission release time (265ms)\n      ✓ deny finalization if the voting key is a contract (737ms)\n      ✓ deny finalization within ballot canceling threshold (305ms)\n      ✓ deny finalization of canceled ballot (284ms)\n  598 passing (18m)\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoanetwork%2Fpoa-network-consensus-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoanetwork%2Fpoa-network-consensus-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoanetwork%2Fpoa-network-consensus-contracts/lists"}