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

fix unsupported sign-mode issue #8728

Merged
merged 4 commits into from
Oct 2, 2024
Merged
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 @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#8563](https://github.com/osmosis-labs/osmosis/pull/8563) Add additional queries in x/gauges
* [#8726](https://github.com/osmosis-labs/osmosis/pull/8726) fix: multiple temp directories on command executions
* [#8731](https://github.com/osmosis-labs/osmosis/pull/8731) fix: in place testnet logs
* [#8728](https://github.com/osmosis-labs/osmosis/pull/8728) fix unsupported sign-mode issue
* [#8743](https://github.com/osmosis-labs/osmosis/pull/8743) chore: bump sdk and cometbft

### State Machine Breaking
Expand Down
25 changes: 25 additions & 0 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"cosmossdk.io/core/appmodule"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/cosmos/cosmos-sdk/x/auth/tx"

cosmosdb "github.com/cosmos/cosmos-db"

Expand Down Expand Up @@ -61,7 +62,9 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
Expand Down Expand Up @@ -389,6 +392,24 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

// This needs to go after ReadFromClientConfig, as that function
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
// is only available if the client is online.
if !initClientCtx.Offline {
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL),
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
txConfigWithTextual, err := tx.NewTxConfigWithOptions(
initClientCtx.Codec,
txConfigOpts,
)
if err != nil {
return err
}
initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual)
}
Comment on lines +398 to +411
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent sign mode configuration across the application

You have correctly enabled SIGN_MODE_TEXTUAL in the NewRootCmd function when the client is online. However, in the autoCliOpts function (lines 1324-1327), EnabledSignModes is set to tx.DefaultSignModes without including SIGN_MODE_TEXTUAL. This inconsistency might lead to issues with transaction signing in the auto-generated CLI commands.

Apply this diff to include SIGN_MODE_TEXTUAL in autoCliOpts:

 func autoCliOpts(initClientCtx client.Context, tempApp *osmosis.OsmosisApp) autocli.AppOptions {
     ...
     TxConfigOpts: tx.ConfigOptions{
-        EnabledSignModes:           tx.DefaultSignModes,
+        EnabledSignModes:           append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL),
         TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
     },
     ...
 }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !initClientCtx.Offline {
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL),
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
txConfigWithTextual, err := tx.NewTxConfigWithOptions(
initClientCtx.Codec,
txConfigOpts,
)
if err != nil {
return err
}
initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual)
}
func autoCliOpts(initClientCtx client.Context, tempApp *osmosis.OsmosisApp) autocli.AppOptions {
...
TxConfigOpts: tx.ConfigOptions{
EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL),
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
},
...
}


// Only loads asset list into a map if human readable denoms are enabled.
assetMap, assetMapRev := map[string]DenomUnitMap{}, map[string]string{}
if humanReadableDenomsInput || humanReadableDenomsOutput {
Expand Down Expand Up @@ -1308,5 +1329,9 @@ func autoCliOpts(initClientCtx client.Context, tempApp *osmosis.OsmosisApp) auto
ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
ClientCtx: initClientCtx,
TxConfigOpts: tx.ConfigOptions{
EnabledSignModes: tx.DefaultSignModes,
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
},
}
}