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

Support dymint signatures verification + add dymint to the default-al… #23

Merged
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: 2 additions & 2 deletions modules/core/02-client/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

var (
// DefaultAllowedClients are "06-solomachine" and "07-tendermint"
DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint}
// DefaultAllowedClients are "01-dymint", "06-solomachine" and "07-tendermint"
DefaultAllowedClients = []string{exported.Dymint, exported.Solomachine, exported.Tendermint}

// KeyAllowedClients is store's key for AllowedClients Params
KeyAllowedClients = []byte("AllowedClients")
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/01-dymint/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func (h Header) ValidateBasic() error {

// ValidateCommit checks if the given commit is a valid commit from the passed-in validatorset
func (h Header) ValidateCommit() (err error) {
chainID := h.Header.ChainID
blockID, err := tmtypes.BlockIDFromProto(&h.SignedHeader.Commit.BlockID)
if err != nil {
return sdkerrors.Wrap(err, "invalid block ID from header SignedHeader.Commit")
Expand Down Expand Up @@ -116,15 +115,16 @@ func (h Header) ValidateCommit() (err error) {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "validator set did not commit to header")
}
// Validate signature.
voteSignBytes := tmCommit.VoteSignBytes(chainID, valIdx)
if !bytes.Equal(commitSig.ValidatorAddress, h.Header.ProposerAddress) {
return fmt.Errorf("wrong proposer address in commit, got %X) but expected %X", valIdx, h.Header.ProposerAddress)
}
if !val.PubKey.VerifySignature(voteSignBytes, commitSig.Signature) {
headerBytes, err := h.SignedHeader.Header.Marshal()
if err != nil {
return err
}
if !val.PubKey.VerifySignature(headerBytes, commitSig.Signature) {
return fmt.Errorf("wrong signature (#%d): %X", valIdx, commitSig.Signature)
}
} else {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "validator set did not commit to header")
}

return nil
Expand Down