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

Remove support for composite (BLS) key type #817

Merged
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 @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (cosmovisor) [\#792](https://github.com/line/lbm-sdk/pull/792) Use upstream's cosmovisor

### Bug Fixes
* (client) [\#817](https://github.com/line/lbm-sdk/pull/817) remove support for composite (BLS) type

### Breaking Changes

Expand Down
4 changes: 2 additions & 2 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test|memory)")
cmd.Flags().String(FlagSignMode, "", "Choose sign mode (direct|amino-json), this is an advanced feature")
cmd.Flags().Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height")
cmd.Flags().String(FlagPrivKeyType, DefaultPrivKeyType, "specify validator's private key type (ed25519|composite). \n"+
"set this to priv_key.type in priv_validator_key.json; default `ed25519`")
cmd.Flags().String(FlagPrivKeyType, DefaultPrivKeyType, "specify validator's private key type (currently only ed25519 is supported).\n"+
"This option affects the priv_key.type setting in priv_validator_key.json")
cmd.Flags().String(FlagFeeAccount, "", "Fee account pays fees for the transaction instead of deducting from the signer")

// --gas can accept integers and "auto"
Expand Down
12 changes: 12 additions & 0 deletions client/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flags_test
import (
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/require"

"github.com/line/lbm-sdk/client/flags"
Expand Down Expand Up @@ -36,3 +37,14 @@ func TestParseGasSetting(t *testing.T) {
})
}
}

func TestAddFlagsToCmd(t *testing.T) {
cmd := cobra.Command{}
flags.AddQueryFlagsToCmd(&cmd)

cmd = cobra.Command{}
flags.AddTxFlagsToCmd(&cmd)

cmd = cobra.Command{}
flags.AddPaginationFlagsToCmd(&cmd, "")
}
4 changes: 2 additions & 2 deletions x/genutil/client/cli/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func CollectGenTxsCmd(genBalIterator types.GenesisBalancesIterator, defaultNodeH

cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
cmd.Flags().String(flagGenTxDir, "", "override default \"gentx\" directory from which collect and execute genesis transactions; default [--home]/config/gentx/")
cmd.Flags().String(flags.FlagPrivKeyType, flags.DefaultPrivKeyType, "specify validator's private key type (ed25519|composite). \n"+
"set this to priv_key.type in priv_validator_key.json; default `ed25519`")
cmd.Flags().String(flags.FlagPrivKeyType, flags.DefaultPrivKeyType, "specify validator's private key type (currently only ed25519 is supported).\n"+
"This option affects the priv_key.type setting in priv_validator_key.json")

return cmd
}
10 changes: 8 additions & 2 deletions x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/cosmos/go-bip39"
cfg "github.com/line/ostracon/config"
"github.com/line/ostracon/libs/cli"
ostos "github.com/line/ostracon/libs/os"
ostrand "github.com/line/ostracon/libs/rand"
"github.com/line/ostracon/privval"
"github.com/line/ostracon/types"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -99,6 +101,10 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
}
}

if strings.ToLower(config.PrivKeyType) != privval.PrivKeyTypeEd25519 {
return fmt.Errorf("unsupported %s: \"%s\"", flags.FlagPrivKeyType, config.PrivKeyType)
}

nodeID, _, err := genutil.InitializeNodeValidatorFilesFromMnemonic(config, mnemonic)
if err != nil {
return err
Expand Down Expand Up @@ -149,8 +155,8 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file")
cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating")
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(flags.FlagPrivKeyType, flags.DefaultPrivKeyType, "specify validator's private key type (ed25519|composite). \n"+
"set this to priv_key.type in priv_validator_key.json; default `ed25519`")
cmd.Flags().String(flags.FlagPrivKeyType, flags.DefaultPrivKeyType, "specify validator's private key type (currently only ed25519 is supported).\n"+
"This option affects the priv_key.type setting in priv_validator_key.json")

return cmd
}
54 changes: 54 additions & 0 deletions x/genutil/client/cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,60 @@ func TestInitCmd(t *testing.T) {
}
}

func TestPrivKeyTypeSupports(t *testing.T) {
tests := []struct {
privKeyType string
shouldErr bool
}{
{
privKeyType: "Ed25519",
shouldErr: false,
},
{
privKeyType: "Composite",
shouldErr: true,
},
{
privKeyType: "Lamport",
shouldErr: true,
},
}

for _, tt := range tests {
tt := tt
t.Run(tt.privKeyType, func(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
require.NoError(t, err)
cfg.PrivKeyType = tt.privKeyType

serverCtx := server.NewContext(viper.New(), cfg, logger)
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
clientCtx := client.Context{}.
WithCodec(marshaler).
WithLegacyAmino(makeCodec()).
WithHomeDir(home)

ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx)

cmd := genutilcli.InitCmd(testMbm, home)
cmd.SetArgs([]string{"alice"})

if tt.shouldErr {
err := cmd.ExecuteContext(ctx)
require.EqualError(t, err, fmt.Sprintf("unsupported priv_key_type: \"%s\"", tt.privKeyType))
} else {
require.NoError(t, cmd.ExecuteContext(ctx))
}
})
}

}

func TestInitRecover(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
Expand Down