Skip to content

Commit

Permalink
remove register-finality-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Dec 4, 2024
1 parent 807263a commit 4898992
Show file tree
Hide file tree
Showing 19 changed files with 600 additions and 1,188 deletions.
63 changes: 2 additions & 61 deletions finality-provider/cmd/fpd/daemon/daemon_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,17 @@ func CommandCreateFP() *cobra.Command {

f := cmd.Flags()
f.String(fpdDaemonAddressFlag, defaultFpdDaemonAddress, "The RPC server address of fpd")
f.String(keyNameFlag, "", "The unique name of the finality provider key")
f.String(keyNameFlag, "", "The unique key name of the finality provider's Babylon account")
f.String(sdkflags.FlagHome, fpcfg.DefaultFpdDir, "The application home directory")
f.String(chainIDFlag, "", "The identifier of the consumer chain")
f.String(passphraseFlag, "", "The pass phrase used to encrypt the keys")
f.String(hdPathFlag, "", "The hd path used to derive the private key")
f.String(commissionRateFlag, "0.05", "The commission rate for the finality provider, e.g., 0.05")
f.String(monikerFlag, "", "A human-readable name for the finality provider")
f.String(identityFlag, "", "An optional identity signature (ex. UPort or Keybase)")
f.String(websiteFlag, "", "An optional website link")
f.String(securityContactFlag, "", "An email for security contact")
f.String(detailsFlag, "", "Other optional details")
f.String(fpEotsPkFlag, "", "The hex string of the EOTS public key")
f.String(fpEotsPkFlag, "", "The hex string of the finality provider's EOTS public key")

// make flags required
if err := cmd.MarkFlagRequired(chainIDFlag); err != nil {
Expand Down Expand Up @@ -168,11 +167,6 @@ func runCommandCreateFP(ctx client.Context, cmd *cobra.Command, _ []string) erro
return fmt.Errorf("failed to read flag %s: %w", passphraseFlag, err)
}

hdPath, err := flags.GetString(hdPathFlag)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", hdPathFlag, err)
}

eotsPkHex, err := flags.GetString(fpEotsPkFlag)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", fpEotsPkFlag, err)
Expand All @@ -188,7 +182,6 @@ func runCommandCreateFP(ctx client.Context, cmd *cobra.Command, _ []string) erro
chainID,
eotsPkHex,
passphrase,
hdPath,
description,
&commissionRate,
)
Expand Down Expand Up @@ -353,58 +346,6 @@ func runCommandInfoFP(cmd *cobra.Command, args []string) error {
return nil
}

// CommandRegisterFP returns the register-finality-provider command by connecting to the fpd daemon.
func CommandRegisterFP() *cobra.Command {
var cmd = &cobra.Command{
Use: "register-finality-provider [fp-eots-pk-hex]",
Aliases: []string{"rfp"},
Short: "Register a created finality provider to Babylon.",
Example: fmt.Sprintf(`fpd register-finality-provider --daemon-address %s`, defaultFpdDaemonAddress),
Args: cobra.ExactArgs(1),
RunE: runCommandRegisterFP,
}
f := cmd.Flags()
f.String(fpdDaemonAddressFlag, defaultFpdDaemonAddress, "The RPC server address of fpd")
f.String(passphraseFlag, "", "The pass phrase used to encrypt the keys")
return cmd
}

func runCommandRegisterFP(cmd *cobra.Command, args []string) error {
fpPk, err := types.NewBIP340PubKeyFromHex(args[0])
if err != nil {
return err
}

flags := cmd.Flags()
daemonAddress, err := flags.GetString(fpdDaemonAddressFlag)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", fpdDaemonAddressFlag, err)
}

client, cleanUp, err := dc.NewFinalityProviderServiceGRpcClient(daemonAddress)
if err != nil {
return err
}
defer func() {
if err := cleanUp(); err != nil {
fmt.Printf("Failed to clean up grpc client: %v\n", err)
}
}()

passphrase, err := flags.GetString(passphraseFlag)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", passphraseFlag, err)
}

res, err := client.RegisterFinalityProvider(context.Background(), fpPk, passphrase)
if err != nil {
return err
}
printRespJSON(res)

return nil
}

// CommandAddFinalitySig returns the add-finality-sig command by connecting to the fpd daemon.
func CommandAddFinalitySig() *cobra.Command {
var cmd = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion finality-provider/cmd/fpd/daemon/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
bbn "github.com/babylonlabs-io/babylon/types"

btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types"

fpcmd "github.com/babylonlabs-io/finality-provider/finality-provider/cmd"
"github.com/babylonlabs-io/finality-provider/finality-provider/cmd/fpd/daemon"
fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config"
Expand Down Expand Up @@ -115,7 +116,7 @@ func rootCmd(outputBuff *bytes.Buffer) *cobra.Command {
cmd.AddCommand(
daemon.CommandInit(), daemon.CommandStart(), daemon.CommandKeys(),
daemon.CommandGetDaemonInfo(), daemon.CommandCreateFP(), daemon.CommandLsFP(),
daemon.CommandInfoFP(), daemon.CommandRegisterFP(), daemon.CommandAddFinalitySig(),
daemon.CommandInfoFP(), daemon.CommandAddFinalitySig(),
daemon.CommandExportFP(), daemon.CommandTxs(),
)

Expand Down
5 changes: 3 additions & 2 deletions finality-provider/cmd/fpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package main

import (
"fmt"
"github.com/babylonlabs-io/finality-provider/version"
"os"

"github.com/babylonlabs-io/finality-provider/version"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -33,7 +34,7 @@ func main() {
cmd.AddCommand(
daemon.CommandInit(), daemon.CommandStart(), daemon.CommandKeys(),
daemon.CommandGetDaemonInfo(), daemon.CommandCreateFP(), daemon.CommandLsFP(),
daemon.CommandInfoFP(), daemon.CommandRegisterFP(), daemon.CommandAddFinalitySig(),
daemon.CommandInfoFP(), daemon.CommandAddFinalitySig(),
daemon.CommandExportFP(), daemon.CommandTxs(), daemon.CommandUnjailFP(),
daemon.CommandEditFinalityDescription(), version.CommandVersion("fpd"),
daemon.CommandCommitPubRand(),
Expand Down
Loading

0 comments on commit 4898992

Please sign in to comment.