forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(proto)!: replace
PubKey
in abci.ValidatorUpdate
with `PubKey…
…Type` and `PubKeyBytes` (cometbft#2843) This PR deprecates `PubKey` in `abci.ValidatorUpdate` and adds two new fields: - string `PubKeyType` - bytes `PubKeyBytes` Co-authored by: @tac0turtle --- #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [x] Updated relevant documentation (`docs/` or `spec/`) and code comments - [x] Title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec --------- Co-authored-by: Marko Baricevic <[email protected]> Co-authored-by: Andy Nogueira <[email protected]>
- Loading branch information
1 parent
7673d74
commit 71cd087
Showing
29 changed files
with
605 additions
and
499 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/breaking-changes/2843-abci-types-go-api.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- [`abci/types`] Rename `UpdateValidator` to `NewValidatorUpdate`, remove | ||
`Ed25519ValidatorUpdate` ([\#2843](https://github.com/cometbft/cometbft/pull/2843)) |
3 changes: 3 additions & 0 deletions
3
.changelog/unreleased/breaking-changes/2843-abci-types-validator-update-pubkey.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- [`abci/types`] Replace `ValidatorUpdate.PubKey` with `PubKeyType` and | ||
`PubKeyBytes` to allow applications to avoid implementing `PubKey` interface. | ||
([\#2843](https://github.com/cometbft/cometbft/pull/2843)) |
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/breaking-changes/2843-proto-abci-v1-validator-update.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- [`proto`] Remove `abci.ValidatorUpdate.pub_key`, add `pub_key_type` and | ||
`pub_key_bytes` ([\#2843](https://github.com/cometbft/cometbft/pull/2843)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,15 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cometbft/cometbft/crypto/ed25519" | ||
cryptoenc "github.com/cometbft/cometbft/crypto/encoding" | ||
"github.com/cometbft/cometbft/crypto/secp256k1" | ||
"github.com/cometbft/cometbft/crypto" | ||
) | ||
|
||
func Ed25519ValidatorUpdate(pk []byte, power int64) ValidatorUpdate { | ||
pke := ed25519.PubKey(pk) | ||
|
||
pkp, err := cryptoenc.PubKeyToProto(pke) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// NewValidatorUpdate creates a new ValidatorUpdate from the given public | ||
// key. | ||
func NewValidatorUpdate(pubKey crypto.PubKey, power int64) ValidatorUpdate { | ||
return ValidatorUpdate{ | ||
// Address: | ||
PubKey: pkp, | ||
Power: power, | ||
} | ||
} | ||
|
||
func UpdateValidator(pk []byte, power int64, keyType string) ValidatorUpdate { | ||
switch keyType { | ||
case "", ed25519.KeyType: | ||
return Ed25519ValidatorUpdate(pk, power) | ||
case secp256k1.KeyType: | ||
pke := secp256k1.PubKey(pk) | ||
pkp, err := cryptoenc.PubKeyToProto(pke) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return ValidatorUpdate{ | ||
// Address: | ||
PubKey: pkp, | ||
Power: power, | ||
} | ||
default: | ||
panic(fmt.Sprintf("key type %s not supported", keyType)) | ||
Power: power, | ||
PubKeyType: pubKey.Type(), | ||
PubKeyBytes: pubKey.Bytes(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.