Skip to content

Vote ext handler and keyregistry user/validator map seperation#5

Open
yusufozmis wants to merge 28 commits intodevelopmentfrom
vote-ext-handler
Open

Vote ext handler and keyregistry user/validator map seperation#5
yusufozmis wants to merge 28 commits intodevelopmentfrom
vote-ext-handler

Conversation

@yusufozmis
Copy link
Copy Markdown
Member

No description provided.

@yusufozmis yusufozmis changed the title Vote ext handler Vote ext handler and keyregistry user/validator map seperation Mar 13, 2026
@yusufozmis yusufozmis requested a review from korayakpinar March 13, 2026 20:36
}
ctx.Logger().Info("Vote extension for block", "voteExt", voteExt)

return MinaSignatureVoteExt{}, nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Niye boş vote extension dönüyor?

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consumer'a geçeceğimiz zaten değiştirmemiz gerek diye TODO bırak

})
}

ctx.Logger().Info("Successfully got all cc validators", "ccValidators", initialValidators)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bu log'u kaldırabiliriz.

}

func (h *VoteExtHandler) wrapValidatorInfo(ctx sdk.Context) ([]ValidatorInfo, error) {
// Get all Cross-chain validators
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bu comment line'daki Cross-chain ve diğer comment linelardaki benzer ifadeleri ("CC" mesela kaldıralım)


initialValidators = append(initialValidators, ValidatorInfo{
MinaAddress: string(minaPubKey),
Power: validator.GetConsensusPower(math.Int{}), // ??
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Boş math.Int{} vermek yerine Staking Keeper'ın PowerReduction() metodunu kullanıp onun output'unu vermeliyiz buna.


func (h *VoteExtHandler) wrapValidatorInfo(ctx sdk.Context) ([]ValidatorInfo, error) {
// Get all Cross-chain validators
validators, err := h.stakingKeeper.GetAllValidators(ctx)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bunun yerine Staking Keeper'ın IterateLastValidators metodunu kullanarak bütün validatör setinin aktif olan kısmını gezmeliyiz.

// Convert CCValidators to ValidatorInfo format
initialValidators := make([]ValidatorInfo, 0, len(validators))
for _, validator := range validators {
consAddr := sdk.ConsAddress(validator.OperatorAddress)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Böyle yapmak yerine burayı IterateLastValidators'a geçirince - o sana ValidatorI interface'inde değerler verecek - GetConsAddr() metodunu kullanıp consAddr'ı elde etmeliyiz.

Signature: sigBytes,
VoteExtBody: extBody,
}
ctx.Logger().Info("Vote extension for block", "voteExt", voteExt)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

// 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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"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,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fonksiyon staking keeper da almalı parametre olarak.

return &VoteExtHandler{
keyregistryKeeper: keyregistryKeeper,
voteextKeeper: voteextKeeper,
MinaPrivateKey: minaPrivateKey,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Burada da aldığın staking keeper'ı set etmelisin, bunu unutma.


secondaryKey := vote_ext.GetSecondaryKeys(appOpts)

app.VoteExtHandler = vote_ext.NewVoteExtHandler(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Burada da staking keeper'ı parametre olarak vermelisin.

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.

2 participants