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

refactor!: remove legacyamino functions #17746

Closed
wants to merge 5 commits into from
Closed
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
2,160 changes: 116 additions & 2,044 deletions api/cosmos/tx/v1beta1/service.pulsar.go

Large diffs are not rendered by default.

86 changes: 0 additions & 86 deletions api/cosmos/tx/v1beta1/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"

cmttypes "github.com/cometbft/cometbft/types"
amino "github.com/tendermint/go-amino"

"github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -27,13 +26,6 @@ func NewLegacyAmino() *LegacyAmino {
return &LegacyAmino{amino.NewCodec()}
}

// RegisterEvidences registers CometBFT evidence types with the provided Amino
// codec.
func RegisterEvidences(cdc *LegacyAmino) {
cdc.Amino.RegisterInterface((*cmttypes.Evidence)(nil), nil)
cdc.Amino.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil)
}

// MarshalJSONIndent provides a utility for indented JSON encoding of an object
// via an Amino codec. It returns an error if it cannot serialize or indent as
// JSON.
Expand Down
3 changes: 0 additions & 3 deletions codec/legacy/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Cdc defines a global generic sealed Amino codec to be used throughout sdk. It
Expand All @@ -15,8 +14,6 @@ var Cdc = codec.NewLegacyAmino()

func init() {
cryptocodec.RegisterCrypto(Cdc)
codec.RegisterEvidences(Cdc)
sdk.RegisterLegacyAminoCodec(Cdc)
}

// PrivKeyFromBytes unmarshals private key bytes and returns a PrivKey
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/build/building-modules/01-module-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go

Let us go through the methods:

* `RegisterLegacyAminoCodec(*codec.LegacyAmino)`: Registers the `amino` codec for the module, which is used to marshal and unmarshal structs to/from `[]byte` in order to persist them in the module's `KVStore`.
* `RegisterInterfaces(codectypes.InterfaceRegistry)`: Registers a module's interface types and their concrete implementations as `proto.Message`.
* `RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux)`: Registers gRPC routes for the module.

Expand Down Expand Up @@ -274,7 +273,6 @@ It implements the following methods:

* `NewBasicManager(modules ...AppModuleBasic)`: Constructor function. It takes a list of the application's `AppModuleBasic` and builds a new `BasicManager`. This function is generally called in the `init()` function of [`app.go`](../../develop/beginner/00-app-anatomy.md#core-application-file) to quickly initialize the independent elements of the application's modules (click [here](https://github.com/cosmos/gaia/blob/main/app/app.go#L59-L74) to see an example).
* `NewBasicManagerFromManager(manager *Manager, customModuleBasics map[string]AppModuleBasic)`: Contructor function. It creates a new `BasicManager` from a `Manager`. The `BasicManager` will contain all `AppModuleBasic` from the `AppModule` manager using `CoreAppModuleBasicAdaptor` whenever possible. Module's `AppModuleBasic` can be overridden by passing a custom AppModuleBasic map
* `RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)`: Registers the [`codec.LegacyAmino`s](../../develop/advanced/05-encoding.md#amino) of each of the application's `AppModuleBasic`. This function is usually called early on in the [application's construction](../../develop/beginner/00-app-anatomy.md#constructor).
* `RegisterInterfaces(registry codectypes.InterfaceRegistry)`: Registers interface types and implementations of each of the application's `AppModuleBasic`.
* `DefaultGenesis(cdc codec.JSONCodec)`: Provides default genesis information for modules in the application by calling the [`DefaultGenesis(cdc codec.JSONCodec)`](./08-genesis.md#defaultgenesis) function of each module. It only calls the modules that implements the `HasGenesisBasics` interfaces.
* `ValidateGenesis(cdc codec.JSONCodec, txEncCfg client.TxEncodingConfig, genesis map[string]json.RawMessage)`: Validates the genesis information modules by calling the [`ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage)`](./08-genesis.md#validategenesis) function of modules implementing the `HasGenesisBasics` interface.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/build/building-modules/06-keeper.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Let us go through the different parameters:

* An expected `keeper` is a `keeper` external to a module that is required by the internal `keeper` of said module. External `keeper`s are listed in the internal `keeper`'s type definition as interfaces. These interfaces are themselves defined in an `expected_keepers.go` file in the root of the module's folder. In this context, interfaces are used to reduce the number of dependencies, as well as to facilitate the maintenance of the module itself.
* `storeKey`s grant access to the store(s) of the [multistore](../../develop/advanced/04-store.md) managed by the module. They should always remain unexposed to external modules.
* `cdc` is the [codec](../../develop/advanced/05-encoding.md) used to marshall and unmarshall structs to/from `[]byte`. The `cdc` can be any of `codec.BinaryCodec`, `codec.JSONCodec` or `codec.Codec` based on your requirements. It can be either a proto or amino codec as long as they implement these interfaces.
* `cdc` is the [codec](../../develop/advanced/05-encoding.md) used to marshall and unmarshall structs to/from `[]byte`. The `cdc` can be any of `codec.BinaryCodec`, `codec.JSONCodec` or `codec.Codec` based on your requirements. It is a proto codec as long as they implement these interfaces.
* The authority listed is a module account or user account that has the right to change module level parameters. Previously this was handled by the param module, which has been deprecated.

Of course, it is possible to define different types of internal `keeper`s for the same module (e.g. a read-only `keeper`). Each type of `keeper` comes with its own constructor function, which is called from the [application's constructor function](../../develop/beginner/00-app-anatomy.md). This is where `keeper`s are instantiated, and where developers make sure to pass correct instances of modules' `keeper`s to other modules that require them.
Expand Down
50 changes: 0 additions & 50 deletions proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
syntax = "proto3";

Check failure on line 1 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "TxDecodeAminoRequest" was deleted from file.

Check failure on line 1 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "TxDecodeAminoResponse" was deleted from file.

Check failure on line 1 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "TxEncodeAminoRequest" was deleted from file.

Check failure on line 1 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "TxEncodeAminoResponse" was deleted from file.
package cosmos.tx.v1beta1;

import "google/api/annotations.proto";
Expand All @@ -11,7 +11,7 @@
option go_package = "github.com/cosmos/cosmos-sdk/types/tx";

// Service defines a gRPC service for interacting with transactions.
service Service {

Check failure on line 14 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present RPC "TxDecodeAmino" on service "Service" was deleted.

Check failure on line 14 in proto/cosmos/tx/v1beta1/service.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present RPC "TxEncodeAmino" on service "Service" was deleted.
// Simulate simulates executing a transaction for estimating gas usage.
rpc Simulate(SimulateRequest) returns (SimulateResponse) {
option (google.api.http) = {
Expand Down Expand Up @@ -58,24 +58,6 @@
body: "*"
};
}
// TxEncodeAmino encodes an Amino transaction from JSON to encoded bytes.
Copy link
Member

Choose a reason for hiding this comment

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

Why do we delete this actually?
Wasn't it added per community request?

Copy link
Member

@kocubinski kocubinski Sep 18, 2023

Choose a reason for hiding this comment

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

I think I agree; we can still encode to amino JSON via the encoder in x/tx or is this talking about a different amino format? (I remember something about a binary amino format).

Instead maybe keep the messages/services and have the decode service return an error since this is what we're dropping support for.

Copy link
Member Author

Choose a reason for hiding this comment

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

technically this doesn't work for modules that dont registerlegacyamino, so we have a bit of a discrepancy on support here. I can look at adding back the encode but decode id just remove.

//
// Since: cosmos-sdk 0.47
rpc TxEncodeAmino(TxEncodeAminoRequest) returns (TxEncodeAminoResponse) {
option (google.api.http) = {
post: "/cosmos/tx/v1beta1/encode/amino"
body: "*"
};
}
// TxDecodeAmino decodes an Amino transaction from encoded bytes to JSON.
//
// Since: cosmos-sdk 0.47
rpc TxDecodeAmino(TxDecodeAminoRequest) returns (TxDecodeAminoResponse) {
option (google.api.http) = {
post: "/cosmos/tx/v1beta1/decode/amino"
body: "*"
};
}
}

// GetTxsEventRequest is the request type for the Service.TxsByEvents
Expand Down Expand Up @@ -258,35 +240,3 @@
// tx_bytes is the encoded transaction bytes.
bytes tx_bytes = 1;
}

// TxEncodeAminoRequest is the request type for the Service.TxEncodeAmino
// RPC method.
//
// Since: cosmos-sdk 0.47
message TxEncodeAminoRequest {
string amino_json = 1;
}

// TxEncodeAminoResponse is the response type for the Service.TxEncodeAmino
// RPC method.
//
// Since: cosmos-sdk 0.47
message TxEncodeAminoResponse {
bytes amino_binary = 1;
}

// TxDecodeAminoRequest is the request type for the Service.TxDecodeAmino
// RPC method.
//
// Since: cosmos-sdk 0.47
message TxDecodeAminoRequest {
bytes amino_binary = 1;
}

// TxDecodeAminoResponse is the response type for the Service.TxDecodeAmino
// RPC method.
//
// Since: cosmos-sdk 0.47
message TxDecodeAminoResponse {
string amino_json = 1;
}
1 change: 0 additions & 1 deletion runtime/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (a *App) RegisterModules(modules ...module.AppModule) error {
a.ModuleManager.Modules[name] = appModule
a.basicManager[name] = appModule
appModule.RegisterInterfaces(a.interfaceRegistry)
appModule.RegisterLegacyAminoCodec(a.amino)

if module, ok := appModule.(module.HasServices); ok {
module.RegisterServices(a.configurator)
Expand Down
3 changes: 0 additions & 3 deletions runtime/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) (
amino := codec.NewLegacyAmino()

std.RegisterInterfaces(interfaceRegistry)
std.RegisterLegacyAminoCodec(amino)

cdc := codec.NewProtoCodec(interfaceRegistry)
msgServiceRouter := baseapp.NewMsgServiceRouter()
Expand Down Expand Up @@ -145,14 +144,12 @@ func SetupAppBuilder(inputs AppInputs) {
if customBasicMod, ok := inputs.CustomModuleBasics[name]; ok {
app.basicManager[name] = customBasicMod
customBasicMod.RegisterInterfaces(inputs.InterfaceRegistry)
customBasicMod.RegisterLegacyAminoCodec(inputs.LegacyAmino)
continue
}

coreAppModuleBasic := module.CoreAppModuleBasicAdaptor(name, mod)
app.basicManager[name] = coreAppModuleBasic
coreAppModuleBasic.RegisterInterfaces(inputs.InterfaceRegistry)
coreAppModuleBasic.RegisterLegacyAminoCodec(inputs.LegacyAmino)
}
}

Expand Down
2 changes: 0 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ func NewSimApp(
legacyAmino := codec.NewLegacyAmino()
txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes)

std.RegisterLegacyAminoCodec(legacyAmino)
std.RegisterInterfaces(interfaceRegistry)

// Below we could construct and set an application specific mempool and
Expand Down Expand Up @@ -416,7 +415,6 @@ func NewSimApp(
},
),
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)

// NOTE: upgrade module is required to be prioritized
Expand Down
8 changes: 0 additions & 8 deletions std/codec.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package std

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
)

// RegisterLegacyAminoCodec registers types with the Amino codec.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
sdk.RegisterLegacyAminoCodec(cdc)
cryptocodec.RegisterCrypto(cdc)
codec.RegisterEvidences(cdc)
}

// RegisterInterfaces registers Interfaces from sdk/types, vesting, crypto, tx.
func RegisterInterfaces(interfaceRegistry types.InterfaceRegistry) {
sdk.RegisterInterfaces(interfaceRegistry)
Expand Down
Loading
Loading