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

remove tendermint keys & toTMPubkey interface #7635

Closed
wants to merge 0 commits into from

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Oct 22, 2020

Description

Removes reliance on tendermint Pubkeys.
Removes totmPubkey interface

closes: #7529


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@@ -18,8 +18,8 @@ import (
//-------------------------------------

const (
PrivKeyName = "cosmos/PrivKeyEd25519"
PubKeyName = "cosmos/PubKeyEd25519"
PrivKeyName = "tendermint/PrivKeyEd25519"
Copy link
Member Author

@tac0turtle tac0turtle Oct 22, 2020

Choose a reason for hiding this comment

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

had to revert this to support backwards compatibility

Copy link
Collaborator

Choose a reason for hiding this comment

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

who is relaying on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

now that i think some more about it, it may not be needed, will test locally

@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #7635 into master will increase coverage by 5.63%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #7635      +/-   ##
==========================================
+ Coverage   54.21%   59.84%   +5.63%     
==========================================
  Files         611      317     -294     
  Lines       38464    17983   -20481     
==========================================
- Hits        20852    10762   -10090     
+ Misses      15503     6073    -9430     
+ Partials     2109     1148     -961     

@@ -29,9 +28,6 @@ func RegisterCrypto(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
// TODO Same as above, for ED25519
cdc.RegisterConcrete(tmed25519.PubKey{},
Copy link
Member Author

Choose a reason for hiding this comment

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

Now we use sdk keys in the sdk and make them tm proto keys when we send them to Tendermint.


// PubKeyToProto takes a crypto.Pubkey and sets it into tendermint's public key oneof
// This is only used when sending information about validators to Tendermint (validator updates)
func PubKeyToProto(k tmcrypto.PubKey) (protocrypto.PublicKey, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func PubKeyToProto(k tmcrypto.PubKey) (protocrypto.PublicKey, error) {
func PubKeyToProto(k cryptotypes.PubKey) (protocrypto.PublicKey, error) {

So all in all:

  • in the SDK, we manipulate cryptotypes.PubKey (our own PubKey)
  • whenever we need to use a TM interface (validator updates, tmtypes.NewValidator...), we call this function to convert to protocrypto.PublicKey

In this case, the SDK should never have to use tmcrypto.PubKey, is that correct?


// IntoTmPubKey allows our own PubKey types be converted into Tendermint's
// pubkey types.
type IntoTmPubKey interface {
Copy link
Contributor

@amaury1093 amaury1093 Oct 23, 2020

Choose a reason for hiding this comment

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

sounds good. A centralized function PubKeyToProto to make the conversion SDK-TM pubkeys is indeed probably a cleaner way to do thinngs.

@@ -18,8 +18,8 @@ import (
//-------------------------------------

const (
PrivKeyName = "cosmos/PrivKeyEd25519"
PubKeyName = "cosmos/PubKeyEd25519"
PrivKeyName = "tendermint/PrivKeyEd25519"
Copy link
Collaborator

Choose a reason for hiding this comment

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

who is relaying on this?

go.mod Outdated Show resolved Hide resolved
types/address.go Outdated
}

return bech32.ConvertAndEncode(bech32Prefix, legacy.Cdc.MustMarshalBinaryBare(pkToMarshal))
return bech32.ConvertAndEncode(bech32Prefix, legacy.Cdc.MustMarshalBinaryBare(pubkey))
Copy link
Collaborator

Choose a reason for hiding this comment

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

overall we want to remove this function.

if intoTmPk, ok := pk.(cryptotypes.IntoTmPubKey); ok {
return intoTmPk.AsTmPubKey()
}

return pk
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's see if all tests will pass after the #7597 merge

Copy link
Member Author

Choose a reason for hiding this comment

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

unless we merge this one first muhahah lol

Copy link
Contributor

Choose a reason for hiding this comment

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

#7597 got merged ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

dam, haha. looks like I have to undo some changes in that PR, it brought tendermint keys deeper into the sdk

@@ -25,3 +28,27 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{})
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &multisig.LegacyAminoPubKey{})
}

// PubKeyToProto takes a crypto.Pubkey and sets it into tendermint's public key oneof
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// PubKeyToProto takes a crypto.Pubkey and sets it into tendermint's public key oneof
// PubKeyToProto takes a crypto.PubKey and sets it into tendermint's public key oneof

if intoTmPk, ok := pk.(cryptotypes.IntoTmPubKey); ok {
return intoTmPk.AsTmPubKey()
}

return pk
Copy link
Contributor

Choose a reason for hiding this comment

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

#7597 got merged ;)

@tac0turtle
Copy link
Member Author

no idea what happened here

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.

Regression: secp256k1 consensus support
4 participants