Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request for AuRa: using getPendingValidators() getter instead of InitiateChange event #49

Closed
varasev opened this issue Dec 12, 2018 · 10 comments
Assignees

Comments

@varasev
Copy link

varasev commented Dec 12, 2018

We agreed that we'll use the getValidators() getPendingValidators() getter instead of catching the InitiateChange event. Parity should just read the current validator set with getValidators() getPendingValidators() every block, and if it discovers that the set is changed in the contract, it launches changing of the set in the engine.

The finalizeChange() function (described in https://wiki.parity.io/Validator-Set.html) should be called by Parity after newValidatorSet() is called and the internal list of validators is updated in engine (this is default behavior for AuRa in Parity, so I think the code of the engine shouldn't be changed for that).

UPDATE: stroke out things below are already implemented by the contracts.

Parity must call newValidatorSet() function by SYSTEM_ADDRESS once a week.

Since in AuRa the block time is determined (5 seconds), the ValidatorSet contract will keep track of elapsed time by itself, so there is no need to measure 1 week in Parity.

1 week = 120960 blocks

Parity must call the newValidatorSetCallable() getter every block and check whether to call newValidatorSet.

So, if newValidatorSetCallable() returns true, the newValidatorSet() must be called at the end of the current block.

Important note: transaction of calling newValidatorSet() must be included in a block before transaction of calling BlockReward.reward().

@varasev
Copy link
Author

varasev commented Dec 14, 2018

The description ⬆️ was updated:

  1. I propose not to measure 1 week (duration of staking epoch) in Parity. We can do this in the contract.

  2. It seems that Parity already uses getValidators() getter to verify that the internal list of validators is the same as the list in the contract. The internal list and contract's list should be identical. So, we need to use a getter with another name: getPendingValidators().

I'll update the contract's code accordingly.

varasev added a commit to poanetwork/posdao-contracts that referenced this issue Dec 17, 2018
@DrPeterVanNostrand DrPeterVanNostrand self-assigned this Dec 18, 2018
@varasev
Copy link
Author

varasev commented Dec 25, 2018

Important note: transaction of calling newValidatorSet() must be included in a block before transaction of calling BlockReward.reward().

@DemiMarie
Copy link

@varasev can it be called by BlockReward.reward()?

@varasev
Copy link
Author

varasev commented Dec 28, 2018

@DemiMarie hmm, it's a good proposal. I'll check if this breaks something in the code. Thanks for the thought.

@DemiMarie
Copy link

@varasev The first thing that newValidatorSet() does is

require(newValidatorSetCallable());

So we can just change it to:

if (!newValidatorSetCallable()) {
    // do nothing
    return;
}

and just call it from BlockRewardAuRa.reward().

@varasev varasev changed the title Feature request for AuRa: newValidatorSet Feature request for AuRa: using getPendingValidators() getter instead of InitiateChange event Dec 30, 2018
@varasev
Copy link
Author

varasev commented Dec 30, 2018

Yes, I've modified the contracts in accordance with this: https://github.com/poanetwork/pos-contracts/blob/8d10a85ad87633a54a7444883b32687faf5b80bf/contracts/BlockRewardAuRa.sol#L38-L39

So, now we don't have to modify the AuRa source code for calling newValidatorSet().

However, we still need to read getPendingValidators() instead of InitiateChange event.

I've updated the description above and changed the title.

@DemiMarie
Copy link

Fixed by #53

@afck
Copy link
Collaborator

afck commented Jan 24, 2019

Reopening; see #71 (comment).

@afck afck reopened this Jan 24, 2019
@afck
Copy link
Collaborator

afck commented Jan 28, 2019

@DemiMarie, @varasev: I see this has been reverted on aura-pos. I guess it can be closed again, in favor of #71?

@varasev
Copy link
Author

varasev commented Jan 28, 2019

@afck Yes, I'm closing this.

@varasev varasev closed this as completed Jan 28, 2019
Oyase-shinobi pushed a commit to Oyase-shinobi/hbbft-posdao-contracts that referenced this issue Jun 12, 2024
crypto523 pushed a commit to crypto523/posdao-contracts that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants