From dd9b2755ddffadc570b5b220d8eb19d25ecedc0d Mon Sep 17 00:00:00 2001 From: Lazar Date: Wed, 9 Oct 2024 16:14:43 +0200 Subject: [PATCH 01/17] adds command for edit fp desc --- clientcontroller/babylon.go | 10 ++ clientcontroller/interface.go | 4 + .../cmd/fpd/daemon/daemon_commands.go | 109 +++++++++++++++++- finality-provider/cmd/fpd/main.go | 1 + .../proto/finality_providers.pb.go | 41 ++++--- .../proto/finality_providers.proto | 3 + .../proto/finality_providers_grpc.pb.go | 55 +++++++-- finality-provider/service/client/rpcclient.go | 12 ++ finality-provider/service/rpcserver.go | 27 +++++ 9 files changed, 234 insertions(+), 28 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index d1f545d7..18a7d497 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -510,6 +510,16 @@ func (bc *BabylonController) QueryFinalityProviders() ([]*btcstakingtypes.Finali return fps, nil } +func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcstakingtypes.QueryFinalityProviderResponse, error) { + fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) + res, err := bc.bbnClient.QueryClient.FinalityProvider(fpPubKey.MarshalHex()) + if err != nil { + return nil, fmt.Errorf("failed to query the finality provider %s: %v", fpPubKey.MarshalHex(), err) + } + + return res, nil +} + func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfoResponse, error) { res, err := bc.bbnClient.QueryClient.BTCHeaderChainTip() if err != nil { diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index 366c860a..a2be601a 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -2,6 +2,7 @@ package clientcontroller import ( "fmt" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "cosmossdk.io/math" "github.com/btcsuite/btcd/btcec/v2" @@ -49,6 +50,9 @@ type ClientController interface { // QueryFinalityProviderSlashedOrJailed queries if the finality provider is slashed or jailed QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) + // QueryFinalityProvider queries the finality provider by pk + QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcstakingtypes.QueryFinalityProviderResponse, error) + // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 1eaac417..edcc81a3 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -10,15 +10,15 @@ import ( "cosmossdk.io/math" "github.com/babylonlabs-io/babylon/types" bbntypes "github.com/babylonlabs-io/babylon/types" + finalitycli "github.com/babylonlabs-io/babylon/x/btcstaking/client/cli" + fpcmd "github.com/babylonlabs-io/finality-provider/finality-provider/cmd" + fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" + dc "github.com/babylonlabs-io/finality-provider/finality-provider/service/client" "github.com/cosmos/cosmos-sdk/client" sdkflags "github.com/cosmos/cosmos-sdk/client/flags" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" "github.com/spf13/pflag" - - fpcmd "github.com/babylonlabs-io/finality-provider/finality-provider/cmd" - fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" - dc "github.com/babylonlabs-io/finality-provider/finality-provider/service/client" ) var ( @@ -446,6 +446,107 @@ func runCommandAddFinalitySig(cmd *cobra.Command, args []string) error { return nil } +// CommandEditFinalityDescription edits description of finality provider +func CommandEditFinalityDescription() *cobra.Command { + var cmd = &cobra.Command{ + Use: "edit-finality-provider [btc_pk]", + Aliases: []string{"efp"}, + Short: "Edit finality provider", + Example: fmt.Sprintf(`fpd edit-finality-provider --daemon-address %s`, defaultFpdDaemonAddress), + Args: cobra.ExactArgs(1), + RunE: runCommandEditFinalityDescription, + } + cmd.Flags().String(fpdDaemonAddressFlag, defaultFpdDaemonAddress, "The RPC server address of fpd") + cmd.Flags().String(monikerFlag, "", "The finality provider's (optional) moniker") + cmd.Flags().String(websiteFlag, "", "The finality provider's (optional) website") + cmd.Flags().String(securityContactFlag, "", "The finality provider's (optional) security contact email") + cmd.Flags().String(detailsFlag, "", "The finality provider's (optional) details") + cmd.Flags().String(identityFlag, "", "The (optional) identity signature (ex. UPort or Keybase)") + + return cmd +} + +func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error { + fpPk, err := bbntypes.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) + } + + grpcClient, 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) + } + }() + + getValueOrDefault := func(flagValue, defaultValue string) string { + if flagValue != "" { + return flagValue + } + return defaultValue + } + + fpRes, err := grpcClient.QueryFinalityProviderInfoRemote(cmd.Context(), fpPk) + if err != nil { + return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) + } + + monFlag, _ := cmd.Flags().GetString(monikerFlag) + idFlag, _ := cmd.Flags().GetString(identityFlag) + webFlag, _ := cmd.Flags().GetString(websiteFlag) + secFlag, _ := cmd.Flags().GetString(securityContactFlag) + detFlag, _ := cmd.Flags().GetString(detailsFlag) + + moniker := getValueOrDefault(monFlag, fpRes.FinalityProvider.Description.Moniker) + identity := getValueOrDefault(idFlag, fpRes.FinalityProvider.Description.Identity) + website := getValueOrDefault(webFlag, fpRes.FinalityProvider.Description.Website) + security := getValueOrDefault(secFlag, fpRes.FinalityProvider.Description.SecurityContact) + details := getValueOrDefault(detFlag, fpRes.FinalityProvider.Description.Details) + + editFinalityCmd := finalitycli.NewEditFinalityProviderCmd() + + if err := editFinalityCmd.Flags().Set(monikerFlag, moniker); err != nil { + return err + } + + if err := editFinalityCmd.Flags().Set(identityFlag, identity); err != nil { + return err + } + + if err := editFinalityCmd.Flags().Set(websiteFlag, website); err != nil { + return err + } + + if err := editFinalityCmd.Flags().Set(securityContactFlag, security); err != nil { + return err + } + + if err := editFinalityCmd.Flags().Set(detailsFlag, details); err != nil { + return err + } + + if err := editFinalityCmd.Flags().Set(commissionRateFlag, fpRes.FinalityProvider.Commission); err != nil { + return err + } + + if err := editFinalityCmd.Execute(); err != nil { + return err + } + + // todo(lazar): if this is successful update local store also + + return nil +} + func printRespJSON(resp interface{}) { jsonBytes, err := json.MarshalIndent(resp, "", " ") if err != nil { diff --git a/finality-provider/cmd/fpd/main.go b/finality-provider/cmd/fpd/main.go index 9d168bbb..5a0c384a 100644 --- a/finality-provider/cmd/fpd/main.go +++ b/finality-provider/cmd/fpd/main.go @@ -34,6 +34,7 @@ func main() { daemon.CommandGetDaemonInfo(), daemon.CommandCreateFP(), daemon.CommandLsFP(), daemon.CommandInfoFP(), daemon.CommandRegisterFP(), daemon.CommandAddFinalitySig(), daemon.CommandExportFP(), daemon.CommandTxs(), daemon.CommandUnjailFP(), + daemon.CommandEditFinalityDescription(), ) if err := cmd.Execute(); err != nil { diff --git a/finality-provider/proto/finality_providers.pb.go b/finality-provider/proto/finality_providers.pb.go index 0a0fa1dd..701ec312 100644 --- a/finality-provider/proto/finality_providers.pb.go +++ b/finality-provider/proto/finality_providers.pb.go @@ -1577,7 +1577,7 @@ var file_finality_providers_proto_rawDesc = []byte{ 0x18, 0x0a, 0x07, 0x53, 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x10, 0x04, 0x1a, 0x0b, 0x8a, 0x9d, 0x20, 0x07, 0x53, 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x4a, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x05, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x4a, 0x41, 0x49, 0x4c, 0x45, - 0x44, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x32, 0xa7, 0x06, 0x0a, 0x11, 0x46, 0x69, 0x6e, 0x61, + 0x44, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x32, 0x91, 0x07, 0x0a, 0x11, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x38, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, @@ -1628,11 +1628,18 @@ var file_finality_providers_proto_rawDesc = []byte{ 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, - 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x12, 0x68, 0x0a, 0x1b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, + 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x45, 0x5a, 0x43, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, + 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, + 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, + 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1688,16 +1695,18 @@ var file_finality_providers_proto_depIdxs = []int32{ 11, // 11: proto.FinalityProviders.QueryFinalityProvider:input_type -> proto.QueryFinalityProviderRequest 13, // 12: proto.FinalityProviders.QueryFinalityProviderList:input_type -> proto.QueryFinalityProviderListRequest 20, // 13: proto.FinalityProviders.SignMessageFromChainKey:input_type -> proto.SignMessageFromChainKeyRequest - 2, // 14: proto.FinalityProviders.GetInfo:output_type -> proto.GetInfoResponse - 4, // 15: proto.FinalityProviders.CreateFinalityProvider:output_type -> proto.CreateFinalityProviderResponse - 6, // 16: proto.FinalityProviders.RegisterFinalityProvider:output_type -> proto.RegisterFinalityProviderResponse - 8, // 17: proto.FinalityProviders.AddFinalitySignature:output_type -> proto.AddFinalitySignatureResponse - 10, // 18: proto.FinalityProviders.UnjailFinalityProvider:output_type -> proto.UnjailFinalityProviderResponse - 12, // 19: proto.FinalityProviders.QueryFinalityProvider:output_type -> proto.QueryFinalityProviderResponse - 14, // 20: proto.FinalityProviders.QueryFinalityProviderList:output_type -> proto.QueryFinalityProviderListResponse - 21, // 21: proto.FinalityProviders.SignMessageFromChainKey:output_type -> proto.SignMessageFromChainKeyResponse - 14, // [14:22] is the sub-list for method output_type - 6, // [6:14] is the sub-list for method input_type + 11, // 14: proto.FinalityProviders.QueryFinalityProviderRemote:input_type -> proto.QueryFinalityProviderRequest + 2, // 15: proto.FinalityProviders.GetInfo:output_type -> proto.GetInfoResponse + 4, // 16: proto.FinalityProviders.CreateFinalityProvider:output_type -> proto.CreateFinalityProviderResponse + 6, // 17: proto.FinalityProviders.RegisterFinalityProvider:output_type -> proto.RegisterFinalityProviderResponse + 8, // 18: proto.FinalityProviders.AddFinalitySignature:output_type -> proto.AddFinalitySignatureResponse + 10, // 19: proto.FinalityProviders.UnjailFinalityProvider:output_type -> proto.UnjailFinalityProviderResponse + 12, // 20: proto.FinalityProviders.QueryFinalityProvider:output_type -> proto.QueryFinalityProviderResponse + 14, // 21: proto.FinalityProviders.QueryFinalityProviderList:output_type -> proto.QueryFinalityProviderListResponse + 21, // 22: proto.FinalityProviders.SignMessageFromChainKey:output_type -> proto.SignMessageFromChainKeyResponse + 12, // 23: proto.FinalityProviders.QueryFinalityProviderRemote:output_type -> proto.QueryFinalityProviderResponse + 15, // [15:24] is the sub-list for method output_type + 6, // [6:15] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name diff --git a/finality-provider/proto/finality_providers.proto b/finality-provider/proto/finality_providers.proto index 8760db57..49e4ecc3 100644 --- a/finality-provider/proto/finality_providers.proto +++ b/finality-provider/proto/finality_providers.proto @@ -41,6 +41,9 @@ service FinalityProviders { // SignMessageFromChainKey signs a message from the chain keyring. rpc SignMessageFromChainKey (SignMessageFromChainKeyRequest) returns (SignMessageFromChainKeyResponse); + + // QueryFinalityProvider queries the finality provider in babylon node. + rpc QueryFinalityProviderRemote (QueryFinalityProviderRequest) returns (QueryFinalityProviderResponse); } message GetInfoRequest { diff --git a/finality-provider/proto/finality_providers_grpc.pb.go b/finality-provider/proto/finality_providers_grpc.pb.go index a3ab355d..2cf302e4 100644 --- a/finality-provider/proto/finality_providers_grpc.pb.go +++ b/finality-provider/proto/finality_providers_grpc.pb.go @@ -19,14 +19,15 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - FinalityProviders_GetInfo_FullMethodName = "/proto.FinalityProviders/GetInfo" - FinalityProviders_CreateFinalityProvider_FullMethodName = "/proto.FinalityProviders/CreateFinalityProvider" - FinalityProviders_RegisterFinalityProvider_FullMethodName = "/proto.FinalityProviders/RegisterFinalityProvider" - FinalityProviders_AddFinalitySignature_FullMethodName = "/proto.FinalityProviders/AddFinalitySignature" - FinalityProviders_UnjailFinalityProvider_FullMethodName = "/proto.FinalityProviders/UnjailFinalityProvider" - FinalityProviders_QueryFinalityProvider_FullMethodName = "/proto.FinalityProviders/QueryFinalityProvider" - FinalityProviders_QueryFinalityProviderList_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderList" - FinalityProviders_SignMessageFromChainKey_FullMethodName = "/proto.FinalityProviders/SignMessageFromChainKey" + FinalityProviders_GetInfo_FullMethodName = "/proto.FinalityProviders/GetInfo" + FinalityProviders_CreateFinalityProvider_FullMethodName = "/proto.FinalityProviders/CreateFinalityProvider" + FinalityProviders_RegisterFinalityProvider_FullMethodName = "/proto.FinalityProviders/RegisterFinalityProvider" + FinalityProviders_AddFinalitySignature_FullMethodName = "/proto.FinalityProviders/AddFinalitySignature" + FinalityProviders_UnjailFinalityProvider_FullMethodName = "/proto.FinalityProviders/UnjailFinalityProvider" + FinalityProviders_QueryFinalityProvider_FullMethodName = "/proto.FinalityProviders/QueryFinalityProvider" + FinalityProviders_QueryFinalityProviderList_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderList" + FinalityProviders_SignMessageFromChainKey_FullMethodName = "/proto.FinalityProviders/SignMessageFromChainKey" + FinalityProviders_QueryFinalityProviderRemote_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderRemote" ) // FinalityProvidersClient is the client API for FinalityProviders service. @@ -52,6 +53,8 @@ type FinalityProvidersClient interface { QueryFinalityProviderList(ctx context.Context, in *QueryFinalityProviderListRequest, opts ...grpc.CallOption) (*QueryFinalityProviderListResponse, error) // SignMessageFromChainKey signs a message from the chain keyring. SignMessageFromChainKey(ctx context.Context, in *SignMessageFromChainKeyRequest, opts ...grpc.CallOption) (*SignMessageFromChainKeyResponse, error) + // QueryFinalityProvider queries the finality provider in babylon node. + QueryFinalityProviderRemote(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) } type finalityProvidersClient struct { @@ -134,6 +137,15 @@ func (c *finalityProvidersClient) SignMessageFromChainKey(ctx context.Context, i return out, nil } +func (c *finalityProvidersClient) QueryFinalityProviderRemote(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { + out := new(QueryFinalityProviderResponse) + err := c.cc.Invoke(ctx, FinalityProviders_QueryFinalityProviderRemote_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // FinalityProvidersServer is the server API for FinalityProviders service. // All implementations must embed UnimplementedFinalityProvidersServer // for forward compatibility @@ -157,6 +169,8 @@ type FinalityProvidersServer interface { QueryFinalityProviderList(context.Context, *QueryFinalityProviderListRequest) (*QueryFinalityProviderListResponse, error) // SignMessageFromChainKey signs a message from the chain keyring. SignMessageFromChainKey(context.Context, *SignMessageFromChainKeyRequest) (*SignMessageFromChainKeyResponse, error) + // QueryFinalityProvider queries the finality provider in babylon node. + QueryFinalityProviderRemote(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) mustEmbedUnimplementedFinalityProvidersServer() } @@ -188,6 +202,9 @@ func (UnimplementedFinalityProvidersServer) QueryFinalityProviderList(context.Co func (UnimplementedFinalityProvidersServer) SignMessageFromChainKey(context.Context, *SignMessageFromChainKeyRequest) (*SignMessageFromChainKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SignMessageFromChainKey not implemented") } +func (UnimplementedFinalityProvidersServer) QueryFinalityProviderRemote(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryFinalityProviderRemote not implemented") +} func (UnimplementedFinalityProvidersServer) mustEmbedUnimplementedFinalityProvidersServer() {} // UnsafeFinalityProvidersServer may be embedded to opt out of forward compatibility for this service. @@ -345,6 +362,24 @@ func _FinalityProviders_SignMessageFromChainKey_Handler(srv interface{}, ctx con return interceptor(ctx, in, info, handler) } +func _FinalityProviders_QueryFinalityProviderRemote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FinalityProvidersServer).QueryFinalityProviderRemote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FinalityProviders_QueryFinalityProviderRemote_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FinalityProvidersServer).QueryFinalityProviderRemote(ctx, req.(*QueryFinalityProviderRequest)) + } + return interceptor(ctx, in, info, handler) +} + // FinalityProviders_ServiceDesc is the grpc.ServiceDesc for FinalityProviders service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -384,6 +419,10 @@ var FinalityProviders_ServiceDesc = grpc.ServiceDesc{ MethodName: "SignMessageFromChainKey", Handler: _FinalityProviders_SignMessageFromChainKey_Handler, }, + { + MethodName: "QueryFinalityProviderRemote", + Handler: _FinalityProviders_QueryFinalityProviderRemote_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "finality_providers.proto", diff --git a/finality-provider/service/client/rpcclient.go b/finality-provider/service/client/rpcclient.go index eee41673..cc352594 100644 --- a/finality-provider/service/client/rpcclient.go +++ b/finality-provider/service/client/rpcclient.go @@ -126,6 +126,7 @@ func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderList(ctx contex return res, nil } +// QueryFinalityProviderInfo - gets the finality provider data from local store func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfo(ctx context.Context, fpPk *bbntypes.BIP340PubKey) (*proto.QueryFinalityProviderResponse, error) { req := &proto.QueryFinalityProviderRequest{BtcPk: fpPk.MarshalHex()} res, err := c.client.QueryFinalityProvider(ctx, req) @@ -136,6 +137,17 @@ func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfo(ctx contex return res, nil } +// QueryFinalityProviderInfoRemote - gets the finality provider data from babylon node +func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfoRemote(ctx context.Context, fpPk *bbntypes.BIP340PubKey) (*proto.QueryFinalityProviderResponse, error) { + req := &proto.QueryFinalityProviderRequest{BtcPk: fpPk.MarshalHex()} + res, err := c.client.QueryFinalityProviderRemote(ctx, req) + if err != nil { + return nil, err + } + + return res, nil +} + func (c *FinalityProviderServiceGRpcClient) SignMessageFromChainKey( ctx context.Context, keyName, passphrase, hdPath string, diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index 3064000e..458152f4 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -224,6 +224,33 @@ func (r *rpcServer) QueryFinalityProvider(ctx context.Context, req *proto.QueryF return &proto.QueryFinalityProviderResponse{FinalityProvider: fp}, nil } +func (r *rpcServer) QueryFinalityProviderRemote(ctx context.Context, req *proto.QueryFinalityProviderRequest) ( + *proto.QueryFinalityProviderResponse, error) { + fpPk, err := bbntypes.NewBIP340PubKeyFromHex(req.BtcPk) + if err != nil { + return nil, err + } + + fp, err := r.app.cc.QueryFinalityProvider(fpPk.MustToBTCPK()) + if err != nil { + return nil, err + } + + return &proto.QueryFinalityProviderResponse{ + FinalityProvider: &proto.FinalityProviderInfo{ + FpAddr: fp.FinalityProvider.Addr, + BtcPkHex: fp.FinalityProvider.BtcPk.MarshalHex(), + Description: &proto.Description{ + Moniker: fp.FinalityProvider.Description.Moniker, + Identity: fp.FinalityProvider.Description.Identity, + Website: fp.FinalityProvider.Description.Website, + SecurityContact: fp.FinalityProvider.Description.SecurityContact, + Details: fp.FinalityProvider.Description.Details, + }, + Commission: fp.FinalityProvider.Commission.String(), + }, + }, nil +} // QueryFinalityProviderList queries the information of a list of finality providers func (r *rpcServer) QueryFinalityProviderList(ctx context.Context, req *proto.QueryFinalityProviderListRequest) ( From b1c0d8576bf052a9904dd9a09e448c62001c78f1 Mon Sep 17 00:00:00 2001 From: Lazar Date: Wed, 9 Oct 2024 17:38:35 +0200 Subject: [PATCH 02/17] pass flags --- clientcontroller/babylon.go | 10 ++++ .../cmd/fpd/daemon/daemon_commands.go | 56 +++++++------------ finality-provider/cmd/fpd/daemon/flags.go | 2 +- itest/eotsmanager_handler.go | 5 +- itest/test_manager.go | 16 +++++- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 18a7d497..7a41e75e 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -520,6 +520,16 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs return res, nil } +func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey) (*btcstakingtypes.QueryFinalityProviderResponse, error) { + fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) + res, err := bc.bbnClient.QueryClient.FinalityProvider(fpPubKey.MarshalHex()) + if err != nil { + return nil, fmt.Errorf("failed to query the finality provider %s: %v", fpPubKey.MarshalHex(), err) + } + + return res, nil +} + func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfoResponse, error) { res, err := bc.bbnClient.QueryClient.BTCHeaderChainTip() if err != nil { diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index edcc81a3..7277f98b 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -500,46 +500,30 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) } - monFlag, _ := cmd.Flags().GetString(monikerFlag) - idFlag, _ := cmd.Flags().GetString(identityFlag) - webFlag, _ := cmd.Flags().GetString(websiteFlag) - secFlag, _ := cmd.Flags().GetString(securityContactFlag) - detFlag, _ := cmd.Flags().GetString(detailsFlag) - - moniker := getValueOrDefault(monFlag, fpRes.FinalityProvider.Description.Moniker) - identity := getValueOrDefault(idFlag, fpRes.FinalityProvider.Description.Identity) - website := getValueOrDefault(webFlag, fpRes.FinalityProvider.Description.Website) - security := getValueOrDefault(secFlag, fpRes.FinalityProvider.Description.SecurityContact) - details := getValueOrDefault(detFlag, fpRes.FinalityProvider.Description.Details) + // define new flags to avoid error of passing flags from this context + newFlags := &pflag.FlagSet{} + + // Add only the flags you want to use for the edit command + newFlags.String(monikerFlag, "", "Moniker of the finality provider") + newFlags.String(identityFlag, "", "Identity of the finality provider") + newFlags.String(websiteFlag, "", "Website of the finality provider") + newFlags.String(securityContactFlag, "", "Security contact of the finality provider") + newFlags.String(detailsFlag, "", "Details of the finality provider") + newFlags.String(commissionRateFlag, "", "Commission rate") + + _ = newFlags.Set(monikerFlag, getValueOrDefault(flags.Lookup(monikerFlag).Value.String(), fpRes.FinalityProvider.Description.Moniker)) + _ = newFlags.Set(identityFlag, getValueOrDefault(flags.Lookup(identityFlag).Value.String(), fpRes.FinalityProvider.Description.Identity)) + _ = newFlags.Set(websiteFlag, getValueOrDefault(flags.Lookup(websiteFlag).Value.String(), fpRes.FinalityProvider.Description.Website)) + _ = newFlags.Set(securityContactFlag, getValueOrDefault(flags.Lookup(securityContactFlag).Value.String(), fpRes.FinalityProvider.Description.SecurityContact)) + _ = newFlags.Set(detailsFlag, getValueOrDefault(flags.Lookup(detailsFlag).Value.String(), fpRes.FinalityProvider.Description.Details)) + _ = newFlags.Set(commissionRateFlag, fpRes.FinalityProvider.Commission) editFinalityCmd := finalitycli.NewEditFinalityProviderCmd() - - if err := editFinalityCmd.Flags().Set(monikerFlag, moniker); err != nil { - return err - } - - if err := editFinalityCmd.Flags().Set(identityFlag, identity); err != nil { - return err - } - - if err := editFinalityCmd.Flags().Set(websiteFlag, website); err != nil { - return err - } - - if err := editFinalityCmd.Flags().Set(securityContactFlag, security); err != nil { - return err - } - - if err := editFinalityCmd.Flags().Set(detailsFlag, details); err != nil { - return err - } - - if err := editFinalityCmd.Flags().Set(commissionRateFlag, fpRes.FinalityProvider.Commission); err != nil { - return err - } + editFinalityCmd.Flags().AddFlagSet(newFlags) + editFinalityCmd.SetArgs(args) if err := editFinalityCmd.Execute(); err != nil { - return err + return fmt.Errorf("failed to execute bbn edit command: %v", err) } // todo(lazar): if this is successful update local store also diff --git a/finality-provider/cmd/fpd/daemon/flags.go b/finality-provider/cmd/fpd/daemon/flags.go index 0debceb2..3041608d 100644 --- a/finality-provider/cmd/fpd/daemon/flags.go +++ b/finality-provider/cmd/fpd/daemon/flags.go @@ -18,5 +18,5 @@ const ( websiteFlag = "website" securityContactFlag = "security-contact" detailsFlag = "details" - commissionRateFlag = "commission" + commissionRateFlag = "commission-rate" ) diff --git a/itest/eotsmanager_handler.go b/itest/eotsmanager_handler.go index a35f51fd..7454720f 100644 --- a/itest/eotsmanager_handler.go +++ b/itest/eotsmanager_handler.go @@ -18,10 +18,7 @@ type EOTSServerHandler struct { eotsServer *service.Server } -func NewEOTSServerHandler(t *testing.T, cfg *config.Config, eotsHomeDir string) *EOTSServerHandler { - shutdownInterceptor, err := signal.Intercept() - require.NoError(t, err) - +func NewEOTSServerHandler(t *testing.T, cfg *config.Config, eotsHomeDir string, shutdownInterceptor signal.Interceptor) *EOTSServerHandler { dbBackend, err := cfg.DatabaseConfig.GetDbBackend() require.NoError(t, err) logger := zap.NewNop() diff --git a/itest/test_manager.go b/itest/test_manager.go index a18397ba..c7ffe6c6 100644 --- a/itest/test_manager.go +++ b/itest/test_manager.go @@ -3,6 +3,7 @@ package e2etest import ( "encoding/hex" "fmt" + "github.com/lightningnetwork/lnd/signal" "math/rand" "os" "path/filepath" @@ -130,14 +131,17 @@ func StartManager(t *testing.T) *TestManager { }, eventuallyWaitTimeOut, eventuallyPollTime) t.Logf("current epoch is %d", currentEpoch) + shutdownInterceptor, err := signal.Intercept() + require.NoError(t, err) + // 3. prepare EOTS manager eotsHomeDir := filepath.Join(testDir, "eots-home") eotsCfg := eotsconfig.DefaultConfigWithHomePath(eotsHomeDir) eotsCfg.RpcListener = fmt.Sprintf("127.0.0.1:%d", testutil.AllocateUniquePort(t)) - eh := NewEOTSServerHandler(t, eotsCfg, eotsHomeDir) + eh := NewEOTSServerHandler(t, eotsCfg, eotsHomeDir, shutdownInterceptor) eh.Start() - cfg.RpcListener = eotsCfg.RpcListener - eotsCli, err := client.NewEOTSManagerGRpcClient(cfg.RpcListener) + cfg.RpcListener = fmt.Sprintf("127.0.0.1:%d", testutil.AllocateUniquePort(t)) + eotsCli, err := client.NewEOTSManagerGRpcClient(eotsCfg.RpcListener) require.NoError(t, err) // 4. prepare finality-provider @@ -148,6 +152,12 @@ func StartManager(t *testing.T) *TestManager { err = fpApp.Start() require.NoError(t, err) + fpServer := service.NewFinalityProviderServer(cfg, logger, fpApp, fpdb, shutdownInterceptor) + go func() { + err = fpServer.RunUntilShutdown() + require.NoError(t, err) + }() + tm := &TestManager{ EOTSServerHandler: eh, FpConfig: cfg, From 336bfba89af1f123b931700e2bc659cefacca8fd Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 12:49:07 +0200 Subject: [PATCH 03/17] edit rpc --- clientcontroller/babylon.go | 44 ++- clientcontroller/interface.go | 6 +- .../cmd/fpd/daemon/daemon_commands.go | 48 +-- .../proto/finality_providers.pb.go | 326 ++++++++++++------ .../proto/finality_providers.proto | 15 +- .../proto/finality_providers_grpc.pb.go | 50 +-- finality-provider/service/client/rpcclient.go | 13 +- finality-provider/service/rpcserver.go | 28 +- go.mod | 2 +- go.sum | 4 +- itest/container/config.go | 1 + 11 files changed, 343 insertions(+), 194 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 7a41e75e..00581ae3 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -520,14 +520,50 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs return res, nil } -func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey) (*btcstakingtypes.QueryFinalityProviderResponse, error) { +func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, + reqDesc sttypes.Description) error { + + fpRes, err := bc.QueryFinalityProvider(fpPk) + if err != nil { + return err + } + getValueOrDefault := func(reqValue, defaultValue string) string { + if reqValue != "" { + return reqValue + } + return defaultValue + } + + resDesc := fpRes.FinalityProvider.Description + + desc := sttypes.Description{ + Moniker: getValueOrDefault(reqDesc.Moniker, resDesc.Moniker), + Identity: getValueOrDefault(reqDesc.Identity, resDesc.Identity), + Website: getValueOrDefault(reqDesc.Website, resDesc.Website), + SecurityContact: getValueOrDefault(reqDesc.SecurityContact, resDesc.SecurityContact), + Details: getValueOrDefault(reqDesc.Details, resDesc.Details), + } + + return bc.EditFinalityProvider(fpPk, fpRes.FinalityProvider.Commission, desc) +} + +func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, + rate *sdkmath.LegacyDec, description sttypes.Description) error { fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) - res, err := bc.bbnClient.QueryClient.FinalityProvider(fpPubKey.MarshalHex()) + fmt.Printf("%s/n --------- ", fpPubKey.MustMarshal()) + msg := &btcstakingtypes.MsgEditFinalityProvider{ + Addr: bc.mustGetTxSigner(), + BtcPk: fpPubKey.MustMarshal(), + Description: &description, + Commission: rate, + } + + _, err := bc.reliablySendMsg(msg, emptyErrs, emptyErrs) if err != nil { - return nil, fmt.Errorf("failed to query the finality provider %s: %v", fpPubKey.MarshalHex(), err) + return fmt.Errorf("failed to query the finality provider %s: %v", fpPk.SerializeCompressed(), err) } - return res, nil + return nil } func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfoResponse, error) { diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index a2be601a..f14a106e 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -2,7 +2,7 @@ package clientcontroller import ( "fmt" - btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + sttypes "github.com/cosmos/cosmos-sdk/x/staking/types" "cosmossdk.io/math" "github.com/btcsuite/btcd/btcec/v2" @@ -50,8 +50,8 @@ type ClientController interface { // QueryFinalityProviderSlashedOrJailed queries if the finality provider is slashed or jailed QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) - // QueryFinalityProvider queries the finality provider by pk - QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcstakingtypes.QueryFinalityProviderResponse, error) + // EditFinalityProviderDescription edits description of the finality provider + EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc sttypes.Description) error // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 7277f98b..2b8dd295 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -5,12 +5,12 @@ import ( "encoding/hex" "encoding/json" "fmt" + "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "strconv" "cosmossdk.io/math" "github.com/babylonlabs-io/babylon/types" bbntypes "github.com/babylonlabs-io/babylon/types" - finalitycli "github.com/babylonlabs-io/babylon/x/btcstaking/client/cli" fpcmd "github.com/babylonlabs-io/finality-provider/finality-provider/cmd" fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" dc "github.com/babylonlabs-io/finality-provider/finality-provider/service/client" @@ -488,42 +488,22 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error } }() - getValueOrDefault := func(flagValue, defaultValue string) string { - if flagValue != "" { - return flagValue - } - return defaultValue - } + moniker, _ := cmd.Flags().GetString(monikerFlag) + website, _ := cmd.Flags().GetString(websiteFlag) + securityContact, _ := cmd.Flags().GetString(securityContactFlag) + details, _ := cmd.Flags().GetString(detailsFlag) + identity, _ := cmd.Flags().GetString(identityFlag) - fpRes, err := grpcClient.QueryFinalityProviderInfoRemote(cmd.Context(), fpPk) - if err != nil { - return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) + desc := &proto.Description{ + Moniker: moniker, + Identity: identity, + Website: website, + SecurityContact: securityContact, + Details: details, } - // define new flags to avoid error of passing flags from this context - newFlags := &pflag.FlagSet{} - - // Add only the flags you want to use for the edit command - newFlags.String(monikerFlag, "", "Moniker of the finality provider") - newFlags.String(identityFlag, "", "Identity of the finality provider") - newFlags.String(websiteFlag, "", "Website of the finality provider") - newFlags.String(securityContactFlag, "", "Security contact of the finality provider") - newFlags.String(detailsFlag, "", "Details of the finality provider") - newFlags.String(commissionRateFlag, "", "Commission rate") - - _ = newFlags.Set(monikerFlag, getValueOrDefault(flags.Lookup(monikerFlag).Value.String(), fpRes.FinalityProvider.Description.Moniker)) - _ = newFlags.Set(identityFlag, getValueOrDefault(flags.Lookup(identityFlag).Value.String(), fpRes.FinalityProvider.Description.Identity)) - _ = newFlags.Set(websiteFlag, getValueOrDefault(flags.Lookup(websiteFlag).Value.String(), fpRes.FinalityProvider.Description.Website)) - _ = newFlags.Set(securityContactFlag, getValueOrDefault(flags.Lookup(securityContactFlag).Value.String(), fpRes.FinalityProvider.Description.SecurityContact)) - _ = newFlags.Set(detailsFlag, getValueOrDefault(flags.Lookup(detailsFlag).Value.String(), fpRes.FinalityProvider.Description.Details)) - _ = newFlags.Set(commissionRateFlag, fpRes.FinalityProvider.Commission) - - editFinalityCmd := finalitycli.NewEditFinalityProviderCmd() - editFinalityCmd.Flags().AddFlagSet(newFlags) - editFinalityCmd.SetArgs(args) - - if err := editFinalityCmd.Execute(); err != nil { - return fmt.Errorf("failed to execute bbn edit command: %v", err) + if err := grpcClient.EditFinalityProvider(cmd.Context(), fpPk, desc); err != nil { + return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) } // todo(lazar): if this is successful update local store also diff --git a/finality-provider/proto/finality_providers.pb.go b/finality-provider/proto/finality_providers.pb.go index 701ec312..7cae505b 100644 --- a/finality-provider/proto/finality_providers.pb.go +++ b/finality-provider/proto/finality_providers.pb.go @@ -1396,6 +1396,103 @@ func (x *SignMessageFromChainKeyResponse) GetSignature() []byte { return nil } +// FinalityProviderInfo is the basic information of a finality provider mainly for external usage +type EditFinalityProviderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // btc_pk is the hex string of the BTC secp256k1 PK of the finality provider encoded in BIP-340 spec + BtcPk string `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3" json:"btc_pk,omitempty"` + // description defines the description terms for the finality provider + Description *Description `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *EditFinalityProviderRequest) Reset() { + *x = EditFinalityProviderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_finality_providers_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EditFinalityProviderRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EditFinalityProviderRequest) ProtoMessage() {} + +func (x *EditFinalityProviderRequest) ProtoReflect() protoreflect.Message { + mi := &file_finality_providers_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EditFinalityProviderRequest.ProtoReflect.Descriptor instead. +func (*EditFinalityProviderRequest) Descriptor() ([]byte, []int) { + return file_finality_providers_proto_rawDescGZIP(), []int{21} +} + +func (x *EditFinalityProviderRequest) GetBtcPk() string { + if x != nil { + return x.BtcPk + } + return "" +} + +func (x *EditFinalityProviderRequest) GetDescription() *Description { + if x != nil { + return x.Description + } + return nil +} + +// Define an empty response message +type EmptyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *EmptyResponse) Reset() { + *x = EmptyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_finality_providers_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmptyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmptyResponse) ProtoMessage() {} + +func (x *EmptyResponse) ProtoReflect() protoreflect.Message { + mi := &file_finality_providers_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EmptyResponse.ProtoReflect.Descriptor instead. +func (*EmptyResponse) Descriptor() ([]byte, []int) { + return file_finality_providers_proto_rawDescGZIP(), []int{22} +} + var File_finality_providers_proto protoreflect.FileDescriptor var file_finality_providers_proto_rawDesc = []byte{ @@ -1565,81 +1662,87 @@ var file_finality_providers_proto_rawDesc = []byte{ 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2a, 0xbe, 0x01, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0x00, 0x1a, 0x0b, - 0x8a, 0x9d, 0x20, 0x07, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x52, - 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x0e, 0x8a, 0x9d, 0x20, - 0x0a, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x41, - 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x41, 0x43, 0x54, - 0x49, 0x56, 0x45, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, - 0x03, 0x1a, 0x0c, 0x8a, 0x9d, 0x20, 0x08, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x12, - 0x18, 0x0a, 0x07, 0x53, 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x10, 0x04, 0x1a, 0x0b, 0x8a, 0x9d, - 0x20, 0x07, 0x53, 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x4a, 0x41, 0x49, - 0x4c, 0x45, 0x44, 0x10, 0x05, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x4a, 0x41, 0x49, 0x4c, 0x45, - 0x44, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x32, 0x91, 0x07, 0x0a, 0x11, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x38, 0x0a, - 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, - 0x72, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x6a, 0x0a, 0x1b, 0x45, 0x64, 0x69, 0x74, 0x46, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x12, 0x34, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0x0f, 0x0a, 0x0d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x2a, 0xbe, 0x01, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, + 0x0a, 0x07, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0x00, 0x1a, 0x0b, 0x8a, 0x9d, 0x20, + 0x07, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x45, 0x47, 0x49, + 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x0e, 0x8a, 0x9d, 0x20, 0x0a, 0x52, 0x45, + 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x43, 0x54, 0x49, + 0x56, 0x45, 0x10, 0x02, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, + 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x03, 0x1a, 0x0c, + 0x8a, 0x9d, 0x20, 0x08, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x12, 0x18, 0x0a, 0x07, + 0x53, 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x10, 0x04, 0x1a, 0x0b, 0x8a, 0x9d, 0x20, 0x07, 0x53, + 0x4c, 0x41, 0x53, 0x48, 0x45, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x4a, 0x41, 0x49, 0x4c, 0x45, 0x44, + 0x10, 0x05, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x4a, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x1a, 0x04, + 0x88, 0xa3, 0x1e, 0x00, 0x32, 0xf9, 0x06, 0x0a, 0x11, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, + 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x38, 0x0a, 0x07, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x24, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x18, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, - 0x0a, 0x18, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x14, 0x41, - 0x64, 0x64, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x46, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x41, 0x64, 0x64, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x16, - 0x55, 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, - 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x23, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, - 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x17, 0x53, 0x69, 0x67, 0x6e, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, - 0x65, 0x79, 0x12, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, - 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, - 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x68, 0x0a, 0x1b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, - 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x45, 0x5a, 0x43, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, - 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, - 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, + 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x16, 0x55, 0x6e, 0x6a, + 0x61, 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x6e, 0x6a, 0x61, + 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x55, 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x62, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, + 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x4c, 0x69, 0x73, + 0x74, 0x12, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, + 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x17, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x12, + 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, + 0x0a, 0x14, 0x45, 0x64, 0x69, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, + 0x64, 0x69, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, + 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1655,7 +1758,7 @@ func file_finality_providers_proto_rawDescGZIP() []byte { } var file_finality_providers_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_finality_providers_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_finality_providers_proto_msgTypes = make([]protoimpl.MessageInfo, 23) var file_finality_providers_proto_goTypes = []interface{}{ (FinalityProviderStatus)(0), // 0: proto.FinalityProviderStatus (*GetInfoRequest)(nil), // 1: proto.GetInfoRequest @@ -1679,6 +1782,8 @@ var file_finality_providers_proto_goTypes = []interface{}{ (*SchnorrRandPair)(nil), // 19: proto.SchnorrRandPair (*SignMessageFromChainKeyRequest)(nil), // 20: proto.SignMessageFromChainKeyRequest (*SignMessageFromChainKeyResponse)(nil), // 21: proto.SignMessageFromChainKeyResponse + (*EditFinalityProviderRequest)(nil), // 22: proto.EditFinalityProviderRequest + (*EmptyResponse)(nil), // 23: proto.EmptyResponse } var file_finality_providers_proto_depIdxs = []int32{ 16, // 0: proto.CreateFinalityProviderResponse.finality_provider:type_name -> proto.FinalityProviderInfo @@ -1687,29 +1792,30 @@ var file_finality_providers_proto_depIdxs = []int32{ 18, // 3: proto.FinalityProvider.pop:type_name -> proto.ProofOfPossession 0, // 4: proto.FinalityProvider.status:type_name -> proto.FinalityProviderStatus 17, // 5: proto.FinalityProviderInfo.description:type_name -> proto.Description - 1, // 6: proto.FinalityProviders.GetInfo:input_type -> proto.GetInfoRequest - 3, // 7: proto.FinalityProviders.CreateFinalityProvider:input_type -> proto.CreateFinalityProviderRequest - 5, // 8: proto.FinalityProviders.RegisterFinalityProvider:input_type -> proto.RegisterFinalityProviderRequest - 7, // 9: proto.FinalityProviders.AddFinalitySignature:input_type -> proto.AddFinalitySignatureRequest - 9, // 10: proto.FinalityProviders.UnjailFinalityProvider:input_type -> proto.UnjailFinalityProviderRequest - 11, // 11: proto.FinalityProviders.QueryFinalityProvider:input_type -> proto.QueryFinalityProviderRequest - 13, // 12: proto.FinalityProviders.QueryFinalityProviderList:input_type -> proto.QueryFinalityProviderListRequest - 20, // 13: proto.FinalityProviders.SignMessageFromChainKey:input_type -> proto.SignMessageFromChainKeyRequest - 11, // 14: proto.FinalityProviders.QueryFinalityProviderRemote:input_type -> proto.QueryFinalityProviderRequest - 2, // 15: proto.FinalityProviders.GetInfo:output_type -> proto.GetInfoResponse - 4, // 16: proto.FinalityProviders.CreateFinalityProvider:output_type -> proto.CreateFinalityProviderResponse - 6, // 17: proto.FinalityProviders.RegisterFinalityProvider:output_type -> proto.RegisterFinalityProviderResponse - 8, // 18: proto.FinalityProviders.AddFinalitySignature:output_type -> proto.AddFinalitySignatureResponse - 10, // 19: proto.FinalityProviders.UnjailFinalityProvider:output_type -> proto.UnjailFinalityProviderResponse - 12, // 20: proto.FinalityProviders.QueryFinalityProvider:output_type -> proto.QueryFinalityProviderResponse - 14, // 21: proto.FinalityProviders.QueryFinalityProviderList:output_type -> proto.QueryFinalityProviderListResponse - 21, // 22: proto.FinalityProviders.SignMessageFromChainKey:output_type -> proto.SignMessageFromChainKeyResponse - 12, // 23: proto.FinalityProviders.QueryFinalityProviderRemote:output_type -> proto.QueryFinalityProviderResponse - 15, // [15:24] is the sub-list for method output_type - 6, // [6:15] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 17, // 6: proto.EditFinalityProviderRequest.description:type_name -> proto.Description + 1, // 7: proto.FinalityProviders.GetInfo:input_type -> proto.GetInfoRequest + 3, // 8: proto.FinalityProviders.CreateFinalityProvider:input_type -> proto.CreateFinalityProviderRequest + 5, // 9: proto.FinalityProviders.RegisterFinalityProvider:input_type -> proto.RegisterFinalityProviderRequest + 7, // 10: proto.FinalityProviders.AddFinalitySignature:input_type -> proto.AddFinalitySignatureRequest + 9, // 11: proto.FinalityProviders.UnjailFinalityProvider:input_type -> proto.UnjailFinalityProviderRequest + 11, // 12: proto.FinalityProviders.QueryFinalityProvider:input_type -> proto.QueryFinalityProviderRequest + 13, // 13: proto.FinalityProviders.QueryFinalityProviderList:input_type -> proto.QueryFinalityProviderListRequest + 20, // 14: proto.FinalityProviders.SignMessageFromChainKey:input_type -> proto.SignMessageFromChainKeyRequest + 22, // 15: proto.FinalityProviders.EditFinalityProvider:input_type -> proto.EditFinalityProviderRequest + 2, // 16: proto.FinalityProviders.GetInfo:output_type -> proto.GetInfoResponse + 4, // 17: proto.FinalityProviders.CreateFinalityProvider:output_type -> proto.CreateFinalityProviderResponse + 6, // 18: proto.FinalityProviders.RegisterFinalityProvider:output_type -> proto.RegisterFinalityProviderResponse + 8, // 19: proto.FinalityProviders.AddFinalitySignature:output_type -> proto.AddFinalitySignatureResponse + 10, // 20: proto.FinalityProviders.UnjailFinalityProvider:output_type -> proto.UnjailFinalityProviderResponse + 12, // 21: proto.FinalityProviders.QueryFinalityProvider:output_type -> proto.QueryFinalityProviderResponse + 14, // 22: proto.FinalityProviders.QueryFinalityProviderList:output_type -> proto.QueryFinalityProviderListResponse + 21, // 23: proto.FinalityProviders.SignMessageFromChainKey:output_type -> proto.SignMessageFromChainKeyResponse + 23, // 24: proto.FinalityProviders.EditFinalityProvider:output_type -> proto.EmptyResponse + 16, // [16:25] is the sub-list for method output_type + 7, // [7:16] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_finality_providers_proto_init() } @@ -1970,6 +2076,30 @@ func file_finality_providers_proto_init() { return nil } } + file_finality_providers_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EditFinalityProviderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_finality_providers_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmptyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1977,7 +2107,7 @@ func file_finality_providers_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_finality_providers_proto_rawDesc, NumEnums: 1, - NumMessages: 21, + NumMessages: 23, NumExtensions: 0, NumServices: 1, }, diff --git a/finality-provider/proto/finality_providers.proto b/finality-provider/proto/finality_providers.proto index 49e4ecc3..7ece9570 100644 --- a/finality-provider/proto/finality_providers.proto +++ b/finality-provider/proto/finality_providers.proto @@ -42,8 +42,8 @@ service FinalityProviders { rpc SignMessageFromChainKey (SignMessageFromChainKeyRequest) returns (SignMessageFromChainKeyResponse); - // QueryFinalityProvider queries the finality provider in babylon node. - rpc QueryFinalityProviderRemote (QueryFinalityProviderRequest) returns (QueryFinalityProviderResponse); + // EditFinalityProvider edits finality provider + rpc EditFinalityProvider (EditFinalityProviderRequest) returns (EmptyResponse); } message GetInfoRequest { @@ -256,3 +256,14 @@ message SignMessageFromChainKeyRequest { message SignMessageFromChainKeyResponse { bytes signature = 1; } + +// FinalityProviderInfo is the basic information of a finality provider mainly for external usage +message EditFinalityProviderRequest { + // btc_pk is the hex string of the BTC secp256k1 PK of the finality provider encoded in BIP-340 spec + string btc_pk = 1; + // description defines the description terms for the finality provider + Description description = 2; +} + +// Define an empty response message +message EmptyResponse {} \ No newline at end of file diff --git a/finality-provider/proto/finality_providers_grpc.pb.go b/finality-provider/proto/finality_providers_grpc.pb.go index 2cf302e4..96b73db6 100644 --- a/finality-provider/proto/finality_providers_grpc.pb.go +++ b/finality-provider/proto/finality_providers_grpc.pb.go @@ -19,15 +19,15 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - FinalityProviders_GetInfo_FullMethodName = "/proto.FinalityProviders/GetInfo" - FinalityProviders_CreateFinalityProvider_FullMethodName = "/proto.FinalityProviders/CreateFinalityProvider" - FinalityProviders_RegisterFinalityProvider_FullMethodName = "/proto.FinalityProviders/RegisterFinalityProvider" - FinalityProviders_AddFinalitySignature_FullMethodName = "/proto.FinalityProviders/AddFinalitySignature" - FinalityProviders_UnjailFinalityProvider_FullMethodName = "/proto.FinalityProviders/UnjailFinalityProvider" - FinalityProviders_QueryFinalityProvider_FullMethodName = "/proto.FinalityProviders/QueryFinalityProvider" - FinalityProviders_QueryFinalityProviderList_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderList" - FinalityProviders_SignMessageFromChainKey_FullMethodName = "/proto.FinalityProviders/SignMessageFromChainKey" - FinalityProviders_QueryFinalityProviderRemote_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderRemote" + FinalityProviders_GetInfo_FullMethodName = "/proto.FinalityProviders/GetInfo" + FinalityProviders_CreateFinalityProvider_FullMethodName = "/proto.FinalityProviders/CreateFinalityProvider" + FinalityProviders_RegisterFinalityProvider_FullMethodName = "/proto.FinalityProviders/RegisterFinalityProvider" + FinalityProviders_AddFinalitySignature_FullMethodName = "/proto.FinalityProviders/AddFinalitySignature" + FinalityProviders_UnjailFinalityProvider_FullMethodName = "/proto.FinalityProviders/UnjailFinalityProvider" + FinalityProviders_QueryFinalityProvider_FullMethodName = "/proto.FinalityProviders/QueryFinalityProvider" + FinalityProviders_QueryFinalityProviderList_FullMethodName = "/proto.FinalityProviders/QueryFinalityProviderList" + FinalityProviders_SignMessageFromChainKey_FullMethodName = "/proto.FinalityProviders/SignMessageFromChainKey" + FinalityProviders_EditFinalityProvider_FullMethodName = "/proto.FinalityProviders/EditFinalityProvider" ) // FinalityProvidersClient is the client API for FinalityProviders service. @@ -53,8 +53,8 @@ type FinalityProvidersClient interface { QueryFinalityProviderList(ctx context.Context, in *QueryFinalityProviderListRequest, opts ...grpc.CallOption) (*QueryFinalityProviderListResponse, error) // SignMessageFromChainKey signs a message from the chain keyring. SignMessageFromChainKey(ctx context.Context, in *SignMessageFromChainKeyRequest, opts ...grpc.CallOption) (*SignMessageFromChainKeyResponse, error) - // QueryFinalityProvider queries the finality provider in babylon node. - QueryFinalityProviderRemote(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) + // EditFinalityProvider edits finality provider + EditFinalityProvider(ctx context.Context, in *EditFinalityProviderRequest, opts ...grpc.CallOption) (*EmptyResponse, error) } type finalityProvidersClient struct { @@ -137,9 +137,9 @@ func (c *finalityProvidersClient) SignMessageFromChainKey(ctx context.Context, i return out, nil } -func (c *finalityProvidersClient) QueryFinalityProviderRemote(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { - out := new(QueryFinalityProviderResponse) - err := c.cc.Invoke(ctx, FinalityProviders_QueryFinalityProviderRemote_FullMethodName, in, out, opts...) +func (c *finalityProvidersClient) EditFinalityProvider(ctx context.Context, in *EditFinalityProviderRequest, opts ...grpc.CallOption) (*EmptyResponse, error) { + out := new(EmptyResponse) + err := c.cc.Invoke(ctx, FinalityProviders_EditFinalityProvider_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -169,8 +169,8 @@ type FinalityProvidersServer interface { QueryFinalityProviderList(context.Context, *QueryFinalityProviderListRequest) (*QueryFinalityProviderListResponse, error) // SignMessageFromChainKey signs a message from the chain keyring. SignMessageFromChainKey(context.Context, *SignMessageFromChainKeyRequest) (*SignMessageFromChainKeyResponse, error) - // QueryFinalityProvider queries the finality provider in babylon node. - QueryFinalityProviderRemote(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) + // EditFinalityProvider edits finality provider + EditFinalityProvider(context.Context, *EditFinalityProviderRequest) (*EmptyResponse, error) mustEmbedUnimplementedFinalityProvidersServer() } @@ -202,8 +202,8 @@ func (UnimplementedFinalityProvidersServer) QueryFinalityProviderList(context.Co func (UnimplementedFinalityProvidersServer) SignMessageFromChainKey(context.Context, *SignMessageFromChainKeyRequest) (*SignMessageFromChainKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SignMessageFromChainKey not implemented") } -func (UnimplementedFinalityProvidersServer) QueryFinalityProviderRemote(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryFinalityProviderRemote not implemented") +func (UnimplementedFinalityProvidersServer) EditFinalityProvider(context.Context, *EditFinalityProviderRequest) (*EmptyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditFinalityProvider not implemented") } func (UnimplementedFinalityProvidersServer) mustEmbedUnimplementedFinalityProvidersServer() {} @@ -362,20 +362,20 @@ func _FinalityProviders_SignMessageFromChainKey_Handler(srv interface{}, ctx con return interceptor(ctx, in, info, handler) } -func _FinalityProviders_QueryFinalityProviderRemote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderRequest) +func _FinalityProviders_EditFinalityProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EditFinalityProviderRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FinalityProvidersServer).QueryFinalityProviderRemote(ctx, in) + return srv.(FinalityProvidersServer).EditFinalityProvider(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: FinalityProviders_QueryFinalityProviderRemote_FullMethodName, + FullMethod: FinalityProviders_EditFinalityProvider_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FinalityProvidersServer).QueryFinalityProviderRemote(ctx, req.(*QueryFinalityProviderRequest)) + return srv.(FinalityProvidersServer).EditFinalityProvider(ctx, req.(*EditFinalityProviderRequest)) } return interceptor(ctx, in, info, handler) } @@ -420,8 +420,8 @@ var FinalityProviders_ServiceDesc = grpc.ServiceDesc{ Handler: _FinalityProviders_SignMessageFromChainKey_Handler, }, { - MethodName: "QueryFinalityProviderRemote", - Handler: _FinalityProviders_QueryFinalityProviderRemote_Handler, + MethodName: "EditFinalityProvider", + Handler: _FinalityProviders_EditFinalityProvider_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/finality-provider/service/client/rpcclient.go b/finality-provider/service/client/rpcclient.go index cc352594..83d649e9 100644 --- a/finality-provider/service/client/rpcclient.go +++ b/finality-provider/service/client/rpcclient.go @@ -137,15 +137,16 @@ func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfo(ctx contex return res, nil } -// QueryFinalityProviderInfoRemote - gets the finality provider data from babylon node -func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfoRemote(ctx context.Context, fpPk *bbntypes.BIP340PubKey) (*proto.QueryFinalityProviderResponse, error) { - req := &proto.QueryFinalityProviderRequest{BtcPk: fpPk.MarshalHex()} - res, err := c.client.QueryFinalityProviderRemote(ctx, req) +// EditFinalityProvider - edit the finality provider data. +func (c *FinalityProviderServiceGRpcClient) EditFinalityProvider( + ctx context.Context, fpPk *bbntypes.BIP340PubKey, desc *proto.Description) error { + req := &proto.EditFinalityProviderRequest{BtcPk: fpPk.MarshalHex(), Description: desc} + _, err := c.client.EditFinalityProvider(ctx, req) if err != nil { - return nil, err + return err } - return res, nil + return nil } func (c *FinalityProviderServiceGRpcClient) SignMessageFromChainKey( diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index 458152f4..16a95747 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -224,32 +224,22 @@ func (r *rpcServer) QueryFinalityProvider(ctx context.Context, req *proto.QueryF return &proto.QueryFinalityProviderResponse{FinalityProvider: fp}, nil } -func (r *rpcServer) QueryFinalityProviderRemote(ctx context.Context, req *proto.QueryFinalityProviderRequest) ( - *proto.QueryFinalityProviderResponse, error) { + +func (r *rpcServer) EditFinalityProvider(ctx context.Context, req *proto.EditFinalityProviderRequest) (*proto.EmptyResponse, error) { fpPk, err := bbntypes.NewBIP340PubKeyFromHex(req.BtcPk) if err != nil { return nil, err } - fp, err := r.app.cc.QueryFinalityProvider(fpPk.MustToBTCPK()) - if err != nil { - return nil, err + desc := stakingtypes.Description{ + Moniker: req.Description.Moniker, + Identity: req.Description.Identity, + Website: req.Description.Website, + SecurityContact: req.Description.SecurityContact, + Details: req.Description.Details, } - return &proto.QueryFinalityProviderResponse{ - FinalityProvider: &proto.FinalityProviderInfo{ - FpAddr: fp.FinalityProvider.Addr, - BtcPkHex: fp.FinalityProvider.BtcPk.MarshalHex(), - Description: &proto.Description{ - Moniker: fp.FinalityProvider.Description.Moniker, - Identity: fp.FinalityProvider.Description.Identity, - Website: fp.FinalityProvider.Description.Website, - SecurityContact: fp.FinalityProvider.Description.SecurityContact, - Details: fp.FinalityProvider.Description.Details, - }, - Commission: fp.FinalityProvider.Commission.String(), - }, - }, nil + return nil, r.app.cc.EditFinalityProviderDescription(fpPk.MustToBTCPK(), desc) } // QueryFinalityProviderList queries the information of a list of finality providers diff --git a/go.mod b/go.mod index a8a45bf2..216aa94a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 github.com/avast/retry-go/v4 v4.5.1 - github.com/babylonlabs-io/babylon v0.11.0 + github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 diff --git a/go.sum b/go.sum index f7ab3904..8b83007b 100644 --- a/go.sum +++ b/go.sum @@ -283,8 +283,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.11.0 h1:gRJEkjgy3M9bGSY7VjusA84qn6ca8hXa78ss5Z8D3Cc= -github.com/babylonlabs-io/babylon v0.11.0/go.mod h1:ZOrTde9vs2xoqGTFw4xhupu2CMulnpywiuk0eh4kPOw= +github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee h1:JXxu9sxnkMBgqQ+RB1NVaqnlc8b7gtd1rUAe9K+reVg= +github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee/go.mod h1:ZOrTde9vs2xoqGTFw4xhupu2CMulnpywiuk0eh4kPOw= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= diff --git a/itest/container/config.go b/itest/container/config.go index d2ddb5d2..7cb0f247 100644 --- a/itest/container/config.go +++ b/itest/container/config.go @@ -21,6 +21,7 @@ const ( // NewImageConfig returns ImageConfig needed for running e2e test. func NewImageConfig(t *testing.T) ImageConfig { babylondVersion, err := testutil.GetBabylonVersion() + babylondVersion = "v0.11.0" require.NoError(t, err) return ImageConfig{ BabylonRepository: dockerBabylondRepository, From c8ce26871419a51567a2a819d8a8dfeb36a0407a Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 15:49:00 +0200 Subject: [PATCH 04/17] e2e for edit command --- clientcontroller/babylon.go | 2 +- itest/e2e_test.go | 94 ++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 00581ae3..b6d1a2d5 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -550,7 +550,7 @@ func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicK func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, rate *sdkmath.LegacyDec, description sttypes.Description) error { fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) - fmt.Printf("%s/n --------- ", fpPubKey.MustMarshal()) + msg := &btcstakingtypes.MsgEditFinalityProvider{ Addr: bc.mustGetTxSigner(), BtcPk: fpPubKey.MustMarshal(), diff --git a/itest/e2e_test.go b/itest/e2e_test.go index 32432ad1..7237b56f 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -1,16 +1,15 @@ -//go:build e2e -// +build e2e - package e2etest import ( - "math/rand" - "testing" - "time" - "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/finality-provider/clientcontroller" + "github.com/babylonlabs-io/finality-provider/finality-provider/cmd/fpd/daemon" "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" + "go.uber.org/zap" + "math/rand" + "testing" + "time" "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "github.com/babylonlabs-io/finality-provider/types" @@ -52,6 +51,7 @@ func TestFinalityProviderLifeCycle(t *testing.T) { lastVotedHeight := tm.WaitForFpVoteCast(t, fpIns) tm.CheckBlockFinalization(t, lastVotedHeight, 1) t.Logf("the block at height %v is finalized", lastVotedHeight) + time.Sleep(5 * time.Minute) } // TestDoubleSigning tests the attack scenario where the finality-provider @@ -164,3 +164,83 @@ func TestFastSync(t *testing.T) { require.NoError(t, err) require.True(t, currentHeight < finalizedHeight+uint64(n)) } + +func TestFinalityProviderEditCmd(t *testing.T) { + tm, fpInsList := StartManagerWithFinalityProvider(t, 1) + defer tm.Stop(t) + + fpIns := fpInsList[0] + + cfg := tm.Fpa.GetConfig() + cfg.BabylonConfig.Key = "test-fp-0" + cc, err := clientcontroller.NewClientController(cfg.ChainName, cfg.BabylonConfig, &cfg.BTCNetParams, zap.NewNop()) + require.NoError(t, err) + tm.Fpa.UpdateClientController(cc) + + cmd := daemon.CommandEditFinalityDescription() + + const ( + monikerFlag = "moniker" + identityFlag = "identity" + websiteFlag = "website" + securityContactFlag = "security-contact" + detailsFlag = "details" + fpdDaemonAddressFlag = "daemon-address" + ) + + moniker := "test-moniker" + website := "https://test.com" + securityContact := "test@test.com" + details := "Test details" + identity := "test-identity" + + args := []string{ + fpIns.GetBtcPkHex(), + "--" + fpdDaemonAddressFlag, tm.FpConfig.RpcListener, + "--" + monikerFlag, moniker, + "--" + websiteFlag, website, + "--" + securityContactFlag, securityContact, + "--" + detailsFlag, details, + "--" + identityFlag, identity, + } + + cmd.SetArgs(args) + + // Run the command + err = cmd.Execute() + require.NoError(t, err) + + gotFp, err := tm.BBNClient.QueryFinalityProvider(fpIns.GetBtcPk()) + require.NoError(t, err) + + require.Equal(t, gotFp.FinalityProvider.Description.Moniker, moniker) + require.Equal(t, gotFp.FinalityProvider.Description.Website, website) + require.Equal(t, gotFp.FinalityProvider.Description.Identity, identity) + require.Equal(t, gotFp.FinalityProvider.Description.Details, details) + require.Equal(t, gotFp.FinalityProvider.Description.SecurityContact, securityContact) + + moniker = "test2-moniker" + args = []string{ + fpIns.GetBtcPkHex(), + "--" + fpdDaemonAddressFlag, tm.FpConfig.RpcListener, + "--" + monikerFlag, moniker, + } + + cmd.SetArgs(args) + + // Run the command + err = cmd.Execute() + require.NoError(t, err) + + updatedFp, err := tm.BBNClient.QueryFinalityProvider(fpIns.GetBtcPk()) + require.NoError(t, err) + + updateFpDesc := updatedFp.FinalityProvider.Description + oldDesc := gotFp.FinalityProvider.Description + + require.Equal(t, updateFpDesc.Moniker, moniker) + require.Equal(t, updateFpDesc.Website, oldDesc.Website) + require.Equal(t, updateFpDesc.Identity, oldDesc.Identity) + require.Equal(t, updateFpDesc.Details, oldDesc.Details) + require.Equal(t, updateFpDesc.SecurityContact, oldDesc.SecurityContact) +} From 7f1281cd53cda63526d6c7aaf45123a2f97f6a71 Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 15:52:53 +0200 Subject: [PATCH 05/17] revert gomod --- go.mod | 2 +- go.sum | 4 ++-- itest/container/config.go | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 216aa94a..a8a45bf2 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 github.com/avast/retry-go/v4 v4.5.1 - github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee + github.com/babylonlabs-io/babylon v0.11.0 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 diff --git a/go.sum b/go.sum index 8b83007b..f7ab3904 100644 --- a/go.sum +++ b/go.sum @@ -283,8 +283,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee h1:JXxu9sxnkMBgqQ+RB1NVaqnlc8b7gtd1rUAe9K+reVg= -github.com/babylonlabs-io/babylon v0.0.0-20241010065740-a5c4e94a03ee/go.mod h1:ZOrTde9vs2xoqGTFw4xhupu2CMulnpywiuk0eh4kPOw= +github.com/babylonlabs-io/babylon v0.11.0 h1:gRJEkjgy3M9bGSY7VjusA84qn6ca8hXa78ss5Z8D3Cc= +github.com/babylonlabs-io/babylon v0.11.0/go.mod h1:ZOrTde9vs2xoqGTFw4xhupu2CMulnpywiuk0eh4kPOw= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= diff --git a/itest/container/config.go b/itest/container/config.go index 7cb0f247..d2ddb5d2 100644 --- a/itest/container/config.go +++ b/itest/container/config.go @@ -21,7 +21,6 @@ const ( // NewImageConfig returns ImageConfig needed for running e2e test. func NewImageConfig(t *testing.T) ImageConfig { babylondVersion, err := testutil.GetBabylonVersion() - babylondVersion = "v0.11.0" require.NoError(t, err) return ImageConfig{ BabylonRepository: dockerBabylondRepository, From d7b5bd0b0e5ffc121dfea8f8b56d88b963885607 Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 16:05:14 +0200 Subject: [PATCH 06/17] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af09fa7..b0dcb936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,3 +36,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased + +### Improvements + +* [#90](https://github.com/babylonlabs-io/finality-provider/pull/90) CLI edit finality provider \ No newline at end of file From a10b2f5ea81a73128356dc2152b93c71f96f32b3 Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 16:09:24 +0200 Subject: [PATCH 07/17] mocks --- testutil/mocks/babylon.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/testutil/mocks/babylon.go b/testutil/mocks/babylon.go index 1f7dcb3b..1989538d 100644 --- a/testutil/mocks/babylon.go +++ b/testutil/mocks/babylon.go @@ -12,6 +12,7 @@ import ( types0 "github.com/babylonlabs-io/finality-provider/types" btcec "github.com/btcsuite/btcd/btcec/v2" schnorr "github.com/btcsuite/btcd/btcec/v2/schnorr" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -67,6 +68,20 @@ func (mr *MockClientControllerMockRecorder) CommitPubRandList(fpPk, startHeight, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitPubRandList", reflect.TypeOf((*MockClientController)(nil).CommitPubRandList), fpPk, startHeight, numPubRand, commitment, sig) } +// EditFinalityProviderDescription mocks base method. +func (m *MockClientController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc types1.Description) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EditFinalityProviderDescription", fpPk, reqDesc) + ret0, _ := ret[0].(error) + return ret0 +} + +// EditFinalityProviderDescription indicates an expected call of EditFinalityProviderDescription. +func (mr *MockClientControllerMockRecorder) EditFinalityProviderDescription(fpPk, reqDesc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFinalityProviderDescription", reflect.TypeOf((*MockClientController)(nil).EditFinalityProviderDescription), fpPk, reqDesc) +} + // QueryActivatedHeight mocks base method. func (m *MockClientController) QueryActivatedHeight() (uint64, error) { m.ctrl.T.Helper() From 14c80ea07770c1affb0cb139d1e922ea8bbea568 Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 16:15:15 +0200 Subject: [PATCH 08/17] e2e flags --- itest/e2e_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/itest/e2e_test.go b/itest/e2e_test.go index 468dae2a..e1e3db9a 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -1,3 +1,6 @@ +//go:build e2e +// +build e2e + package e2etest import ( From 6a7af43242458de476825fef7203aa2907cee22b Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 17:52:58 +0200 Subject: [PATCH 09/17] update fp in localstore --- clientcontroller/babylon.go | 16 ++++++++++------ clientcontroller/interface.go | 2 +- finality-provider/service/rpcserver.go | 12 +++++++++++- finality-provider/store/fpstore.go | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index b6d1a2d5..9ba0ba1e 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -521,11 +521,11 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs } func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, - reqDesc sttypes.Description) error { + reqDesc sttypes.Description) (*sttypes.Description, error) { fpRes, err := bc.QueryFinalityProvider(fpPk) if err != nil { - return err + return nil, err } getValueOrDefault := func(reqValue, defaultValue string) string { if reqValue != "" { @@ -536,7 +536,7 @@ func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicK resDesc := fpRes.FinalityProvider.Description - desc := sttypes.Description{ + desc := &sttypes.Description{ Moniker: getValueOrDefault(reqDesc.Moniker, resDesc.Moniker), Identity: getValueOrDefault(reqDesc.Identity, resDesc.Identity), Website: getValueOrDefault(reqDesc.Website, resDesc.Website), @@ -544,17 +544,21 @@ func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicK Details: getValueOrDefault(reqDesc.Details, resDesc.Details), } - return bc.EditFinalityProvider(fpPk, fpRes.FinalityProvider.Commission, desc) + if err := bc.EditFinalityProvider(fpPk, fpRes.FinalityProvider.Commission, desc); err != nil { + return nil, err + } + + return desc, nil } func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, - rate *sdkmath.LegacyDec, description sttypes.Description) error { + rate *sdkmath.LegacyDec, description *sttypes.Description) error { fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) msg := &btcstakingtypes.MsgEditFinalityProvider{ Addr: bc.mustGetTxSigner(), BtcPk: fpPubKey.MustMarshal(), - Description: &description, + Description: description, Commission: rate, } diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index f14a106e..23543396 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -51,7 +51,7 @@ type ClientController interface { QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) // EditFinalityProviderDescription edits description of the finality provider - EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc sttypes.Description) error + EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc sttypes.Description) (*sttypes.Description, error) // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index 31d68da9..df3dc62c 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -245,7 +245,17 @@ func (r *rpcServer) EditFinalityProvider(ctx context.Context, req *proto.EditFin Details: req.Description.Details, } - return nil, r.app.cc.EditFinalityProviderDescription(fpPk.MustToBTCPK(), desc) + fpPub := fpPk.MustToBTCPK() + updatedDesc, err := r.app.cc.EditFinalityProviderDescription(fpPub, desc) + if err != nil { + return nil, err + } + + if err := r.app.fps.SetFpDescription(fpPub, updatedDesc); err != nil { + return nil, err + } + + return nil, nil } // QueryFinalityProviderList queries the information of a list of finality providers diff --git a/finality-provider/store/fpstore.go b/finality-provider/store/fpstore.go index 24715279..19576574 100644 --- a/finality-provider/store/fpstore.go +++ b/finality-provider/store/fpstore.go @@ -270,3 +270,19 @@ func (s *FinalityProviderStore) GetAllStoredFinalityProviders() ([]*StoredFinali return storedFps, nil } + +// SetFpDescription updates description of finality provider +func (s *FinalityProviderStore) SetFpDescription(btcPk *btcec.PublicKey, description *stakingtypes.Description) error { + setDescription := func(fp *proto.FinalityProvider) error { + descBytes, err := description.Marshal() + if err != nil { + return err + } + + fp.Description = descBytes + + return nil + } + + return s.setFinalityProviderState(btcPk, setDescription) +} From b579ac019063342e4cf9750529d0e560ba5dc2e7 Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 10 Oct 2024 17:53:40 +0200 Subject: [PATCH 10/17] lints --- testutil/mocks/babylon.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testutil/mocks/babylon.go b/testutil/mocks/babylon.go index 1989538d..ed5702d6 100644 --- a/testutil/mocks/babylon.go +++ b/testutil/mocks/babylon.go @@ -69,11 +69,12 @@ func (mr *MockClientControllerMockRecorder) CommitPubRandList(fpPk, startHeight, } // EditFinalityProviderDescription mocks base method. -func (m *MockClientController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc types1.Description) error { +func (m *MockClientController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc types1.Description) (*types1.Description, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EditFinalityProviderDescription", fpPk, reqDesc) - ret0, _ := ret[0].(error) - return ret0 + ret0, _ := ret[0].(*types1.Description) + ret1, _ := ret[1].(error) + return ret0, ret1 } // EditFinalityProviderDescription indicates an expected call of EditFinalityProviderDescription. From 7e2066df89e179e0d37130cde2a5e6490c419c92 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 11:53:13 +0200 Subject: [PATCH 11/17] validate fp address and signer --- clientcontroller/babylon.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 9ba0ba1e..bf0d2110 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -3,6 +3,7 @@ package clientcontroller import ( "context" "fmt" + "strings" "time" sdkErr "cosmossdk.io/errors" @@ -522,11 +523,16 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc sttypes.Description) (*sttypes.Description, error) { - fpRes, err := bc.QueryFinalityProvider(fpPk) if err != nil { return nil, err } + + if !strings.EqualFold(fpRes.FinalityProvider.Addr, bc.mustGetTxSigner()) { + return nil, fmt.Errorf("the signer does not correspond to the finality provider's "+ + "Babylon address, expected %s got %s", bc.mustGetTxSigner(), fpRes.FinalityProvider.Addr) + } + getValueOrDefault := func(reqValue, defaultValue string) string { if reqValue != "" { return reqValue From 408fecda34217a9dd311ec541b2651820c3eca87 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 13:44:48 +0200 Subject: [PATCH 12/17] edit commission rate --- clientcontroller/babylon.go | 31 ++++------ clientcontroller/interface.go | 11 ++-- .../cmd/fpd/daemon/daemon_commands.go | 6 +- .../proto/finality_providers.pb.go | 28 ++++++--- .../proto/finality_providers.proto | 5 ++ finality-provider/service/client/rpcclient.go | 4 +- finality-provider/service/rpcserver.go | 17 ++++-- finality-provider/store/fpstore.go | 5 +- itest/e2e_test.go | 11 +++- testutil/mocks/babylon.go | 61 ++++++++++--------- 10 files changed, 104 insertions(+), 75 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index bf0d2110..736e0f52 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -521,8 +521,10 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs return res, nil } -func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, - reqDesc sttypes.Description) (*sttypes.Description, error) { +func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, + rate *sdkmath.LegacyDec, reqDesc *sttypes.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) { + fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) + fpRes, err := bc.QueryFinalityProvider(fpPk) if err != nil { return nil, err @@ -550,30 +552,23 @@ func (bc *BabylonController) EditFinalityProviderDescription(fpPk *btcec.PublicK Details: getValueOrDefault(reqDesc.Details, resDesc.Details), } - if err := bc.EditFinalityProvider(fpPk, fpRes.FinalityProvider.Commission, desc); err != nil { - return nil, err - } - - return desc, nil -} - -func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, - rate *sdkmath.LegacyDec, description *sttypes.Description) error { - fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) - msg := &btcstakingtypes.MsgEditFinalityProvider{ Addr: bc.mustGetTxSigner(), BtcPk: fpPubKey.MustMarshal(), - Description: description, - Commission: rate, + Description: desc, + Commission: fpRes.FinalityProvider.Commission, + } + + if rate != nil { + msg.Commission = rate } - _, err := bc.reliablySendMsg(msg, emptyErrs, emptyErrs) + _, err = bc.reliablySendMsg(msg, emptyErrs, emptyErrs) if err != nil { - return fmt.Errorf("failed to query the finality provider %s: %v", fpPk.SerializeCompressed(), err) + return nil, fmt.Errorf("failed to query the finality provider %s: %v", fpPk.SerializeCompressed(), err) } - return nil + return msg, nil } func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfoResponse, error) { diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index 23543396..3ed381b4 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -1,13 +1,14 @@ package clientcontroller import ( - "fmt" - sttypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" + "fmt" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/chaincfg" + sttypes "github.com/cosmos/cosmos-sdk/x/staking/types" "go.uber.org/zap" finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" @@ -50,8 +51,8 @@ type ClientController interface { // QueryFinalityProviderSlashedOrJailed queries if the finality provider is slashed or jailed QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) - // EditFinalityProviderDescription edits description of the finality provider - EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc sttypes.Description) (*sttypes.Description, error) + // EditFinalityProvider edits description and commission of a finality provider + EditFinalityProvider(fpPk *btcec.PublicKey, rate *sdkmath.LegacyDec, reqDesc *sttypes.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 2b8dd295..e6a912b3 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -462,6 +462,7 @@ func CommandEditFinalityDescription() *cobra.Command { cmd.Flags().String(securityContactFlag, "", "The finality provider's (optional) security contact email") cmd.Flags().String(detailsFlag, "", "The finality provider's (optional) details") cmd.Flags().String(identityFlag, "", "The (optional) identity signature (ex. UPort or Keybase)") + cmd.Flags().String(commissionRateFlag, "", "The (optional) identity signature (ex. UPort or Keybase)") return cmd } @@ -493,6 +494,7 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error securityContact, _ := cmd.Flags().GetString(securityContactFlag) details, _ := cmd.Flags().GetString(detailsFlag) identity, _ := cmd.Flags().GetString(identityFlag) + rate, _ := cmd.Flags().GetString(commissionRateFlag) desc := &proto.Description{ Moniker: moniker, @@ -502,12 +504,10 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error Details: details, } - if err := grpcClient.EditFinalityProvider(cmd.Context(), fpPk, desc); err != nil { + if err := grpcClient.EditFinalityProvider(cmd.Context(), fpPk, desc, rate); err != nil { return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) } - // todo(lazar): if this is successful update local store also - return nil } diff --git a/finality-provider/proto/finality_providers.pb.go b/finality-provider/proto/finality_providers.pb.go index 7cae505b..627c2f31 100644 --- a/finality-provider/proto/finality_providers.pb.go +++ b/finality-provider/proto/finality_providers.pb.go @@ -1406,6 +1406,8 @@ type EditFinalityProviderRequest struct { BtcPk string `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3" json:"btc_pk,omitempty"` // description defines the description terms for the finality provider Description *Description `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // commission defines the updated commission rate of the finality provider + Commission string `protobuf:"bytes,4,opt,name=commission,proto3" json:"commission,omitempty"` } func (x *EditFinalityProviderRequest) Reset() { @@ -1454,6 +1456,13 @@ func (x *EditFinalityProviderRequest) GetDescription() *Description { return nil } +func (x *EditFinalityProviderRequest) GetCommission() string { + if x != nil { + return x.Commission + } + return "" +} + // Define an empty response message type EmptyResponse struct { state protoimpl.MessageState @@ -1662,13 +1671,18 @@ var file_finality_providers_proto_rawDesc = []byte{ 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x6a, 0x0a, 0x1b, 0x45, 0x64, 0x69, 0x74, 0x46, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x12, 0x34, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xb9, 0x01, 0x0a, 0x1b, 0x45, 0x64, 0x69, 0x74, 0x46, + 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x12, 0x34, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2d, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, + 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x0f, 0x0a, 0x0d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0xbe, 0x01, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, diff --git a/finality-provider/proto/finality_providers.proto b/finality-provider/proto/finality_providers.proto index 7ece9570..0704bbcb 100644 --- a/finality-provider/proto/finality_providers.proto +++ b/finality-provider/proto/finality_providers.proto @@ -263,6 +263,11 @@ message EditFinalityProviderRequest { string btc_pk = 1; // description defines the description terms for the finality provider Description description = 2; + // commission defines the updated commission rate of the finality provider + string commission = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; } // Define an empty response message diff --git a/finality-provider/service/client/rpcclient.go b/finality-provider/service/client/rpcclient.go index 83d649e9..dc16da2e 100644 --- a/finality-provider/service/client/rpcclient.go +++ b/finality-provider/service/client/rpcclient.go @@ -139,8 +139,8 @@ func (c *FinalityProviderServiceGRpcClient) QueryFinalityProviderInfo(ctx contex // EditFinalityProvider - edit the finality provider data. func (c *FinalityProviderServiceGRpcClient) EditFinalityProvider( - ctx context.Context, fpPk *bbntypes.BIP340PubKey, desc *proto.Description) error { - req := &proto.EditFinalityProviderRequest{BtcPk: fpPk.MarshalHex(), Description: desc} + ctx context.Context, fpPk *bbntypes.BIP340PubKey, desc *proto.Description, rate string) error { + req := &proto.EditFinalityProviderRequest{BtcPk: fpPk.MarshalHex(), Description: desc, Commission: rate} _, err := c.client.EditFinalityProvider(ctx, req) if err != nil { return err diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index df3dc62c..81b49bfd 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -2,14 +2,14 @@ package service import ( "context" - "fmt" - "sync" - "sync/atomic" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" + "fmt" bbntypes "github.com/babylonlabs-io/babylon/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "google.golang.org/grpc" + "sync" + "sync/atomic" "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "github.com/babylonlabs-io/finality-provider/types" @@ -245,13 +245,18 @@ func (r *rpcServer) EditFinalityProvider(ctx context.Context, req *proto.EditFin Details: req.Description.Details, } + rate, err := sdkmath.LegacyNewDecFromStr(req.Commission) + if err != nil { + return nil, err + } + fpPub := fpPk.MustToBTCPK() - updatedDesc, err := r.app.cc.EditFinalityProviderDescription(fpPub, desc) + updatedMsg, err := r.app.cc.EditFinalityProvider(fpPub, &rate, &desc) if err != nil { return nil, err } - if err := r.app.fps.SetFpDescription(fpPub, updatedDesc); err != nil { + if err := r.app.fps.SetFpDescription(fpPub, updatedMsg.Description, updatedMsg.Commission); err != nil { return nil, err } diff --git a/finality-provider/store/fpstore.go b/finality-provider/store/fpstore.go index 19576574..d0c2ce74 100644 --- a/finality-provider/store/fpstore.go +++ b/finality-provider/store/fpstore.go @@ -272,14 +272,15 @@ func (s *FinalityProviderStore) GetAllStoredFinalityProviders() ([]*StoredFinali } // SetFpDescription updates description of finality provider -func (s *FinalityProviderStore) SetFpDescription(btcPk *btcec.PublicKey, description *stakingtypes.Description) error { +func (s *FinalityProviderStore) SetFpDescription(btcPk *btcec.PublicKey, desc *stakingtypes.Description, rate *sdkmath.LegacyDec) error { setDescription := func(fp *proto.FinalityProvider) error { - descBytes, err := description.Marshal() + descBytes, err := desc.Marshal() if err != nil { return err } fp.Description = descBytes + fp.Commission = rate.String() return nil } diff --git a/itest/e2e_test.go b/itest/e2e_test.go index e1e3db9a..f2763024 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -4,17 +4,17 @@ package e2etest import ( + sdkmath "cosmossdk.io/math" "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/babylonlabs-io/finality-provider/clientcontroller" "github.com/babylonlabs-io/finality-provider/finality-provider/cmd/fpd/daemon" + "github.com/babylonlabs-io/finality-provider/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" "go.uber.org/zap" "math/rand" "testing" "time" - - "github.com/babylonlabs-io/finality-provider/types" ) var ( @@ -174,6 +174,7 @@ func TestFinalityProviderEditCmd(t *testing.T) { securityContactFlag = "security-contact" detailsFlag = "details" fpdDaemonAddressFlag = "daemon-address" + commissionRateFlag = "commission-rate" ) moniker := "test-moniker" @@ -181,6 +182,7 @@ func TestFinalityProviderEditCmd(t *testing.T) { securityContact := "test@test.com" details := "Test details" identity := "test-identity" + commissionRateStr := "0.3" args := []string{ fpIns.GetBtcPkHex(), @@ -190,6 +192,7 @@ func TestFinalityProviderEditCmd(t *testing.T) { "--" + securityContactFlag, securityContact, "--" + detailsFlag, details, "--" + identityFlag, identity, + "--" + commissionRateFlag, commissionRateStr, } cmd.SetArgs(args) @@ -201,11 +204,15 @@ func TestFinalityProviderEditCmd(t *testing.T) { gotFp, err := tm.BBNClient.QueryFinalityProvider(fpIns.GetBtcPk()) require.NoError(t, err) + rate, err := sdkmath.LegacyNewDecFromStr(commissionRateStr) + require.NoError(t, err) + require.Equal(t, gotFp.FinalityProvider.Description.Moniker, moniker) require.Equal(t, gotFp.FinalityProvider.Description.Website, website) require.Equal(t, gotFp.FinalityProvider.Description.Identity, identity) require.Equal(t, gotFp.FinalityProvider.Description.Details, details) require.Equal(t, gotFp.FinalityProvider.Description.SecurityContact, securityContact) + require.Equal(t, gotFp.FinalityProvider.Commission, &rate) moniker = "test2-moniker" args = []string{ diff --git a/testutil/mocks/babylon.go b/testutil/mocks/babylon.go index ed5702d6..9f9ef7e5 100644 --- a/testutil/mocks/babylon.go +++ b/testutil/mocks/babylon.go @@ -8,11 +8,12 @@ import ( reflect "reflect" math "cosmossdk.io/math" - types "github.com/babylonlabs-io/babylon/x/finality/types" - types0 "github.com/babylonlabs-io/finality-provider/types" + types "github.com/babylonlabs-io/babylon/x/btcstaking/types" + types0 "github.com/babylonlabs-io/babylon/x/finality/types" + types1 "github.com/babylonlabs-io/finality-provider/types" btcec "github.com/btcsuite/btcd/btcec/v2" schnorr "github.com/btcsuite/btcd/btcec/v2/schnorr" - types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -54,10 +55,10 @@ func (mr *MockClientControllerMockRecorder) Close() *gomock.Call { } // CommitPubRandList mocks base method. -func (m *MockClientController) CommitPubRandList(fpPk *btcec.PublicKey, startHeight, numPubRand uint64, commitment []byte, sig *schnorr.Signature) (*types0.TxResponse, error) { +func (m *MockClientController) CommitPubRandList(fpPk *btcec.PublicKey, startHeight, numPubRand uint64, commitment []byte, sig *schnorr.Signature) (*types1.TxResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CommitPubRandList", fpPk, startHeight, numPubRand, commitment, sig) - ret0, _ := ret[0].(*types0.TxResponse) + ret0, _ := ret[0].(*types1.TxResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -68,19 +69,19 @@ func (mr *MockClientControllerMockRecorder) CommitPubRandList(fpPk, startHeight, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitPubRandList", reflect.TypeOf((*MockClientController)(nil).CommitPubRandList), fpPk, startHeight, numPubRand, commitment, sig) } -// EditFinalityProviderDescription mocks base method. -func (m *MockClientController) EditFinalityProviderDescription(fpPk *btcec.PublicKey, reqDesc types1.Description) (*types1.Description, error) { +// EditFinalityProvider mocks base method. +func (m *MockClientController) EditFinalityProvider(fpPk *btcec.PublicKey, rate *math.LegacyDec, reqDesc *types2.Description) (*types.MsgEditFinalityProvider, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "EditFinalityProviderDescription", fpPk, reqDesc) - ret0, _ := ret[0].(*types1.Description) + ret := m.ctrl.Call(m, "EditFinalityProvider", fpPk, rate, reqDesc) + ret0, _ := ret[0].(*types.MsgEditFinalityProvider) ret1, _ := ret[1].(error) return ret0, ret1 } -// EditFinalityProviderDescription indicates an expected call of EditFinalityProviderDescription. -func (mr *MockClientControllerMockRecorder) EditFinalityProviderDescription(fpPk, reqDesc interface{}) *gomock.Call { +// EditFinalityProvider indicates an expected call of EditFinalityProvider. +func (mr *MockClientControllerMockRecorder) EditFinalityProvider(fpPk, rate, reqDesc interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFinalityProviderDescription", reflect.TypeOf((*MockClientController)(nil).EditFinalityProviderDescription), fpPk, reqDesc) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFinalityProvider", reflect.TypeOf((*MockClientController)(nil).EditFinalityProvider), fpPk, rate, reqDesc) } // QueryActivatedHeight mocks base method. @@ -99,10 +100,10 @@ func (mr *MockClientControllerMockRecorder) QueryActivatedHeight() *gomock.Call } // QueryBestBlock mocks base method. -func (m *MockClientController) QueryBestBlock() (*types0.BlockInfo, error) { +func (m *MockClientController) QueryBestBlock() (*types1.BlockInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryBestBlock") - ret0, _ := ret[0].(*types0.BlockInfo) + ret0, _ := ret[0].(*types1.BlockInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -114,10 +115,10 @@ func (mr *MockClientControllerMockRecorder) QueryBestBlock() *gomock.Call { } // QueryBlock mocks base method. -func (m *MockClientController) QueryBlock(height uint64) (*types0.BlockInfo, error) { +func (m *MockClientController) QueryBlock(height uint64) (*types1.BlockInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryBlock", height) - ret0, _ := ret[0].(*types0.BlockInfo) + ret0, _ := ret[0].(*types1.BlockInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -129,10 +130,10 @@ func (mr *MockClientControllerMockRecorder) QueryBlock(height interface{}) *gomo } // QueryBlocks mocks base method. -func (m *MockClientController) QueryBlocks(startHeight, endHeight uint64, limit uint32) ([]*types0.BlockInfo, error) { +func (m *MockClientController) QueryBlocks(startHeight, endHeight uint64, limit uint32) ([]*types1.BlockInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryBlocks", startHeight, endHeight, limit) - ret0, _ := ret[0].([]*types0.BlockInfo) + ret0, _ := ret[0].([]*types1.BlockInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -175,10 +176,10 @@ func (mr *MockClientControllerMockRecorder) QueryFinalityProviderVotingPower(fpP } // QueryLastCommittedPublicRand mocks base method. -func (m *MockClientController) QueryLastCommittedPublicRand(fpPk *btcec.PublicKey, count uint64) (map[uint64]*types.PubRandCommitResponse, error) { +func (m *MockClientController) QueryLastCommittedPublicRand(fpPk *btcec.PublicKey, count uint64) (map[uint64]*types0.PubRandCommitResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryLastCommittedPublicRand", fpPk, count) - ret0, _ := ret[0].(map[uint64]*types.PubRandCommitResponse) + ret0, _ := ret[0].(map[uint64]*types0.PubRandCommitResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -190,10 +191,10 @@ func (mr *MockClientControllerMockRecorder) QueryLastCommittedPublicRand(fpPk, c } // QueryLatestFinalizedBlocks mocks base method. -func (m *MockClientController) QueryLatestFinalizedBlocks(count uint64) ([]*types0.BlockInfo, error) { +func (m *MockClientController) QueryLatestFinalizedBlocks(count uint64) ([]*types1.BlockInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryLatestFinalizedBlocks", count) - ret0, _ := ret[0].([]*types0.BlockInfo) + ret0, _ := ret[0].([]*types1.BlockInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -205,10 +206,10 @@ func (mr *MockClientControllerMockRecorder) QueryLatestFinalizedBlocks(count int } // RegisterFinalityProvider mocks base method. -func (m *MockClientController) RegisterFinalityProvider(fpPk *btcec.PublicKey, pop []byte, commission *math.LegacyDec, description []byte) (*types0.TxResponse, error) { +func (m *MockClientController) RegisterFinalityProvider(fpPk *btcec.PublicKey, pop []byte, commission *math.LegacyDec, description []byte) (*types1.TxResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RegisterFinalityProvider", fpPk, pop, commission, description) - ret0, _ := ret[0].(*types0.TxResponse) + ret0, _ := ret[0].(*types1.TxResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -220,10 +221,10 @@ func (mr *MockClientControllerMockRecorder) RegisterFinalityProvider(fpPk, pop, } // SubmitBatchFinalitySigs mocks base method. -func (m *MockClientController) SubmitBatchFinalitySigs(fpPk *btcec.PublicKey, blocks []*types0.BlockInfo, pubRandList []*btcec.FieldVal, proofList [][]byte, sigs []*btcec.ModNScalar) (*types0.TxResponse, error) { +func (m *MockClientController) SubmitBatchFinalitySigs(fpPk *btcec.PublicKey, blocks []*types1.BlockInfo, pubRandList []*btcec.FieldVal, proofList [][]byte, sigs []*btcec.ModNScalar) (*types1.TxResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SubmitBatchFinalitySigs", fpPk, blocks, pubRandList, proofList, sigs) - ret0, _ := ret[0].(*types0.TxResponse) + ret0, _ := ret[0].(*types1.TxResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -235,10 +236,10 @@ func (mr *MockClientControllerMockRecorder) SubmitBatchFinalitySigs(fpPk, blocks } // SubmitFinalitySig mocks base method. -func (m *MockClientController) SubmitFinalitySig(fpPk *btcec.PublicKey, block *types0.BlockInfo, pubRand *btcec.FieldVal, proof []byte, sig *btcec.ModNScalar) (*types0.TxResponse, error) { +func (m *MockClientController) SubmitFinalitySig(fpPk *btcec.PublicKey, block *types1.BlockInfo, pubRand *btcec.FieldVal, proof []byte, sig *btcec.ModNScalar) (*types1.TxResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SubmitFinalitySig", fpPk, block, pubRand, proof, sig) - ret0, _ := ret[0].(*types0.TxResponse) + ret0, _ := ret[0].(*types1.TxResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -250,10 +251,10 @@ func (mr *MockClientControllerMockRecorder) SubmitFinalitySig(fpPk, block, pubRa } // UnjailFinalityProvider mocks base method. -func (m *MockClientController) UnjailFinalityProvider(fpPk *btcec.PublicKey) (*types0.TxResponse, error) { +func (m *MockClientController) UnjailFinalityProvider(fpPk *btcec.PublicKey) (*types1.TxResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnjailFinalityProvider", fpPk) - ret0, _ := ret[0].(*types0.TxResponse) + ret0, _ := ret[0].(*types1.TxResponse) ret1, _ := ret[1].(error) return ret0, ret1 } From 80eab345fca6ed5ee0207854a3c9c7fa04762067 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 14:07:34 +0200 Subject: [PATCH 13/17] better cmd docs --- finality-provider/cmd/fpd/daemon/daemon_commands.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index e6a912b3..2355d949 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -451,8 +451,11 @@ func CommandEditFinalityDescription() *cobra.Command { var cmd = &cobra.Command{ Use: "edit-finality-provider [btc_pk]", Aliases: []string{"efp"}, - Short: "Edit finality provider", - Example: fmt.Sprintf(`fpd edit-finality-provider --daemon-address %s`, defaultFpdDaemonAddress), + Short: "Edit finality provider data without resetting unchanged fields", + Long: "Edit the details of a finality provider using the specified BTC public key. " + + "\nIf one or more optional flags are passed (such as --moniker, --website, etc.), " + + "the corresponding values are updated, while unchanged fields retain their current values from the Babylon Node.", + Example: fmt.Sprintf(`fpd edit-finality-provider [btc_pk] --daemon-address %s --moniker "new-moniker"`, defaultFpdDaemonAddress), Args: cobra.ExactArgs(1), RunE: runCommandEditFinalityDescription, } @@ -462,7 +465,7 @@ func CommandEditFinalityDescription() *cobra.Command { cmd.Flags().String(securityContactFlag, "", "The finality provider's (optional) security contact email") cmd.Flags().String(detailsFlag, "", "The finality provider's (optional) details") cmd.Flags().String(identityFlag, "", "The (optional) identity signature (ex. UPort or Keybase)") - cmd.Flags().String(commissionRateFlag, "", "The (optional) identity signature (ex. UPort or Keybase)") + cmd.Flags().String(commissionRateFlag, "", "The (optional) commission rate percentage (ex. 0.2)") return cmd } From 515084c37f37b3125a8e5952c0c3e29ed5b753e8 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 14:09:15 +0200 Subject: [PATCH 14/17] nit --- finality-provider/cmd/fpd/daemon/daemon_commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 2355d949..66b8e6a2 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -508,7 +508,7 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error } if err := grpcClient.EditFinalityProvider(cmd.Context(), fpPk, desc, rate); err != nil { - return fmt.Errorf("failed to get finality provider %v err %v", fpPk.MarshalHex(), err) + return fmt.Errorf("failed to edit finality provider %v err %v", fpPk.MarshalHex(), err) } return nil From 63ae87015cd861cba3f089572f83fce342ed42d8 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 14:30:33 +0200 Subject: [PATCH 15/17] pr comment: desc types --- clientcontroller/babylon.go | 3 ++- clientcontroller/interface.go | 4 ++-- finality-provider/service/rpcserver.go | 10 +--------- testutil/mocks/babylon.go | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 736e0f52..cab3d267 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -3,6 +3,7 @@ package clientcontroller import ( "context" "fmt" + "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "strings" "time" @@ -522,7 +523,7 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs } func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, - rate *sdkmath.LegacyDec, reqDesc *sttypes.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) { + rate *sdkmath.LegacyDec, reqDesc *proto.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) { fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) fpRes, err := bc.QueryFinalityProvider(fpPk) diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index 3ed381b4..d0cdb1c6 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -5,10 +5,10 @@ import ( sdkmath "cosmossdk.io/math" "fmt" btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/chaincfg" - sttypes "github.com/cosmos/cosmos-sdk/x/staking/types" "go.uber.org/zap" finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" @@ -52,7 +52,7 @@ type ClientController interface { QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) // EditFinalityProvider edits description and commission of a finality provider - EditFinalityProvider(fpPk *btcec.PublicKey, rate *sdkmath.LegacyDec, reqDesc *sttypes.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) + EditFinalityProvider(fpPk *btcec.PublicKey, rate *sdkmath.LegacyDec, reqDesc *proto.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index 81b49bfd..a76d5995 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -237,21 +237,13 @@ func (r *rpcServer) EditFinalityProvider(ctx context.Context, req *proto.EditFin return nil, err } - desc := stakingtypes.Description{ - Moniker: req.Description.Moniker, - Identity: req.Description.Identity, - Website: req.Description.Website, - SecurityContact: req.Description.SecurityContact, - Details: req.Description.Details, - } - rate, err := sdkmath.LegacyNewDecFromStr(req.Commission) if err != nil { return nil, err } fpPub := fpPk.MustToBTCPK() - updatedMsg, err := r.app.cc.EditFinalityProvider(fpPub, &rate, &desc) + updatedMsg, err := r.app.cc.EditFinalityProvider(fpPub, &rate, req.Description) if err != nil { return nil, err } diff --git a/testutil/mocks/babylon.go b/testutil/mocks/babylon.go index 9f9ef7e5..ae3c5e46 100644 --- a/testutil/mocks/babylon.go +++ b/testutil/mocks/babylon.go @@ -10,10 +10,10 @@ import ( math "cosmossdk.io/math" types "github.com/babylonlabs-io/babylon/x/btcstaking/types" types0 "github.com/babylonlabs-io/babylon/x/finality/types" + proto "github.com/babylonlabs-io/finality-provider/finality-provider/proto" types1 "github.com/babylonlabs-io/finality-provider/types" btcec "github.com/btcsuite/btcd/btcec/v2" schnorr "github.com/btcsuite/btcd/btcec/v2/schnorr" - types2 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -70,7 +70,7 @@ func (mr *MockClientControllerMockRecorder) CommitPubRandList(fpPk, startHeight, } // EditFinalityProvider mocks base method. -func (m *MockClientController) EditFinalityProvider(fpPk *btcec.PublicKey, rate *math.LegacyDec, reqDesc *types2.Description) (*types.MsgEditFinalityProvider, error) { +func (m *MockClientController) EditFinalityProvider(fpPk *btcec.PublicKey, rate *math.LegacyDec, reqDesc *proto.Description) (*types.MsgEditFinalityProvider, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EditFinalityProvider", fpPk, rate, reqDesc) ret0, _ := ret[0].(*types.MsgEditFinalityProvider) From d48c58de76b3e4b315f20b7d2dd9905718f54c61 Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 16:41:16 +0200 Subject: [PATCH 16/17] pr comments --- clientcontroller/babylon.go | 12 ++++++++---- clientcontroller/interface.go | 4 +--- finality-provider/service/rpcserver.go | 8 +++++++- itest/e2e_test.go | 1 + testutil/mocks/babylon.go | 9 ++++----- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index cab3d267..3538ca41 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -15,6 +15,8 @@ import ( btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" + fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" + "github.com/babylonlabs-io/finality-provider/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" @@ -25,9 +27,7 @@ import ( sttypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/relayer/v2/relayer/provider" "go.uber.org/zap" - - fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" - "github.com/babylonlabs-io/finality-provider/types" + protobuf "google.golang.org/protobuf/proto" ) var _ ClientController = &BabylonController{} @@ -523,7 +523,11 @@ func (bc *BabylonController) QueryFinalityProvider(fpPk *btcec.PublicKey) (*btcs } func (bc *BabylonController) EditFinalityProvider(fpPk *btcec.PublicKey, - rate *sdkmath.LegacyDec, reqDesc *proto.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) { + rate *sdkmath.LegacyDec, description []byte) (*btcstakingtypes.MsgEditFinalityProvider, error) { + var reqDesc proto.Description + if err := protobuf.Unmarshal(description, &reqDesc); err != nil { + return nil, err + } fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk) fpRes, err := bc.QueryFinalityProvider(fpPk) diff --git a/clientcontroller/interface.go b/clientcontroller/interface.go index d0cdb1c6..975088e8 100644 --- a/clientcontroller/interface.go +++ b/clientcontroller/interface.go @@ -2,10 +2,8 @@ package clientcontroller import ( "cosmossdk.io/math" - sdkmath "cosmossdk.io/math" "fmt" btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/chaincfg" @@ -52,7 +50,7 @@ type ClientController interface { QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) // EditFinalityProvider edits description and commission of a finality provider - EditFinalityProvider(fpPk *btcec.PublicKey, rate *sdkmath.LegacyDec, reqDesc *proto.Description) (*btcstakingtypes.MsgEditFinalityProvider, error) + EditFinalityProvider(fpPk *btcec.PublicKey, commission *math.LegacyDec, description []byte) (*btcstakingtypes.MsgEditFinalityProvider, error) // QueryLatestFinalizedBlocks returns the latest finalized blocks QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) diff --git a/finality-provider/service/rpcserver.go b/finality-provider/service/rpcserver.go index a76d5995..a377903d 100644 --- a/finality-provider/service/rpcserver.go +++ b/finality-provider/service/rpcserver.go @@ -8,6 +8,7 @@ import ( bbntypes "github.com/babylonlabs-io/babylon/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "google.golang.org/grpc" + protobuf "google.golang.org/protobuf/proto" "sync" "sync/atomic" @@ -242,8 +243,13 @@ func (r *rpcServer) EditFinalityProvider(ctx context.Context, req *proto.EditFin return nil, err } + descBytes, err := protobuf.Marshal(req.Description) + if err != nil { + return nil, err + } + fpPub := fpPk.MustToBTCPK() - updatedMsg, err := r.app.cc.EditFinalityProvider(fpPub, &rate, req.Description) + updatedMsg, err := r.app.cc.EditFinalityProvider(fpPub, &rate, descBytes) if err != nil { return nil, err } diff --git a/itest/e2e_test.go b/itest/e2e_test.go index f2763024..49383832 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -238,4 +238,5 @@ func TestFinalityProviderEditCmd(t *testing.T) { require.Equal(t, updateFpDesc.Identity, oldDesc.Identity) require.Equal(t, updateFpDesc.Details, oldDesc.Details) require.Equal(t, updateFpDesc.SecurityContact, oldDesc.SecurityContact) + require.Equal(t, updatedFp.FinalityProvider.Commission, &rate) } diff --git a/testutil/mocks/babylon.go b/testutil/mocks/babylon.go index ae3c5e46..004ba4ff 100644 --- a/testutil/mocks/babylon.go +++ b/testutil/mocks/babylon.go @@ -10,7 +10,6 @@ import ( math "cosmossdk.io/math" types "github.com/babylonlabs-io/babylon/x/btcstaking/types" types0 "github.com/babylonlabs-io/babylon/x/finality/types" - proto "github.com/babylonlabs-io/finality-provider/finality-provider/proto" types1 "github.com/babylonlabs-io/finality-provider/types" btcec "github.com/btcsuite/btcd/btcec/v2" schnorr "github.com/btcsuite/btcd/btcec/v2/schnorr" @@ -70,18 +69,18 @@ func (mr *MockClientControllerMockRecorder) CommitPubRandList(fpPk, startHeight, } // EditFinalityProvider mocks base method. -func (m *MockClientController) EditFinalityProvider(fpPk *btcec.PublicKey, rate *math.LegacyDec, reqDesc *proto.Description) (*types.MsgEditFinalityProvider, error) { +func (m *MockClientController) EditFinalityProvider(fpPk *btcec.PublicKey, commission *math.LegacyDec, description []byte) (*types.MsgEditFinalityProvider, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "EditFinalityProvider", fpPk, rate, reqDesc) + ret := m.ctrl.Call(m, "EditFinalityProvider", fpPk, commission, description) ret0, _ := ret[0].(*types.MsgEditFinalityProvider) ret1, _ := ret[1].(error) return ret0, ret1 } // EditFinalityProvider indicates an expected call of EditFinalityProvider. -func (mr *MockClientControllerMockRecorder) EditFinalityProvider(fpPk, rate, reqDesc interface{}) *gomock.Call { +func (mr *MockClientControllerMockRecorder) EditFinalityProvider(fpPk, commission, description interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFinalityProvider", reflect.TypeOf((*MockClientController)(nil).EditFinalityProvider), fpPk, rate, reqDesc) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditFinalityProvider", reflect.TypeOf((*MockClientController)(nil).EditFinalityProvider), fpPk, commission, description) } // QueryActivatedHeight mocks base method. From 23f549d2752cfca959e8392f3a714635a543079c Mon Sep 17 00:00:00 2001 From: Lazar Date: Tue, 15 Oct 2024 16:48:56 +0200 Subject: [PATCH 17/17] pr comments: doc for cmd --- finality-provider/cmd/fpd/daemon/daemon_commands.go | 1 + 1 file changed, 1 insertion(+) diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 66b8e6a2..2238ffee 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -453,6 +453,7 @@ func CommandEditFinalityDescription() *cobra.Command { Aliases: []string{"efp"}, Short: "Edit finality provider data without resetting unchanged fields", Long: "Edit the details of a finality provider using the specified BTC public key. " + + "\nThe provided [btc_pk] must correspond to the Babylon address controlled by the key specified in fpd.conf. " + "\nIf one or more optional flags are passed (such as --moniker, --website, etc.), " + "the corresponding values are updated, while unchanged fields retain their current values from the Babylon Node.", Example: fmt.Sprintf(`fpd edit-finality-provider [btc_pk] --daemon-address %s --moniker "new-moniker"`, defaultFpdDaemonAddress),