Vote ext handler and keyregistry user/validator map seperation#5
Vote ext handler and keyregistry user/validator map seperation#5yusufozmis wants to merge 28 commits intodevelopmentfrom
Conversation
abci/extend_vote.go
Outdated
| } | ||
| ctx.Logger().Info("Vote extension for block", "voteExt", voteExt) | ||
|
|
||
| return MinaSignatureVoteExt{}, nil |
There was a problem hiding this comment.
Niye boş vote extension dönüyor?
abci/extend_vote.go
Outdated
| func (h *VoteExtHandler) constructVoteExtBody(ctx sdk.Context, req *abci.RequestExtendVote, hash poseidon.Poseidon) (voteexthandler.Body, error) { | ||
|
|
||
| // Get validator updates from the pending changes | ||
| validatorUpdates, err := h.stakingKeeper.GetValidatorUpdates(ctx) |
There was a problem hiding this comment.
Consumer'a geçeceğimiz zaten değiştirmemiz gerek diye TODO bırak
abci/extend_vote.go
Outdated
| }) | ||
| } | ||
|
|
||
| ctx.Logger().Info("Successfully got all cc validators", "ccValidators", initialValidators) |
abci/extend_vote.go
Outdated
| } | ||
|
|
||
| func (h *VoteExtHandler) wrapValidatorInfo(ctx sdk.Context) ([]ValidatorInfo, error) { | ||
| // Get all Cross-chain validators |
There was a problem hiding this comment.
Bu comment line'daki Cross-chain ve diğer comment linelardaki benzer ifadeleri ("CC" mesela kaldıralım)
abci/extend_vote.go
Outdated
|
|
||
| initialValidators = append(initialValidators, ValidatorInfo{ | ||
| MinaAddress: string(minaPubKey), | ||
| Power: validator.GetConsensusPower(math.Int{}), // ?? |
There was a problem hiding this comment.
Boş math.Int{} vermek yerine Staking Keeper'ın PowerReduction() metodunu kullanıp onun output'unu vermeliyiz buna.
abci/extend_vote.go
Outdated
|
|
||
| func (h *VoteExtHandler) wrapValidatorInfo(ctx sdk.Context) ([]ValidatorInfo, error) { | ||
| // Get all Cross-chain validators | ||
| validators, err := h.stakingKeeper.GetAllValidators(ctx) |
There was a problem hiding this comment.
Bunun yerine Staking Keeper'ın IterateLastValidators metodunu kullanarak bütün validatör setinin aktif olan kısmını gezmeliyiz.
abci/extend_vote.go
Outdated
| // Convert CCValidators to ValidatorInfo format | ||
| initialValidators := make([]ValidatorInfo, 0, len(validators)) | ||
| for _, validator := range validators { | ||
| consAddr := sdk.ConsAddress(validator.OperatorAddress) |
There was a problem hiding this comment.
Böyle yapmak yerine burayı IterateLastValidators'a geçirince - o sana ValidatorI interface'inde değerler verecek - GetConsAddr() metodunu kullanıp consAddr'ı elde etmeliyiz.
abci/extend_vote.go
Outdated
| Signature: sigBytes, | ||
| VoteExtBody: extBody, | ||
| } | ||
| ctx.Logger().Info("Vote extension for block", "voteExt", voteExt) |
There was a problem hiding this comment.
Test amaçlı kullanabilirsin ama işin bittiğin kaldırıver.
abci/helpers.go
Outdated
| votes: make(map[uint64]map[string][]byte), | ||
| } | ||
| } | ||
| func GetSecondaryKeys(appOpts servertypes.AppOptions) types.SecondaryKey { |
There was a problem hiding this comment.
Böyle bir metodun olmaması lazım. NewVoteExtHandler zaten bir SecondaryKey alıyor. O SecondaryKey'i app.toml'dan app.go'nun içinde alıp sonra da NewVoteExtHandler'ın parametresi olarak vermeliyiz.
abci/prepare_proposal.go
Outdated
| // A simple JSON payload prefixed by "VOTEEXT:" is used; this is *not* part of | ||
| // consensus state and will be verified by ProcessProposal on peers. | ||
| func (h *VoteExtHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { | ||
| type payload struct { |
There was a problem hiding this comment.
Bu payload'un aynısını process_proposal'da da kullanıyoruz, bunu bir public bi tip haline getirmek lazım.
abci/helpers.go
Outdated
|
|
||
| func NewVoteExtHandler(keyregistryKeeper keyregistrykeeper.Keeper, | ||
| voteextKeeper voteextkeeper.Keeper, | ||
| minaPrivateKey *types.SecondaryKey) *VoteExtHandler { |
There was a problem hiding this comment.
"if minaPrivateKey == nil" check'i koy buraya ve nil ise panic'le.
| votes map[uint64]map[string][]byte // height -> consAddr -> extension bytes | ||
| } | ||
|
|
||
| func NewVoteExtHandler(keyregistryKeeper keyregistrykeeper.Keeper, |
There was a problem hiding this comment.
Fonksiyon staking keeper da almalı parametre olarak.
| return &VoteExtHandler{ | ||
| keyregistryKeeper: keyregistryKeeper, | ||
| voteextKeeper: voteextKeeper, | ||
| MinaPrivateKey: minaPrivateKey, |
There was a problem hiding this comment.
Burada da aldığın staking keeper'ı set etmelisin, bunu unutma.
|
|
||
| secondaryKey := vote_ext.GetSecondaryKeys(appOpts) | ||
|
|
||
| app.VoteExtHandler = vote_ext.NewVoteExtHandler( |
There was a problem hiding this comment.
Burada da staking keeper'ı parametre olarak vermelisin.
No description provided.