diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 9c181d04..3eda12ca 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -488,19 +488,22 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error return nil } -// CommandUnsafeDeleteMerkleProof removes merkle proof -func CommandUnsafeDeleteMerkleProof() *cobra.Command { +// CommandUnsafePruneMerkleProof prunes merkle proof +func CommandUnsafePruneMerkleProof() *cobra.Command { var cmd = &cobra.Command{ - Use: "unsafe-remove-merkle-proof [eots_pk]", + Use: "unsafe-prune-merkle-proof [eots_pk]", Aliases: []string{"rmp"}, - Short: "Removes merkle proofs up to the specified target height", - Example: fmt.Sprintf(`fpd unsafe-remove-merkle-proof [eots_pk] --daemon-address %s`, defaultFpdDaemonAddress), + Short: "Prunes merkle proofs up to the specified target height", + Long: strings.TrimSpace(`This command will prune all merkle proof up to the target height. The +operator of this command should ensure that finality provider has voted, or doesn't have voting power up to the target height.' +`), + Example: fmt.Sprintf(`fpd unsafe-prune-merkle-proof [eots_pk] --daemon-address %s`, defaultFpdDaemonAddress), Args: cobra.ExactArgs(1), - RunE: runCommandUnsafeDeleteMerkleProof, + RunE: runCommandUnsafePruneMerkleProof, } cmd.Flags().String(fpdDaemonAddressFlag, defaultFpdDaemonAddress, "The RPC server address of fpd") cmd.Flags().String(chainIDFlag, "", "The identifier of the consumer chain") - cmd.Flags().Uint64(upToHeight, 0, "Target height to delete proofs") + cmd.Flags().Uint64(upToHeight, 0, "Target height to prune merkle proofs") if err := cmd.MarkFlagRequired(chainIDFlag); err != nil { panic(err) @@ -513,7 +516,7 @@ func CommandUnsafeDeleteMerkleProof() *cobra.Command { return cmd } -func runCommandUnsafeDeleteMerkleProof(cmd *cobra.Command, args []string) error { +func runCommandUnsafePruneMerkleProof(cmd *cobra.Command, args []string) error { fpPk, err := types.NewBIP340PubKeyFromHex(args[0]) if err != nil { return err diff --git a/finality-provider/cmd/fpd/main.go b/finality-provider/cmd/fpd/main.go index 3df6401a..88aee363 100644 --- a/finality-provider/cmd/fpd/main.go +++ b/finality-provider/cmd/fpd/main.go @@ -37,7 +37,7 @@ func main() { daemon.CommandInfoFP(), daemon.CommandAddFinalitySig(), daemon.CommandUnjailFP(), daemon.CommandEditFinalityDescription(), daemon.CommandCommitPubRand(), incentivecli.NewWithdrawRewardCmd(), incentivecli.NewSetWithdrawAddressCmd(), - version.CommandVersion("fpd"), daemon.CommandUnsafeDeleteMerkleProof(), + version.CommandVersion("fpd"), daemon.CommandUnsafePruneMerkleProof(), ) if err := cmd.Execute(); err != nil { diff --git a/finality-provider/service/fp_instance.go b/finality-provider/service/fp_instance.go index 17a424dc..211060d4 100644 --- a/finality-provider/service/fp_instance.go +++ b/finality-provider/service/fp_instance.go @@ -1026,8 +1026,3 @@ func (fp *FinalityProviderInstance) GetFinalityProviderSlashedOrJailedWithRetry( return slashed, jailed, nil } - -// TestGetPubProof only used for tests to get access to the store -func (fp *FinalityProviderInstance) TestGetPubProof(height uint64) ([]byte, error) { - return fp.pubRandState.getPubRandProof(fp.btcPk.MustMarshal(), fp.GetChainID(), height) -} diff --git a/itest/e2e_test.go b/itest/e2e_test.go index a8f3e00e..01b8bf0f 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -333,7 +333,7 @@ func TestRemoveMerkleProofsCmd(t *testing.T) { fpIns := fps[0] tm.WaitForFpPubRandTimestamped(t, fps[0]) - cmd := daemon.CommandUnsafeDeleteMerkleProof() + cmd := daemon.CommandUnsafePruneMerkleProof() cmd.SetArgs([]string{ fpIns.GetBtcPkHex(), @@ -346,7 +346,9 @@ func TestRemoveMerkleProofsCmd(t *testing.T) { require.NoError(t, err) require.Eventually(t, func() bool { - _, err := fpIns.TestGetPubProof(99) + _, err := tm.Fps[0].GetPubRandProofStore(). + GetPubRandProof(fpIns.GetChainID(), fpIns.GetBtcPkBIP340().MustMarshal(), 99) + return errors.Is(err, store.ErrPubRandProofNotFound) }, eventuallyWaitTimeOut, eventuallyPollTime) }