diff --git a/lcp b/lcp index 8b97ea9..16fa999 160000 --- a/lcp +++ b/lcp @@ -1 +1 @@ -Subproject commit 8b97ea90a724395d1260aadd39aa165fd8e4f9b3 +Subproject commit 16fa999ccb49cc75365f49b624978616dc85c2c9 diff --git a/relay/cmd.go b/relay/cmd.go index a82949e..3078bd9 100644 --- a/relay/cmd.go +++ b/relay/cmd.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/hyperledger-labs/yui-relayer/config" "github.com/hyperledger-labs/yui-relayer/core" "github.com/spf13/cobra" @@ -26,9 +27,11 @@ func LCPCmd(ctx *config.Context) *cobra.Command { cmd.AddCommand( createELCCmd(ctx), updateELCCmd(ctx), + restoreELCCmd(ctx), + queryELCCmd(ctx), + flags.LineBreak, updateEnclaveKeyCmd(ctx), activateClientCmd(ctx), - restoreELCStateCmd(ctx), removeEnclaveKeyInfoCmd(ctx), ) @@ -112,7 +115,13 @@ func createELCCmd(ctx *config.Context) *cobra.Command { target = c[dst] } prover := target.Prover.(*Prover) - out, err := prover.doCreateELC(viper.GetUint64(flagHeight)) + var elcClientID string + if viper.GetString(flagELCClientID) != "" { + elcClientID = viper.GetString(flagELCClientID) + } else { + elcClientID = prover.config.ElcClientId + } + out, err := prover.doCreateELC(elcClientID, viper.GetUint64(flagHeight)) if err != nil { return err } @@ -124,7 +133,9 @@ func createELCCmd(ctx *config.Context) *cobra.Command { return nil }, } - return heightFlag(srcFlag(cmd)) + cmd = elcClientIDFlag(heightFlag(srcFlag(cmd))) + cmd.MarkFlagRequired(flagELCClientID) + return cmd } func updateELCCmd(ctx *config.Context) *cobra.Command { @@ -149,7 +160,51 @@ func updateELCCmd(ctx *config.Context) *cobra.Command { counterparty = c[src] } prover := target.Prover.(*Prover) - out, err := prover.doUpdateELC(viper.GetString(flagELCClientID), counterparty) + var elcClientID string + if id := viper.GetString(flagELCClientID); id != "" { + elcClientID = id + } else { + elcClientID = prover.config.ElcClientId + } + out, err := prover.doUpdateELC(elcClientID, counterparty) + if err != nil { + return err + } + bz, err := json.Marshal(out) + if err != nil { + return err + } + fmt.Println(string(bz)) + return nil + }, + } + return elcClientIDFlag(srcFlag(cmd)) +} + +func queryELCCmd(ctx *config.Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "query-elc [path]", + Short: "Query ELC client", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + c, src, dst, err := ctx.Config.ChainsFromPath(args[0]) + if err != nil { + return err + } + var target *core.ProvableChain + if viper.GetBool(flagSrc) { + target = c[src] + } else { + target = c[dst] + } + prover := target.Prover.(*Prover) + var elcClientID string + if id := viper.GetString(flagELCClientID); id != "" { + elcClientID = id + } else { + elcClientID = prover.config.ElcClientId + } + out, err := prover.doQueryELC(elcClientID) if err != nil { return err } @@ -164,10 +219,10 @@ func updateELCCmd(ctx *config.Context) *cobra.Command { return elcClientIDFlag(srcFlag(cmd)) } -func restoreELCStateCmd(ctx *config.Context) *cobra.Command { +func restoreELCCmd(ctx *config.Context) *cobra.Command { cmd := &cobra.Command{ - Use: "restore-elc-state [path]", - Short: "Restore ELC state on LCP", + Use: "restore-elc [path]", + Short: "Restore ELC client state with the latest height of the LCP Client on the counterparty chain", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, src, dst, err := ctx.Config.ChainsFromPath(args[0]) @@ -186,22 +241,22 @@ func restoreELCStateCmd(ctx *config.Context) *cobra.Command { verifier = c[src] } prover := target.Prover.(*Prover) - if err := prover.restoreELCState(context.TODO(), verifier, viper.GetUint64(flagHeight)); err != nil { - return err - } - if err := prover.removeEnclaveKeyInfos(context.TODO()); err != nil { - return err + var elcClientID string + if id := viper.GetString(flagELCClientID); id != "" { + elcClientID = id + } else { + elcClientID = prover.config.ElcClientId } - return nil + return prover.restoreELC(context.TODO(), verifier, elcClientID, viper.GetUint64(flagHeight)) }, } - return heightFlag(srcFlag(cmd)) + return elcClientIDFlag(heightFlag(srcFlag(cmd))) } func removeEnclaveKeyInfoCmd(ctx *config.Context) *cobra.Command { cmd := &cobra.Command{ Use: "remove-eki [path]", - Short: "Remove finalized and unfinalized EKIs in the relayer home directory", + Short: "Remove finalized and unfinalized EKIs in the relayer's home directory", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, src, dst, err := ctx.Config.ChainsFromPath(args[0]) diff --git a/relay/elc/query.pb.go b/relay/elc/query.pb.go index d138bc5..c5a8997 100644 --- a/relay/elc/query.pb.go +++ b/relay/elc/query.pb.go @@ -68,11 +68,13 @@ func (m *QueryClientRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryClientRequest proto.InternalMessageInfo type QueryClientResponse struct { + // if false, the client_state and consensus_state fields will be empty + Found bool `protobuf:"varint,1,opt,name=found,proto3" json:"found,omitempty"` // light client state - ClientState *types.Any `protobuf:"bytes,1,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` // consensus state associated with the client that corresponds to a given // height. - ConsensusState *types.Any `protobuf:"bytes,2,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` + ConsensusState *types.Any `protobuf:"bytes,3,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` } func (m *QueryClientResponse) Reset() { *m = QueryClientResponse{} } @@ -116,31 +118,32 @@ func init() { func init() { proto.RegisterFile("lcp/service/elc/v1/query.proto", fileDescriptor_b220343112c27a37) } var fileDescriptor_b220343112c27a37 = []byte{ - // 369 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xbb, 0x4e, 0xc3, 0x30, - 0x14, 0x4d, 0x90, 0xa8, 0x5a, 0x17, 0x81, 0xe4, 0x56, 0x3c, 0x82, 0xe4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, 0x4c, 0x63, 0x9e, 0x2b, 0x54, 0x5b, 0x75, 0xac, 0xf6, 0xc4, 0x5f, 0x7b, 0xe2, 0x0b, - 0x3f, 0xed, 0xec, 0x2d, 0x67, 0x66, 0x2d, 0xa5, 0x03, 0xd1, 0xb6, 0x7e, 0x73, 0x2c, 0xbb, 0xaa, - 0xd2, 0xbb, 0x2c, 0x83, 0x5d, 0xb0, 0xc3, 0x32, 0x69, 0x3f, 0x4a, 0xa2, 0x42, 0x74, 0xe3, 0x0f, - 0x51, 0x63, 0x39, 0x33, 0x77, 0x0b, 0xd1, 0x55, 0x9a, 0x65, 0x6f, 0x7f, 0x57, 0x72, 0xe9, 0x1f, - 0x3b, 0x2d, 0x07, 0x6c, 0xe6, 0x6e, 0x60, 0x17, 0x94, 0x94, 0x23, 0x78, 0x8c, 0xd7, 0x5f, 0x01, - 0xaf, 0x1f, 0xcc, 0x38, 0xf9, 0x17, 0xa7, 0x4e, 0xd3, 0xb9, 0x9a, 0xbc, 0x23, 0x6d, 0x32, 0x47, - 0xfa, 0x74, 0x8e, 0xf4, 0xb7, 0x39, 0xd2, 0x9f, 0x17, 0x48, 0x9b, 0x2e, 0x90, 0xf6, 0xba, 0x40, - 0xda, 0x7d, 0xc3, 0xf5, 0xe2, 0x7e, 0xe2, 0x60, 0x26, 0x07, 0xa4, 0x47, 0x63, 0xca, 0xfa, 0xd4, - 0xf3, 0x05, 0x75, 0x88, 0x60, 0xc1, 0xa9, 0x2b, 0x49, 0xc8, 0x05, 0x4d, 0xb3, 0xcf, 0xe2, 0x94, - 0x72, 0xbf, 0x67, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x99, 0xd1, 0x6f, 0x46, 0x02, 0x00, - 0x00, + // 386 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xbb, 0x6e, 0xe2, 0x40, + 0x14, 0xb5, 0x77, 0x05, 0x82, 0x61, 0xb5, 0x2b, 0x0d, 0x68, 0x97, 0xf5, 0x4a, 0x63, 0xe4, 0x62, + 0x97, 0x66, 0x67, 0x04, 0xe9, 0x48, 0x15, 0x22, 0x45, 0x4a, 0x97, 0x38, 0x15, 0x69, 0xa2, 0xf1, + 0x30, 0x18, 0x4b, 0x83, 0xc7, 0xf8, 0x81, 0xe4, 0x3f, 0x48, 0x99, 0x4f, 0xe0, 0x73, 0x28, 0x29, + 0x53, 0xa1, 0xc4, 0x34, 0xa9, 0xf9, 0x82, 0xc8, 0x1e, 0xe7, 0x81, 0x90, 0x92, 0x6e, 0xce, 0xbd, + 0xe7, 0x9c, 0x7b, 0xcf, 0xb5, 0x01, 0x12, 0x2c, 0x20, 0x11, 0x0f, 0x17, 0x1e, 0xe3, 0x84, 0x0b, + 0x46, 0x16, 0x3d, 0x32, 0x4f, 0x78, 0x98, 0xe2, 0x20, 0x94, 0xb1, 0x84, 0x50, 0xb0, 0x00, 0x97, + 0x7d, 0xcc, 0x05, 0xc3, 0x8b, 0x9e, 0xd1, 0x72, 0xa5, 0x2b, 0x8b, 0x36, 0xc9, 0x5f, 0x8a, 0x69, + 0xfc, 0x76, 0xa5, 0x74, 0x05, 0x27, 0x05, 0x72, 0x92, 0x09, 0xa1, 0x7e, 0x69, 0x62, 0x98, 0x9e, + 0xc3, 0x08, 0x93, 0x21, 0x27, 0x4c, 0x78, 0xdc, 0x8f, 0xf3, 0x21, 0xea, 0xa5, 0x08, 0xd6, 0x31, + 0x80, 0x97, 0xf9, 0xd0, 0xd3, 0xa2, 0x68, 0xf3, 0x79, 0xc2, 0xa3, 0x18, 0xfe, 0x01, 0x75, 0xc5, + 0xba, 0xf1, 0xc6, 0x6d, 0xbd, 0xa3, 0x77, 0xeb, 0x76, 0x4d, 0x15, 0xce, 0xc7, 0x83, 0xda, 0xed, + 0xd2, 0xd4, 0x9e, 0x96, 0xa6, 0x66, 0x65, 0x3a, 0x68, 0xee, 0xa9, 0xa3, 0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} // Reference imports to suppress errors if they are not otherwise used. @@ -283,7 +286,7 @@ func (m *QueryClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if m.ClientState != nil { { @@ -295,7 +298,17 @@ func (m *QueryClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Found { + i-- + if m.Found { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -330,6 +343,9 @@ func (m *QueryClientResponse) Size() (n int) { } var l int _ = l + if m.Found { + n += 2 + } if m.ClientState != nil { l = m.ClientState.Size() n += 1 + l + sovQuery(uint64(l)) @@ -459,6 +475,26 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Found", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Found = bool(v != 0) + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) } @@ -494,7 +530,7 @@ func (m *QueryClientResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) } diff --git a/relay/elc/tx.pb.go b/relay/elc/tx.pb.go index e95954b..47c054d 100644 --- a/relay/elc/tx.pb.go +++ b/relay/elc/tx.pb.go @@ -32,13 +32,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgCreateClient defines a message to create an IBC client type MsgCreateClient struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` // light client state - ClientState *types.Any `protobuf:"bytes,1,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` // consensus state associated with the client that corresponds to a given // height. - ConsensusState *types.Any `protobuf:"bytes,2,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` + ConsensusState *types.Any `protobuf:"bytes,3,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` // enclave key for signing - Signer []byte `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` + Signer []byte `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} } @@ -76,10 +77,9 @@ var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo // MsgCreateClientResponse defines the Msg/CreateClient response type. type MsgCreateClientResponse struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - Message []byte `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - Signer []byte `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` - Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"` + Message []byte `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Signer []byte `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` } func (m *MsgCreateClientResponse) Reset() { *m = MsgCreateClientResponse{} } @@ -460,56 +460,55 @@ func init() { func init() { proto.RegisterFile("lcp/service/elc/v1/tx.proto", fileDescriptor_28db3542707b11e8) } var fileDescriptor_28db3542707b11e8 = []byte{ - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0x8e, 0x49, 0x08, 0xc9, 0xc1, 0xf7, 0xc2, 0x35, 0x51, 0xf0, 0x35, 0xc8, 0x41, 0x61, 0x71, - 0xa3, 0x7b, 0x6f, 0xed, 0x86, 0xee, 0xd8, 0x11, 0xa4, 0xaa, 0x5d, 0xa4, 0xaa, 0x5c, 0xb5, 0x52, - 0xbb, 0x81, 0x89, 0x33, 0x99, 0x58, 0x72, 0x6c, 0xcb, 0xe3, 0xa4, 0xa4, 0x4f, 0xd0, 0x25, 0x6f, - 0x50, 0x5e, 0xa3, 0x6f, 0xc0, 0x92, 0x65, 0x57, 0x11, 0x85, 0x4d, 0xb7, 0xe5, 0x09, 0x2a, 0xcf, - 0x38, 0xc6, 0xf9, 0x71, 0x14, 0xa9, 0x82, 0xdd, 0x9c, 0x73, 0x3e, 0x7f, 0xdf, 0x39, 0x1f, 0xc3, - 0x99, 0xc0, 0x8e, 0x6d, 0x7a, 0x3a, 0xc5, 0xfe, 0xc0, 0x32, 0xb1, 0x8e, 0x6d, 0x53, 0x1f, 0xd4, - 0xf5, 0xe0, 0x4c, 0xf3, 0x7c, 0x37, 0x70, 0x25, 0xc9, 0x36, 0x3d, 0x2d, 0x2a, 0x6a, 0xd8, 0x36, - 0xb5, 0x41, 0x5d, 0x29, 0x11, 0x97, 0xb8, 0xac, 0xac, 0x87, 0x27, 0x8e, 0x54, 0xfe, 0x26, 0xae, - 0x4b, 0x6c, 0xac, 0xb3, 0xa8, 0xd5, 0xef, 0xe8, 0xc8, 0x19, 0x46, 0xa5, 0x8a, 0xd5, 0x32, 0x75, - 0xd3, 0xf5, 0xb1, 0x6e, 0xda, 0x16, 0x76, 0x82, 0x50, 0x81, 0x9f, 0x38, 0xa0, 0x7a, 0x2d, 0xc0, - 0x46, 0x93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0x1a, 0xfc, 0x1f, 0xf2, 0x5d, 0x8c, 0xda, 0xd8, 0x5f, - 0xe4, 0xa6, 0x11, 0x61, 0xa4, 0x7d, 0xf8, 0xc3, 0x72, 0x4c, 0xbb, 0xdf, 0xc6, 0xd1, 0x9f, 0x20, - 0xec, 0xbd, 0x60, 0x88, 0x51, 0x72, 0xda, 0xce, 0x5c, 0x8a, 0x9d, 0x94, 0xb9, 0x99, 0x6c, 0x3d, - 0x76, 0x33, 0x61, 0x98, 0x90, 0x66, 0xd8, 0x4a, 0xba, 0x61, 0xd9, 0x74, 0xc3, 0x02, 0x28, 0x35, - 0x29, 0x39, 0x22, 0xc4, 0xc7, 0x04, 0x05, 0xb8, 0xc9, 0x69, 0x69, 0x82, 0x57, 0x98, 0xe0, 0x55, - 0xa0, 0x10, 0x49, 0x53, 0x79, 0x65, 0x2f, 0x5b, 0x13, 0x8d, 0x38, 0x96, 0x54, 0x80, 0x58, 0x82, - 0xca, 0x59, 0x56, 0x4d, 0x64, 0x12, 0xaa, 0x67, 0xb0, 0x3b, 0x4f, 0xf5, 0x11, 0xe6, 0xfd, 0x29, - 0xc0, 0x56, 0x93, 0x92, 0x77, 0xd8, 0xb7, 0x3a, 0xc3, 0x26, 0xee, 0xb5, 0xb0, 0x4f, 0xbb, 0x96, - 0xb7, 0xf8, 0xbe, 0x96, 0x21, 0xef, 0xf9, 0xb8, 0x63, 0x9d, 0x8d, 0x45, 0x79, 0x24, 0x49, 0x90, - 0xf3, 0x50, 0xd0, 0x65, 0x7a, 0x45, 0x83, 0x9d, 0xa5, 0x12, 0xac, 0x0e, 0x90, 0xdd, 0x1f, 0xdf, - 0x52, 0x1e, 0x48, 0xc7, 0x20, 0x7a, 0xbe, 0xeb, 0x76, 0x4e, 0xba, 0xd8, 0x22, 0xdd, 0x40, 0x5e, - 0x65, 0xd7, 0x4a, 0xd1, 0xac, 0x96, 0xa9, 0x85, 0x5b, 0x44, 0x8b, 0x76, 0xc7, 0xa0, 0xae, 0xb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a, 0xba, 0xfd, 0x96, 0x66, 0xba, 0x3d, 0xbd, 0x8d, 0x02, 0x64, - 0x76, 0x91, 0xe5, 0xd8, 0xa8, 0xa5, 0xdb, 0xa6, 0xf7, 0x84, 0xb8, 0xba, 0x8f, 0x6d, 0x34, 0x0c, - 0x7f, 0x3c, 0xb5, 0xf2, 0xec, 0xd5, 0x7b, 0xf6, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x86, 0xd3, 0x63, - 0x0f, 0x56, 0x09, 0x00, 0x00, + // 760 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x6e, 0xda, 0x4a, + 0x14, 0xc6, 0x40, 0x08, 0x9c, 0xf8, 0xde, 0xe4, 0x4e, 0x10, 0xf1, 0x75, 0x22, 0x83, 0xc8, 0xa2, + 0xa8, 0x3f, 0x76, 0x49, 0x77, 0xd9, 0x85, 0x48, 0x55, 0xbb, 0xa0, 0xaa, 0x5c, 0xb5, 0x52, 0xbb, + 0x49, 0x06, 0x33, 0x0c, 0x96, 0x8c, 0x6d, 0x79, 0x0c, 0x0d, 0x7d, 0x82, 0x2e, 0x2b, 0xf5, 0x01, + 0x9a, 0xd7, 0xe8, 0x1b, 0x64, 0x99, 0x65, 0x57, 0xa8, 0x4d, 0x36, 0xdd, 0x36, 0x4f, 0x50, 0x79, + 0x6c, 0x5c, 0xf3, 0x17, 0x51, 0x45, 0xc9, 0x6e, 0xce, 0x39, 0x9f, 0xbf, 0x6f, 0xce, 0x37, 0xc3, + 0x19, 0x60, 0xdb, 0x32, 0x5c, 0x8d, 0x11, 0x6f, 0x60, 0x1a, 0x44, 0x23, 0x96, 0xa1, 0x0d, 0xea, + 0x9a, 0x7f, 0xa2, 0xba, 0x9e, 0xe3, 0x3b, 0x08, 0x59, 0x86, 0xab, 0x46, 0x45, 0x95, 0x58, 0x86, + 0x3a, 0xa8, 0xcb, 0x45, 0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e8, 0x84, 0xb9, 0x01, 0x0b, 0x92, + 0x60, 0xb5, 0x47, 0x18, 0xc3, 0x94, 0x70, 0x6b, 0x44, 0x7d, 0x1c, 0x26, 0x68, 0xd3, 0x49, 0x5a, + 0xb4, 0x03, 0x85, 0x60, 0x85, 0xfd, 0xbe, 0x17, 0xf6, 0x20, 0xea, 0x7f, 0x12, 0x09, 0xd1, 0xaf, + 0x02, 0x3f, 0x8a, 0xd7, 0x6e, 0xfb, 0x46, 0x47, 0xf1, 0x10, 0x72, 0x5d, 0x82, 0xdb, 0xd1, 0x36, + 0x16, 0xf8, 0xa5, 0x47, 0x18, 0xb4, 0x0b, 0xff, 0x98, 0xb6, 0x61, 0xf5, 0xdb, 0x24, 0x61, 0x72, + 0x5e, 0x17, 0xa3, 0xe4, 0xdf, 0x19, 0x96, 0xdc, 0xfa, 0x1d, 0x18, 0xe6, 0x43, 0xb1, 0xc9, 0xe8, + 0x01, 0xa5, 0x1e, 0xa1, 0xd8, 0x27, 0xcd, 0x90, 0x96, 0x25, 0x78, 0x85, 0x09, 0x5e, 0x19, 0xf2, + 0x91, 0x34, 0x93, 0xd2, 0x95, 0x4c, 0x4d, 0xd4, 0xe3, 0x18, 0x29, 0x00, 0xb1, 0x04, 0x93, 0x32, + 0xbc, 0x9a, 0xc8, 0x24, 0x54, 0x4f, 0x60, 0x67, 0x9e, 0xea, 0x1d, 0xf4, 0xfb, 0x4b, 0x80, 0xcd, + 0x26, 0xa3, 0x6f, 0x88, 0x67, 0x76, 0x86, 0x4d, 0xd2, 0x6b, 0x11, 0x8f, 0x75, 0x4d, 0x17, 0x6d, + 0xcf, 0x5c, 0x92, 0xc4, 0x75, 0x28, 0x41, 0xce, 0xf5, 0x48, 0xc7, 0x3c, 0x19, 0x8b, 0x86, 0x11, + 0x42, 0x90, 0x75, 0xb1, 0xdf, 0xe5, 0x7a, 0x05, 0x9d, 0xaf, 0x51, 0x11, 0x56, 0x06, 0xd8, 0xea, + 0x93, 0xe8, 0x98,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 0x3c, 0x3d, 0xfb, 0xa1, 0xa4, 0xce, + 0x2e, 0x14, 0xe1, 0xfc, 0x42, 0x11, 0xbe, 0x5f, 0x28, 0xc2, 0xa7, 0x4b, 0x25, 0x75, 0x7e, 0xa9, + 0xa4, 0xbe, 0x5d, 0x2a, 0xa9, 0x77, 0x35, 0x6a, 0xfa, 0xdd, 0x7e, 0x4b, 0x35, 0x9c, 0x9e, 0xd6, + 0xc6, 0x3e, 0x36, 0xba, 0xd8, 0xb4, 0x2d, 0xdc, 0xd2, 0x2c, 0xc3, 0x7d, 0x44, 0x1d, 0xcd, 0x23, + 0x16, 0x1e, 0x06, 0xff, 0xa8, 0x5a, 0x39, 0xfe, 0xea, 0x3d, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, + 0x88, 0x6f, 0xfe, 0xca, 0x6b, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -771,7 +770,7 @@ func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.ConsensusState != nil { { @@ -783,7 +782,7 @@ func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if m.ClientState != nil { { @@ -795,6 +794,13 @@ func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -825,27 +831,20 @@ func (m *MsgCreateClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.Signature) i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.Message) > 0 { i -= len(m.Message) copy(dAtA[i:], m.Message) i = encodeVarintTx(dAtA, i, uint64(len(m.Message))) i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -1294,6 +1293,10 @@ func (m *MsgCreateClient) Size() (n int) { } var l int _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } if m.ClientState != nil { l = m.ClientState.Size() n += 1 + l + sovTx(uint64(l)) @@ -1315,10 +1318,6 @@ func (m *MsgCreateClientResponse) Size() (n int) { } var l int _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } l = len(m.Message) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1569,6 +1568,38 @@ func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) } @@ -1604,7 +1635,7 @@ func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) } @@ -1640,7 +1671,7 @@ func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -1725,38 +1756,6 @@ func (m *MsgCreateClientResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) } @@ -1790,7 +1789,7 @@ func (m *MsgCreateClientResponse) Unmarshal(dAtA []byte) error { m.Message = []byte{} } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -1824,7 +1823,7 @@ func (m *MsgCreateClientResponse) Unmarshal(dAtA []byte) error { m.Signer = []byte{} } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) } diff --git a/relay/lcp.go b/relay/lcp.go index 4754217..6fb70ac 100644 --- a/relay/lcp.go +++ b/relay/lcp.go @@ -348,12 +348,12 @@ func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKe } type CreateELCResult struct { - ELCClientID string `json:"elc_client_id"` - Message *lcptypes.UpdateStateProxyMessage `json:"message"` + Created bool `json:"created"` + Message *lcptypes.UpdateStateProxyMessage `json:"message,omitempty"` } // height: 0 means the latest height -func (pr *Prover) doCreateELC(height uint64) (*CreateELCResult, error) { +func (pr *Prover) doCreateELC(elcClientID string, height uint64) (*CreateELCResult, error) { header, err := pr.originProver.GetLatestFinalizedHeader() if err != nil { return nil, err @@ -365,12 +365,15 @@ func (pr *Prover) doCreateELC(height uint64) (*CreateELCResult, error) { return nil, fmt.Errorf("height %v is greater than the latest height %v", height, latestHeight.GetRevisionHeight()) } h := clienttypes.NewHeight(latestHeight.GetRevisionNumber(), height) - log.GetLogger().Info("try to create ELC client", "height", h) - res, err := pr.createELC(h) + log.GetLogger().Info("try to create ELC client", "client_id", elcClientID, "height", h) + res, err := pr.createELC(elcClientID, h) if err != nil { return nil, err + } else if res == nil { + log.GetLogger().Info("no need to create ELC client", "client_id", elcClientID) + return &CreateELCResult{Created: false}, nil } - log.GetLogger().Info("created ELC client", "client_id", res.ClientId) + log.GetLogger().Info("created ELC client", "client_id", elcClientID, "height", h) // ensure the message is valid msg, err := lcptypes.EthABIDecodeHeaderedProxyMessage(res.Message) if err != nil { @@ -382,8 +385,8 @@ func (pr *Prover) doCreateELC(height uint64) (*CreateELCResult, error) { } log.GetLogger().Info("created state", "post_height", m.PostHeight, "post_state_id", m.PostStateID.String(), "timestamp", m.Timestamp.String()) return &CreateELCResult{ - ELCClientID: res.ClientId, - Message: m, + Created: true, + Message: m, }, nil } @@ -395,9 +398,6 @@ func (pr *Prover) doUpdateELC(elcClientID string, counterparty core.FinalityAwar if err := pr.UpdateEKIfNeeded(context.TODO(), counterparty); err != nil { return nil, err } - if elcClientID == "" { - elcClientID = pr.config.ElcClientId - } log.GetLogger().Info("try to update the ELC client", "elc_client_id", elcClientID) updates, err := pr.updateELC(elcClientID, false) if err != nil { @@ -427,7 +427,68 @@ func (pr *Prover) doUpdateELC(elcClientID string, counterparty core.FinalityAwar }, nil } -func (pr *Prover) createELC(height exported.Height) (*elc.MsgCreateClientResponse, error) { +type QueryELCResult struct { + // if false, `Raw` and `Decoded` are empty + Found bool `json:"found"` + Raw struct { + ClientState Any `json:"client_state"` + ConsensusState Any `json:"consensus_state"` + } `json:"raw"` + // if cannot decode the client state or the consensus state, `Decoded` is empty + Decoded struct { + ClientState ibcexported.ClientState `json:"client_state"` + ConsensusState ibcexported.ConsensusState `json:"consensus_state"` + } `json:"decoded,omitempty"` +} + +type Any struct { + TypeURL string `json:"type_url"` + Value []byte `json:"value"` +} + +func (pr *Prover) doQueryELC(elcClientID string) (*QueryELCResult, error) { + r, err := pr.lcpServiceClient.Client(context.TODO(), &elc.QueryClientRequest{ClientId: elcClientID}) + if err != nil { + return nil, err + } else if !r.Found { + return &QueryELCResult{ + Found: false, + }, nil + } + var result QueryELCResult + result.Found = true + result.Raw.ClientState = Any{ + TypeURL: r.ClientState.TypeUrl, + Value: r.ClientState.Value, + } + result.Raw.ConsensusState = Any{ + TypeURL: r.ConsensusState.TypeUrl, + Value: r.ConsensusState.Value, + } + var ( + clientState ibcexported.ClientState + consensusState ibcexported.ConsensusState + ) + if err := pr.codec.UnpackAny(r.ClientState, &clientState); err != nil { + log.GetLogger().Warn("failed to unpack client state", "error", err) + return &result, nil + } + if err := pr.codec.UnpackAny(r.ConsensusState, &consensusState); err != nil { + log.GetLogger().Warn("failed to unpack consensus state", "error", err) + return &result, nil + } + result.Decoded.ClientState = clientState + result.Decoded.ConsensusState = consensusState + return &result, nil +} + +func (pr *Prover) createELC(elcClientID string, height exported.Height) (*elc.MsgCreateClientResponse, error) { + res, err := pr.lcpServiceClient.Client(context.TODO(), &elc.QueryClientRequest{ClientId: elcClientID}) + if err != nil { + return nil, err + } else if res.Found { + return nil, nil + } // NOTE: Query the LCP for available keys, but no need to register it into on-chain here tmpEKI, err := pr.selectNewEnclaveKey(context.TODO()) if err != nil { @@ -446,6 +507,7 @@ func (pr *Prover) createELC(height exported.Height) (*elc.MsgCreateClientRespons return nil, err } return pr.lcpServiceClient.CreateClient(context.TODO(), &elc.MsgCreateClient{ + ClientId: elcClientID, ClientState: anyOriginClientState, ConsensusState: anyOriginConsensusState, Signer: tmpEKI.EnclaveKeyAddress, diff --git a/relay/prover.go b/relay/prover.go index b2e1bcf..72f50d2 100644 --- a/relay/prover.go +++ b/relay/prover.go @@ -99,14 +99,10 @@ func (pr *Prover) GetChainID() string { // These states will be submitted to the counterparty chain as MsgCreateClient. // If `height` is nil, the latest finalized height is selected automatically. func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exported.ClientState, exported.ConsensusState, error) { - res, err := pr.createELC(height) - if err != nil { + if res, err := pr.createELC(pr.config.ElcClientId, height); err != nil { return nil, nil, err - } - - // TODO relayer should persist res.ClientId - if pr.config.ElcClientId != res.ClientId { - return nil, nil, fmt.Errorf("you must specify '%v' as elc_client_id, but got %v", res.ClientId, pr.config.ElcClientId) + } else if res == nil { + log.GetLogger().Info("no need to create ELC", "client_id", pr.config.ElcClientId) } clientState := &lcptypes.ClientState{ diff --git a/relay/restore.go b/relay/restore.go index e3de05d..3daf8a4 100644 --- a/relay/restore.go +++ b/relay/restore.go @@ -14,14 +14,14 @@ import ( "github.com/hyperledger-labs/yui-relayer/log" ) -func (pr *Prover) restoreELCState(ctx context.Context, counterparty core.FinalityAwareChain, height uint64) error { - +func (pr *Prover) restoreELC(ctx context.Context, counterparty core.FinalityAwareChain, elcClientID string, height uint64) error { // ensure the client does not exist in the LCP service - _, err := pr.lcpServiceClient.Client(ctx, &elc.QueryClientRequest{ - ClientId: pr.config.ElcClientId, - }) - if err == nil { - return fmt.Errorf("client '%v' already exists", pr.config.ElcClientId) + if res, err := pr.lcpServiceClient.Client(ctx, &elc.QueryClientRequest{ + ClientId: elcClientID, + }); err != nil { + return err + } else if res.Found { + return fmt.Errorf("client '%v' already exists", elcClientID) } cplatestHeight, err := counterparty.LatestHeight() @@ -93,6 +93,7 @@ func (pr *Prover) restoreELCState(ctx context.Context, counterparty core.Finalit return err } res, err := pr.lcpServiceClient.CreateClient(context.TODO(), &elc.MsgCreateClient{ + ClientId: elcClientID, ClientState: originAnyClientState, ConsensusState: originAnyConsensusState, Signer: tmpEKI.EnclaveKeyAddress, @@ -118,12 +119,7 @@ func (pr *Prover) restoreELCState(ctx context.Context, counterparty core.Finalit return fmt.Errorf("unexpected height: expected %v, but got %v", restoreHeight, usm.PostHeight) } - // TODO relayer should update res.ClientId in the config - if pr.config.ElcClientId != res.ClientId { - return fmt.Errorf("you must specify '%v' as elc_client_id, but got %v", res.ClientId, pr.config.ElcClientId) - } - - log.GetLogger().Info("successfully restored ELC state", "client_id", res.ClientId, "state_id", usm.PostStateID.String(), "height", usm.PostHeight) + log.GetLogger().Info("successfully restored ELC state", "client_id", elcClientID, "state_id", usm.PostStateID.String(), "height", usm.PostHeight) return nil } diff --git a/scripts/run_e2e_test.sh b/scripts/run_e2e_test.sh index bf8d11a..9394762 100755 --- a/scripts/run_e2e_test.sh +++ b/scripts/run_e2e_test.sh @@ -30,6 +30,6 @@ LCP_PID=$! make -C tests/e2e/cases/tm2tm restore make -C tests/e2e/cases/tm2tm test-relay -make -C tests/e2e/cases/tm2tm test-elc-update +make -C tests/e2e/cases/tm2tm test-elc-cmd make -C tests/e2e/cases/tm2tm network-down kill $LCP_PID diff --git a/tests/e2e/cases/tm2tm/Makefile b/tests/e2e/cases/tm2tm/Makefile index 7517567..a6dc18d 100644 --- a/tests/e2e/cases/tm2tm/Makefile +++ b/tests/e2e/cases/tm2tm/Makefile @@ -36,6 +36,6 @@ test-relay: restore: RLY_BIN=$(RLY_BIN) ./scripts/restore -.PHONY: test-elc-update -test-elc-update: - RLY_BIN=$(RLY_BIN) ./scripts/test-elc-update +.PHONY: test-elc-cmd +test-elc-cmd: + RLY_BIN=$(RLY_BIN) ./scripts/test-elc-cmd diff --git a/tests/e2e/cases/tm2tm/scripts/restore b/tests/e2e/cases/tm2tm/scripts/restore index bab5b1b..ea37127 100755 --- a/tests/e2e/cases/tm2tm/scripts/restore +++ b/tests/e2e/cases/tm2tm/scripts/restore @@ -3,8 +3,8 @@ set -eux RLY="${RLY_BIN} --debug" -${RLY} lcp restore-elc-state ibc01 --src=false -${RLY} lcp restore-elc-state ibc01 --src=true +${RLY} lcp restore-elc ibc01 --src=false +${RLY} lcp restore-elc ibc01 --src=true ${RLY} lcp remove-eki ibc01 --src=false ${RLY} lcp remove-eki ibc01 --src=true diff --git a/tests/e2e/cases/tm2tm/scripts/test-elc-cmd b/tests/e2e/cases/tm2tm/scripts/test-elc-cmd new file mode 100755 index 0000000..e2343d4 --- /dev/null +++ b/tests/e2e/cases/tm2tm/scripts/test-elc-cmd @@ -0,0 +1,66 @@ +#!/bin/bash + +set -eu + +RLY="${RLY_BIN} --debug" + +echo "query non-existent ELCs" + +src_elc_exists=$(${RLY} lcp query-elc ibc01 --elc_client_id=07-tendermint-2 --src | jq -r '.found') +if [ "${src_elc_exists}" != "false" ]; then + echo "src elc already exists" + exit 1 +fi +dst_elc_exists=$(${RLY} lcp query-elc ibc01 --elc_client_id=07-tendermint-3 --src=false | jq -r '.found') +if [ "${dst_elc_exists}" != "false" ]; then + echo "dst elc already exists" + exit 1 +fi + +echo "create a new ELCs" + +src_elc_created=$(${RLY} lcp create-elc ibc01 --elc_client_id=07-tendermint-2 --src | jq -r '.created') +if [ "${src_elc_created}" != "true" ]; then + echo "failed to create src elc" + exit 1 +fi +dst_elc_created=$(${RLY} lcp create-elc ibc01 --elc_client_id=07-tendermint-3 --src=false | jq -r '.created') +if [ "${dst_elc_created}" != "true" ]; then + echo "failed to create dst elc" + exit 1 +fi + +echo "query the ELCs" + +src_elc_exists=$(${RLY} lcp query-elc ibc01 --elc_client_id=07-tendermint-2 --src | jq -r '.found') +if [ "${src_elc_exists}" != "true" ]; then + echo "src elc does not exist" + exit 1 +fi + +dst_elc_exists=$(${RLY} lcp query-elc ibc01 --elc_client_id=07-tendermint-3 --src=false | jq -r '.found') +if [ "${dst_elc_exists}" != "true" ]; then + echo "dst elc does not exist" + exit 1 +fi + +echo "sleeping for 5 seconds" +sleep 5 + +echo "update the ELCs" + +${RLY} lcp update-elc ibc01 --src --elc_client_id=07-tendermint-2 +${RLY} lcp update-elc ibc01 --src=false --elc_client_id=07-tendermint-3 + +echo "ensure that the same elc ID cannot be used for both src and dst" + +src_elc_created=$(${RLY} lcp create-elc ibc01 --elc_client_id=07-tendermint-2 --src | jq -r '.created') +if [ "${src_elc_created}" != "false" ]; then + echo "failed to create src elc" + exit 1 +fi +dst_elc_created=$(${RLY} lcp create-elc ibc01 --elc_client_id=07-tendermint-3 --src=false | jq -r '.created') +if [ "${dst_elc_created}" != "false" ]; then + echo "failed to create dst elc" + exit 1 +fi diff --git a/tests/e2e/cases/tm2tm/scripts/test-elc-update b/tests/e2e/cases/tm2tm/scripts/test-elc-update deleted file mode 100755 index 8af8cf9..0000000 --- a/tests/e2e/cases/tm2tm/scripts/test-elc-update +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -eu - -RLY="${RLY_BIN} --debug" - -src_elc_client_id=$(${RLY} lcp create-elc ibc01 --src | jq -r '.elc_client_id') -dst_elc_client_id=$(${RLY} lcp create-elc ibc01 --src=false | jq -r '.elc_client_id') - -echo "src: ELC client id: ${src_elc_client_id}" -echo "dst: ELC client id: ${dst_elc_client_id}" - -echo "sleeping for 5 seconds" -sleep 5 - -${RLY} lcp update-elc ibc01 --src --elc_client_id=${src_elc_client_id} -${RLY} lcp update-elc ibc01 --src=false --elc_client_id=${dst_elc_client_id}