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

En 8340/selection at end of epoch #2541

Merged

Conversation

sasurobert
Copy link
Contributor

logic has been implemented - tests and fixes of broken tests in next commits

@AdoAdoAdo AdoAdoAdo self-requested a review December 3, 2020 08:11
epochStart/metachain/stakingDataProvider.go Show resolved Hide resolved
if len(waitingKeys) > 0 {
selectedKeys = append(selectedKeys, eligibleKeys...)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it's a good idea to sort the selectedKeys slice so the reslice on L360 will always trim the same nodes based on their keys? Kind of a way for a validator to predict each time which node will be unstaked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe yes.

}

var vmOutput *vmcommon.VMOutput
for _, blsKey := range nodesToUnStake {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be another function as to keep the same abstraction level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -910,7 +1101,8 @@ func (s *systemSCProcessor) EpochConfirmed(epoch uint32) {
s.flagDelegationEnabled.Toggle(epoch == s.delegationEnableEpoch)
log.Debug("systemSCProcessor: delegation", "enabled", epoch >= s.delegationEnableEpoch)

s.flagStakingV2Enabled.Toggle(epoch == s.stakingV2EnableEpoch)
s.flagSetOwnerEnabled.Toggle(epoch == s.stakingV2EnableEpoch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need an additional flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One has to be called only once. The other at every start of epoch. Activated by the same enabled epoch value


validatorInfo := &state.ValidatorInfo{
PublicKey: blsKey,
ShardId: peerAcc.GetShardId(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What shardID would they have here, is it default "0"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 0. It does not really matter :) as shuffler will put the actual ID a little later

@@ -809,7 +980,11 @@ func (s *systemSCProcessor) updateSystemSCContractsCode(contractMetadata []byte)
return nil
}

func (s *systemSCProcessor) stakeNodesFromWaitingList(nodesToStake uint32, nonce uint64) error {
func (s *systemSCProcessor) stakeNodesFromWaitingList(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to stakeNodesFromStakingQueue
not to be confused with the shards waiting lists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return nil, nil, nil, fmt.Errorf("%w, error: totalStaked string returned is not a number", epochStart.ErrExecutingSystemScCode)
}

return topUpValue, totalStakedValue, vmOutput.ReturnData[2:], nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the "leaving" keys also among the returned keys here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the blsKeys are returned. Everything which was registered

@sasurobert sasurobert merged commit 5e15225 into feat/staking-delegation-v2 Dec 4, 2020
@sasurobert sasurobert deleted the EN-8340/Selection-at-end-of-epoch branch December 4, 2020 12:27
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

Successfully merging this pull request may close these issues.

None yet

3 participants