From 06e40e63aaadf1f927e1ec8c823b503c354761a9 Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 09:46:26 +0800 Subject: [PATCH 1/9] refactor: remove bytes/HexBytes --- UPGRADING.md | 64 ++++++++++ api/cosmos/evidence/v1beta1/query.pulsar.go | 127 ++++++++++---------- client/query.go | 7 +- client/rpc/status.go | 3 +- proto/cosmos/evidence/v1beta1/query.proto | 3 +- testutil/cli/cmt_mocks.go | 18 ++- types/context.go | 5 +- types/result_test.go | 5 +- x/bank/keeper/keeper_test.go | 3 +- x/evidence/README.md | 2 +- x/evidence/exported/evidence.go | 3 +- x/evidence/keeper/keeper.go | 9 +- x/evidence/types/evidence.go | 3 +- x/evidence/types/genesis_test.go | 5 +- x/evidence/types/query.pb.go | 65 +++++----- x/simulation/mock_cometbft.go | 3 +- 16 files changed, 186 insertions(+), 139 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index ea4994fc662..7220272cca9 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,70 @@ # Upgrading Cosmos SDK This guide provides instructions for upgrading to specific versions of Cosmos SDK. +## [Unreleased] + +### Refactor:remove bytes/HexBytes + +The Cosmos SDK has removed the import of cmtbytes "github.com/cometbft/cometbft/libs/bytes". +There is something changed.Due to the import changes, this is a breaking change. Chains need to remove **entirely** their imports in their codebase, from direct and indirects imports. + +* Remove `github.com/cometbft/cometbft/libs/bytes` +* Replace All `cmtbytes.HexBytes` by `[]byte` except `*pb.go`files +* Verify `github.com/cometbft/cometbft/libs/bytes` is not an indirect or direct dependency +* Run `make proto-gen` + +### Client + +### Protobuf + +The SDK is in the process of removing all `(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"`. + +### Modules + +#### `x/bank` + +All the bank removed `github.com/cometbft/cometbft/libs/bytes` +All the bank functions or params are now renamed to use `[]byte` instead of `cmtbytes.HexBytes` or `bytes.HexBytes` across the SDK. + +#### `evidence` + +All the evidence removed `github.com/cometbft/cometbft/libs/bytes` +All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK + +renamed to use `strings.ToUpper(hex.EncodeToString(evidence.Hash()))` instead of `evidence.Hash().String()` + +as follows: + +```go +func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) error { + if _, ok := k.GetEvidence(ctx, evidence.Hash()); ok { + return errors.Wrap(types.ErrEvidenceExists, strings.ToUpper(hex.EncodeToString(evidence.Hash()))) + } + if !k.router.HasRoute(evidence.Route()) { + return errors.Wrap(types.ErrNoEvidenceHandlerExists, evidence.Route()) + } + + handler := k.router.GetRoute(evidence.Route()) + if err := handler(ctx, evidence); err != nil { + return errors.Wrap(types.ErrInvalidEvidence, err.Error()) + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSubmitEvidence, + sdk.NewAttribute(types.AttributeKeyEvidenceHash, strings.ToUpper(hex.EncodeToString(evidence.Hash()))), + ), + ) + + k.SetEvidence(ctx, evidence) + return nil +} +``` + +#### `simulation` + +All the simulation removed `github.com/cometbft/cometbft/libs/bytes` +All the simulation functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK ## [Unreleased] diff --git a/api/cosmos/evidence/v1beta1/query.pulsar.go b/api/cosmos/evidence/v1beta1/query.pulsar.go index 8510d4f360b..5bf1f19dcb5 100644 --- a/api/cosmos/evidence/v1beta1/query.pulsar.go +++ b/api/cosmos/evidence/v1beta1/query.pulsar.go @@ -2146,71 +2146,68 @@ var file_cosmos_evidence_v1beta1_query_proto_rawDesc = []byte{ 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x87, 0x01, 0x0a, 0x14, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x5b, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x68, - 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x36, 0x18, 0x01, 0xfa, 0xde, 0x1f, - 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6d, 0x65, - 0x74, 0x62, 0x66, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, 0x74, 0x2f, 0x6c, 0x69, - 0x62, 0x73, 0x2f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2e, 0x48, 0x65, 0x78, 0x42, 0x79, 0x74, 0x65, - 0x73, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, - 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, - 0x61, 0x73, 0x68, 0x22, 0x49, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, - 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, - 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x61, - 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x22, 0x95, 0x01, 0x0a, 0x18, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, - 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, - 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, - 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xc5, 0x02, 0x0a, 0x05, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x12, 0x9b, 0x01, 0x0a, 0x08, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, - 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x7b, 0x68, 0x61, 0x73, 0x68, - 0x7d, 0x12, 0x9d, 0x01, 0x0a, 0x0b, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, - 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x42, 0xe1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x58, 0xaa, - 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x53, 0x0a, 0x14, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x27, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x68, 0x61, + 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0c, 0x65, 0x76, + 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, + 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0x49, + 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x61, 0x0a, 0x17, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x95, 0x01, 0x0a, + 0x18, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x65, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xc5, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x9b, + 0x01, 0x0a, 0x08, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x2d, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, + 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x65, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x7b, 0x68, 0x61, 0x73, 0x68, 0x7d, 0x12, 0x9d, 0x01, 0x0a, + 0x0b, 0x41, 0x6c, 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x30, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x45, + 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, + 0x6c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0xe1, 0x01, 0x0a, + 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, + 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x56, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, + 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, + 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x45, + 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/client/query.go b/client/query.go index 26608dac684..29b99bb918e 100644 --- a/client/query.go +++ b/client/query.go @@ -7,7 +7,6 @@ import ( "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" rpcclient "github.com/cometbft/cometbft/rpc/client" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -45,7 +44,7 @@ func (ctx Context) QueryWithData(path string, data []byte) ([]byte, int64, error // QueryStore performs a query to a CometBFT node with the provided key and // store name. It returns the result and height of the query upon success // or an error if the query fails. -func (ctx Context) QueryStore(key cmtbytes.HexBytes, storeName string) ([]byte, int64, error) { +func (ctx Context) QueryStore(key []byte, storeName string) ([]byte, int64, error) { return ctx.queryStore(key, storeName, "key") } @@ -129,7 +128,7 @@ func sdkErrorToGRPCError(resp abci.ResponseQuery) error { // query performs a query to a CometBFT node with the provided store name // and path. It returns the result and height of the query upon success // or an error if the query fails. -func (ctx Context) query(path string, key cmtbytes.HexBytes) ([]byte, int64, error) { +func (ctx Context) query(path string, key []byte) ([]byte, int64, error) { resp, err := ctx.queryABCI(abci.RequestQuery{ Path: path, Data: key, @@ -145,7 +144,7 @@ func (ctx Context) query(path string, key cmtbytes.HexBytes) ([]byte, int64, err // queryStore performs a query to a CometBFT node with the provided a store // name and path. It returns the result and height of the query upon success // or an error if the query fails. -func (ctx Context) queryStore(key cmtbytes.HexBytes, storeName, endPath string) ([]byte, int64, error) { +func (ctx Context) queryStore(key []byte, storeName, endPath string) ([]byte, int64, error) { path := fmt.Sprintf("/store/%s/%s", storeName, endPath) return ctx.query(path, key) } diff --git a/client/rpc/status.go b/client/rpc/status.go index 448ad872254..c27d83d6852 100644 --- a/client/rpc/status.go +++ b/client/rpc/status.go @@ -5,7 +5,6 @@ import ( "github.com/spf13/cobra" - "github.com/cometbft/cometbft/libs/bytes" "github.com/cometbft/cometbft/p2p" coretypes "github.com/cometbft/cometbft/rpc/core/types" @@ -18,7 +17,7 @@ import ( // ValidatorInfo is info about the node's validator, same as CometBFT, // except that we use our own PubKey. type validatorInfo struct { - Address bytes.HexBytes + Address []byte PubKey cryptotypes.PubKey VotingPower int64 } diff --git a/proto/cosmos/evidence/v1beta1/query.proto b/proto/cosmos/evidence/v1beta1/query.proto index 4949c832461..feba4ef7117 100644 --- a/proto/cosmos/evidence/v1beta1/query.proto +++ b/proto/cosmos/evidence/v1beta1/query.proto @@ -25,8 +25,7 @@ service Query { message QueryEvidenceRequest { // evidence_hash defines the hash of the requested evidence. // Deprecated: Use hash, a HEX encoded string, instead. - bytes evidence_hash = 1 - [deprecated = true, (gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"]; + bytes evidence_hash = 1 [deprecated = true]; // hash defines the evidence hash of the requested evidence. // diff --git a/testutil/cli/cmt_mocks.go b/testutil/cli/cmt_mocks.go index a03ea176060..3c15e4e546b 100644 --- a/testutil/cli/cmt_mocks.go +++ b/testutil/cli/cmt_mocks.go @@ -4,8 +4,6 @@ import ( "context" abci "github.com/cometbft/cometbft/abci/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" - rpcclient "github.com/cometbft/cometbft/rpc/client" rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" coretypes "github.com/cometbft/cometbft/rpc/core/types" cmttypes "github.com/cometbft/cometbft/types" @@ -31,11 +29,11 @@ func (MockCometRPC) BroadcastTxSync(context.Context, cmttypes.Tx) (*coretypes.Re return &coretypes.ResultBroadcastTx{Code: 0}, nil } -func (m MockCometRPC) ABCIQueryWithOptions( - _ context.Context, - _ string, - _ cmtbytes.HexBytes, - _ rpcclient.ABCIQueryOptions, -) (*coretypes.ResultABCIQuery, error) { - return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil -} +//func (m MockCometRPC) ABCIQueryWithOptions( +// _ context.Context, +// _ string, +// _ cmtbytes.HexBytes, +// _ rpcclient.ABCIQueryOptions, +//) (*coretypes.ResultABCIQuery, error) { +// return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil +//} diff --git a/types/context.go b/types/context.go index 5c3a072053b..89d2d41e37e 100644 --- a/types/context.go +++ b/types/context.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/gogoproto/proto" @@ -26,7 +25,7 @@ type Context struct { baseCtx context.Context ms storetypes.MultiStore header cmtproto.Header - headerHash cmtbytes.HexBytes + headerHash []byte chainID string txBytes []byte logger log.Logger @@ -72,7 +71,7 @@ func (c Context) BlockHeader() cmtproto.Header { } // HeaderHash returns a copy of the header hash obtained during abci.RequestBeginBlock -func (c Context) HeaderHash() cmtbytes.HexBytes { +func (c Context) HeaderHash() []byte { hash := make([]byte, len(c.headerHash)) copy(hash, c.headerHash) return hash diff --git a/types/result_test.go b/types/result_test.go index bd1276975df..d672b1a9f08 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -8,7 +8,6 @@ import ( "time" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/bytes" coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/golang/protobuf/proto" //nolint:staticcheck // grpc-gateway uses deprecated golang/protobuf "github.com/stretchr/testify/require" @@ -81,7 +80,7 @@ func (s *resultTestSuite) TestResponseResultTx() { GasUsed: 90, } resultTx := &coretypes.ResultTx{ - Hash: bytes.HexBytes([]byte("test")), + Hash: []byte("test"), Height: 10, TxResult: deliverTxResult, } @@ -128,7 +127,7 @@ txhash: "74657374" Codespace: "codespace", Data: []byte("data"), Log: `[]`, - Hash: bytes.HexBytes([]byte("test")), + Hash: []byte("test"), } s.Require().Equal(&sdk.TxResponse{ diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index b0fcc72e9b9..f65b770d592 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -16,7 +16,6 @@ import ( storetypes "cosmossdk.io/store/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -82,7 +81,7 @@ func getIBCDenom(path string, baseDenom string) string { return fmt.Sprintf("%s/%s", "ibc", getIBCHash(path, baseDenom)) } -func getIBCHash(path string, baseDenom string) cmtbytes.HexBytes { +func getIBCHash(path string, baseDenom string) []byte { hash := sha256.Sum256([]byte(path + "/" + baseDenom)) return hash[:] } diff --git a/x/evidence/README.md b/x/evidence/README.md index f8ca0505d22..49401204e72 100644 --- a/x/evidence/README.md +++ b/x/evidence/README.md @@ -54,7 +54,7 @@ type Evidence interface { Route() string String() string - Hash() cmtbytes.HexBytes + Hash() []byte ValidateBasic() error // Height at which the infraction occurred diff --git a/x/evidence/exported/evidence.go b/x/evidence/exported/evidence.go index 57a70e55d01..77d5f1a8a20 100644 --- a/x/evidence/exported/evidence.go +++ b/x/evidence/exported/evidence.go @@ -1,7 +1,6 @@ package exported import ( - cmtbytes "github.com/cometbft/cometbft/libs/bytes" "github.com/cosmos/gogoproto/proto" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,7 +13,7 @@ type Evidence interface { Route() string String() string - Hash() cmtbytes.HexBytes + Hash() []byte ValidateBasic() error // Height at which the infraction occurred diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index 0581484e665..dc0d091a5c2 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -1,12 +1,13 @@ package keeper import ( + "encoding/hex" "fmt" + "strings" "cosmossdk.io/log" "cosmossdk.io/x/evidence/exported" "cosmossdk.io/x/evidence/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" "cosmossdk.io/errors" "cosmossdk.io/store/prefix" @@ -79,7 +80,7 @@ func (k Keeper) GetEvidenceHandler(evidenceRoute string) (types.Handler, error) // persisted. func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) error { if _, ok := k.GetEvidence(ctx, evidence.Hash()); ok { - return errors.Wrap(types.ErrEvidenceExists, evidence.Hash().String()) + return errors.Wrap(types.ErrEvidenceExists, strings.ToUpper(hex.EncodeToString(evidence.Hash()))) } if !k.router.HasRoute(evidence.Route()) { return errors.Wrap(types.ErrNoEvidenceHandlerExists, evidence.Route()) @@ -93,7 +94,7 @@ func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) erro ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSubmitEvidence, - sdk.NewAttribute(types.AttributeKeyEvidenceHash, evidence.Hash().String()), + sdk.NewAttribute(types.AttributeKeyEvidenceHash, strings.ToUpper(hex.EncodeToString(evidence.Hash()))), ), ) @@ -109,7 +110,7 @@ func (k Keeper) SetEvidence(ctx sdk.Context, evidence exported.Evidence) { // GetEvidence retrieves Evidence by hash if it exists. If no Evidence exists for // the given hash, (nil, false) is returned. -func (k Keeper) GetEvidence(ctx sdk.Context, hash cmtbytes.HexBytes) (exported.Evidence, bool) { +func (k Keeper) GetEvidence(ctx sdk.Context, hash []byte) (exported.Evidence, bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixEvidence) bz := store.Get(hash) diff --git a/x/evidence/types/evidence.go b/x/evidence/types/evidence.go index d6967339704..8d26304708a 100644 --- a/x/evidence/types/evidence.go +++ b/x/evidence/types/evidence.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/evidence/exported" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/tmhash" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,7 +20,7 @@ var _ exported.Evidence = &Equivocation{} func (e *Equivocation) Route() string { return RouteEquivocation } // Hash returns the hash of an Equivocation object. -func (e *Equivocation) Hash() cmtbytes.HexBytes { +func (e *Equivocation) Hash() []byte { bz, err := e.Marshal() if err != nil { panic(err) diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index b06df5622c3..ab6aa024559 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/evidence/exported" "cosmossdk.io/x/evidence/types" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" @@ -171,8 +170,8 @@ func (*TestEvidence) Route() string { func (*TestEvidence) ProtoMessage() {} func (*TestEvidence) Reset() {} -func (*TestEvidence) Hash() cmtbytes.HexBytes { - return cmtbytes.HexBytes([]byte("test-hash")) +func (*TestEvidence) Hash() []byte { + return []byte("test-hash") } func (*TestEvidence) ValidateBasic() error { diff --git a/x/evidence/types/query.pb.go b/x/evidence/types/query.pb.go index 8dc6c6cb3e9..b27190a62a3 100644 --- a/x/evidence/types/query.pb.go +++ b/x/evidence/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - github_com_cometbft_cometbft_libs_bytes "github.com/cometbft/cometbft/libs/bytes" types "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" @@ -36,7 +35,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryEvidenceRequest struct { // evidence_hash defines the hash of the requested evidence. // Deprecated: Use hash, a HEX encoded string, instead. - EvidenceHash github_com_cometbft_cometbft_libs_bytes.HexBytes `protobuf:"bytes,1,opt,name=evidence_hash,json=evidenceHash,proto3,casttype=github.com/cometbft/cometbft/libs/bytes.HexBytes" json:"evidence_hash,omitempty"` // Deprecated: Do not use. + EvidenceHash []byte `protobuf:"bytes,1,opt,name=evidence_hash,json=evidenceHash,proto3" json:"evidence_hash,omitempty"` // Deprecated: Do not use. // hash defines the evidence hash of the requested evidence. // // Since: cosmos-sdk 0.47 @@ -77,7 +76,7 @@ func (m *QueryEvidenceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEvidenceRequest proto.InternalMessageInfo // Deprecated: Do not use. -func (m *QueryEvidenceRequest) GetEvidenceHash() github_com_cometbft_cometbft_libs_bytes.HexBytes { +func (m *QueryEvidenceRequest) GetEvidenceHash() []byte { if m != nil { return m.EvidenceHash } @@ -252,37 +251,35 @@ func init() { } var fileDescriptor_07043de1a84d215a = []byte{ - // 477 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xeb, 0xf2, 0x47, 0xc3, 0x1b, 0x17, 0xab, 0x68, 0x25, 0x82, 0x30, 0x32, 0x09, 0xca, - 0x24, 0xec, 0x74, 0x48, 0x70, 0x5e, 0x25, 0x60, 0xdc, 0x20, 0x47, 0x38, 0x20, 0x3b, 0xf3, 0x92, - 0x88, 0xd4, 0xce, 0x66, 0x67, 0x5a, 0x84, 0xb8, 0x70, 0xe1, 0x8a, 0x84, 0x38, 0x21, 0x3e, 0x0e, - 0x12, 0xc7, 0x49, 0x5c, 0x38, 0x21, 0xd4, 0xf2, 0x29, 0x38, 0xa1, 0xd8, 0x4e, 0x5b, 0xb6, 0x95, - 0xb2, 0xdb, 0x5b, 0xfb, 0x7d, 0x9e, 0xf7, 0xe7, 0xf7, 0x69, 0xe0, 0x7a, 0x2c, 0xd5, 0x50, 0x2a, - 0xc2, 0x0f, 0xb2, 0x1d, 0x2e, 0x62, 0x4e, 0x0e, 0xfa, 0x8c, 0x6b, 0xda, 0x27, 0x7b, 0x25, 0xdf, - 0xaf, 0x70, 0xb1, 0x2f, 0xb5, 0x44, 0xab, 0xb6, 0x09, 0x37, 0x4d, 0xd8, 0x35, 0x79, 0x1b, 0x4e, - 0xcd, 0xa8, 0xe2, 0x56, 0x31, 0xd1, 0x17, 0x34, 0xc9, 0x04, 0xd5, 0x99, 0x14, 0xd6, 0xc4, 0xeb, - 0x24, 0x32, 0x91, 0xa6, 0x24, 0x75, 0xe5, 0x4e, 0xaf, 0x26, 0x52, 0x26, 0x39, 0x27, 0xe6, 0x17, - 0x2b, 0x77, 0x09, 0x15, 0x6e, 0xaa, 0x77, 0xcd, 0x5d, 0xd1, 0x22, 0x23, 0x54, 0x08, 0xa9, 0x8d, - 0x9b, 0xb2, 0xb7, 0xc1, 0x3b, 0x00, 0x3b, 0xcf, 0xea, 0x89, 0x0f, 0x1d, 0x54, 0xc4, 0xf7, 0x4a, - 0xae, 0x34, 0x7a, 0x01, 0x2f, 0x37, 0x9c, 0x2f, 0x53, 0xaa, 0xd2, 0x2e, 0x58, 0x03, 0xbd, 0x95, - 0xc1, 0xfd, 0xdf, 0x3f, 0x6e, 0x84, 0x49, 0xa6, 0xd3, 0x92, 0xe1, 0x58, 0x0e, 0x49, 0x2c, 0x87, - 0x5c, 0xb3, 0x5d, 0x3d, 0x2d, 0xf2, 0x8c, 0x29, 0xc2, 0x2a, 0xcd, 0x15, 0xde, 0xe6, 0x87, 0x83, - 0xba, 0xe8, 0x82, 0x68, 0xa5, 0x31, 0xdb, 0xa6, 0x2a, 0x45, 0x08, 0x9e, 0x37, 0x9e, 0xed, 0x35, - 0xd0, 0xbb, 0x14, 0x99, 0x3a, 0x78, 0x02, 0xaf, 0x1c, 0x03, 0x51, 0x85, 0x14, 0x8a, 0xa3, 0x10, - 0x2e, 0x35, 0x62, 0x03, 0xb1, 0xbc, 0xd9, 0xc1, 0xf6, 0x4d, 0xb8, 0x79, 0x2e, 0xde, 0x12, 0x55, - 0x34, 0xe9, 0x0a, 0x28, 0x5c, 0x35, 0x56, 0x5b, 0x79, 0x7e, 0xfc, 0x59, 0x8f, 0x20, 0x9c, 0xae, - 0xd4, 0xd9, 0xdd, 0xc2, 0x2e, 0x98, 0x7a, 0xff, 0xd8, 0x26, 0xe6, 0xf6, 0x8f, 0x9f, 0xd2, 0xa4, - 0xd1, 0x46, 0x33, 0xca, 0xe0, 0x23, 0x80, 0xdd, 0x93, 0x33, 0x4e, 0x25, 0x3e, 0xb7, 0x98, 0x18, - 0x3d, 0xfe, 0x0b, 0xab, 0x6d, 0xb0, 0x6e, 0x2f, 0xc4, 0xb2, 0xe3, 0x66, 0xb9, 0x36, 0xbf, 0xb4, - 0xe1, 0x05, 0xc3, 0x85, 0x3e, 0x01, 0xb8, 0xd4, 0x90, 0xa1, 0xbb, 0x78, 0xce, 0x7f, 0x0f, 0x9f, - 0x16, 0xbe, 0x87, 0xff, 0xb7, 0xdd, 0x12, 0x04, 0xe1, 0xdb, 0x6f, 0xbf, 0x3e, 0xb4, 0x37, 0x50, - 0x8f, 0xcc, 0xfb, 0x0e, 0x26, 0x07, 0xaf, 0xeb, 0xb0, 0xdf, 0xa0, 0xcf, 0x00, 0x2e, 0xcf, 0xac, - 0x0e, 0x85, 0xff, 0x9e, 0x78, 0x32, 0x49, 0xaf, 0x7f, 0x06, 0x85, 0xc3, 0xbc, 0x63, 0x30, 0xd7, - 0xd1, 0xcd, 0x85, 0x98, 0x83, 0x07, 0x5f, 0x47, 0x3e, 0x38, 0x1a, 0xf9, 0xe0, 0xe7, 0xc8, 0x07, - 0xef, 0xc7, 0x7e, 0xeb, 0x68, 0xec, 0xb7, 0xbe, 0x8f, 0xfd, 0xd6, 0xf3, 0xeb, 0x56, 0xab, 0x76, - 0x5e, 0xe1, 0x4c, 0x92, 0xc3, 0xa9, 0x87, 0xae, 0x0a, 0xae, 0xd8, 0x45, 0x93, 0xf0, 0xbd, 0x3f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xec, 0x43, 0xd3, 0x6e, 0x12, 0x04, 0x00, 0x00, + // 438 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcb, 0x8e, 0x12, 0x41, + 0x14, 0x86, 0xa9, 0xf6, 0x12, 0x2c, 0x70, 0x53, 0xc1, 0x80, 0x1d, 0xed, 0x60, 0x93, 0x08, 0x92, + 0x58, 0x05, 0xb8, 0x70, 0x0d, 0x89, 0xb7, 0x9d, 0xb6, 0x3b, 0x37, 0xa6, 0x1a, 0xca, 0xa6, 0x23, + 0x56, 0x35, 0x54, 0x43, 0x24, 0xc6, 0x8d, 0x4f, 0x60, 0x62, 0x5c, 0x19, 0x1f, 0x67, 0x92, 0x59, + 0x92, 0xcc, 0x66, 0x96, 0x13, 0x98, 0x07, 0x99, 0x74, 0x55, 0x35, 0x30, 0x5c, 0x86, 0x99, 0xdd, + 0xe9, 0x3e, 0xe7, 0xff, 0xcf, 0x97, 0xff, 0x14, 0xac, 0x74, 0x85, 0xfc, 0x26, 0x24, 0x61, 0x93, + 0xb0, 0xc7, 0x78, 0x97, 0x91, 0x49, 0xd3, 0x67, 0x31, 0x6d, 0x92, 0xe1, 0x98, 0x8d, 0xa6, 0x38, + 0x1a, 0x89, 0x58, 0xa0, 0xa2, 0x1e, 0xc2, 0xe9, 0x10, 0x36, 0x43, 0x76, 0xdd, 0xa8, 0x7d, 0x2a, + 0x99, 0x56, 0x2c, 0xf5, 0x11, 0x0d, 0x42, 0x4e, 0xe3, 0x50, 0x70, 0x6d, 0x62, 0x17, 0x02, 0x11, + 0x08, 0x55, 0x92, 0xa4, 0x32, 0x7f, 0x1f, 0x06, 0x42, 0x04, 0x03, 0x46, 0xd4, 0x97, 0x3f, 0xfe, + 0x42, 0x28, 0x37, 0x5b, 0xed, 0x47, 0xa6, 0x45, 0xa3, 0x90, 0x50, 0xce, 0x45, 0xac, 0xdc, 0xa4, + 0xee, 0xba, 0x1f, 0x61, 0xe1, 0x43, 0xb2, 0xf0, 0x95, 0x61, 0xf2, 0xd8, 0x70, 0xcc, 0x64, 0x8c, + 0xaa, 0xf0, 0x7e, 0x8a, 0xf9, 0xb9, 0x4f, 0x65, 0xbf, 0x04, 0xca, 0xa0, 0x96, 0xef, 0x58, 0x25, + 0xe0, 0xe5, 0xd3, 0xc6, 0x5b, 0x2a, 0xfb, 0x08, 0xc1, 0xdb, 0xaa, 0x6f, 0x95, 0x41, 0xed, 0x9e, + 0xa7, 0x6a, 0xf7, 0x1d, 0x7c, 0xb0, 0x61, 0x2a, 0x23, 0xc1, 0x25, 0x43, 0x0d, 0x98, 0x4d, 0xc5, + 0xca, 0x30, 0xd7, 0x2a, 0x60, 0x8d, 0x87, 0x53, 0x72, 0xdc, 0xe6, 0x53, 0x6f, 0x39, 0xe5, 0x52, + 0x58, 0x54, 0x56, 0xed, 0xc1, 0x60, 0x13, 0xf1, 0x35, 0x84, 0xab, 0x74, 0x8c, 0xdd, 0x53, 0x6c, + 0x32, 0x4e, 0xa2, 0xc4, 0x3a, 0x7c, 0x13, 0x25, 0x7e, 0x4f, 0x83, 0x54, 0xeb, 0xad, 0x29, 0xdd, + 0xbf, 0x00, 0x96, 0xb6, 0x77, 0xec, 0x24, 0xbe, 0x75, 0x98, 0x18, 0xbd, 0xb9, 0x84, 0x65, 0x29, + 0xac, 0xea, 0x41, 0x2c, 0xbd, 0x6e, 0x9d, 0xab, 0x75, 0x64, 0xc1, 0x3b, 0x8a, 0x0b, 0xfd, 0x03, + 0x30, 0x9b, 0x92, 0xa1, 0xe7, 0x78, 0xcf, 0x33, 0xc2, 0xbb, 0x0e, 0x69, 0xe3, 0xeb, 0x8e, 0x6b, + 0x02, 0xb7, 0xf1, 0xeb, 0xe4, 0xfc, 0x8f, 0x55, 0x47, 0x35, 0xb2, 0xef, 0x49, 0x2f, 0x7f, 0xfc, + 0x48, 0x8e, 0xfd, 0x13, 0xfd, 0x07, 0x30, 0xb7, 0x16, 0x1d, 0x6a, 0x5c, 0xbd, 0x71, 0xfb, 0x92, + 0x76, 0xf3, 0x06, 0x0a, 0x83, 0xf9, 0x4c, 0x61, 0x56, 0xd0, 0x93, 0x83, 0x98, 0x9d, 0x97, 0xc7, + 0x73, 0x07, 0xcc, 0xe6, 0x0e, 0x38, 0x9b, 0x3b, 0xe0, 0xf7, 0xc2, 0xc9, 0xcc, 0x16, 0x4e, 0xe6, + 0x74, 0xe1, 0x64, 0x3e, 0x3d, 0xd6, 0x5a, 0xd9, 0xfb, 0x8a, 0x43, 0x41, 0xbe, 0xaf, 0x3c, 0xe2, + 0x69, 0xc4, 0xa4, 0x7f, 0x57, 0x5d, 0xf8, 0xc5, 0x45, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x24, + 0xb4, 0x3c, 0xdd, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/simulation/mock_cometbft.go b/x/simulation/mock_cometbft.go index b16d563df1e..166cf40a87d 100644 --- a/x/simulation/mock_cometbft.go +++ b/x/simulation/mock_cometbft.go @@ -9,7 +9,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" cryptoenc "github.com/cometbft/cometbft/crypto/encoding" - cmtbytes "github.com/cometbft/cometbft/libs/bytes" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" ) @@ -60,7 +59,7 @@ func (vals mockValidators) getKeys() []string { } // randomProposer picks a random proposer from the current validator set -func (vals mockValidators) randomProposer(r *rand.Rand) cmtbytes.HexBytes { +func (vals mockValidators) randomProposer(r *rand.Rand) []byte { keys := vals.getKeys() if len(keys) == 0 { return nil From 582937fdc28c7d032fc111c1b818d1ec0e635033 Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 10:01:41 +0800 Subject: [PATCH 2/9] refactor: remove bytes/HexBytes --- UPGRADING.md | 2 -- types/context_test.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 7220272cca9..9bdf435564d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -13,8 +13,6 @@ There is something changed.Due to the import changes, this is a breaking change. * Verify `github.com/cometbft/cometbft/libs/bytes` is not an indirect or direct dependency * Run `make proto-gen` -### Client - ### Protobuf The SDK is in the process of removing all `(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"`. diff --git a/types/context_test.go b/types/context_test.go index 10cfba09221..fb51ce739f0 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -121,7 +121,7 @@ func (s *contextTestSuite) TestContextWithCustom() { s.Require().Equal(meter, ctx.GasMeter()) s.Require().Equal(minGasPrices, ctx.MinGasPrices()) s.Require().Equal(blockGasMeter, ctx.BlockGasMeter()) - s.Require().Equal(headerHash, ctx.HeaderHash().Bytes()) + s.Require().Equal(headerHash, ctx.HeaderHash()) s.Require().False(ctx.WithIsCheckTx(false).IsCheckTx()) s.Require().Equal(zeroGasCfg, ctx.KVGasConfig()) s.Require().Equal(zeroGasCfg, ctx.TransientKVGasConfig()) From b21b5fa333692a030cf23667eee701ec9b354d3e Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 10:18:48 +0800 Subject: [PATCH 3/9] doc: update UPGRADING.md --- UPGRADING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPGRADING.md b/UPGRADING.md index 9bdf435564d..93368e08ec8 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -17,6 +17,11 @@ There is something changed.Due to the import changes, this is a breaking change. The SDK is in the process of removing all `(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"`. +### test + +use `ctx.HeaderHash()` in `context_test.go` instead of `ctx.HeaderHash().Bytes()` +use `[]byte("xxx")` instead of `bytes.HexBytes([]byte("xxx"))` + ### Modules #### `x/bank` From d8fa071a2f6e50d861b305b56f242b2ed989ef36 Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 10:45:05 +0800 Subject: [PATCH 4/9] doc: update UPGRADING.md --- UPGRADING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADING.md b/UPGRADING.md index 93368e08ec8..700b164a93d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,7 @@ # Upgrading Cosmos SDK This guide provides instructions for upgrading to specific versions of Cosmos SDK. + ## [Unreleased] ### Refactor:remove bytes/HexBytes From 80fac8a4124462acd31b2466ba0a5a6c7c4ce4c2 Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 12:59:39 +0800 Subject: [PATCH 5/9] fix: add ABCIQueryWithOptions to ensure ci --- testutil/cli/cmt_mocks.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/testutil/cli/cmt_mocks.go b/testutil/cli/cmt_mocks.go index 3c15e4e546b..a03ea176060 100644 --- a/testutil/cli/cmt_mocks.go +++ b/testutil/cli/cmt_mocks.go @@ -4,6 +4,8 @@ import ( "context" abci "github.com/cometbft/cometbft/abci/types" + cmtbytes "github.com/cometbft/cometbft/libs/bytes" + rpcclient "github.com/cometbft/cometbft/rpc/client" rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock" coretypes "github.com/cometbft/cometbft/rpc/core/types" cmttypes "github.com/cometbft/cometbft/types" @@ -29,11 +31,11 @@ func (MockCometRPC) BroadcastTxSync(context.Context, cmttypes.Tx) (*coretypes.Re return &coretypes.ResultBroadcastTx{Code: 0}, nil } -//func (m MockCometRPC) ABCIQueryWithOptions( -// _ context.Context, -// _ string, -// _ cmtbytes.HexBytes, -// _ rpcclient.ABCIQueryOptions, -//) (*coretypes.ResultABCIQuery, error) { -// return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil -//} +func (m MockCometRPC) ABCIQueryWithOptions( + _ context.Context, + _ string, + _ cmtbytes.HexBytes, + _ rpcclient.ABCIQueryOptions, +) (*coretypes.ResultABCIQuery, error) { + return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil +} From 607a23a5a762ec6cf516ecfa768daabab0b654ed Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 19:16:12 +0800 Subject: [PATCH 6/9] modify to pass test --- UPGRADING.md | 4 ++-- x/evidence/README.md | 4 ++-- x/evidence/keeper/grpc_query_test.go | 5 +++-- x/evidence/types/evidence_test.go | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 700b164a93d..d32b0f67050 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -30,7 +30,7 @@ use `[]byte("xxx")` instead of `bytes.HexBytes([]byte("xxx"))` All the bank removed `github.com/cometbft/cometbft/libs/bytes` All the bank functions or params are now renamed to use `[]byte` instead of `cmtbytes.HexBytes` or `bytes.HexBytes` across the SDK. -#### `evidence` +#### `x/evidence` All the evidence removed `github.com/cometbft/cometbft/libs/bytes` All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK @@ -65,7 +65,7 @@ func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) erro } ``` -#### `simulation` +#### `x/simulation` All the simulation removed `github.com/cometbft/cometbft/libs/bytes` All the simulation functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK diff --git a/x/evidence/README.md b/x/evidence/README.md index 49401204e72..263481b0cea 100644 --- a/x/evidence/README.md +++ b/x/evidence/README.md @@ -153,7 +153,7 @@ as follows: ```go func SubmitEvidence(ctx Context, evidence Evidence) error { if _, ok := GetEvidence(ctx, evidence.Hash()); ok { - return errorsmod.Wrap(types.ErrEvidenceExists, evidence.Hash().String()) + return errorsmod.Wrap(types.ErrEvidenceExists, strings.ToUpper(hex.EncodeToString(evidence.Hash()))) } if !router.HasRoute(evidence.Route()) { return errorsmod.Wrap(types.ErrNoEvidenceHandlerExists, evidence.Route()) @@ -167,7 +167,7 @@ func SubmitEvidence(ctx Context, evidence Evidence) error { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSubmitEvidence, - sdk.NewAttribute(types.AttributeKeyEvidenceHash, evidence.Hash().String()), + sdk.NewAttribute(types.AttributeKeyEvidenceHash, strings.ToUpper(hex.EncodeToString(evidence.Hash()))), ), ) diff --git a/x/evidence/keeper/grpc_query_test.go b/x/evidence/keeper/grpc_query_test.go index 1860165c6c3..41e984ad924 100644 --- a/x/evidence/keeper/grpc_query_test.go +++ b/x/evidence/keeper/grpc_query_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "encoding/hex" "fmt" "strings" @@ -37,7 +38,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence() { func() { numEvidence := 1 evidence = suite.populateEvidence(suite.ctx, numEvidence) - evidenceHash := evidence[0].Hash().String() + evidenceHash := strings.ToUpper(hex.EncodeToString(evidence[0].Hash())) reqHash := strings.Repeat("a", len(evidenceHash)) req = types.NewQueryEvidenceRequest(reqHash) }, @@ -51,7 +52,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence() { func() { numEvidence := 100 evidence = suite.populateEvidence(suite.ctx, numEvidence) - req = types.NewQueryEvidenceRequest(evidence[0].Hash().String()) + req = types.NewQueryEvidenceRequest(strings.ToUpper(hex.EncodeToString(evidence[0].Hash()))) }, true, "", diff --git a/x/evidence/types/evidence_test.go b/x/evidence/types/evidence_test.go index 44009b52b1f..29ec7b442b2 100644 --- a/x/evidence/types/evidence_test.go +++ b/x/evidence/types/evidence_test.go @@ -1,6 +1,8 @@ package types_test import ( + "encoding/hex" + "strings" "testing" "time" @@ -28,7 +30,7 @@ func TestEquivocation_Valid(t *testing.T) { require.Equal(t, e.GetConsensusAddress().String(), e.ConsensusAddress) require.Equal(t, e.GetHeight(), e.Height) require.Equal(t, e.Route(), types.RouteEquivocation) - require.Equal(t, e.Hash().String(), "1E10F9267BEA3A9A4AB5302C2C510CC1AFD7C54E232DA5B2E3360DFAFACF7A76") + require.Equal(t, strings.ToUpper(hex.EncodeToString(e.Hash())), "1E10F9267BEA3A9A4AB5302C2C510CC1AFD7C54E232DA5B2E3360DFAFACF7A76") require.Equal(t, "height:100 time: power:1000000 consensus_address:\"cosmosvalcons1vehk7h6lta047h6lta047h6lta047h6l8m4r53\" ", e.String()) require.NoError(t, e.ValidateBasic()) @@ -38,7 +40,7 @@ func TestEquivocation_Valid(t *testing.T) { require.Equal(t, e.ConsensusAddress, e.GetConsensusAddress().String()) require.Equal(t, e.Height, e.GetHeight()) require.Equal(t, types.RouteEquivocation, e.Route()) - require.Equal(t, "1E10F9267BEA3A9A4AB5302C2C510CC1AFD7C54E232DA5B2E3360DFAFACF7A76", e.Hash().String()) + require.Equal(t, "1E10F9267BEA3A9A4AB5302C2C510CC1AFD7C54E232DA5B2E3360DFAFACF7A76", strings.ToUpper(hex.EncodeToString(e.Hash()))) require.Equal(t, "height:100 time: power:1000000 consensus_address:\"cosmosvalcons1vehk7h6lta047h6lta047h6lta047h6l8m4r53\" ", e.String()) require.NoError(t, e.ValidateBasic()) } From 3d63015dd341d58f83c6f22d4e8e6d8eab610ce3 Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Tue, 28 Feb 2023 20:36:03 +0800 Subject: [PATCH 7/9] fix: encode ibcHash to pass test --- x/bank/keeper/keeper_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index f65b770d592..470e2dbe54e 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "crypto/sha256" + "encoding/hex" "fmt" "strings" "testing" @@ -78,7 +79,7 @@ func newIbcCoin(amt int64) sdk.Coin { } func getIBCDenom(path string, baseDenom string) string { - return fmt.Sprintf("%s/%s", "ibc", getIBCHash(path, baseDenom)) + return fmt.Sprintf("%s/%s", "ibc", hex.EncodeToString(getIBCHash(path, baseDenom))) } func getIBCHash(path string, baseDenom string) []byte { From 14b36c751e689b008bbb1d4887bcff2d860fa19f Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Wed, 1 Mar 2023 12:48:43 +0800 Subject: [PATCH 8/9] update md --- UPGRADING.md | 87 +++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 69 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index d32b0f67050..c82de2bc944 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,78 +4,11 @@ This guide provides instructions for upgrading to specific versions of Cosmos SD ## [Unreleased] -### Refactor:remove bytes/HexBytes - -The Cosmos SDK has removed the import of cmtbytes "github.com/cometbft/cometbft/libs/bytes". -There is something changed.Due to the import changes, this is a breaking change. Chains need to remove **entirely** their imports in their codebase, from direct and indirects imports. - -* Remove `github.com/cometbft/cometbft/libs/bytes` -* Replace All `cmtbytes.HexBytes` by `[]byte` except `*pb.go`files -* Verify `github.com/cometbft/cometbft/libs/bytes` is not an indirect or direct dependency -* Run `make proto-gen` - -### Protobuf - -The SDK is in the process of removing all `(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"`. - -### test - -use `ctx.HeaderHash()` in `context_test.go` instead of `ctx.HeaderHash().Bytes()` -use `[]byte("xxx")` instead of `bytes.HexBytes([]byte("xxx"))` - -### Modules - -#### `x/bank` - -All the bank removed `github.com/cometbft/cometbft/libs/bytes` -All the bank functions or params are now renamed to use `[]byte` instead of `cmtbytes.HexBytes` or `bytes.HexBytes` across the SDK. - -#### `x/evidence` - -All the evidence removed `github.com/cometbft/cometbft/libs/bytes` -All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK - -renamed to use `strings.ToUpper(hex.EncodeToString(evidence.Hash()))` instead of `evidence.Hash().String()` - -as follows: - -```go -func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) error { - if _, ok := k.GetEvidence(ctx, evidence.Hash()); ok { - return errors.Wrap(types.ErrEvidenceExists, strings.ToUpper(hex.EncodeToString(evidence.Hash()))) - } - if !k.router.HasRoute(evidence.Route()) { - return errors.Wrap(types.ErrNoEvidenceHandlerExists, evidence.Route()) - } - - handler := k.router.GetRoute(evidence.Route()) - if err := handler(ctx, evidence); err != nil { - return errors.Wrap(types.ErrInvalidEvidence, err.Error()) - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeSubmitEvidence, - sdk.NewAttribute(types.AttributeKeyEvidenceHash, strings.ToUpper(hex.EncodeToString(evidence.Hash()))), - ), - ) - - k.SetEvidence(ctx, evidence) - return nil -} -``` - -#### `x/simulation` - -All the simulation removed `github.com/cometbft/cometbft/libs/bytes` -All the simulation functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK - -## [Unreleased] - ### Migration to CometBFT (Part 2) The Cosmos SDK has migrated in, its previous versions, to CometBFT. -Some functions have been renamed to reflect the naming change. +Some functions have been renamed to reflect the naming change. And the Cosmos SDK has removed the import of cmtbytes "github.com/cometbft/cometbft/libs/bytes". +There is something changed.Due to the import changes, this is a breaking change. Chains need to remove **entirely** their imports in their codebase, from direct and indirects imports. Following an exhaustive list: @@ -83,6 +16,9 @@ Following an exhaustive list: * `clitestutil.MockTendermintRPC` -> `clitestutil.MockCometRPC` * `clitestutilgenutil.CreateDefaultTendermintConfig` -> `clitestutilgenutil.CreateDefaultCometConfig` * Package `client/grpc/tmservice` -> `client/grpc/cmtservice` +* Remove `github.com/cometbft/cometbft/libs/bytes` & Replace All `cmtbytes.HexBytes` by `[]byte` except `*pb.go`files +* Verify `github.com/cometbft/cometbft/libs/bytes` is not an indirect or direct dependency +* Run `make proto-gen` Additionally, the commands and flags mentionning `tendermint` have been renamed to `comet`. However, these commands and flags is still supported for backward compatibility. @@ -120,6 +56,7 @@ See related issues: ### Protobuf The SDK is in the process of removing all `gogoproto` annotations. +The SDK is in the process of removing all `(gogoproto.casttype) = "github.com/cometbft/cometbft/libs/bytes.HexBytes"`. #### Stringer @@ -169,6 +106,18 @@ By default, the new `ProposalCancelRatio` parameter is set to 0.5 during migrati The `x/evidence` module is extracted to have a separate go.mod file which allows it be a standalone module. All the evidence imports are now renamed to use `cosmossdk.io/x/evidence` instead of `github.com/cosmos/cosmos-sdk/x/evidence` across the SDK. +All the evidence removed `github.com/cometbft/cometbft/libs/bytes` +All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK + +#### `x/bank` + +All the bank removed `github.com/cometbft/cometbft/libs/bytes` +All the bank functions or params are now renamed to use `[]byte` instead of `cmtbytes.HexBytes` or `bytes.HexBytes` across the SDK. + +#### `x/simulation` + +All the simulation removed `github.com/cometbft/cometbft/libs/bytes` +All the simulation functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK. #### `x/nft` From be09bbeebec5932ab7591597bd20084eefa4a13b Mon Sep 17 00:00:00 2001 From: chixiaowen Date: Wed, 1 Mar 2023 12:51:43 +0800 Subject: [PATCH 9/9] update upgrading.md --- UPGRADING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index c82de2bc944..80f097204ac 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -106,12 +106,12 @@ By default, the new `ProposalCancelRatio` parameter is set to 0.5 during migrati The `x/evidence` module is extracted to have a separate go.mod file which allows it be a standalone module. All the evidence imports are now renamed to use `cosmossdk.io/x/evidence` instead of `github.com/cosmos/cosmos-sdk/x/evidence` across the SDK. -All the evidence removed `github.com/cometbft/cometbft/libs/bytes` -All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK +All the evidence removed `github.com/cometbft/cometbft/libs/bytes`. +All the evidence functions or params are now renamed to use `cmtbytes.HexBytes` or `bytes.HexBytes` instead of `[]byte` across the SDK. #### `x/bank` -All the bank removed `github.com/cometbft/cometbft/libs/bytes` +All the bank removed `github.com/cometbft/cometbft/libs/bytes`. All the bank functions or params are now renamed to use `[]byte` instead of `cmtbytes.HexBytes` or `bytes.HexBytes` across the SDK. #### `x/simulation`