diff --git a/light-clients/lcp/types/client_state.go b/light-clients/lcp/types/client_state.go index 802ff8e..865ea3e 100644 --- a/light-clients/lcp/types/client_state.go +++ b/light-clients/lcp/types/client_state.go @@ -197,7 +197,7 @@ func (cs ClientState) VerifyMembership( } commitment := crypto.Keccak256Hash(commitmentProofs.Message) - return cs.VerifyOperatorProofs(ctx, clientStore, commitment, commitmentProofs.Signatures) + return cs.VerifySignatures(ctx, clientStore, commitment, commitmentProofs.Signatures) } // VerifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height. diff --git a/light-clients/lcp/types/lcp.go b/light-clients/lcp/types/lcp.go index b116831..f23cb09 100644 --- a/light-clients/lcp/types/lcp.go +++ b/light-clients/lcp/types/lcp.go @@ -103,14 +103,18 @@ func GetUpdateOperatorsTypedData(salt common.Hash, clientID string, nonce uint64 } } -func ComputeEIP712RegisterEnclaveKey(chainID string, prefix []byte, report string) ([]byte, error) { - _, raw, err := apitypes.TypedDataAndHash(GetRegisterEnclaveKeyTypedData(ComputeChainSalt(chainID, prefix), report)) +func ComputeEIP712RegisterEnclaveKeyWithSalt(salt common.Hash, report string) ([]byte, error) { + _, raw, err := apitypes.TypedDataAndHash(GetRegisterEnclaveKeyTypedData(salt, report)) if err != nil { return nil, err } return []byte(raw), nil } +func ComputeEIP712RegisterEnclaveKey(chainID string, prefix []byte, report string) ([]byte, error) { + return ComputeEIP712RegisterEnclaveKeyWithSalt(ComputeChainSalt(chainID, prefix), report) +} + func ComputeEIP712RegisterEnclaveKeyHash(chainID string, prefix []byte, report string) (common.Hash, error) { bz, err := ComputeEIP712RegisterEnclaveKey(chainID, prefix, report) if err != nil { diff --git a/light-clients/lcp/types/update.go b/light-clients/lcp/types/update.go index b97f4b3..c485e1e 100644 --- a/light-clients/lcp/types/update.go +++ b/light-clients/lcp/types/update.go @@ -18,6 +18,19 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) +type EKInfo struct { + ExpiredAt uint64 + Operator common.Address +} + +func (ei EKInfo) IsExpired(blockTime time.Time) bool { + return time.Unix(int64(ei.ExpiredAt), 0).Before(blockTime) +} + +func (ei EKInfo) IsMatchOperator(operator common.Address) bool { + return ei.Operator == operator +} + func (cs ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) error { switch clientMsg := clientMsg.(type) { case *UpdateClientMessage: @@ -25,7 +38,7 @@ func (cs ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec if err != nil { return errorsmod.Wrapf(clienttypes.ErrInvalidHeader, "invalid message: %v", err) } - if err := cs.VerifyOperatorProofs(ctx, clientStore, crypto.Keccak256Hash(clientMsg.ProxyMessage), clientMsg.Signatures); err != nil { + if err := cs.VerifySignatures(ctx, clientStore, crypto.Keccak256Hash(clientMsg.ProxyMessage), clientMsg.Signatures); err != nil { return errorsmod.Wrapf(clienttypes.ErrInvalidHeader, err.Error()) } switch pmsg := pmsg.(type) { @@ -170,10 +183,21 @@ func (cs ClientState) registerEnclaveKey(ctx sdk.Context, clientStore storetypes if err != nil { panic(err) } - ek, operator, err := ias.GetEKAndOperator(quote) + ek, _, err := ias.GetEKAndOperator(quote) if err != nil { panic(err) } + var operator common.Address + if len(message.OperatorSignature) > 0 { + commitment, err := ComputeEIP712RegisterEnclaveKeyHash(ctx.ChainID(), []byte(exported.StoreKey), message.Report) + if err != nil { + panic(errorsmod.Wrapf(clienttypes.ErrInvalidHeader, "failed to compute commitment: %v", err)) + } + operator, err = RecoverAddress(commitment, message.OperatorSignature) + if err != nil { + panic(errorsmod.Wrapf(clienttypes.ErrInvalidHeader, "failed to recover operator address: %v", err)) + } + } expiredAt := avr.GetTimestamp().Add(cs.getKeyExpiration()) if cs.Contains(clientStore, ek) { if err := cs.ensureEKInfoMatch(clientStore, ek, operator, expiredAt); err != nil { @@ -234,34 +258,7 @@ func (cs ClientState) SetEKInfo(clientStore storetypes.KVStore, ek, operator com return nil } -type EKInfo struct { - ExpiredAt uint64 - Operator common.Address -} - -func (cs ClientState) IsActiveKey(blockTime time.Time, clientStore storetypes.KVStore, ek common.Address) (bool, error) { - ekInfo, err := cs.GetEKInfo(clientStore, ek) - if err != nil { - return false, err - } - if ekInfo == nil { - return false, nil - } - return time.Unix(int64(ekInfo.ExpiredAt), 0).After(blockTime), nil -} - -func (cs ClientState) IsActiveKeyOperator(blockTime time.Time, clientStore storetypes.KVStore, ek, operator common.Address) (bool, error) { - ekInfo, err := cs.GetEKInfo(clientStore, ek) - if err != nil { - return false, err - } - if ekInfo == nil { - return false, nil - } - return ekInfo.Operator == operator && time.Unix(int64(ekInfo.ExpiredAt), 0).After(blockTime), nil -} - -func (cs ClientState) VerifyOperatorProofs(ctx sdk.Context, clientStore storetypes.KVStore, commitment [32]byte, signatures [][]byte) error { +func (cs ClientState) VerifySignatures(ctx sdk.Context, clientStore storetypes.KVStore, commitment [32]byte, signatures [][]byte) error { operators := cs.GetOperators() sigNum := len(signatures) opNum := len(operators) @@ -273,12 +270,13 @@ func (cs ClientState) VerifyOperatorProofs(ctx sdk.Context, clientStore storetyp if err != nil { return err } - active, err := cs.IsActiveKey(ctx.BlockTime(), clientStore, ek) + ekInfo, err := cs.GetEKInfo(clientStore, ek) if err != nil { return err - } - if !active { - return fmt.Errorf("enclave key '%v' is not active", ek) + } else if ekInfo == nil { + return fmt.Errorf("enclave key '%v' not found", ek) + } else if ekInfo.IsExpired(ctx.BlockTime()) { + return fmt.Errorf("enclave key '%v' is expired", ek) } return nil } else if opNum != sigNum { @@ -294,12 +292,15 @@ func (cs ClientState) VerifyOperatorProofs(ctx sdk.Context, clientStore storetyp if err != nil { return err } - active, err := cs.IsActiveKeyOperator(ctx.BlockTime(), clientStore, ek, op) + ekInfo, err := cs.GetEKInfo(clientStore, ek) if err != nil { return err - } - if !active { - return fmt.Errorf("enclave key '%v' is not active", ek) + } else if ekInfo == nil { + return fmt.Errorf("enclave key '%v' not found", ek) + } else if ekInfo.IsExpired(ctx.BlockTime()) { + return fmt.Errorf("enclave key '%v' is expired", ek) + } else if !ekInfo.IsMatchOperator(op) { + return fmt.Errorf("enclave key '%v' operator mismatch: expected=%v actual=%v", ek, op, ekInfo.Operator) } success++ } diff --git a/proto/relayer/provers/lcp/config/config.proto b/proto/relayer/provers/lcp/config/config.proto index 52e84fe..e3a747f 100644 --- a/proto/relayer/provers/lcp/config/config.proto +++ b/proto/relayer/provers/lcp/config/config.proto @@ -30,10 +30,25 @@ message ProverConfig { // the value must be less than or equal to 1 Fraction operators_threshold = 13 [(gogoproto.nullable) = false]; // TODO use signer module instead + // hex string string operator_private_key = 14; + oneof operators_eip712_salt { + EVMChainSalt evm_chain_eip712_salt = 31; + CosmosChainSalt cosmos_chain_eip712_salt = 32; + } } message Fraction { uint64 numerator = 1; uint64 denominator = 2; } + +message EVMChainSalt { + uint64 chain_id = 1; + string verifying_contract_address = 2; +} + +message CosmosChainSalt { + string chain_id = 1; + string prefix = 2; +} diff --git a/relay/config.go b/relay/config.go index 3005529..c98dd8c 100644 --- a/relay/config.go +++ b/relay/config.go @@ -8,14 +8,35 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" lcptypes "github.com/datachainlab/lcp-go/light-clients/lcp/types" + "github.com/ethereum/go-ethereum/common" "github.com/hyperledger-labs/yui-relayer/core" ) const ( DefaultDialTimeout = 20 // seconds DefaultMessageAggregationBatchSize = 8 + + ChainTypeEVM ChainType = 1 + ChainTypeCosmos ChainType = 2 ) +type ChainType uint16 + +func (t ChainType) String() string { + switch t { + case ChainTypeEVM: + return "EVM" + case ChainTypeCosmos: + return "Cosmos" + default: + return fmt.Sprintf("UnknownChainType(%d)", t.Uint16()) + } +} + +func (t ChainType) Uint16() uint16 { + return uint16(t) +} + var _ core.ProverConfig = (*ProverConfig)(nil) var _ codectypes.UnpackInterfacesMessage = (*ProverConfig)(nil) @@ -65,6 +86,17 @@ func (pc ProverConfig) GetMessageAggregationBatchSize() uint64 { } } +func (pc ProverConfig) ChainType() ChainType { + switch pc.OperatorsEip712Salt.(type) { + case *ProverConfig_EvmChainEip712Salt: + return ChainTypeEVM + case *ProverConfig_CosmosChainEip712Salt: + return ChainTypeCosmos + default: + panic(fmt.Sprintf("unknown chain salt: %v", pc.OperatorsEip712Salt)) + } +} + func (pc ProverConfig) Validate() error { // origin prover config validation if err := pc.OriginProver.GetCachedValue().(core.ProverConfig).Validate(); err != nil { @@ -88,6 +120,28 @@ func (pc ProverConfig) Validate() error { if l := len(pc.Operators); l > 1 { return fmt.Errorf("Operators: greater than 1 operator is not supported yet") } + if pc.OperatorsEip712Salt == nil { + return fmt.Errorf("OperatorsEip712Salt must be set") + } else { + switch salt := pc.OperatorsEip712Salt.(type) { + case *ProverConfig_EvmChainEip712Salt: + if salt.EvmChainEip712Salt.ChainId == 0 { + return fmt.Errorf("OperatorsEip712Salt: EvmChainSalt.ChainId must be set") + } + if !common.IsHexAddress(salt.EvmChainEip712Salt.VerifyingContractAddress) { + return fmt.Errorf("OperatorsEip712Salt: EvmChainSalt.VerifyingContractAddress must be a valid hex address") + } + case *ProverConfig_CosmosChainEip712Salt: + if salt.CosmosChainEip712Salt.ChainId == "" { + return fmt.Errorf("OperatorsEip712Salt: CosmosChainSalt.ChainId must be set") + } + if salt.CosmosChainEip712Salt.Prefix == "" { + return fmt.Errorf("OperatorsEip712Salt: CosmosChainSalt.Prefix must be set") + } + default: + return fmt.Errorf("OperatorsEip712Salt: unknown type") + } + } return nil } diff --git a/relay/config.pb.go b/relay/config.pb.go index 8ce19c4..a95d6d3 100644 --- a/relay/config.pb.go +++ b/relay/config.pb.go @@ -35,15 +35,24 @@ type ProverConfig struct { AllowedQuoteStatuses []string `protobuf:"bytes,5,rep,name=allowed_quote_statuses,json=allowedQuoteStatuses,proto3" json:"allowed_quote_statuses,omitempty"` AllowedAdvisoryIds []string `protobuf:"bytes,6,rep,name=allowed_advisory_ids,json=allowedAdvisoryIds,proto3" json:"allowed_advisory_ids,omitempty"` // unit: seconds - KeyExpiration uint64 `protobuf:"varint,7,opt,name=key_expiration,json=keyExpiration,proto3" json:"key_expiration,omitempty"` - ElcClientId string `protobuf:"bytes,8,opt,name=elc_client_id,json=elcClientId,proto3" json:"elc_client_id,omitempty"` - MessageAggregation bool `protobuf:"varint,9,opt,name=message_aggregation,json=messageAggregation,proto3" json:"message_aggregation,omitempty"` - MessageAggregationBatchSize uint64 `protobuf:"varint,10,opt,name=message_aggregation_batch_size,json=messageAggregationBatchSize,proto3" json:"message_aggregation_batch_size,omitempty"` - IsDebugEnclave bool `protobuf:"varint,11,opt,name=is_debug_enclave,json=isDebugEnclave,proto3" json:"is_debug_enclave,omitempty"` - Operators []string `protobuf:"bytes,12,rep,name=operators,proto3" json:"operators,omitempty"` - OperatorsThreshold Fraction `protobuf:"bytes,13,opt,name=operators_threshold,json=operatorsThreshold,proto3" json:"operators_threshold"` + KeyExpiration uint64 `protobuf:"varint,7,opt,name=key_expiration,json=keyExpiration,proto3" json:"key_expiration,omitempty"` + ElcClientId string `protobuf:"bytes,8,opt,name=elc_client_id,json=elcClientId,proto3" json:"elc_client_id,omitempty"` + MessageAggregation bool `protobuf:"varint,9,opt,name=message_aggregation,json=messageAggregation,proto3" json:"message_aggregation,omitempty"` + MessageAggregationBatchSize uint64 `protobuf:"varint,10,opt,name=message_aggregation_batch_size,json=messageAggregationBatchSize,proto3" json:"message_aggregation_batch_size,omitempty"` + IsDebugEnclave bool `protobuf:"varint,11,opt,name=is_debug_enclave,json=isDebugEnclave,proto3" json:"is_debug_enclave,omitempty"` + // if empty, any operator is allowed (default) + // otherwise, only operators in this list are allowed + Operators []string `protobuf:"bytes,12,rep,name=operators,proto3" json:"operators,omitempty"` + // this only works when operators is not empty + // the value must be less than or equal to 1 + OperatorsThreshold Fraction `protobuf:"bytes,13,opt,name=operators_threshold,json=operatorsThreshold,proto3" json:"operators_threshold"` // TODO use signer module instead + // hex string OperatorPrivateKey string `protobuf:"bytes,14,opt,name=operator_private_key,json=operatorPrivateKey,proto3" json:"operator_private_key,omitempty"` + // Types that are valid to be assigned to OperatorsEip712Salt: + // *ProverConfig_EvmChainEip712Salt + // *ProverConfig_CosmosChainEip712Salt + OperatorsEip712Salt isProverConfig_OperatorsEip712Salt `protobuf_oneof:"operators_eip712_salt"` } func (m *ProverConfig) Reset() { *m = ProverConfig{} } @@ -79,6 +88,51 @@ func (m *ProverConfig) XXX_DiscardUnknown() { var xxx_messageInfo_ProverConfig proto.InternalMessageInfo +type isProverConfig_OperatorsEip712Salt interface { + isProverConfig_OperatorsEip712Salt() + MarshalTo([]byte) (int, error) + Size() int +} + +type ProverConfig_EvmChainEip712Salt struct { + EvmChainEip712Salt *EVMChainSalt `protobuf:"bytes,31,opt,name=evm_chain_eip712_salt,json=evmChainEip712Salt,proto3,oneof" json:"evm_chain_eip712_salt,omitempty"` +} +type ProverConfig_CosmosChainEip712Salt struct { + CosmosChainEip712Salt *CosmosChainSalt `protobuf:"bytes,32,opt,name=cosmos_chain_eip712_salt,json=cosmosChainEip712Salt,proto3,oneof" json:"cosmos_chain_eip712_salt,omitempty"` +} + +func (*ProverConfig_EvmChainEip712Salt) isProverConfig_OperatorsEip712Salt() {} +func (*ProverConfig_CosmosChainEip712Salt) isProverConfig_OperatorsEip712Salt() {} + +func (m *ProverConfig) GetOperatorsEip712Salt() isProverConfig_OperatorsEip712Salt { + if m != nil { + return m.OperatorsEip712Salt + } + return nil +} + +func (m *ProverConfig) GetEvmChainEip712Salt() *EVMChainSalt { + if x, ok := m.GetOperatorsEip712Salt().(*ProverConfig_EvmChainEip712Salt); ok { + return x.EvmChainEip712Salt + } + return nil +} + +func (m *ProverConfig) GetCosmosChainEip712Salt() *CosmosChainSalt { + if x, ok := m.GetOperatorsEip712Salt().(*ProverConfig_CosmosChainEip712Salt); ok { + return x.CosmosChainEip712Salt + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ProverConfig) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ProverConfig_EvmChainEip712Salt)(nil), + (*ProverConfig_CosmosChainEip712Salt)(nil), + } +} + type Fraction struct { Numerator uint64 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"` Denominator uint64 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"` @@ -117,9 +171,87 @@ func (m *Fraction) XXX_DiscardUnknown() { var xxx_messageInfo_Fraction proto.InternalMessageInfo +type EVMChainSalt struct { + ChainId uint64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + VerifyingContractAddress string `protobuf:"bytes,2,opt,name=verifying_contract_address,json=verifyingContractAddress,proto3" json:"verifying_contract_address,omitempty"` +} + +func (m *EVMChainSalt) Reset() { *m = EVMChainSalt{} } +func (m *EVMChainSalt) String() string { return proto.CompactTextString(m) } +func (*EVMChainSalt) ProtoMessage() {} +func (*EVMChainSalt) Descriptor() ([]byte, []int) { + return fileDescriptor_2e6956e1b8ef896e, []int{2} +} +func (m *EVMChainSalt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EVMChainSalt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EVMChainSalt.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EVMChainSalt) XXX_Merge(src proto.Message) { + xxx_messageInfo_EVMChainSalt.Merge(m, src) +} +func (m *EVMChainSalt) XXX_Size() int { + return m.Size() +} +func (m *EVMChainSalt) XXX_DiscardUnknown() { + xxx_messageInfo_EVMChainSalt.DiscardUnknown(m) +} + +var xxx_messageInfo_EVMChainSalt proto.InternalMessageInfo + +type CosmosChainSalt struct { + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Prefix string `protobuf:"bytes,2,opt,name=prefix,proto3" json:"prefix,omitempty"` +} + +func (m *CosmosChainSalt) Reset() { *m = CosmosChainSalt{} } +func (m *CosmosChainSalt) String() string { return proto.CompactTextString(m) } +func (*CosmosChainSalt) ProtoMessage() {} +func (*CosmosChainSalt) Descriptor() ([]byte, []int) { + return fileDescriptor_2e6956e1b8ef896e, []int{3} +} +func (m *CosmosChainSalt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CosmosChainSalt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CosmosChainSalt.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CosmosChainSalt) XXX_Merge(src proto.Message) { + xxx_messageInfo_CosmosChainSalt.Merge(m, src) +} +func (m *CosmosChainSalt) XXX_Size() int { + return m.Size() +} +func (m *CosmosChainSalt) XXX_DiscardUnknown() { + xxx_messageInfo_CosmosChainSalt.DiscardUnknown(m) +} + +var xxx_messageInfo_CosmosChainSalt proto.InternalMessageInfo + func init() { proto.RegisterType((*ProverConfig)(nil), "relayer.provers.lcp.config.ProverConfig") proto.RegisterType((*Fraction)(nil), "relayer.provers.lcp.config.Fraction") + proto.RegisterType((*EVMChainSalt)(nil), "relayer.provers.lcp.config.EVMChainSalt") + proto.RegisterType((*CosmosChainSalt)(nil), "relayer.provers.lcp.config.CosmosChainSalt") } func init() { @@ -127,45 +259,55 @@ func init() { } var fileDescriptor_2e6956e1b8ef896e = []byte{ - // 598 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x5f, 0x6f, 0xd3, 0x3c, - 0x14, 0xc6, 0x9b, 0xad, 0xdb, 0xbb, 0xba, 0xeb, 0xf4, 0xe2, 0x0d, 0x14, 0xc6, 0x14, 0xaa, 0x69, - 0x88, 0xde, 0x90, 0x20, 0x40, 0x42, 0x5c, 0x76, 0x7f, 0x90, 0x06, 0x37, 0x23, 0xdb, 0x15, 0x5c, - 0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, 0x00, + // 753 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x5d, 0x8f, 0xdb, 0x44, + 0x14, 0x8d, 0xdb, 0x65, 0x77, 0x33, 0xfb, 0x01, 0xcc, 0x6e, 0xca, 0x34, 0x54, 0x6e, 0x14, 0x15, + 0x11, 0x09, 0x61, 0x43, 0x41, 0xaa, 0x90, 0x78, 0x49, 0xb2, 0x41, 0x2c, 0x08, 0xa9, 0x38, 0x15, + 0x0f, 0x20, 0x34, 0x9a, 0x8c, 0x6f, 0x9c, 0xd1, 0x8e, 0x3d, 0x66, 0x66, 0x62, 0xea, 0xfe, 0x0a, + 0x7e, 0x0a, 0x3f, 0x63, 0x1f, 0xfb, 0xc8, 0x13, 0x82, 0xdd, 0x3f, 0x82, 0x3c, 0x76, 0xe2, 0xa8, + 0x2d, 0x7d, 0x4a, 0xee, 0x39, 0xe7, 0x9e, 0x73, 0x7d, 0xc7, 0x63, 0xf4, 0xb1, 0x06, 0xc9, 0x4a, + 0xd0, 0x61, 0xae, 0x55, 0x01, 0xda, 0x84, 0x92, 0xe7, 0x21, 0x57, 0xd9, 0x52, 0x24, 0xcd, 0x4f, + 0x90, 0x6b, 0x65, 0x15, 0xee, 0x37, 0xc2, 0xa0, 0x11, 0x06, 0x92, 0xe7, 0x41, 0xad, 0xe8, 0x9f, + 0x27, 0x2a, 0x51, 0x4e, 0x16, 0x56, 0xff, 0xea, 0x8e, 0xfe, 0xfd, 0x44, 0xa9, 0x44, 0x42, 0xe8, + 0xaa, 0xc5, 0x7a, 0x19, 0xb2, 0xac, 0xac, 0xa9, 0xe1, 0x9f, 0x07, 0xe8, 0xf8, 0xa9, 0xf3, 0x99, + 0x3a, 0x07, 0xfc, 0x15, 0x3a, 0x51, 0x5a, 0x24, 0x22, 0xa3, 0xb5, 0x3d, 0xf1, 0x06, 0xde, 0xe8, + 0xe8, 0xf1, 0x79, 0x50, 0x7b, 0x04, 0x1b, 0x8f, 0x60, 0x9c, 0x95, 0xd1, 0x71, 0x2d, 0xad, 0x0d, + 0x70, 0x80, 0xce, 0x24, 0xcf, 0xa9, 0x01, 0x5d, 0x08, 0x0e, 0x94, 0xc5, 0xb1, 0x06, 0x63, 0xc8, + 0x9d, 0x81, 0x37, 0xea, 0x46, 0xef, 0x4b, 0x9e, 0xcf, 0x6b, 0x66, 0x5c, 0x13, 0xf8, 0x09, 0x22, + 0xbb, 0xfa, 0x58, 0x30, 0x49, 0xad, 0x48, 0x41, 0xad, 0x2d, 0xb9, 0x3b, 0xf0, 0x46, 0x7b, 0x51, + 0xaf, 0x6d, 0xba, 0x10, 0x4c, 0x3e, 0xab, 0x49, 0xfc, 0x00, 0x75, 0x53, 0x0d, 0x19, 0x97, 0xac, + 0x00, 0xb2, 0xe7, 0xec, 0x5b, 0x00, 0x7f, 0x89, 0xee, 0x31, 0x29, 0xd5, 0xef, 0x10, 0xd3, 0xdf, + 0xd6, 0xca, 0x02, 0x35, 0x96, 0xd9, 0xb5, 0x01, 0x43, 0xde, 0x19, 0xdc, 0x1d, 0x75, 0xa3, 0xf3, + 0x86, 0xfd, 0xb1, 0x22, 0xe7, 0x0d, 0x87, 0x3f, 0x43, 0x1b, 0x9c, 0xb2, 0xb8, 0x10, 0x46, 0xe9, + 0x92, 0x8a, 0xd8, 0x90, 0x7d, 0xd7, 0x83, 0x1b, 0x6e, 0xdc, 0x50, 0x97, 0xb1, 0xc1, 0x1f, 0xa1, + 0xd3, 0x2b, 0x28, 0x29, 0x3c, 0xcf, 0x85, 0x66, 0x56, 0xa8, 0x8c, 0x1c, 0xb8, 0xa1, 0x4f, 0xae, + 0xa0, 0x9c, 0x6d, 0x41, 0x3c, 0x44, 0x27, 0x20, 0x39, 0xe5, 0x52, 0x40, 0x66, 0xa9, 0x88, 0xc9, + 0xa1, 0x1b, 0xf8, 0x08, 0x24, 0x9f, 0x3a, 0xec, 0x32, 0xc6, 0x21, 0x3a, 0x4b, 0xc1, 0x18, 0x96, + 0x00, 0x65, 0x49, 0xa2, 0x21, 0xa9, 0xfd, 0xba, 0x03, 0x6f, 0x74, 0x18, 0xe1, 0x86, 0x1a, 0xb7, + 0x0c, 0x9e, 0x22, 0xff, 0x0d, 0x0d, 0x74, 0xc1, 0x2c, 0x5f, 0x51, 0x23, 0x5e, 0x00, 0x41, 0x6e, + 0x96, 0x0f, 0x5f, 0xef, 0x9d, 0x54, 0x9a, 0xb9, 0x78, 0x01, 0x78, 0x84, 0xde, 0x13, 0x86, 0xc6, + 0xb0, 0x58, 0x27, 0x74, 0xb3, 0xcd, 0x23, 0x17, 0x79, 0x2a, 0xcc, 0x45, 0x05, 0xcf, 0x9a, 0x95, + 0x3e, 0x40, 0x5d, 0x95, 0x83, 0x66, 0x56, 0x69, 0x43, 0x8e, 0xdd, 0x46, 0x5a, 0x00, 0xff, 0x82, + 0xce, 0xb6, 0x05, 0xb5, 0x2b, 0x0d, 0x66, 0xa5, 0x64, 0x4c, 0x4e, 0xdc, 0x8b, 0xf3, 0x28, 0xf8, + 0xff, 0xd7, 0x35, 0xf8, 0x46, 0x33, 0xee, 0x66, 0xda, 0xbb, 0xfe, 0xfb, 0x61, 0x27, 0xc2, 0x5b, + 0x9b, 0x67, 0x1b, 0x97, 0xea, 0x5c, 0x36, 0x28, 0xcd, 0xb5, 0x28, 0x98, 0x05, 0x7a, 0x05, 0x25, + 0x39, 0x75, 0x5b, 0xdc, 0x76, 0x3c, 0xad, 0xa9, 0xef, 0xa1, 0xc4, 0xbf, 0xa2, 0x1e, 0x14, 0x29, + 0xe5, 0x2b, 0x26, 0x32, 0x0a, 0x22, 0x7f, 0xf2, 0xf9, 0x63, 0x6a, 0x98, 0xb4, 0xe4, 0xa1, 0x1b, + 0x68, 0xf4, 0xb6, 0x81, 0x66, 0x3f, 0xfd, 0x30, 0xad, 0xfa, 0xe6, 0x4c, 0xda, 0x6f, 0x3b, 0x11, + 0x86, 0x22, 0x75, 0x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7d, 0x49, 0x3f, 0x4d, 0x54, 0xe8, 0x4e, 0x65, 0xb1, 0xef, + 0xbe, 0x60, 0x5f, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xde, 0xd1, 0x3c, 0x70, 0x05, 0x00, + 0x00, } func (m *ProverConfig) Marshal() (dAtA []byte, err error) { @@ -188,6 +330,15 @@ func (m *ProverConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.OperatorsEip712Salt != nil { + { + size := m.OperatorsEip712Salt.Size() + i -= size + if _, err := m.OperatorsEip712Salt.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } if len(m.OperatorPrivateKey) > 0 { i -= len(m.OperatorPrivateKey) copy(dAtA[i:], m.OperatorPrivateKey) @@ -303,6 +454,52 @@ func (m *ProverConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ProverConfig_EvmChainEip712Salt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProverConfig_EvmChainEip712Salt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.EvmChainEip712Salt != nil { + { + size, err := m.EvmChainEip712Salt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xfa + } + return len(dAtA) - i, nil +} +func (m *ProverConfig_CosmosChainEip712Salt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProverConfig_CosmosChainEip712Salt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.CosmosChainEip712Salt != nil { + { + size, err := m.CosmosChainEip712Salt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x82 + } + return len(dAtA) - i, nil +} func (m *Fraction) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -336,6 +533,78 @@ func (m *Fraction) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EVMChainSalt) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EVMChainSalt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EVMChainSalt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VerifyingContractAddress) > 0 { + i -= len(m.VerifyingContractAddress) + copy(dAtA[i:], m.VerifyingContractAddress) + i = encodeVarintConfig(dAtA, i, uint64(len(m.VerifyingContractAddress))) + i-- + dAtA[i] = 0x12 + } + if m.ChainId != 0 { + i = encodeVarintConfig(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CosmosChainSalt) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CosmosChainSalt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CosmosChainSalt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Prefix) > 0 { + i -= len(m.Prefix) + copy(dAtA[i:], m.Prefix) + i = encodeVarintConfig(dAtA, i, uint64(len(m.Prefix))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintConfig(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintConfig(dAtA []byte, offset int, v uint64) int { offset -= sovConfig(v) base := offset @@ -408,9 +677,36 @@ func (m *ProverConfig) Size() (n int) { if l > 0 { n += 1 + l + sovConfig(uint64(l)) } + if m.OperatorsEip712Salt != nil { + n += m.OperatorsEip712Salt.Size() + } return n } +func (m *ProverConfig_EvmChainEip712Salt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EvmChainEip712Salt != nil { + l = m.EvmChainEip712Salt.Size() + n += 2 + l + sovConfig(uint64(l)) + } + return n +} +func (m *ProverConfig_CosmosChainEip712Salt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CosmosChainEip712Salt != nil { + l = m.CosmosChainEip712Salt.Size() + n += 2 + l + sovConfig(uint64(l)) + } + return n +} func (m *Fraction) Size() (n int) { if m == nil { return 0 @@ -426,6 +722,39 @@ func (m *Fraction) Size() (n int) { return n } +func (m *EVMChainSalt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainId != 0 { + n += 1 + sovConfig(uint64(m.ChainId)) + } + l = len(m.VerifyingContractAddress) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + return n +} + +func (m *CosmosChainSalt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + return n +} + func sovConfig(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -851,6 +1180,76 @@ func (m *ProverConfig) Unmarshal(dAtA []byte) error { } m.OperatorPrivateKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 31: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmChainEip712Salt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EVMChainSalt{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.OperatorsEip712Salt = &ProverConfig_EvmChainEip712Salt{v} + iNdEx = postIndex + case 32: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmosChainEip712Salt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &CosmosChainSalt{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.OperatorsEip712Salt = &ProverConfig_CosmosChainEip712Salt{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipConfig(dAtA[iNdEx:]) @@ -960,6 +1359,221 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { } return nil } +func (m *EVMChainSalt) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EVMChainSalt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EVMChainSalt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerifyingContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + 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 ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VerifyingContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CosmosChainSalt) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CosmosChainSalt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CosmosChainSalt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + 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 ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + 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 ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prefix = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipConfig(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/relay/lcp.go b/relay/lcp.go index 434941d..729193f 100644 --- a/relay/lcp.go +++ b/relay/lcp.go @@ -2,6 +2,7 @@ package relay import ( "context" + "encoding/binary" "encoding/hex" "errors" "fmt" @@ -11,6 +12,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" mapset "github.com/deckarep/golang-set/v2" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/hyperledger-labs/yui-relayer/core" oias "github.com/oasisprotocol/oasis-core/go/common/sgx/ias" @@ -317,6 +319,7 @@ func (pr *Prover) updateELC(elcClientID string, includeState bool) ([]*elc.MsgUp } func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKeyInfo) (core.MsgID, error) { + clientLogger := pr.getClientLogger(pr.originChain.Path().ClientID) if err := ias.VerifyReport(eki.Report, eki.Signature, eki.SigningCert, time.Now()); err != nil { return nil, err } @@ -330,11 +333,16 @@ func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKe OperatorSignature: nil, } if pr.IsOperatorEnabled() { - sig, err := pr.OperatorSign(crypto.Keccak256Hash([]byte(eki.Report))) + commitment, err := pr.ComputeEIP712RegisterEnclaveKeyHash(eki.Report) + if err != nil { + return nil, err + } + sig, err := pr.OperatorSign(commitment) if err != nil { return nil, err } message.OperatorSignature = sig + clientLogger.Info("operator signature", "signature", hex.EncodeToString(sig)) } signer, err := verifier.GetAddress() if err != nil { @@ -354,6 +362,36 @@ func (pr *Prover) registerEnclaveKey(verifier core.Chain, eki *enclave.EnclaveKe return ids[0], nil } +func (pr *Prover) ComputeEIP712RegisterEnclaveKeyHash(report string) (common.Hash, error) { + bz, err := lcptypes.ComputeEIP712RegisterEnclaveKeyWithSalt(pr.computeEIP712ChainSalt(), report) + if err != nil { + return common.Hash{}, err + } + return crypto.Keccak256Hash(bz), nil +} + +func (pr *Prover) computeEIP712ChainSalt() common.Hash { + switch pr.config.ChainType() { + case ChainTypeEVM: + return pr.computeEIP712EVMChainSalt() + case ChainTypeCosmos: + return pr.computeEIP712CosmosChainSalt() + default: + panic(fmt.Sprintf("unsupported chain type: %v", pr.config.ChainType())) + } +} + +func (pr *Prover) computeEIP712EVMChainSalt() common.Hash { + var bz [2]byte + binary.BigEndian.PutUint16(bz[:], ChainTypeEVM.Uint16()) + return crypto.Keccak256Hash(bz[:]) +} + +func (pr *Prover) computeEIP712CosmosChainSalt() common.Hash { + salt := pr.config.GetCosmosChainEip712Salt() + return lcptypes.ComputeChainSalt(salt.ChainId, []byte(salt.Prefix)) +} + type CreateELCResult struct { Created bool `json:"created"` Message *lcptypes.UpdateStateProxyMessage `json:"message,omitempty"` diff --git a/relay/operator.go b/relay/operator.go index 1fcebbf..b1cd557 100644 --- a/relay/operator.go +++ b/relay/operator.go @@ -37,3 +37,10 @@ func (pr *Prover) GetOperators() ([]common.Address, error) { } return operators, nil } + +func (pr *Prover) GetOperatorsThreshold() Fraction { + if pr.config.OperatorsThreshold.Denominator == 0 && pr.config.OperatorsThreshold.Numerator == 0 { + return Fraction{Numerator: 1, Denominator: 1} + } + return pr.config.OperatorsThreshold +} diff --git a/relay/prover.go b/relay/prover.go index cdb2cc9..26eca5c 100644 --- a/relay/prover.go +++ b/relay/prover.go @@ -120,8 +120,8 @@ func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exporte AllowedAdvisoryIds: pr.config.AllowedAdvisoryIds, Operators: operators, OperatorsNonce: 0, - OperatorsThresholdNumerator: pr.config.OperatorsThreshold.Numerator, - OperatorsThresholdDenominator: pr.config.OperatorsThreshold.Denominator, + OperatorsThresholdNumerator: pr.GetOperatorsThreshold().Numerator, + OperatorsThresholdDenominator: pr.GetOperatorsThreshold().Denominator, } consensusState := &lcptypes.ConsensusState{} // NOTE after creates client, register an enclave key into the client state @@ -336,3 +336,12 @@ func (pr *Prover) getLogger() *log.RelayLogger { } return logger.WithChain(pr.path.ChainID) } + +func (pr *Prover) getClientLogger(clientID string) *log.RelayLogger { + logger := pr.getLogger() + return &log.RelayLogger{ + Logger: logger.With( + "client_id", clientID, + ), + } +} diff --git a/tests/e2e/cases/tm2tm/configs/templates/ibc-0.json.tpl b/tests/e2e/cases/tm2tm/configs/templates/ibc-0.json.tpl index e1bc5cd..28e1668 100644 --- a/tests/e2e/cases/tm2tm/configs/templates/ibc-0.json.tpl +++ b/tests/e2e/cases/tm2tm/configs/templates/ibc-0.json.tpl @@ -26,6 +26,14 @@ "allowed_advisory_ids": ["INTEL-SA-00219","INTEL-SA-00289","INTEL-SA-00334","INTEL-SA-00477","INTEL-SA-00614","INTEL-SA-00615","INTEL-SA-00617"], "key_expiration": 604800, "elc_client_id": "07-tendermint-1", - "is_debug_enclave": true + "is_debug_enclave": true, + "operators": [ + "0xcb96F8d6C2d543102184d679D7829b39434E4EEc" + ], + "operator_private_key": "0x99b107441d0bce8e5b0078450f10f309910d8c0a2cc91671bd6cc1a284809642", + "cosmos_chain_eip712_salt": { + "chain_id": "ibc1", + "prefix": "ibc" + } } } diff --git a/tests/e2e/cases/tm2tm/configs/templates/ibc-1.json.tpl b/tests/e2e/cases/tm2tm/configs/templates/ibc-1.json.tpl index b52be04..74bee5d 100644 --- a/tests/e2e/cases/tm2tm/configs/templates/ibc-1.json.tpl +++ b/tests/e2e/cases/tm2tm/configs/templates/ibc-1.json.tpl @@ -26,6 +26,14 @@ "allowed_advisory_ids": ["INTEL-SA-00219","INTEL-SA-00289","INTEL-SA-00334","INTEL-SA-00477","INTEL-SA-00614","INTEL-SA-00615","INTEL-SA-00617"], "key_expiration": 604800, "elc_client_id": "07-tendermint-0", - "is_debug_enclave": true + "is_debug_enclave": true, + "operators": [ + "0x9722414d09f43fb02235d739B50F4C027F43e657" + ], + "operator_private_key": "0x8a94e9f944a297c402a997aa9a60026ce47a6e018192d111c1703176bbc26651", + "cosmos_chain_eip712_salt": { + "chain_id": "ibc0", + "prefix": "ibc" + } } }