poanetwork / poa-network-consensus-contracts

Main repository for POADAO consensus. Includes contracts for Initial Ceremony, Governance, Management of Validators
GNU General Public License v3.0
68 stars 64 forks source link

Question about PoaNetworkConsensus contract validator states #206

Open ngyam opened 5 years ago

ngyam commented 5 years ago

Hi,

When a validator is added, but it is still pending (not finalized), why is it already considered a validator? The isValidator call on it returns true already if pending. For Kovan, the validator is only an isValidator if it is in the finalized validators list. What is the reason behind this different approach? https://github.com/poanetwork/poa-network-consensus-contracts/blob/master/contracts/PoaNetworkConsensus.sol#L212 https://github.com/poanetwork/poa-network-consensus-contracts/blob/master/contracts/PoaNetworkConsensus.sol#L178 https://github.com/parity-contracts/kovan-validator-set/blob/master/contracts/interfaces/BaseOwnedSet.sol#L66

varasev commented 5 years ago

Hi @ngyam,

Yes, you're right, the isValidator shouldn't return true until the pending validator set is not finalized (the finalizeChange is called). The isValidator is lying for the newly added or removed validator in the period of time when the validator set is already changed but not yet finalized (several blocks between callings of the addValidator and finalizeChange).

We, unfortunately, missed this moment and didn't fix it when we were working on the last hard fork. However, the isValidatorFinalized getter can be used instead to determine if the specified address is a finalized validator.

For the current version of PoaNetworkConsensus contract, it's recommended to use the getValidators() getter: if some address is in the current validator set, that address will be in the returned array of the getValidators(). The getValidators() always returns an actual validator set taking into account the finalization.

Thank you for this issue - we should fix this when we have next hard fork which we'll ever do.

ngyam commented 5 years ago

Hi @varasev Thanks for the clarification!