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

tendermint: set value to TotalVotingPower #76

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion chains/tendermint/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ func (pr *Prover) GetLightSignedHeaderAtHeight(height int64) (*tmclient.Header,
return nil, err
}

protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

return &tmclient.Header{SignedHeader: sh.SignedHeader.ToProto(), ValidatorSet: protoVal}, nil
}
Expand Down
8 changes: 6 additions & 2 deletions chains/tendermint/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ func (pr *Prover) UpdateLightWithHeader() (header core.HeaderI, provableHeight i
}
}

protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, 0, 0, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

h := &tmclient.Header{
SignedHeader: sh.SignedHeader.ToProto(),
Expand Down Expand Up @@ -237,10 +239,12 @@ func (c *Prover) queryHeaderAtHeight(height int64) (*tmclient.Header, error) {
return nil, err
}

protoVal, err := tmtypes.NewValidatorSet(val.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(val.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

return &tmclient.Header{
// NOTE: This is not a SignedHeader
Expand Down
7 changes: 6 additions & 1 deletion chains/tendermint/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ func (c *Chain) QueryValsetAtHeight(height clienttypes.Height) (*tmproto.Validat
}
tmValSet.GetProposer()

return tmValSet.ToProto()
protoValSet, err := tmValSet.ToProto()
if err != nil {
return nil, err
}
protoValSet.TotalVotingPower = tmValSet.TotalVotingPower()
return protoValSet, err
}

func (c *Chain) toTmValidators(vals stakingtypes.Validators) ([]*tmtypes.Validator, error) {
Expand Down