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

All eligible validators are included in the validator set at genesis #3177

Closed
kostko opened this issue Aug 6, 2020 · 0 comments · Fixed by #3759
Closed

All eligible validators are included in the validator set at genesis #3177

kostko opened this issue Aug 6, 2020 · 0 comments · Fixed by #3759
Assignees
Labels
c:bug Category: bug c:consensus/tendermint Category: Tendermint-based consensus

Comments

@kostko
Copy link
Member

kostko commented Aug 6, 2020

Currently it seems that all eligible validator nodes are included in the validator set at genesis instead of the top K. We should instead run the election algorithm to derive the initial set.

Reference:

var tmValidators []tmtypes.GenesisValidator
for _, v := range d.Registry.Nodes {
var openedNode node.Node
if err = v.Open(registry.RegisterGenesisNodeSignatureContext, &openedNode); err != nil {
return nil, fmt.Errorf("tendermint: failed to verify validator: %w", err)
}
// TODO: This should cross check that the entity is valid.
if !openedNode.HasRoles(node.RoleValidator) {
continue
}
var power int64
if d.Scheduler.Parameters.DebugBypassStake {
power = 1
} else {
var stake *quantity.Quantity
acctAddr := staking.NewAddress(openedNode.EntityID)
if account, ok := d.Staking.Ledger[acctAddr]; ok {
stake = account.Escrow.Active.Balance.Clone()
} else {
// If all balances and stuff are zero, it's permitted not to have an account in the ledger at all.
stake = &quantity.Quantity{}
}
power, err = scheduler.VotingPowerFromStake(stake)
if err != nil {
return nil, fmt.Errorf("tendermint: computing voting power for entity %s with account %s and stake %v: %w",
openedNode.EntityID,
acctAddr,
stake,
err,
)
}
}
pk := crypto.PublicKeyToTendermint(&openedNode.Consensus.ID)
validator := tmtypes.GenesisValidator{
Address: pk.Address(),
PubKey: pk,
Power: power,
Name: "oasis-validator-" + openedNode.ID.String(),
}
tmValidators = append(tmValidators, validator)
}

@kostko kostko added c:consensus/tendermint Category: Tendermint-based consensus c:bug Category: bug labels Aug 6, 2020
@abukosek abukosek self-assigned this Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:bug Category: bug c:consensus/tendermint Category: Tendermint-based consensus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants