Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Dec 16, 2024
1 parent 514b202 commit 66af147
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
19 changes: 11 additions & 8 deletions finality-provider/cmd/fpd/daemon/daemon_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion finality-provider/cmd/fpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 4 additions & 2 deletions itest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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)
}

0 comments on commit 66af147

Please sign in to comment.