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

feat: EIP191 sign mode (backport #11533) #11544

Closed
wants to merge 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (tx) [#\11533](https://github.com/cosmos/cosmos-sdk/pull/11533) Register [`EIP191`](https://eips.ethereum.org/EIPS/eip-191) as an available `SignMode` for chains to use.
* [\#11430](https://github.com/cosmos/cosmos-sdk/pull/11430) Introduce a new `grpc-only` flag, such that when enabled, will start the node in a query-only mode. Note, gRPC MUST be enabled with this flag.
* (x/upgrade) [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `MsgSoftwareUpgrade` and has been added to support v1beta2 msgs-based gov proposals.
* (x/bank) [\#11417](https://github.com/cosmos/cosmos-sdk/pull/11417) Introduce a new `SpendableBalances` gRPC query that retrieves an account's total (paginated) spendable balances.
Expand Down
2 changes: 2 additions & 0 deletions api/cosmos/distribution/v1beta1/tx.pulsar.go

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

46 changes: 27 additions & 19 deletions api/cosmos/tx/signing/v1beta1/signing.pulsar.go

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

2 changes: 1 addition & 1 deletion client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
clientCtx = clientCtx.WithOutputFormat("json")
}

// If the user didn't explicity set a --sign-mode flag, use
// If the user didn't explicitly set a --sign-mode flag, use
// DIRECT_AUX by default.
if clientCtx.SignModeStr == "" || !flagSet.Changed(flags.FlagSignMode) {
clientCtx = clientCtx.WithSignModeStr(flags.SignModeDirectAux)
Expand Down
2 changes: 2 additions & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const (
SignModeLegacyAminoJSON = "amino-json"
// SignModeDirectAux is the value of the --sign-mode flag for SIGN_MODE_DIRECT_AUX
SignModeDirectAux = "direct-aux"
// SignModeEIP191 is the value of the --sign-mode flag for SIGN_MODE_EIP_191
SignModeEIP191 = "eip-191"
)

// List of CLI flags
Expand Down
2 changes: 2 additions & 0 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
case flags.SignModeDirectAux:
signMode = signing.SignMode_SIGN_MODE_DIRECT_AUX
case flags.SignModeEIP191:
signMode = signing.SignMode_SIGN_MODE_EIP_191
}

accNum, _ := flagSet.GetUint64(flags.FlagAccountNumber)
Expand Down
12 changes: 12 additions & 0 deletions proto/cosmos/tx/signing/v1beta1/signing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ enum SignMode {
// SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// Amino JSON and will be removed in the future.
SIGN_MODE_LEGACY_AMINO_JSON = 127;

// SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos
// SDK. Ref: https://eips.ethereum.org/EIPS/eip-191
//
// Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant,
// but is not implemented on the SDK by default. To enable EIP-191, you need
// to pass a custom `TxConfig` that has an implementation of
// `SignModeHandler` for EIP-191. The SDK may decide to fully support
// EIP-191 in the future.
//
// Since: cosmos-sdk 0.45.2
SIGN_MODE_EIP_191 = 191;
}

// SignatureDescriptors wraps multiple SignatureDescriptor's.
Expand Down
78 changes: 43 additions & 35 deletions types/tx/signing/signing.pb.go

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

9 changes: 8 additions & 1 deletion x/auth/tx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ type config struct {

// NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and sign modes. The
// first enabled sign mode will become the default sign mode.
// NOTE: Use NewTxConfigWithHandler to provide a custom signing handler in case the sign mode
// is not supported by default (eg: SignMode_SIGN_MODE_EIP_191).
func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signingtypes.SignMode) client.TxConfig {
return NewTxConfigWithHandler(protoCodec, makeSignModeHandler(enabledSignModes))
}

// NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and signing handler.
func NewTxConfigWithHandler(protoCodec codec.ProtoCodecMarshaler, handler signing.SignModeHandler) client.TxConfig {
return &config{
handler: makeSignModeHandler(enabledSignModes),
handler: handler,
decoder: DefaultTxDecoder(protoCodec),
encoder: DefaultTxEncoder(),
jsonDecoder: DefaultJSONTxDecoder(protoCodec),
Expand Down
2 changes: 2 additions & 0 deletions x/distribution/types/tx.pb.go

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