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

chore: Remove register-finality-provider cmd #189

Merged
merged 6 commits into from
Dec 5, 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 @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* [#179](https://github.com/babylonlabs-io/finality-provider/pull/179) Change `btc_pk` text to `eots_pk` in CLI
* [#182](https://github.com/babylonlabs-io/finality-provider/pull/182) Remove fp manager
* [#184](https://github.com/babylonlabs-io/finality-provider/pull/184) eots manager sign record store
* [#189](https://github.com/babylonlabs-io/finality-provider/pull/189) Remove `fpd register-finality-provider` cmd
* [#190](https://github.com/babylonlabs-io/finality-provider/pull/190) Benchmark pub rand

### Bug Fixes
Expand Down
73 changes: 21 additions & 52 deletions docs/finality-provider-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ gain an overall understanding of the finality provider.
4. [Starting the Finality Provider Daemon](#44-starting-the-finality-provider-daemon)
5. [Finality Provider Operation](#5-finality-provider-operations)
1. [Create Finality Provider](#51-create-finality-provider)
2. [Register Finality Provider](#52-register-finality-provider)
3. [Withdrawing Rewards](#53-withdrawing-rewards)
4. [Jailing and Unjailing](#54-jailing-and-unjailing)
5. [Slashing](#55-slashing)
2. [Withdrawing Rewards](#52-withdrawing-rewards)
3. [Jailing and Unjailing](#53-jailing-and-unjailing)
4. [Slashing](#54-slashing)

## 1. A note about Phase-1 Finality Providers

Expand Down Expand Up @@ -479,14 +478,14 @@ RPC will have access to all the EOTS keys held within it

For example, after registering a finality provider, you can start its daemon by
providing the EOTS public key `fpd start --eots-pk <hex-string-of-eots-public-key>`
```

## 5. Finality Provider Operations

### 5.1 Create Finality Provider

The `create-finality-provider` command initializes a new finality provider
instance locally.
The `create-finality-provider` command initializes a new finality provider,
submits `MsgCreateFinalityProvider` to register it on the Babylon chain, and
saves the finality provider information in the database.

``` shell
fpd create-finality-provider \
Expand Down Expand Up @@ -531,9 +530,11 @@ your finality provider's details:

``` json
{
"fp_addr": "bbn1ht2nxa6hlyl89m8xpdde9xsj40n0sxd2f9shsq",
"eots_pk_hex":
"cf0f03b9ee2d4a0f27240e2d8b8c8ef609e24358b2eb3cfd89ae4e4f472e1a41",
"finality_provider":
{
"fp_addr": "bbn1ht2nxa6hlyl89m8xpdde9xsj40n0sxd2f9shsq",
"eots_pk_hex":
"cf0f03b9ee2d4a0f27240e2d8b8c8ef609e24358b2eb3cfd89ae4e4f472e1a41",
"description":
{
"moniker": "MyFinalityProvider",
Expand All @@ -542,7 +543,9 @@ your finality provider's details:
"details": "finality provider for the Babylon network"
},
"commission": "0.050000000000000000",
"status": "CREATED"
"status": "REGISTERED"
}
"tx_hash": "C08377CF289DF0DC5FA462E6409ADCB65A3492C22A112C58EA449F4DC544A3B1"
}
```

Expand All @@ -552,11 +555,13 @@ The response includes:
- `description`: Your finality provider's metadata
- `commission`: Your set commission rate
- `status`: Current status of the finality provider.
- `tx_hash`: Babylon transaction hash of the finality provider creation
transaction, which you can use to verify the success of the transaction
on the Babylon chain.

Below you can see a list of the statuses that a finality provider can transition
to:
- `CREATED`: defines a finality provider that is awaiting registration
- `REGISTERED`: defines a finality provider that has been registered
- `REGISTERED`: defines a finality provider that has been created and registered
to the consumer chain but has no delegated stake
- `ACTIVE`: defines a finality provider that is delegated to vote
- `INACTIVE`: defines a finality provider whose delegations are reduced to
Expand All @@ -569,56 +574,20 @@ to:
For more information on statuses please refer to diagram in the core documentation
[fp-core](fp-core.md).

### 5.2. Register Finality Provider

The `register-finality-provider` command registers your finality provider on the
Babylon chain. This command requires you to specify:

1. The EOTS public key of the finality provider you wish to register
2. The Babylon account associated with your finality provider
(the one specified in the creation) having sufficient funds
to pay for the transaction fee.
3. A running fpd daemon

``` shell
fpd register-finality-provider \
<fp-eots-pk-hex> \
--daemon-address <rpc-address> \
--home <path>
```

Parameters:
- `<fp-eots-pk-hex>`: The EOTS public key of the finality provider you want to
register (e.g., `cf0f03b9ee2d4a0f27240e2d8b8c8ef609e24358b2eb3cfd89ae4e4f472e1a41`)
- `--daemon-address`: RPC address of the finality provider daemon
(default: `127.0.0.1:12581`)
- `--home`: Path to your finality provider daemon home directory (e.g., `~/.fpdHome`)

If successful, the command will return a transaction hash:

``` shell
{ "tx_hash":
"C08377CF289DF0DC5FA462E6409ADCB65A3492C22A112C58EA449F4DC544A3B1" }
```

You can verify the transaction was successful by looking up this transaction
hash on the Babylon chain.


<!-- vitsalis: TODO: How about listing the finality providers using the CLI to
demonstrate that the finality provider has the status `REGISTERED`?
That would be a native way to verify the installation, without having to
touch Babylon. Natural way to introduce the `CREATED` status.
-->

### 5.3. Withdrawing Rewards
### 5.2. Withdrawing Rewards

As a participant in the Finality Provider Program, you will earn rewards that
can be withdrawn. The functionality for withdrawing rewards is currently under
development and will be available soon. Further updates will be provided once
this feature is implemented.

### 5.4. Jailing and Unjailing
### 5.3. Jailing and Unjailing

A finality provider can be jailed for the following reasons:
1. Missing Votes
Expand Down Expand Up @@ -655,7 +624,7 @@ Parameters:

> ⚠️ Before unjailing, ensure you've fixed the underlying issue that caused jailing

### 5.5. Slashing
### 5.4. Slashing

**Slashing occurs** when a finality provider **double signs**, meaning that the
finality provider signs conflicting blocks at the same height. This results in
Expand Down
67 changes: 4 additions & 63 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 @@ -182,21 +176,20 @@ func runCommandCreateFP(ctx client.Context, cmd *cobra.Command, _ []string) erro
return fmt.Errorf("eots-pk cannot be empty")
}

info, err := client.CreateFinalityProvider(
res, err := client.CreateFinalityProvider(
context.Background(),
keyName,
chainID,
eotsPkHex,
passphrase,
hdPath,
description,
&commissionRate,
)
if err != nil {
return err
}

printRespJSON(info.FinalityProvider)
printRespJSON(res)
return nil
}

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
Loading