Skip to content

poanetwork/poa-network-consensus-contracts

Repository files navigation

poa-network-consensus-contracts

Build Status

Security Audit

Start POA network

  • Install npm dependencies npm i
  • Generate flat sources of contracts with the script ./make_flat.sh
  • We need a bytecode of PoaNetworkConsensus contract to add it to spec.json of the network.
    Go to scripts directory and run poa-bytecode.js:
$ cd scripts
$ npm i
$ MASTER_OF_CEREMONY=0x0039F22efB07A647557C7C5d17854CFD6D489eF3 node poa-bytecode.js

It will show the bytecode of PoaNetworkConsensus contract. Copy the bytecode and paste it into spec.json.

Add Contracts to Parity UI.

Start Parity UI. In the contracts section press Develop button. Select 0.4.24 Solidity compiler version. Set Optimize to true.

  • In Parity UI Contracts tab choose watch custom contract. Paste bytecode and ABI of PoaNetworkConsensus contract from Remix.

Compile and deploy contracts in the next sequence:

  • ProxyStorage_flat.sol - Deploy ProxyStorage contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - equal to zero, _implementationAddress - address of ProxyStorage contract.
  • 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.
  • Select PoaNetworkConsensus contract and call setProxyStorage with the address of ProxyStorage contract.
  • KeysManager_flat.sol - Deploy KeysManager contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of KeysManager contract.
  • Make a call to KeysManager init with _previousKeysManager parameter equal to 0x0000000000000000000000000000000000000000, using the address of EternalStorageProxy and ABI of KeysManager.
  • BallotsStorage_flat.sol - Deploy BallotsStorage contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of BallotsStorage contract.
  • Make a call to BallotsStorage init with _thresholds parameter equal to [3, 2], using the address of EternalStorageProxy and ABI of BallotsStorage.
  • VotingToChangeKeys_flat.sol - Deploy VotingToChangeKeys contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of VotingToChangeKeys contract.
  • Make a call to VotingToChangeKeys init with _minBallotDuration parameter equal to 172800, using the address of EternalStorageProxy and ABI of VotingToChangeKeys.
  • Make a call to VotingToChangeKeys migrateDisable, using the address of EternalStorageProxy and ABI of VotingToChangeKeys.
  • VotingToChangeMinThreshold_flat.sol - Deploy VotingToChangeMinThreshold contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of VotingToChangeMinThreshold contract.
  • 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.
  • Make a call to VotingToChangeMinThreshold migrateDisable, using the address of EternalStorageProxy and ABI of VotingToChangeMinThreshold.
  • VotingToChangeProxyAddress_flat.sol - Deploy VotingToChangeProxyAddress contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of VotingToChangeProxyAddress contract.
  • Make a call to VotingToChangeProxyAddress init with _minBallotDuration parameter equal to 172800, using the address of EternalStorageProxy and ABI of VotingToChangeProxyAddress.
  • Make a call to VotingToChangeProxyAddress migrateDisable, using the address of EternalStorageProxy and ABI of VotingToChangeProxyAddress.
  • ValidatorMetadata_flat.sol - Deploy ValidatorMetadata contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of ValidatorMetadata contract.
  • VotingToManageEmissionFunds_flat.sol - Deploy VotingToManageEmissionFunds contract.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of VotingToManageEmissionFunds contract.
  • EmissionFunds_flat.sol - Deploy EmissionFunds contract with constructor parameter _votingToManageEmissionFunds equal to EternalStorageProxy address of VotingToManageEmissionFunds contract.
  • RewardByBlock_flat.sol - Deploy RewardByBlock contract and replace emissionFunds constant value 0x00... inside it with the address of deployed EmissionFunds. Then deploy RewardByBlock.
  • EternalStorageProxy_flat.sol - Deploy EternalStorageProxy contract with constructor parameters:
    _proxyStorage - address of ProxyStorage contract, _implementationAddress - address of RewardByBlock contract.
  • Make a call to VotingToManageEmissionFunds init, using the address of EternalStorageProxy and ABI of VotingToManageEmissionFunds, with the next parameters:
    _emissionFunds - address of EmissionFunds contract, _emissionReleaseTime - your emission release unix timestamp, _emissionReleaseThreshold - your emission release threshold in seconds, _distributionThreshold - your distribution threshold in seconds.
  • Select deployed ProxyStorage contract and make a call from MoC address to initializeAddresses with relevant addresses.

Unit tests

Full Test Report

  Contract: BallotsStorage [all features]
    #init
      βœ“ prevent from double init
      βœ“ thresholds are correct (40ms)
    #migrate
      βœ“ should copy thresholds from an old contract (282ms)
    #setThreshold
      βœ“ can only be called from votingToChangeThreshold address (66ms)
      βœ“ cannot be set for Invalid threshold (200ms)
      βœ“ new value cannot be equal to 0 (124ms)
      βœ“ sets new value for Keys threshold (57ms)
      βœ“ sets new value for MetadataChange threshold (71ms)
    #getProxyThreshold
      βœ“ return value is correct (392ms)
      βœ“ return value is correct if MoC is removed (1286ms)
    #getVotingToChangeThreshold
      βœ“ returns voting to change min threshold address (71ms)
    #getBallotLimitPerValidator
      βœ“ returns correct limit (253ms)
      βœ“ returns correct limit if MoC is removed (1044ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (131ms)
      βœ“ should change implementation address (145ms)
      βœ“ should increment implementation version (125ms)
      βœ“ new implementation should work (156ms)
      βœ“ new implementation should use the same proxyStorage address (121ms)
      βœ“ new implementation should use the same storage (157ms)
  Contract: BallotsStorage upgraded [all features]
    #init
      βœ“ prevent from double init
      βœ“ thresholds are correct
    #migrate
      βœ“ should copy thresholds from an old contract (222ms)
    #setThreshold
      βœ“ can only be called from votingToChangeThreshold address (58ms)
      βœ“ cannot be set for Invalid threshold (181ms)
      βœ“ new value cannot be equal to 0 (138ms)
      βœ“ sets new value for Keys threshold (53ms)
      βœ“ sets new value for MetadataChange threshold (66ms)
    #getProxyThreshold
      βœ“ return value is correct (370ms)
      βœ“ return value is correct if MoC is removed (1220ms)
    #getVotingToChangeThreshold
      βœ“ returns voting to change min threshold address (51ms)
    #getBallotLimitPerValidator
      βœ“ returns correct limit (243ms)
      βœ“ returns correct limit if MoC is removed (1079ms)
  Contract: EmissionFunds [all features]
    constructor
      βœ“ should save VotingToManageEmissionFunds address
    #fallback
      βœ“ should receive funds (327ms)
    #sendFundsTo
      βœ“ may only be called by VotingToManageEmissionFunds (39ms)
      βœ“ should send funds to receiver (332ms)
      βœ“ should send entire amount (339ms)
      βœ“ should not send funds if amount greater than balance (319ms)
      βœ“ should not send funds if amount is too much (312ms)
      βœ“ should be fulfilled if receiver is 0x0 (168ms)
      βœ“ should be fulfilled if amount is zero (328ms)
      βœ“ should fail if receiver address is not full (664ms)
    #burnFunds
      βœ“ may only be called by VotingToManageEmissionFunds
      βœ“ should burn funds (163ms)
      βœ“ should burn entire amount (165ms)
      βœ“ should not burn funds if amount greater than balance (165ms)
      βœ“ should not burn funds if amount is too much (263ms)
      βœ“ should be fulfilled if amount is zero (159ms)
    #freezeFunds
      βœ“ may only be called by VotingToManageEmissionFunds (45ms)
      βœ“ should freeze funds (168ms)
      βœ“ should be fulfilled if amount is zero (159ms)
  Contract: EternalStorageProxy [all features]
    constructor
      βœ“ should revert if implementation address is equal to 0x0
      βœ“ should allow ProxyStorage address equal to 0x0 (53ms)
      βœ“ should set ProxyStorage address (52ms)
      βœ“ should set implementation address (61ms)
      βœ“ should set owner (42ms)
    #renounceOwnership
      βœ“ may only be called by an owner
      βœ“ should set owner to 0x0
    #transferOwnership
      βœ“ may only be called by an owner (129ms)
      βœ“ should change owner
      βœ“ should not change owner if its address is 0x0
    #upgradeTo
      βœ“ may only be called by ProxyStorage (41ms)
      βœ“ should not change implementation address if it is the same
      βœ“ should not change implementation address if it is 0x0
      βœ“ should change implementation address
      βœ“ should increment version (53ms)
  Contract: KeysManager [all features]
    #constructor
      βœ“ sets masterOfCeremony, proxyStorage, poaConsensus (133ms)
      βœ“ adds masterOfCeremony to validators hash
      βœ“ cannot be called twice
    #initiateKeys
      βœ“ can only be called by master of ceremony (104ms)
      βœ“ cannot allow 0x0 addresses (57ms)
      βœ“ should not allow to initialize already initialized key (74ms)
      βœ“ should not allow to initialize already initialized key after validator created mining key (172ms)
      βœ“ should not equal to master of ceremony
      βœ“ should not allow to initialize more than maxNumberOfInitialKeys (595ms)
      βœ“ should increment initialKeyCount by 1 (80ms)
      βœ“ should set initialKeys hash to activated status (103ms)
    #createKeys
      βœ“ should only be called from initialized key (162ms)
      βœ“ params should not be equal to 0x0 (209ms)
      βœ“ params should not be equal to each other (138ms)
      βœ“ any of params should not be equal to initialKey (231ms)
      βœ“ should not allow passing the same key after it is already created (355ms)
      βœ“ should assign mining, voting, payout keys to relative mappings (184ms)
      βœ“ should assign voting <-> mining key and payout <-> mining key relationships (156ms)
      βœ“ adds validator to poaConsensus contract (156ms)
      βœ“ should set validatorKeys hash (149ms)
      βœ“ should set validatorKeys hash (148ms)
    #addMiningKey
      βœ“ may only be called if KeysManager.init had been called before (85ms)
      βœ“ should only be called from votingToChangeKeys (111ms)
      βœ“ should not let add more than maxLimit (64ms)
      βœ“ should set validatorKeys hash (92ms)
    #addVotingKey
      βœ“ may only be called if KeysManager.init had been called before (125ms)
      βœ“ may only be called if params are not the same (150ms)
      βœ“ should add VotingKey (165ms)
      βœ“ should only be called if mining is active (239ms)
      βœ“ swaps keys if voting already exists (236ms)
    #addPayoutKey
      βœ“ may only be called if KeysManager.init had been called before (132ms)
      βœ“ may only be called if params are not the same (147ms)
      βœ“ should add PayoutKey (175ms)
      βœ“ should only be called if mining is active (321ms)
      βœ“ swaps keys if voting already exists (252ms)
    #removeMiningKey
      βœ“ may only be called if KeysManager.init had been called before (183ms)
      βœ“ should remove miningKey (667ms)
      βœ“ removes validator from poaConsensus (331ms)
      βœ“ removes MoC from poaConsensus (1040ms)
      βœ“ should still enforce removal of votingKey to 0x0 even if voting key did not exist (299ms)
    #removeVotingKey
      βœ“ may only be called if KeysManager.init had been called before (208ms)
      βœ“ should be successful only for active voting key (245ms)
      βœ“ should remove votingKey (283ms)
    #removePayoutKey
      βœ“ may only be called if KeysManager.init had been called before (215ms)
      βœ“ should be successful only for active payout key (257ms)
      βœ“ should remove payoutKey (274ms)
    #swapMiningKey
      βœ“ should swap mining key (702ms)
      βœ“ should swap MoC (352ms)
      βœ“ should keep voting and payout keys (531ms)
    #swapVotingKey
      βœ“ should swap voting key (221ms)
    #swapPayoutKey
      βœ“ should swap payout key (256ms)
    #migrateInitialKey
      βœ“ can copy initial keys (390ms)
    #migrateMiningKey
      βœ“ copies validator keys (1208ms)
      βœ“ throws when trying to copy invalid mining key (208ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (99ms)
      βœ“ should change implementation address (174ms)
      βœ“ should increment implementation version (89ms)
      βœ“ new implementation should work (123ms)
      βœ“ new implementation should use the same proxyStorage address (186ms)
      βœ“ new implementation should use the same storage (324ms)
  Contract: KeysManager upgraded [all features]
    #constructor
      βœ“ sets masterOfCeremony, proxyStorage, poaConsensus (169ms)
      βœ“ adds masterOfCeremony to validators hash
      βœ“ cannot be called twice
    #initiateKeys
      βœ“ can only be called by master of ceremony (81ms)
      βœ“ cannot allow 0x0 addresses (64ms)
      βœ“ should not allow to initialize already initialized key (87ms)
      βœ“ should not allow to initialize already initialized key after validator created mining key (185ms)
      βœ“ should not equal to master of ceremony (44ms)
      βœ“ should not allow to initialize more than maxNumberOfInitialKeys (674ms)
      βœ“ should increment initialKeyCount by 1 (82ms)
      βœ“ should set initialKeys hash to activated status (100ms)
    #createKeys
      βœ“ should only be called from initialized key (182ms)
      βœ“ params should not be equal to 0x0 (246ms)
      βœ“ params should not be equal to each other (149ms)
      βœ“ any of params should not be equal to initialKey (152ms)
      βœ“ should not allow passing the same key after it is already created (380ms)
      βœ“ should assign mining, voting, payout keys to relative mappings (171ms)
      βœ“ should assign voting <-> mining key and payout <-> mining key relationships (187ms)
      βœ“ adds validator to poaConsensus contract (154ms)
      βœ“ should set validatorKeys hash (165ms)
      βœ“ should set validatorKeys hash (247ms)
    #addMiningKey
      βœ“ may only be called if KeysManager.init had been called before (88ms)
      βœ“ should only be called from votingToChangeKeys (122ms)
      βœ“ should not let add more than maxLimit (50ms)
      βœ“ should set validatorKeys hash (108ms)
    #addVotingKey
      βœ“ may only be called if KeysManager.init had been called before (117ms)
      βœ“ may only be called if params are not the same (156ms)
      βœ“ should add VotingKey (179ms)
      βœ“ should only be called if mining is active (239ms)
      βœ“ swaps keys if voting already exists (238ms)
    #addPayoutKey
      βœ“ may only be called if KeysManager.init had been called before (145ms)
      βœ“ may only be called if params are not the same (143ms)
      βœ“ should add PayoutKey (169ms)
      βœ“ should only be called if mining is active (344ms)
      βœ“ swaps keys if voting already exists (251ms)
    #removeMiningKey
      βœ“ may only be called if KeysManager.init had been called before (181ms)
      βœ“ should remove miningKey (707ms)
      βœ“ removes validator from poaConsensus (348ms)
      βœ“ removes MoC from poaConsensus (1048ms)
      βœ“ should still enforce removal of votingKey to 0x0 even if voting key did not exist (308ms)
    #removeVotingKey
      βœ“ may only be called if KeysManager.init had been called before (216ms)
      βœ“ should be successful only for active voting key (229ms)
      βœ“ should remove votingKey (377ms)
    #removePayoutKey
      βœ“ may only be called if KeysManager.init had been called before (206ms)
      βœ“ should be successful only for active payout key (231ms)
      βœ“ should remove payoutKey (260ms)
    #swapMiningKey
      βœ“ should swap mining key (737ms)
      βœ“ should swap MoC (384ms)
      βœ“ should keep voting and payout keys (523ms)
    #swapVotingKey
      βœ“ should swap voting key (230ms)
    #swapPayoutKey
      βœ“ should swap payout key (283ms)
    #migrateInitialKey
      βœ“ can copy initial keys (445ms)
    #migrateMiningKey
      βœ“ copies validator keys (1228ms)
      βœ“ throws when trying to copy invalid mining key (205ms)
  Contract: ValidatorMetadata [all features]
    #createMetadata
      βœ“ happy path (170ms)
      βœ“ should not let create metadata if fullAddress is too long (200ms)
      βœ“ should not let create metadata if called by non-voting key (86ms)
      βœ“ should not let create metadata if called second time (153ms)
    #clearMetadata
      βœ“ happy path (770ms)
    #moveMetadata
      βœ“ happy path (1142ms)
    #initMetadata
      βœ“ happy path (441ms)
    #changeRequest
      βœ“ happy path (248ms)
      βœ“ should not let call if there is no metadata
      βœ“ resets confirmations when changeRequest recreated (515ms)
    #cancelPendingChange
      βœ“ happy path (473ms)
      βœ“ should not let delete records for someone else miningKey (490ms)
    #confirmPendingChange
      βœ“ should not let confirm your own changes (236ms)
      βœ“ should confirm changes (316ms)
      βœ“ prevent from double voting (337ms)
      βœ“ should not exceed confirmations limit (577ms)
    #finalize
      βœ“ happy path (758ms)
    #getMinThreshold
      βœ“ returns default value
    #upgradeTo
      βœ“ may only be called by ProxyStorage (82ms)
      βœ“ should change implementation address (79ms)
      βœ“ should increment implementation version (80ms)
      βœ“ new implementation should work (120ms)
      βœ“ new implementation should use the same proxyStorage address (80ms)
      βœ“ new implementation should use the same storage (321ms)
  Contract: ValidatorMetadata upgraded [all features]
    #createMetadata
      βœ“ happy path (169ms)
      βœ“ should not let create metadata if fullAddress is too long (210ms)
      βœ“ should not let create metadata if called by non-voting key (88ms)
      βœ“ should not let create metadata if called second time (145ms)
    #clearMetadata
      βœ“ happy path (677ms)
    #moveMetadata
      βœ“ happy path (1014ms)
    #initMetadata
      βœ“ happy path (553ms)
    #changeRequest
      βœ“ happy path (165ms)
      βœ“ should not let call if there is no metadata
      βœ“ resets confirmations when changeRequest recreated (495ms)
    #cancelPendingChange
      βœ“ happy path (586ms)
      βœ“ should not let delete records for someone else miningKey (490ms)
    #confirmPendingChange
      βœ“ should not let confirm your own changes (415ms)
      βœ“ should confirm changes (310ms)
      βœ“ prevent from double voting (383ms)
      βœ“ should not exceed confirmations limit (608ms)
    #finalize
      βœ“ happy path (760ms)
    #getMinThreshold
      βœ“ returns default value
  Contract: PoaNetworkConsensus [all features]
    default values
      βœ“ finalized should be false
      βœ“ checks systemAddress
      βœ“ allows you to set current list of validators (87ms)
      βœ“ validators in the list must differ (129ms)
    #finalizeChange
      βœ“ should only be called by systemAddress (79ms)
      βœ“ should set finalized to true (73ms)
      βœ“ should set currentValidators to pendingList (78ms)
      βœ“ set currentValidators to pendingList after addValidator call (301ms)
    #addValidator
      βœ“ should only be called from keys manager (63ms)
      βœ“ should not allow to add already existing validator (78ms)
      βœ“ should not allow 0x0 addresses (74ms)
      βœ“ should set validatorsState for new validator (80ms)
      βœ“ should set finalized to false (72ms)
      βœ“ should emit InitiateChange with blockhash and pendingList as params (284ms)
    #swapValidatorKey
      βœ“ should swap validator key (294ms)
      βœ“ should swap MoC (271ms)
    #removeValidator
      βœ“ should remove validator (95ms)
      βœ“ should remove MoC (249ms)
      βœ“ should only be called from keys manager (112ms)
      βœ“ should only be allowed to remove from existing set of validators (46ms)
      βœ“ should decrease length of pendingList (258ms)
      βœ“ should change validatorsState (100ms)
      βœ“ should set finalized to false (114ms)
    #setProxyStorage
      βœ“ can be called by MoC (62ms)
      βœ“ can be called by owner (67ms)
      βœ“ can only be called once
      βœ“ cannot be set to 0x0 address
      βœ“ sets proxyStorage (51ms)
      βœ“ sets wasProxyStorageSet (47ms)
      βœ“ emits MoCInitializedProxyStorage (38ms)
      βœ“ #getKeysManager (58ms)
    #isValidator
      βœ“ returns true for validator
    #isValidatorFinalized
      βœ“ returns true for finalized validator (1654ms)
  Contract: ProxyStorage [all features]
    #constructor
      βœ“ sets PoA
    #initializeAddresses
      βœ“ sets all addresses (158ms)
      βœ“ prevents Moc to call it more than once (89ms)
    #setContractAddress
      βœ“ can only be called from votingToChangeProxy address (93ms)
      βœ“ cannot be set to 0x0 address (69ms)
      βœ“ sets keysManager (142ms)
      βœ“ sets votingToChangeKeys (154ms)
      βœ“ sets votingToChangeMinThreshold (253ms)
      βœ“ sets ballotsStorage (142ms)
      βœ“ sets poaConsensus (81ms)
      βœ“ sets validatorMetadata (227ms)
      βœ“ changes proxyStorage (itself) implementation (205ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (itself) (119ms)
      βœ“ should change implementation address (115ms)
      βœ“ should increment implementation version (127ms)
      βœ“ new implementation should work (168ms)
      βœ“ new implementation should use the same storage (182ms)
  Contract: ProxyStorage upgraded [all features]
    #constructor
      βœ“ sets PoA
    #initializeAddresses
      βœ“ sets all addresses (165ms)
      βœ“ prevents Moc to call it more than once (81ms)
    #setContractAddress
      βœ“ can only be called from votingToChangeProxy address (180ms)
      βœ“ cannot be set to 0x0 address (67ms)
      βœ“ sets keysManager (158ms)
      βœ“ sets votingToChangeKeys (163ms)
      βœ“ sets votingToChangeMinThreshold (144ms)
      βœ“ sets ballotsStorage (253ms)
      βœ“ sets poaConsensus (81ms)
      βœ“ sets validatorMetadata (172ms)
      βœ“ changes proxyStorage (itself) implementation (145ms)
  Contract: RewardByBlock [all features]
    #reward
      βœ“ may only be called by system address (94ms)
      βœ“ should revert if input array contains more than one item
      βœ“ should revert if lengths of input arrays are not equal (38ms)
      βœ“ should revert if `kind` parameter is not 0
      βœ“ should revert if mining key does not exist (252ms)
      βœ“ should assign rewards to payout key and EmissionFunds (88ms)
      βœ“ should assign reward to mining key if payout key is 0 (143ms)
      βœ“ should assign rewards to extra receivers and clear extra receivers list (369ms)
    #addExtraReceiver
      βœ“ may only be called by bridge contract (59ms)
      βœ“ should revert if receiver address is 0x0
      βœ“ should revert if amount is 0 (39ms)
      βœ“ can only be called once for the same recipient (79ms)
      βœ“ should add receivers (214ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (111ms)
      βœ“ should change implementation address (111ms)
      βœ“ should increment implementation version (116ms)
      βœ“ new implementation should work (154ms)
      βœ“ new implementation should use the same proxyStorage address (112ms)
  Contract: RewardByBlock upgraded [all features]
    #reward
      βœ“ may only be called by system address (89ms)
      βœ“ should revert if input array contains more than one item
      βœ“ should revert if lengths of input arrays are not equal (46ms)
      βœ“ should revert if `kind` parameter is not 0 (48ms)
      βœ“ should revert if mining key does not exist (246ms)
      βœ“ should assign rewards to payout key and EmissionFunds (81ms)
      βœ“ should assign reward to mining key if payout key is 0 (121ms)
      βœ“ should assign rewards to extra receivers and clear extra receivers list (421ms)
    #addExtraReceiver
      βœ“ may only be called by bridge contract (68ms)
      βœ“ should revert if receiver address is 0x0 (45ms)
      βœ“ should revert if amount is 0 (47ms)
      βœ“ can only be called once for the same recipient (72ms)
      βœ“ should add receivers (199ms)
  Contract: RewardByTime [all features]
    #reward
      βœ“ may only be called by system address (152ms)
      βœ“ should assign rewards to payout keys and EmissionFunds (3292ms)
      βœ“ should work fine after some validators are removed and added (1355ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (108ms)
      βœ“ should change implementation address (111ms)
      βœ“ should increment implementation version (112ms)
      βœ“ new implementation should work (259ms)
      βœ“ new implementation should use the same proxyStorage address (113ms)
  Contract: RewardByTime upgraded [all features]
    #reward
      βœ“ may only be called by system address (150ms)
      βœ“ should assign rewards to payout keys and EmissionFunds (3160ms)
      βœ“ should work fine after some validators are removed and added (1459ms)
  Contract: Voting to change keys [all features]
    #createBallot
      βœ“ happy path (705ms)
      βœ“ should not let create voting with invalid duration (170ms)
      βœ“ should not let add votingKey for MoC (416ms)
      βœ“ should not let add votingKey for 0x0 (447ms)
      βœ“ should not let add payoutKey for 0x0 (588ms)
      βœ“ should not let create more ballots than the limit (10140ms)
    #createBallotToAddNewValidator
      βœ“ happy path (296ms)
      βœ“ deny adding already existed voting key
      βœ“ deny adding already existed payout key (199ms)
      βœ“ should create validator with all keys after finalization (1282ms)
      βœ“ should allow removing new validator if finalizeChange did not happen (2249ms)
    #vote
      βœ“ should let a validator to vote (194ms)
      βœ“ reject vote should be accepted (199ms)
      βœ“ should allow multiple voters to vote (875ms)
      βœ“ should not let vote nonVoting key (57ms)
      βœ“ should not let vote before startTime key (102ms)
      βœ“ should not let vote after endTime key (97ms)
      βœ“ should not let vote with already voted key (271ms)
      βœ“ should not let vote with invalid choice (267ms)
      βœ“ should not let vote with invalid id (170ms)
    #finalize
      βœ“ happy path - no action since it did not meet minimum number of totalVoters (803ms)
      βœ“ finalize addition of payout key (933ms)
      βœ“ finalize addition of VotingKey (1027ms)
      βœ“ cannot create ballot for using previous mining key (2257ms)
      βœ“ finalize addition of MiningKey (1144ms)
      βœ“ finalize removal of MiningKey (2097ms)
      βœ“ finalize removal of VotingKey (1237ms)
      βœ“ finalize removal of PayoutKey (1178ms)
      βœ“ finalize swap of VotingKey (1216ms)
      βœ“ finalize swap of PayoutKey (1178ms)
      βœ“ finalize swap of MiningKey (1373ms)
      βœ“ prevent double finalize (1841ms)
      βœ“ allowed at once after all validators gave their votes (1730ms)
    #migrate
      βœ“ should copy a ballot to the new contract (2013ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (98ms)
      βœ“ should change implementation address (101ms)
      βœ“ should increment implementation version (98ms)
      βœ“ new implementation should work (148ms)
      βœ“ new implementation should use the same proxyStorage address (186ms)
      βœ“ new implementation should use the same storage (963ms)
  Contract: Voting to change keys upgraded [all features]
    #createBallot
      βœ“ happy path (782ms)
      βœ“ should not let create voting with invalid duration (187ms)
      βœ“ should not let add votingKey for MoC (624ms)
      βœ“ should not let add votingKey for 0x0 (518ms)
      βœ“ should not let add payoutKey for 0x0 (480ms)
      βœ“ should not let create more ballots than the limit (10430ms)
    #createBallotToAddNewValidator
      βœ“ happy path (316ms)
      βœ“ deny adding already existed voting key
      βœ“ deny adding already existed payout key (227ms)
      βœ“ should create validator with all keys after finalization (1418ms)
      βœ“ should allow removing new validator if finalizeChange did not happen (2165ms)
    #vote
      βœ“ should let a validator to vote (190ms)
      βœ“ reject vote should be accepted (196ms)
      βœ“ should allow multiple voters to vote (831ms)
      βœ“ should not let vote nonVoting key (57ms)
      βœ“ should not let vote before startTime key (93ms)
      βœ“ should not let vote after endTime key (94ms)
      βœ“ should not let vote with already voted key (191ms)
      βœ“ should not let vote with invalid choice (179ms)
      βœ“ should not let vote with invalid id (173ms)
    #finalize
      βœ“ happy path - no action since it did not meet minimum number of totalVoters (830ms)
      βœ“ finalize addition of payout key (910ms)
      βœ“ finalize addition of VotingKey (1022ms)
      βœ“ cannot create ballot for using previous mining key (2234ms)
      βœ“ finalize addition of MiningKey (1023ms)
      βœ“ finalize removal of MiningKey (2017ms)
      βœ“ finalize removal of VotingKey (1237ms)
      βœ“ finalize removal of PayoutKey (1142ms)
      βœ“ finalize swap of VotingKey (1172ms)
      βœ“ finalize swap of PayoutKey (1155ms)
      βœ“ finalize swap of MiningKey (1503ms)
      βœ“ prevent double finalize (1828ms)
      βœ“ allowed at once after all validators gave their votes (1722ms)
    #migrate
      βœ“ should copy a ballot to the new contract (2024ms)
  Contract: VotingToChangeMinThreshold [all features]
    #createBallot
      βœ“ happy path (377ms)
      βœ“ proposed value should be more than or equal to 3
      βœ“ proposed value should not be equal to the same value
      βœ“ should not let create more ballots than the limit (10284ms)
    #vote
      βœ“ should let a validator to vote (181ms)
      βœ“ reject vote should be accepted (407ms)
      βœ“ should allow multiple voters to vote (422ms)
      βœ“ should not let vote nonVoting key (69ms)
      βœ“ should not let vote before startTime key (91ms)
      βœ“ should not let vote after endTime key (95ms)
      βœ“ should not let vote with already voted key (209ms)
      βœ“ should not let vote with invalid choice (166ms)
      βœ“ should not let vote with invalid id (169ms)
    #finalize
      βœ“ does not change if it did not pass minimum threshold (561ms)
      βœ“ should change to proposedValue when quorum is reached (1253ms)
      βœ“ prevents double finalize (1671ms)
      βœ“ allowed at once after all validators gave their votes (2039ms)
      βœ“ should decrease validator limit only once when calling finalize more than once (1589ms)
    #migrate
      βœ“ should copy a ballot to the new contract (1495ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (77ms)
      βœ“ should change implementation address (93ms)
      βœ“ should increment implementation version (91ms)
      βœ“ new implementation should work (120ms)
      βœ“ new implementation should use the same proxyStorage address (89ms)
      βœ“ new implementation should use the same storage (585ms)
  Contract: VotingToChangeMinThreshold upgraded [all features]
    #createBallot
      βœ“ happy path (271ms)
      βœ“ proposed value should be more than or equal to 3 (133ms)
      βœ“ proposed value should not be equal to the same value
      βœ“ should not let create more ballots than the limit (10305ms)
    #vote
      βœ“ should let a validator to vote (194ms)
      βœ“ reject vote should be accepted (190ms)
      βœ“ should allow multiple voters to vote (481ms)
      βœ“ should not let vote nonVoting key (51ms)
      βœ“ should not let vote before startTime key (108ms)
      βœ“ should not let vote after endTime key (108ms)
      βœ“ should not let vote with already voted key (193ms)
      βœ“ should not let vote with invalid choice (182ms)
      βœ“ should not let vote with invalid id (262ms)
    #finalize
      βœ“ does not change if it did not pass minimum threshold (560ms)
      βœ“ should change to proposedValue when quorum is reached (1312ms)
      βœ“ prevents double finalize (1806ms)
      βœ“ allowed at once after all validators gave their votes (2331ms)
      βœ“ should decrease validator limit only once when calling finalize more than once (1595ms)
    #migrate
      βœ“ should copy a ballot to the new contract (1508ms)
  Contract: VotingToChangeProxyAddress [all features]
    #createBallot
      βœ“ happy path (278ms)
      βœ“ proposed address should not be 0x0
      βœ“ can create multiple ballots (489ms)
      βœ“ should not let create more ballots than the limit (9893ms)
    #vote
      βœ“ should let a validator to vote (183ms)
      βœ“ reject vote should be accepted (284ms)
      βœ“ should allow multiple voters to vote (852ms)
      βœ“ should not let vote nonVoting key (52ms)
      βœ“ should not let vote before startTime key (103ms)
      βœ“ should not let vote after endTime key (97ms)
      βœ“ should not let vote with already voted key (195ms)
      βœ“ should not let vote with invalid choice (181ms)
      βœ“ should not let vote with invalid id (180ms)
    #finalize
      βœ“ does not change if it did not pass minimum threshold (598ms)
      βœ“ should change KeysManager implementation (920ms)
      βœ“ should change VotingToChangeKeys implementation (1053ms)
      βœ“ should change VotingToChangeMinThreshold implementation (995ms)
      βœ“ should change VotingToChangeProxy implementation (1083ms)
      βœ“ should change BallotsStorage implementation (1075ms)
      βœ“ should change ValidatorMetadata implementation (1062ms)
      βœ“ should change ProxyStorage implementation (1068ms)
      βœ“ prevents double finalize (1513ms)
      βœ“ allowed at once after all validators gave their votes (1768ms)
    #migrate
      βœ“ should copy a ballot to the new contract (1995ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (88ms)
      βœ“ should change implementation address (87ms)
      βœ“ should increment implementation version (113ms)
      βœ“ new implementation should work (139ms)
      βœ“ new implementation should use the same proxyStorage address (86ms)
      βœ“ new implementation should use the same storage (620ms)
  Contract: VotingToChangeProxyAddress upgraded [all features]
    #createBallot
      βœ“ happy path (395ms)
      βœ“ proposed address should not be 0x0 (119ms)
      βœ“ can create multiple ballots (394ms)
      βœ“ should not let create more ballots than the limit (10105ms)
    #vote
      βœ“ should let a validator to vote (179ms)
      βœ“ reject vote should be accepted (194ms)
      βœ“ should allow multiple voters to vote (805ms)
      βœ“ should not let vote nonVoting key (55ms)
      βœ“ should not let vote before startTime key (103ms)
      βœ“ should not let vote after endTime key (213ms)
      βœ“ should not let vote with already voted key (224ms)
      βœ“ should not let vote with invalid choice (225ms)
      βœ“ should not let vote with invalid id (196ms)
    #finalize
      βœ“ does not change if it did not pass minimum threshold (684ms)
      βœ“ should change KeysManager implementation (1177ms)
      βœ“ should change VotingToChangeKeys implementation (1182ms)
      βœ“ should change VotingToChangeMinThreshold implementation (1065ms)
      βœ“ should change VotingToChangeProxy implementation (1115ms)
      βœ“ should change BallotsStorage implementation (985ms)
      βœ“ should change ValidatorMetadata implementation (1082ms)
      βœ“ should change ProxyStorage implementation (1080ms)
      βœ“ prevents double finalize (1522ms)
      βœ“ allowed at once after all validators gave their votes (1686ms)
    #migrate
      βœ“ should copy a ballot to the new contract (2022ms)
  Contract: VotingToManageEmissionFunds [all features]
    #init
      βœ“ should change state correctly (119ms)
      βœ“ cannot be called more than once
    #createBallot
      βœ“ happy path (866ms)
      βœ“ may only be called by valid voting key (139ms)
      βœ“ endTime must be greater than startTime
      βœ“ startTime must be greater than current time (39ms)
      βœ“ cannot be called before emission release time (64ms)
      βœ“ ballot cannot last longer than distribution threshold (55ms)
      βœ“ receiver address should not be 0x0 (64ms)
      βœ“ cannot create multiple ballots during the same distribution period (435ms)
      βœ“ should allow creating new ballot after the next emission release threshold (490ms)
    #cancelNewBallot
      βœ“ happy path (880ms)
      βœ“ cannot cancel nonexistent or finalized ballot (341ms)
      βœ“ may only be called by creator of a ballot (232ms)
      βœ“ may only be called within ballot canceling threshold (265ms)
      βœ“ cannot cancel already cancelled ballot (221ms)
      βœ“ should restore emission release time (493ms)
    #refreshEmissionReleaseTime
      βœ“ should not update until the next threshold (130ms)
      βœ“ should update to the next threshold (72ms)
      βœ“ should update to the future threshold (86ms)
    #vote
      βœ“ should let a validator to vote (959ms)
      βœ“ should allow multiple voters to vote (1497ms)
      βœ“ should not let vote by nonvoting key (57ms)
      βœ“ should not let vote before startTime (94ms)
      βœ“ should not let vote after endTime (260ms)
      βœ“ should not let vote with already voted key (207ms)
      βœ“ should not let vote with invalid choice (152ms)
      βœ“ should not let vote with invalid id (164ms)
      βœ“ should not let vote if already finalized (1535ms)
      βœ“ should not let vote with old miningKey (2431ms)
      βœ“ should not let vote if ballot is canceled (256ms)
    #finalize
      βœ“ happy path (591ms)
      βœ“ freeze funds if it did not pass minimum voters count (1036ms)
      βœ“ freeze funds if there is no majority of 3 votes (1322ms)
      βœ“ freeze funds if there is no majority of 4 votes (1678ms)
      βœ“ send funds to receiver if most votes are for sending (2089ms)
      βœ“ send funds to receiver if most votes are for sending (1749ms)
      βœ“ burn funds if most votes are for burning (1704ms)
      βœ“ prevents finalize with invalid id (280ms)
      βœ“ do not let finalize if a ballot is active (189ms)
      βœ“ finalize immediately if the last validator gave his vote (1187ms)
      βœ“ does not finalize immediately until ballot canceling threshold is reached (1236ms)
      βœ“ prevents double finalize (279ms)
      βœ“ should refresh emission release time (256ms)
      βœ“ deny finalization if the voting key is a contract (703ms)
      βœ“ deny finalization within ballot canceling threshold (301ms)
      βœ“ deny finalization of canceled ballot (461ms)
    #upgradeTo
      βœ“ may only be called by ProxyStorage (91ms)
      βœ“ should change implementation address (92ms)
      βœ“ should increment implementation version (91ms)
      βœ“ new implementation should work (129ms)
      βœ“ new implementation should use the same proxyStorage address (92ms)
      βœ“ new implementation should use the same storage (960ms)
  Contract: VotingToManageEmissionFunds upgraded [all features]
    #init
      βœ“ should change state correctly (111ms)
      βœ“ cannot be called more than once
    #createBallot
      βœ“ happy path (835ms)
      βœ“ may only be called by valid voting key (142ms)
      βœ“ endTime must be greater than startTime (45ms)
      βœ“ startTime must be greater than current time (126ms)
      βœ“ cannot be called before emission release time (64ms)
      βœ“ ballot cannot last longer than distribution threshold (41ms)
      βœ“ receiver address should not be 0x0 (52ms)
      βœ“ cannot create multiple ballots during the same distribution period (467ms)
      βœ“ should allow creating new ballot after the next emission release threshold (464ms)
    #cancelNewBallot
      βœ“ happy path (878ms)
      βœ“ cannot cancel nonexistent or finalized ballot (300ms)
      βœ“ may only be called by creator of a ballot (290ms)
      βœ“ may only be called within ballot canceling threshold (250ms)
      βœ“ cannot cancel already cancelled ballot (244ms)
      βœ“ should restore emission release time (601ms)
    #refreshEmissionReleaseTime
      βœ“ should not update until the next threshold (129ms)
      βœ“ should update to the next threshold (273ms)
      βœ“ should update to the future threshold (72ms)
    #vote
      βœ“ should let a validator to vote (842ms)
      βœ“ should allow multiple voters to vote (1572ms)
      βœ“ should not let vote by nonvoting key (60ms)
      βœ“ should not let vote before startTime (89ms)
      βœ“ should not let vote after endTime (253ms)
      βœ“ should not let vote with already voted key (202ms)
      βœ“ should not let vote with invalid choice (173ms)
      βœ“ should not let vote with invalid id (155ms)
      βœ“ should not let vote if already finalized (1404ms)
      βœ“ should not let vote with old miningKey (2283ms)
      βœ“ should not let vote if ballot is canceled (152ms)
    #finalize
      βœ“ happy path (569ms)
      βœ“ freeze funds if it did not pass minimum voters count (1142ms)
      βœ“ freeze funds if there is no majority of 3 votes (1393ms)
      βœ“ freeze funds if there is no majority of 4 votes (1872ms)
      βœ“ send funds to receiver if most votes are for sending (2304ms)
      βœ“ send funds to receiver if most votes are for sending (1816ms)
      βœ“ burn funds if most votes are for burning (1898ms)
      βœ“ prevents finalize with invalid id (209ms)
      βœ“ do not let finalize if a ballot is active (211ms)
      βœ“ finalize immediately if the last validator gave his vote (1281ms)
      βœ“ does not finalize immediately until ballot canceling threshold is reached (1316ms)
      βœ“ prevents double finalize (292ms)
      βœ“ should refresh emission release time (265ms)
      βœ“ deny finalization if the voting key is a contract (737ms)
      βœ“ deny finalization within ballot canceling threshold (305ms)
      βœ“ deny finalization of canceled ballot (284ms)
  598 passing (18m)

About

Main repository for POADAO consensus. Includes contracts for Initial Ceremony, Governance, Management of Validators

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6