diff --git a/api/band/bandtss/v1beta1/genesis.pulsar.go b/api/band/bandtss/v1beta1/genesis.pulsar.go index de6945837..a2dfbccc4 100644 --- a/api/band/bandtss/v1beta1/genesis.pulsar.go +++ b/api/band/bandtss/v1beta1/genesis.pulsar.go @@ -667,54 +667,54 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { } } -var _ protoreflect.List = (*_Params_4_list)(nil) +var _ protoreflect.List = (*_Params_5_list)(nil) -type _Params_4_list struct { +type _Params_5_list struct { list *[]*v1beta1.Coin } -func (x *_Params_4_list) Len() int { +func (x *_Params_5_list) Len() int { if x.list == nil { return 0 } return len(*x.list) } -func (x *_Params_4_list) Get(i int) protoreflect.Value { +func (x *_Params_5_list) Get(i int) protoreflect.Value { return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) } -func (x *_Params_4_list) Set(i int, value protoreflect.Value) { +func (x *_Params_5_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) (*x.list)[i] = concreteValue } -func (x *_Params_4_list) Append(value protoreflect.Value) { +func (x *_Params_5_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) *x.list = append(*x.list, concreteValue) } -func (x *_Params_4_list) AppendMutable() protoreflect.Value { +func (x *_Params_5_list) AppendMutable() protoreflect.Value { v := new(v1beta1.Coin) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_Params_4_list) Truncate(n int) { +func (x *_Params_5_list) Truncate(n int) { for i := n; i < len(*x.list); i++ { (*x.list)[i] = nil } *x.list = (*x.list)[:n] } -func (x *_Params_4_list) NewElement() protoreflect.Value { +func (x *_Params_5_list) NewElement() protoreflect.Value { v := new(v1beta1.Coin) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_Params_4_list) IsValid() bool { +func (x *_Params_5_list) IsValid() bool { return x.list != nil } @@ -722,8 +722,9 @@ var ( md_Params protoreflect.MessageDescriptor fd_Params_reward_percentage protoreflect.FieldDescriptor fd_Params_inactive_penalty_duration protoreflect.FieldDescriptor + fd_Params_min_transition_duration protoreflect.FieldDescriptor fd_Params_max_transition_duration protoreflect.FieldDescriptor - fd_Params_fee protoreflect.FieldDescriptor + fd_Params_fee_per_signer protoreflect.FieldDescriptor ) func init() { @@ -731,8 +732,9 @@ func init() { md_Params = File_band_bandtss_v1beta1_genesis_proto.Messages().ByName("Params") fd_Params_reward_percentage = md_Params.Fields().ByName("reward_percentage") fd_Params_inactive_penalty_duration = md_Params.Fields().ByName("inactive_penalty_duration") + fd_Params_min_transition_duration = md_Params.Fields().ByName("min_transition_duration") fd_Params_max_transition_duration = md_Params.Fields().ByName("max_transition_duration") - fd_Params_fee = md_Params.Fields().ByName("fee") + fd_Params_fee_per_signer = md_Params.Fields().ByName("fee_per_signer") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -812,15 +814,21 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.MinTransitionDuration != nil { + value := protoreflect.ValueOfMessage(x.MinTransitionDuration.ProtoReflect()) + if !f(fd_Params_min_transition_duration, value) { + return + } + } if x.MaxTransitionDuration != nil { value := protoreflect.ValueOfMessage(x.MaxTransitionDuration.ProtoReflect()) if !f(fd_Params_max_transition_duration, value) { return } } - if len(x.Fee) != 0 { - value := protoreflect.ValueOfList(&_Params_4_list{list: &x.Fee}) - if !f(fd_Params_fee, value) { + if len(x.FeePerSigner) != 0 { + value := protoreflect.ValueOfList(&_Params_5_list{list: &x.FeePerSigner}) + if !f(fd_Params_fee_per_signer, value) { return } } @@ -843,10 +851,12 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.RewardPercentage != uint64(0) case "band.bandtss.v1beta1.Params.inactive_penalty_duration": return x.InactivePenaltyDuration != nil + case "band.bandtss.v1beta1.Params.min_transition_duration": + return x.MinTransitionDuration != nil case "band.bandtss.v1beta1.Params.max_transition_duration": return x.MaxTransitionDuration != nil - case "band.bandtss.v1beta1.Params.fee": - return len(x.Fee) != 0 + case "band.bandtss.v1beta1.Params.fee_per_signer": + return len(x.FeePerSigner) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.bandtss.v1beta1.Params")) @@ -867,10 +877,12 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.RewardPercentage = uint64(0) case "band.bandtss.v1beta1.Params.inactive_penalty_duration": x.InactivePenaltyDuration = nil + case "band.bandtss.v1beta1.Params.min_transition_duration": + x.MinTransitionDuration = nil case "band.bandtss.v1beta1.Params.max_transition_duration": x.MaxTransitionDuration = nil - case "band.bandtss.v1beta1.Params.fee": - x.Fee = nil + case "band.bandtss.v1beta1.Params.fee_per_signer": + x.FeePerSigner = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.bandtss.v1beta1.Params")) @@ -893,14 +905,17 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "band.bandtss.v1beta1.Params.inactive_penalty_duration": value := x.InactivePenaltyDuration return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "band.bandtss.v1beta1.Params.min_transition_duration": + value := x.MinTransitionDuration + return protoreflect.ValueOfMessage(value.ProtoReflect()) case "band.bandtss.v1beta1.Params.max_transition_duration": value := x.MaxTransitionDuration return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "band.bandtss.v1beta1.Params.fee": - if len(x.Fee) == 0 { - return protoreflect.ValueOfList(&_Params_4_list{}) + case "band.bandtss.v1beta1.Params.fee_per_signer": + if len(x.FeePerSigner) == 0 { + return protoreflect.ValueOfList(&_Params_5_list{}) } - listValue := &_Params_4_list{list: &x.Fee} + listValue := &_Params_5_list{list: &x.FeePerSigner} return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { @@ -926,12 +941,14 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.RewardPercentage = value.Uint() case "band.bandtss.v1beta1.Params.inactive_penalty_duration": x.InactivePenaltyDuration = value.Message().Interface().(*durationpb.Duration) + case "band.bandtss.v1beta1.Params.min_transition_duration": + x.MinTransitionDuration = value.Message().Interface().(*durationpb.Duration) case "band.bandtss.v1beta1.Params.max_transition_duration": x.MaxTransitionDuration = value.Message().Interface().(*durationpb.Duration) - case "band.bandtss.v1beta1.Params.fee": + case "band.bandtss.v1beta1.Params.fee_per_signer": lv := value.List() - clv := lv.(*_Params_4_list) - x.Fee = *clv.list + clv := lv.(*_Params_5_list) + x.FeePerSigner = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.bandtss.v1beta1.Params")) @@ -957,16 +974,21 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore x.InactivePenaltyDuration = new(durationpb.Duration) } return protoreflect.ValueOfMessage(x.InactivePenaltyDuration.ProtoReflect()) + case "band.bandtss.v1beta1.Params.min_transition_duration": + if x.MinTransitionDuration == nil { + x.MinTransitionDuration = new(durationpb.Duration) + } + return protoreflect.ValueOfMessage(x.MinTransitionDuration.ProtoReflect()) case "band.bandtss.v1beta1.Params.max_transition_duration": if x.MaxTransitionDuration == nil { x.MaxTransitionDuration = new(durationpb.Duration) } return protoreflect.ValueOfMessage(x.MaxTransitionDuration.ProtoReflect()) - case "band.bandtss.v1beta1.Params.fee": - if x.Fee == nil { - x.Fee = []*v1beta1.Coin{} + case "band.bandtss.v1beta1.Params.fee_per_signer": + if x.FeePerSigner == nil { + x.FeePerSigner = []*v1beta1.Coin{} } - value := &_Params_4_list{list: &x.Fee} + value := &_Params_5_list{list: &x.FeePerSigner} return protoreflect.ValueOfList(value) case "band.bandtss.v1beta1.Params.reward_percentage": panic(fmt.Errorf("field reward_percentage of message band.bandtss.v1beta1.Params is not mutable")) @@ -988,12 +1010,15 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor case "band.bandtss.v1beta1.Params.inactive_penalty_duration": m := new(durationpb.Duration) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "band.bandtss.v1beta1.Params.min_transition_duration": + m := new(durationpb.Duration) + return protoreflect.ValueOfMessage(m.ProtoReflect()) case "band.bandtss.v1beta1.Params.max_transition_duration": m := new(durationpb.Duration) return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "band.bandtss.v1beta1.Params.fee": + case "band.bandtss.v1beta1.Params.fee_per_signer": list := []*v1beta1.Coin{} - return protoreflect.ValueOfList(&_Params_4_list{list: &list}) + return protoreflect.ValueOfList(&_Params_5_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.bandtss.v1beta1.Params")) @@ -1070,12 +1095,16 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { l = options.Size(x.InactivePenaltyDuration) n += 1 + l + runtime.Sov(uint64(l)) } + if x.MinTransitionDuration != nil { + l = options.Size(x.MinTransitionDuration) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.MaxTransitionDuration != nil { l = options.Size(x.MaxTransitionDuration) n += 1 + l + runtime.Sov(uint64(l)) } - if len(x.Fee) > 0 { - for _, e := range x.Fee { + if len(x.FeePerSigner) > 0 { + for _, e := range x.FeePerSigner { l = options.Size(e) n += 1 + l + runtime.Sov(uint64(l)) } @@ -1109,9 +1138,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Fee) > 0 { - for iNdEx := len(x.Fee) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.Fee[iNdEx]) + if len(x.FeePerSigner) > 0 { + for iNdEx := len(x.FeePerSigner) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.FeePerSigner[iNdEx]) if err != nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1122,7 +1151,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } if x.MaxTransitionDuration != nil { @@ -1137,6 +1166,20 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- + dAtA[i] = 0x22 + } + if x.MinTransitionDuration != nil { + encoded, err := options.Marshal(x.MinTransitionDuration) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- dAtA[i] = 0x1a } if x.InactivePenaltyDuration != nil { @@ -1263,6 +1306,42 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } iNdEx = postIndex case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinTransitionDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.MinTransitionDuration == nil { + x.MinTransitionDuration = &durationpb.Duration{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.MinTransitionDuration); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 4: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MaxTransitionDuration", wireType) } @@ -1298,9 +1377,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeePerSigner", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1327,8 +1406,8 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Fee = append(x.Fee, &v1beta1.Coin{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Fee[len(x.Fee)-1]); err != nil { + x.FeePerSigner = append(x.FeePerSigner, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.FeePerSigner[len(x.FeePerSigner)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex @@ -1446,11 +1525,12 @@ type Params struct { RewardPercentage uint64 `protobuf:"varint,1,opt,name=reward_percentage,json=rewardPercentage,proto3" json:"reward_percentage,omitempty"` // inactive_penalty_duration is the duration where a member cannot activate back after being set to inactive. InactivePenaltyDuration *durationpb.Duration `protobuf:"bytes,2,opt,name=inactive_penalty_duration,json=inactivePenaltyDuration,proto3" json:"inactive_penalty_duration,omitempty"` - // max_transition_duration is the maximum duration where the transition process waits - // since the start of the process until an incoming group replaces a current group. - MaxTransitionDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=max_transition_duration,json=maxTransitionDuration,proto3" json:"max_transition_duration,omitempty"` - // fee is the tokens that will be paid per signer. - Fee []*v1beta1.Coin `protobuf:"bytes,4,rep,name=fee,proto3" json:"fee,omitempty"` + // min_transition_duration is the minimum duration that the transition process waits before execution. + MinTransitionDuration *durationpb.Duration `protobuf:"bytes,3,opt,name=min_transition_duration,json=minTransitionDuration,proto3" json:"min_transition_duration,omitempty"` + // max_transition_duration is the maximum duration that the transition process waits before execution. + MaxTransitionDuration *durationpb.Duration `protobuf:"bytes,4,opt,name=max_transition_duration,json=maxTransitionDuration,proto3" json:"max_transition_duration,omitempty"` + // fee_per_signer is the tokens that will be paid per signer. + FeePerSigner []*v1beta1.Coin `protobuf:"bytes,5,rep,name=fee_per_signer,json=feePerSigner,proto3" json:"fee_per_signer,omitempty"` } func (x *Params) Reset() { @@ -1487,6 +1567,13 @@ func (x *Params) GetInactivePenaltyDuration() *durationpb.Duration { return nil } +func (x *Params) GetMinTransitionDuration() *durationpb.Duration { + if x != nil { + return x.MinTransitionDuration + } + return nil +} + func (x *Params) GetMaxTransitionDuration() *durationpb.Duration { if x != nil { return x.MaxTransitionDuration @@ -1494,9 +1581,9 @@ func (x *Params) GetMaxTransitionDuration() *durationpb.Duration { return nil } -func (x *Params) GetFee() []*v1beta1.Coin { +func (x *Params) GetFeePerSigner() []*v1beta1.Coin { if x != nil { - return x.Fee + return x.FeePerSigner } return nil } @@ -1528,8 +1615,8 @@ var file_band_bandtss_v1beta1_genesis_proto_rawDesc = []byte{ 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, - 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x22, 0xee, - 0x02, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x11, 0x72, 0x65, 0x77, + 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x22, 0xdf, + 0x03, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x11, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x5f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x14, 0xe2, 0xde, 0x1f, 0x10, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x52, 0x10, 0x72, 0x65, 0x77, 0x61, @@ -1540,33 +1627,40 @@ var file_band_bandtss_v1beta1_genesis_proto_rawDesc = []byte{ 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, 0x1f, 0x01, 0x52, 0x17, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x50, 0x65, 0x6e, 0x61, 0x6c, 0x74, 0x79, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5b, 0x0a, - 0x17, 0x6d, 0x61, 0x78, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x17, 0x6d, 0x69, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, - 0xdf, 0x1f, 0x01, 0x52, 0x15, 0x6d, 0x61, 0x78, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5d, 0x0a, 0x03, 0x66, 0x65, - 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, - 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x03, 0x66, 0x65, 0x65, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, 0x42, - 0xe4, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x62, 0x61, 0x6e, - 0x64, 0x74, 0x73, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, - 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2f, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x42, 0x58, 0xaa, 0x02, 0x14, 0x42, - 0x61, 0x6e, 0x64, 0x2e, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2e, 0x56, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0xca, 0x02, 0x14, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x42, 0x61, 0x6e, 0x64, 0x74, - 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x42, 0x61, 0x6e, - 0x64, 0x5c, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, - 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x3a, 0x3a, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xdf, 0x1f, 0x01, 0x52, 0x15, 0x6d, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5b, 0x0a, 0x17, 0x6d, 0x61, + 0x78, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, 0x1f, 0x01, + 0x52, 0x15, 0x6d, 0x61, 0x78, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x71, 0x0a, 0x0e, 0x66, 0x65, 0x65, 0x5f, 0x70, + 0x65, 0x72, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, + 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x0c, 0x66, 0x65, + 0x65, 0x50, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, + 0x42, 0xe4, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x62, 0x61, + 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x42, 0x58, 0xaa, 0x02, 0x14, + 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2e, 0x56, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x14, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x42, 0x61, 0x6e, 0x64, + 0x74, 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x42, 0x61, + 0x6e, 0x64, 0x5c, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x16, 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1595,13 +1689,14 @@ var file_band_bandtss_v1beta1_genesis_proto_depIdxs = []int32{ 2, // 1: band.bandtss.v1beta1.GenesisState.members:type_name -> band.bandtss.v1beta1.Member 3, // 2: band.bandtss.v1beta1.GenesisState.current_group:type_name -> band.bandtss.v1beta1.CurrentGroup 4, // 3: band.bandtss.v1beta1.Params.inactive_penalty_duration:type_name -> google.protobuf.Duration - 4, // 4: band.bandtss.v1beta1.Params.max_transition_duration:type_name -> google.protobuf.Duration - 5, // 5: band.bandtss.v1beta1.Params.fee:type_name -> cosmos.base.v1beta1.Coin - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] 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 + 4, // 4: band.bandtss.v1beta1.Params.min_transition_duration:type_name -> google.protobuf.Duration + 4, // 5: band.bandtss.v1beta1.Params.max_transition_duration:type_name -> google.protobuf.Duration + 5, // 6: band.bandtss.v1beta1.Params.fee_per_signer:type_name -> cosmos.base.v1beta1.Coin + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] 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_band_bandtss_v1beta1_genesis_proto_init() } diff --git a/api/band/tss/v1beta1/originator.pulsar.go b/api/band/tss/v1beta1/originator.pulsar.go index 48c76fb76..fd1a5d74c 100644 --- a/api/band/tss/v1beta1/originator.pulsar.go +++ b/api/band/tss/v1beta1/originator.pulsar.go @@ -563,11 +563,11 @@ func (x *fastReflection_DirectOriginator) ProtoMethods() *protoiface.Methods { } var ( - md_TunnelOriginator protoreflect.MessageDescriptor - fd_TunnelOriginator_source_chain_id protoreflect.FieldDescriptor - fd_TunnelOriginator_tunnel_id protoreflect.FieldDescriptor - fd_TunnelOriginator_contract_address protoreflect.FieldDescriptor - fd_TunnelOriginator_target_chain_id protoreflect.FieldDescriptor + md_TunnelOriginator protoreflect.MessageDescriptor + fd_TunnelOriginator_source_chain_id protoreflect.FieldDescriptor + fd_TunnelOriginator_tunnel_id protoreflect.FieldDescriptor + fd_TunnelOriginator_destination_chain_id protoreflect.FieldDescriptor + fd_TunnelOriginator_destination_contract_address protoreflect.FieldDescriptor ) func init() { @@ -575,8 +575,8 @@ func init() { md_TunnelOriginator = File_band_tss_v1beta1_originator_proto.Messages().ByName("TunnelOriginator") fd_TunnelOriginator_source_chain_id = md_TunnelOriginator.Fields().ByName("source_chain_id") fd_TunnelOriginator_tunnel_id = md_TunnelOriginator.Fields().ByName("tunnel_id") - fd_TunnelOriginator_contract_address = md_TunnelOriginator.Fields().ByName("contract_address") - fd_TunnelOriginator_target_chain_id = md_TunnelOriginator.Fields().ByName("target_chain_id") + fd_TunnelOriginator_destination_chain_id = md_TunnelOriginator.Fields().ByName("destination_chain_id") + fd_TunnelOriginator_destination_contract_address = md_TunnelOriginator.Fields().ByName("destination_contract_address") } var _ protoreflect.Message = (*fastReflection_TunnelOriginator)(nil) @@ -656,15 +656,15 @@ func (x *fastReflection_TunnelOriginator) Range(f func(protoreflect.FieldDescrip return } } - if x.ContractAddress != "" { - value := protoreflect.ValueOfString(x.ContractAddress) - if !f(fd_TunnelOriginator_contract_address, value) { + if x.DestinationChainId != "" { + value := protoreflect.ValueOfString(x.DestinationChainId) + if !f(fd_TunnelOriginator_destination_chain_id, value) { return } } - if x.TargetChainId != "" { - value := protoreflect.ValueOfString(x.TargetChainId) - if !f(fd_TunnelOriginator_target_chain_id, value) { + if x.DestinationContractAddress != "" { + value := protoreflect.ValueOfString(x.DestinationContractAddress) + if !f(fd_TunnelOriginator_destination_contract_address, value) { return } } @@ -687,10 +687,10 @@ func (x *fastReflection_TunnelOriginator) Has(fd protoreflect.FieldDescriptor) b return x.SourceChainId != "" case "band.tss.v1beta1.TunnelOriginator.tunnel_id": return x.TunnelId != uint64(0) - case "band.tss.v1beta1.TunnelOriginator.contract_address": - return x.ContractAddress != "" - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": - return x.TargetChainId != "" + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": + return x.DestinationChainId != "" + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": + return x.DestinationContractAddress != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tss.v1beta1.TunnelOriginator")) @@ -711,10 +711,10 @@ func (x *fastReflection_TunnelOriginator) Clear(fd protoreflect.FieldDescriptor) x.SourceChainId = "" case "band.tss.v1beta1.TunnelOriginator.tunnel_id": x.TunnelId = uint64(0) - case "band.tss.v1beta1.TunnelOriginator.contract_address": - x.ContractAddress = "" - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": - x.TargetChainId = "" + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": + x.DestinationChainId = "" + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": + x.DestinationContractAddress = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tss.v1beta1.TunnelOriginator")) @@ -737,11 +737,11 @@ func (x *fastReflection_TunnelOriginator) Get(descriptor protoreflect.FieldDescr case "band.tss.v1beta1.TunnelOriginator.tunnel_id": value := x.TunnelId return protoreflect.ValueOfUint64(value) - case "band.tss.v1beta1.TunnelOriginator.contract_address": - value := x.ContractAddress + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": + value := x.DestinationChainId return protoreflect.ValueOfString(value) - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": - value := x.TargetChainId + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": + value := x.DestinationContractAddress return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -767,10 +767,10 @@ func (x *fastReflection_TunnelOriginator) Set(fd protoreflect.FieldDescriptor, v x.SourceChainId = value.Interface().(string) case "band.tss.v1beta1.TunnelOriginator.tunnel_id": x.TunnelId = value.Uint() - case "band.tss.v1beta1.TunnelOriginator.contract_address": - x.ContractAddress = value.Interface().(string) - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": - x.TargetChainId = value.Interface().(string) + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": + x.DestinationChainId = value.Interface().(string) + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": + x.DestinationContractAddress = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tss.v1beta1.TunnelOriginator")) @@ -795,10 +795,10 @@ func (x *fastReflection_TunnelOriginator) Mutable(fd protoreflect.FieldDescripto panic(fmt.Errorf("field source_chain_id of message band.tss.v1beta1.TunnelOriginator is not mutable")) case "band.tss.v1beta1.TunnelOriginator.tunnel_id": panic(fmt.Errorf("field tunnel_id of message band.tss.v1beta1.TunnelOriginator is not mutable")) - case "band.tss.v1beta1.TunnelOriginator.contract_address": - panic(fmt.Errorf("field contract_address of message band.tss.v1beta1.TunnelOriginator is not mutable")) - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": - panic(fmt.Errorf("field target_chain_id of message band.tss.v1beta1.TunnelOriginator is not mutable")) + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": + panic(fmt.Errorf("field destination_chain_id of message band.tss.v1beta1.TunnelOriginator is not mutable")) + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": + panic(fmt.Errorf("field destination_contract_address of message band.tss.v1beta1.TunnelOriginator is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tss.v1beta1.TunnelOriginator")) @@ -816,9 +816,9 @@ func (x *fastReflection_TunnelOriginator) NewField(fd protoreflect.FieldDescript return protoreflect.ValueOfString("") case "band.tss.v1beta1.TunnelOriginator.tunnel_id": return protoreflect.ValueOfUint64(uint64(0)) - case "band.tss.v1beta1.TunnelOriginator.contract_address": + case "band.tss.v1beta1.TunnelOriginator.destination_chain_id": return protoreflect.ValueOfString("") - case "band.tss.v1beta1.TunnelOriginator.target_chain_id": + case "band.tss.v1beta1.TunnelOriginator.destination_contract_address": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -896,11 +896,11 @@ func (x *fastReflection_TunnelOriginator) ProtoMethods() *protoiface.Methods { if x.TunnelId != 0 { n += 1 + runtime.Sov(uint64(x.TunnelId)) } - l = len(x.ContractAddress) + l = len(x.DestinationChainId) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.TargetChainId) + l = len(x.DestinationContractAddress) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -933,17 +933,17 @@ func (x *fastReflection_TunnelOriginator) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.TargetChainId) > 0 { - i -= len(x.TargetChainId) - copy(dAtA[i:], x.TargetChainId) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.TargetChainId))) + if len(x.DestinationContractAddress) > 0 { + i -= len(x.DestinationContractAddress) + copy(dAtA[i:], x.DestinationContractAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DestinationContractAddress))) i-- dAtA[i] = 0x22 } - if len(x.ContractAddress) > 0 { - i -= len(x.ContractAddress) - copy(dAtA[i:], x.ContractAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ContractAddress))) + if len(x.DestinationChainId) > 0 { + i -= len(x.DestinationChainId) + copy(dAtA[i:], x.DestinationChainId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DestinationChainId))) i-- dAtA[i] = 0x1a } @@ -1061,7 +1061,7 @@ func (x *fastReflection_TunnelOriginator) ProtoMethods() *protoiface.Methods { } case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DestinationChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1089,11 +1089,11 @@ func (x *fastReflection_TunnelOriginator) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.ContractAddress = string(dAtA[iNdEx:postIndex]) + x.DestinationChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TargetChainId", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1121,7 +1121,7 @@ func (x *fastReflection_TunnelOriginator) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.TargetChainId = string(dAtA[iNdEx:postIndex]) + x.DestinationContractAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1238,10 +1238,10 @@ type TunnelOriginator struct { SourceChainId string `protobuf:"bytes,1,opt,name=source_chain_id,json=sourceChainId,proto3" json:"source_chain_id,omitempty"` // tunnel_id is the tunnel ID that the request is originated from. TunnelId uint64 `protobuf:"varint,2,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` - // contract_address is the target address that the data should be relayed to. - ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - // target_chain_id is the target chain ID that the data should be relayed to. - TargetChainId string `protobuf:"bytes,4,opt,name=target_chain_id,json=targetChainId,proto3" json:"target_chain_id,omitempty"` + // destination_chain_id is the destination chain ID that the data should be relayed to. + DestinationChainId string `protobuf:"bytes,3,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"` + // destination_contract_address is the destination address that the data should be relayed to. + DestinationContractAddress string `protobuf:"bytes,4,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` } func (x *TunnelOriginator) Reset() { @@ -1278,16 +1278,16 @@ func (x *TunnelOriginator) GetTunnelId() uint64 { return 0 } -func (x *TunnelOriginator) GetContractAddress() string { +func (x *TunnelOriginator) GetDestinationChainId() string { if x != nil { - return x.ContractAddress + return x.DestinationChainId } return "" } -func (x *TunnelOriginator) GetTargetChainId() string { +func (x *TunnelOriginator) GetDestinationContractAddress() string { if x != nil { - return x.TargetChainId + return x.DestinationContractAddress } return "" } @@ -1310,7 +1310,7 @@ var file_band_tss_v1beta1_originator_proto_rawDesc = []byte{ 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x3a, 0x0e, 0xca, 0xb4, 0x2d, 0x0a, 0x4f, 0x72, - 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x22, 0xee, 0x01, 0x0a, 0x10, 0x54, 0x75, 0x6e, + 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x94, 0x02, 0x0a, 0x10, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x39, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x11, 0xe2, 0xde, 0x1f, 0x0d, 0x53, 0x6f, 0x75, 0x72, @@ -1318,27 +1318,30 @@ var file_band_tss_v1beta1_originator_proto_rawDesc = []byte{ 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, - 0x6c, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x39, - 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, - 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x11, 0xe2, 0xde, 0x1f, 0x0d, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x3a, 0x0e, 0xca, 0xb4, 0x2d, 0x0a, 0x4f, - 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x42, 0xcb, 0x01, 0x0a, 0x14, 0x63, 0x6f, - 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x74, 0x73, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x42, 0x0f, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, - 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, - 0x2f, 0x74, 0x73, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x73, 0x73, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, 0x02, 0x10, - 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x73, 0x73, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0xca, 0x02, 0x10, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1c, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x73, 0x73, 0x5c, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x12, 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x54, 0x73, 0x73, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x49, 0x64, 0x12, 0x48, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x16, 0xe2, 0xde, 0x1f, 0x12, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x52, 0x12, 0x64, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x40, 0x0a, + 0x1c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x1a, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, + 0x0e, 0xca, 0xb4, 0x2d, 0x0a, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x42, + 0xcb, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x74, 0x73, 0x73, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, + 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x73, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x3b, 0x74, 0x73, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, + 0x42, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x73, 0x73, 0x2e, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x10, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x73, + 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1c, 0x42, 0x61, 0x6e, 0x64, + 0x5c, 0x54, 0x73, 0x73, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x42, 0x61, 0x6e, 0x64, 0x3a, + 0x3a, 0x54, 0x73, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/band/tunnel/v1beta1/route.pulsar.go b/api/band/tunnel/v1beta1/route.pulsar.go index 71a2d5797..88b50a5d3 100644 --- a/api/band/tunnel/v1beta1/route.pulsar.go +++ b/api/band/tunnel/v1beta1/route.pulsar.go @@ -3,6 +3,7 @@ package tunnelv1beta1 import ( fmt "fmt" + v1beta1 "github.com/bandprotocol/chain/v3/api/band/feeds/v1beta1" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -499,29 +500,25 @@ func (x *fastReflection_TSSRoute) ProtoMethods() *protoiface.Methods { } var ( - md_TSSPacketContent protoreflect.MessageDescriptor - fd_TSSPacketContent_signing_id protoreflect.FieldDescriptor - fd_TSSPacketContent_destination_chain_id protoreflect.FieldDescriptor - fd_TSSPacketContent_destination_contract_address protoreflect.FieldDescriptor + md_TSSPacketReceipt protoreflect.MessageDescriptor + fd_TSSPacketReceipt_signing_id protoreflect.FieldDescriptor ) func init() { file_band_tunnel_v1beta1_route_proto_init() - md_TSSPacketContent = File_band_tunnel_v1beta1_route_proto.Messages().ByName("TSSPacketContent") - fd_TSSPacketContent_signing_id = md_TSSPacketContent.Fields().ByName("signing_id") - fd_TSSPacketContent_destination_chain_id = md_TSSPacketContent.Fields().ByName("destination_chain_id") - fd_TSSPacketContent_destination_contract_address = md_TSSPacketContent.Fields().ByName("destination_contract_address") + md_TSSPacketReceipt = File_band_tunnel_v1beta1_route_proto.Messages().ByName("TSSPacketReceipt") + fd_TSSPacketReceipt_signing_id = md_TSSPacketReceipt.Fields().ByName("signing_id") } -var _ protoreflect.Message = (*fastReflection_TSSPacketContent)(nil) +var _ protoreflect.Message = (*fastReflection_TSSPacketReceipt)(nil) -type fastReflection_TSSPacketContent TSSPacketContent +type fastReflection_TSSPacketReceipt TSSPacketReceipt -func (x *TSSPacketContent) ProtoReflect() protoreflect.Message { - return (*fastReflection_TSSPacketContent)(x) +func (x *TSSPacketReceipt) ProtoReflect() protoreflect.Message { + return (*fastReflection_TSSPacketReceipt)(x) } -func (x *TSSPacketContent) slowProtoReflect() protoreflect.Message { +func (x *TSSPacketReceipt) slowProtoReflect() protoreflect.Message { mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -533,43 +530,43 @@ func (x *TSSPacketContent) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_TSSPacketContent_messageType fastReflection_TSSPacketContent_messageType -var _ protoreflect.MessageType = fastReflection_TSSPacketContent_messageType{} +var _fastReflection_TSSPacketReceipt_messageType fastReflection_TSSPacketReceipt_messageType +var _ protoreflect.MessageType = fastReflection_TSSPacketReceipt_messageType{} -type fastReflection_TSSPacketContent_messageType struct{} +type fastReflection_TSSPacketReceipt_messageType struct{} -func (x fastReflection_TSSPacketContent_messageType) Zero() protoreflect.Message { - return (*fastReflection_TSSPacketContent)(nil) +func (x fastReflection_TSSPacketReceipt_messageType) Zero() protoreflect.Message { + return (*fastReflection_TSSPacketReceipt)(nil) } -func (x fastReflection_TSSPacketContent_messageType) New() protoreflect.Message { - return new(fastReflection_TSSPacketContent) +func (x fastReflection_TSSPacketReceipt_messageType) New() protoreflect.Message { + return new(fastReflection_TSSPacketReceipt) } -func (x fastReflection_TSSPacketContent_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_TSSPacketContent +func (x fastReflection_TSSPacketReceipt_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TSSPacketReceipt } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_TSSPacketContent) Descriptor() protoreflect.MessageDescriptor { - return md_TSSPacketContent +func (x *fastReflection_TSSPacketReceipt) Descriptor() protoreflect.MessageDescriptor { + return md_TSSPacketReceipt } // Type returns the message type, which encapsulates both Go and protobuf // type information. If the Go type information is not needed, // it is recommended that the message descriptor be used instead. -func (x *fastReflection_TSSPacketContent) Type() protoreflect.MessageType { - return _fastReflection_TSSPacketContent_messageType +func (x *fastReflection_TSSPacketReceipt) Type() protoreflect.MessageType { + return _fastReflection_TSSPacketReceipt_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_TSSPacketContent) New() protoreflect.Message { - return new(fastReflection_TSSPacketContent) +func (x *fastReflection_TSSPacketReceipt) New() protoreflect.Message { + return new(fastReflection_TSSPacketReceipt) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_TSSPacketContent) Interface() protoreflect.ProtoMessage { - return (*TSSPacketContent)(x) +func (x *fastReflection_TSSPacketReceipt) Interface() protoreflect.ProtoMessage { + return (*TSSPacketReceipt)(x) } // Range iterates over every populated field in an undefined order, @@ -577,22 +574,1313 @@ func (x *fastReflection_TSSPacketContent) Interface() protoreflect.ProtoMessage // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_TSSPacketContent) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +func (x *fastReflection_TSSPacketReceipt) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if x.SigningId != uint64(0) { value := protoreflect.ValueOfUint64(x.SigningId) - if !f(fd_TSSPacketContent_signing_id, value) { + if !f(fd_TSSPacketReceipt_signing_id, value) { return } } - if x.DestinationChainId != "" { - value := protoreflect.ValueOfString(x.DestinationChainId) - if !f(fd_TSSPacketContent_destination_chain_id, value) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TSSPacketReceipt) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + return x.SigningId != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TSSPacketReceipt) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + x.SigningId = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TSSPacketReceipt) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + value := x.SigningId + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TSSPacketReceipt) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + x.SigningId = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TSSPacketReceipt) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + panic(fmt.Errorf("field signing_id of message band.tunnel.v1beta1.TSSPacketReceipt is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TSSPacketReceipt) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.TSSPacketReceipt.signing_id": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TSSPacketReceipt) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.TSSPacketReceipt", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TSSPacketReceipt) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TSSPacketReceipt) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TSSPacketReceipt) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TSSPacketReceipt) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TSSPacketReceipt) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.SigningId != 0 { + n += 1 + runtime.Sov(uint64(x.SigningId)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TSSPacketReceipt) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.SigningId != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.SigningId)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TSSPacketReceipt) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TSSPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TSSPacketReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SigningId", wireType) + } + x.SigningId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.SigningId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_IBCRoute protoreflect.MessageDescriptor + fd_IBCRoute_channel_id protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCRoute = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCRoute") + fd_IBCRoute_channel_id = md_IBCRoute.Fields().ByName("channel_id") +} + +var _ protoreflect.Message = (*fastReflection_IBCRoute)(nil) + +type fastReflection_IBCRoute IBCRoute + +func (x *IBCRoute) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCRoute)(x) +} + +func (x *IBCRoute) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[2] + 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) +} + +var _fastReflection_IBCRoute_messageType fastReflection_IBCRoute_messageType +var _ protoreflect.MessageType = fastReflection_IBCRoute_messageType{} + +type fastReflection_IBCRoute_messageType struct{} + +func (x fastReflection_IBCRoute_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCRoute)(nil) +} +func (x fastReflection_IBCRoute_messageType) New() protoreflect.Message { + return new(fastReflection_IBCRoute) +} +func (x fastReflection_IBCRoute_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCRoute +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCRoute) Descriptor() protoreflect.MessageDescriptor { + return md_IBCRoute +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_IBCRoute) Type() protoreflect.MessageType { + return _fastReflection_IBCRoute_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCRoute) New() protoreflect.Message { + return new(fastReflection_IBCRoute) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCRoute) Interface() protoreflect.ProtoMessage { + return (*IBCRoute)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_IBCRoute) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ChannelId != "" { + value := protoreflect.ValueOfString(x.ChannelId) + if !f(fd_IBCRoute_channel_id, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_IBCRoute) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + return x.ChannelId != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + x.ChannelId = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_IBCRoute) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + value := x.ChannelId + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + x.ChannelId = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + panic(fmt.Errorf("field channel_id of message band.tunnel.v1beta1.IBCRoute is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_IBCRoute) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCRoute.channel_id": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCRoute")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCRoute does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_IBCRoute) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCRoute", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_IBCRoute) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCRoute) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_IBCRoute) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_IBCRoute) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.ChannelId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ChannelId) > 0 { + i -= len(x.ChannelId) + copy(dAtA[i:], x.ChannelId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ChannelId))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*IBCRoute) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_IBCPacketReceipt protoreflect.MessageDescriptor + fd_IBCPacketReceipt_sequence protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_IBCPacketReceipt = File_band_tunnel_v1beta1_route_proto.Messages().ByName("IBCPacketReceipt") + fd_IBCPacketReceipt_sequence = md_IBCPacketReceipt.Fields().ByName("sequence") +} + +var _ protoreflect.Message = (*fastReflection_IBCPacketReceipt)(nil) + +type fastReflection_IBCPacketReceipt IBCPacketReceipt + +func (x *IBCPacketReceipt) ProtoReflect() protoreflect.Message { + return (*fastReflection_IBCPacketReceipt)(x) +} + +func (x *IBCPacketReceipt) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[3] + 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) +} + +var _fastReflection_IBCPacketReceipt_messageType fastReflection_IBCPacketReceipt_messageType +var _ protoreflect.MessageType = fastReflection_IBCPacketReceipt_messageType{} + +type fastReflection_IBCPacketReceipt_messageType struct{} + +func (x fastReflection_IBCPacketReceipt_messageType) Zero() protoreflect.Message { + return (*fastReflection_IBCPacketReceipt)(nil) +} +func (x fastReflection_IBCPacketReceipt_messageType) New() protoreflect.Message { + return new(fastReflection_IBCPacketReceipt) +} +func (x fastReflection_IBCPacketReceipt_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IBCPacketReceipt +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IBCPacketReceipt) Descriptor() protoreflect.MessageDescriptor { + return md_IBCPacketReceipt +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_IBCPacketReceipt) Type() protoreflect.MessageType { + return _fastReflection_IBCPacketReceipt_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IBCPacketReceipt) New() protoreflect.Message { + return new(fastReflection_IBCPacketReceipt) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IBCPacketReceipt) Interface() protoreflect.ProtoMessage { + return (*IBCPacketReceipt)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_IBCPacketReceipt) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_IBCPacketReceipt_sequence, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_IBCPacketReceipt) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + return x.Sequence != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + x.Sequence = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_IBCPacketReceipt) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + x.Sequence = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.IBCPacketReceipt is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_IBCPacketReceipt) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "band.tunnel.v1beta1.IBCPacketReceipt.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.IBCPacketReceipt")) + } + panic(fmt.Errorf("message band.tunnel.v1beta1.IBCPacketReceipt does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_IBCPacketReceipt) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.IBCPacketReceipt", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_IBCPacketReceipt) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_IBCPacketReceipt) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_IBCPacketReceipt) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_IBCPacketReceipt) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*IBCPacketReceipt) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IBCPacketReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + x.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_TunnelPricesPacketData_3_list)(nil) + +type _TunnelPricesPacketData_3_list struct { + list *[]*v1beta1.Price +} + +func (x *_TunnelPricesPacketData_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_TunnelPricesPacketData_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Price) + (*x.list)[i] = concreteValue +} + +func (x *_TunnelPricesPacketData_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Price) + *x.list = append(*x.list, concreteValue) +} + +func (x *_TunnelPricesPacketData_3_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Price) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_TunnelPricesPacketData_3_list) NewElement() protoreflect.Value { + v := new(v1beta1.Price) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelPricesPacketData_3_list) IsValid() bool { + return x.list != nil +} + +var ( + md_TunnelPricesPacketData protoreflect.MessageDescriptor + fd_TunnelPricesPacketData_tunnel_id protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_sequence protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_prices protoreflect.FieldDescriptor + fd_TunnelPricesPacketData_created_at protoreflect.FieldDescriptor +) + +func init() { + file_band_tunnel_v1beta1_route_proto_init() + md_TunnelPricesPacketData = File_band_tunnel_v1beta1_route_proto.Messages().ByName("TunnelPricesPacketData") + fd_TunnelPricesPacketData_tunnel_id = md_TunnelPricesPacketData.Fields().ByName("tunnel_id") + fd_TunnelPricesPacketData_sequence = md_TunnelPricesPacketData.Fields().ByName("sequence") + fd_TunnelPricesPacketData_prices = md_TunnelPricesPacketData.Fields().ByName("prices") + fd_TunnelPricesPacketData_created_at = md_TunnelPricesPacketData.Fields().ByName("created_at") +} + +var _ protoreflect.Message = (*fastReflection_TunnelPricesPacketData)(nil) + +type fastReflection_TunnelPricesPacketData TunnelPricesPacketData + +func (x *TunnelPricesPacketData) ProtoReflect() protoreflect.Message { + return (*fastReflection_TunnelPricesPacketData)(x) +} + +func (x *TunnelPricesPacketData) slowProtoReflect() protoreflect.Message { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[4] + 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) +} + +var _fastReflection_TunnelPricesPacketData_messageType fastReflection_TunnelPricesPacketData_messageType +var _ protoreflect.MessageType = fastReflection_TunnelPricesPacketData_messageType{} + +type fastReflection_TunnelPricesPacketData_messageType struct{} + +func (x fastReflection_TunnelPricesPacketData_messageType) Zero() protoreflect.Message { + return (*fastReflection_TunnelPricesPacketData)(nil) +} +func (x fastReflection_TunnelPricesPacketData_messageType) New() protoreflect.Message { + return new(fastReflection_TunnelPricesPacketData) +} +func (x fastReflection_TunnelPricesPacketData_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TunnelPricesPacketData +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TunnelPricesPacketData) Descriptor() protoreflect.MessageDescriptor { + return md_TunnelPricesPacketData +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TunnelPricesPacketData) Type() protoreflect.MessageType { + return _fastReflection_TunnelPricesPacketData_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TunnelPricesPacketData) New() protoreflect.Message { + return new(fastReflection_TunnelPricesPacketData) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TunnelPricesPacketData) Interface() protoreflect.ProtoMessage { + return (*TunnelPricesPacketData)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TunnelPricesPacketData) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.TunnelId != uint64(0) { + value := protoreflect.ValueOfUint64(x.TunnelId) + if !f(fd_TunnelPricesPacketData_tunnel_id, value) { return } } - if x.DestinationContractAddress != "" { - value := protoreflect.ValueOfString(x.DestinationContractAddress) - if !f(fd_TSSPacketContent_destination_contract_address, value) { + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_TunnelPricesPacketData_sequence, value) { + return + } + } + if len(x.Prices) != 0 { + value := protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{list: &x.Prices}) + if !f(fd_TunnelPricesPacketData_prices, value) { + return + } + } + if x.CreatedAt != int64(0) { + value := protoreflect.ValueOfInt64(x.CreatedAt) + if !f(fd_TunnelPricesPacketData_created_at, value) { return } } @@ -609,19 +1897,21 @@ func (x *fastReflection_TSSPacketContent) Range(f func(protoreflect.FieldDescrip // In other cases (aside from the nullable cases above), // a proto3 scalar field is populated if it contains a non-zero value, and // a repeated field is populated if it is non-empty. -func (x *fastReflection_TSSPacketContent) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_TunnelPricesPacketData) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": - return x.SigningId != uint64(0) - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - return x.DestinationChainId != "" - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - return x.DestinationContractAddress != "" + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + return x.TunnelId != uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + return x.Sequence != uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + return len(x.Prices) != 0 + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + return x.CreatedAt != int64(0) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) } } @@ -631,19 +1921,21 @@ func (x *fastReflection_TSSPacketContent) Has(fd protoreflect.FieldDescriptor) b // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_TSSPacketContent) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_TunnelPricesPacketData) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": - x.SigningId = uint64(0) - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - x.DestinationChainId = "" - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - x.DestinationContractAddress = "" + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + x.TunnelId = uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + x.Sequence = uint64(0) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + x.Prices = nil + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + x.CreatedAt = int64(0) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) } } @@ -653,22 +1945,28 @@ func (x *fastReflection_TSSPacketContent) Clear(fd protoreflect.FieldDescriptor) // the default value of a bytes scalar is guaranteed to be a copy. // For unpopulated composite types, it returns an empty, read-only view // of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_TSSPacketContent) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_TunnelPricesPacketData) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": - value := x.SigningId + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + value := x.TunnelId return protoreflect.ValueOfUint64(value) - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - value := x.DestinationChainId - return protoreflect.ValueOfString(value) - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - value := x.DestinationContractAddress - return protoreflect.ValueOfString(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + if len(x.Prices) == 0 { + return protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{}) + } + listValue := &_TunnelPricesPacketData_3_list{list: &x.Prices} + return protoreflect.ValueOfList(listValue) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + value := x.CreatedAt + return protoreflect.ValueOfInt64(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", descriptor.FullName())) } } @@ -682,19 +1980,23 @@ func (x *fastReflection_TSSPacketContent) Get(descriptor protoreflect.FieldDescr // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_TSSPacketContent) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_TunnelPricesPacketData) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": - x.SigningId = value.Uint() - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - x.DestinationChainId = value.Interface().(string) - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - x.DestinationContractAddress = value.Interface().(string) + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + x.TunnelId = value.Uint() + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + x.Sequence = value.Uint() + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + lv := value.List() + clv := lv.(*_TunnelPricesPacketData_3_list) + x.Prices = *clv.list + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + x.CreatedAt = value.Int() default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) } } @@ -708,48 +2010,57 @@ func (x *fastReflection_TSSPacketContent) Set(fd protoreflect.FieldDescriptor, v // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_TSSPacketContent) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_TunnelPricesPacketData) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": - panic(fmt.Errorf("field signing_id of message band.tunnel.v1beta1.TSSPacketContent is not mutable")) - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - panic(fmt.Errorf("field destination_chain_id of message band.tunnel.v1beta1.TSSPacketContent is not mutable")) - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - panic(fmt.Errorf("field destination_contract_address of message band.tunnel.v1beta1.TSSPacketContent is not mutable")) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + if x.Prices == nil { + x.Prices = []*v1beta1.Price{} + } + value := &_TunnelPricesPacketData_3_list{list: &x.Prices} + return protoreflect.ValueOfList(value) + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": + panic(fmt.Errorf("field tunnel_id of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + panic(fmt.Errorf("field created_at of message band.tunnel.v1beta1.TunnelPricesPacketData is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) } } // NewField returns a new value that is assignable to the field // for the given descriptor. For scalars, this returns the default value. // For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_TSSPacketContent) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_TunnelPricesPacketData) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TSSPacketContent.signing_id": + case "band.tunnel.v1beta1.TunnelPricesPacketData.tunnel_id": return protoreflect.ValueOfUint64(uint64(0)) - case "band.tunnel.v1beta1.TSSPacketContent.destination_chain_id": - return protoreflect.ValueOfString("") - case "band.tunnel.v1beta1.TSSPacketContent.destination_contract_address": - return protoreflect.ValueOfString("") + case "band.tunnel.v1beta1.TunnelPricesPacketData.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + case "band.tunnel.v1beta1.TunnelPricesPacketData.prices": + list := []*v1beta1.Price{} + return protoreflect.ValueOfList(&_TunnelPricesPacketData_3_list{list: &list}) + case "band.tunnel.v1beta1.TunnelPricesPacketData.created_at": + return protoreflect.ValueOfInt64(int64(0)) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TSSPacketContent")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelPricesPacketData")) } - panic(fmt.Errorf("message band.tunnel.v1beta1.TSSPacketContent does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message band.tunnel.v1beta1.TunnelPricesPacketData does not contain field %s", fd.FullName())) } } // WhichOneof reports which field within the oneof is populated, // returning nil if none are populated. // It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_TSSPacketContent) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_TunnelPricesPacketData) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.TSSPacketContent", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in band.tunnel.v1beta1.TunnelPricesPacketData", d.FullName())) } panic("unreachable") } @@ -757,7 +2068,7 @@ func (x *fastReflection_TSSPacketContent) WhichOneof(d protoreflect.OneofDescrip // GetUnknown retrieves the entire list of unknown fields. // The caller may only mutate the contents of the RawFields // if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_TSSPacketContent) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_TunnelPricesPacketData) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -768,7 +2079,7 @@ func (x *fastReflection_TSSPacketContent) GetUnknown() protoreflect.RawFields { // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_TSSPacketContent) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_TunnelPricesPacketData) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -780,7 +2091,7 @@ func (x *fastReflection_TSSPacketContent) SetUnknown(fields protoreflect.RawFiel // message type, but the details are implementation dependent. // Validity is not part of the protobuf data model, and may not // be preserved in marshaling or other operations. -func (x *fastReflection_TSSPacketContent) IsValid() bool { +func (x *fastReflection_TunnelPricesPacketData) IsValid() bool { return x != nil } @@ -790,9 +2101,9 @@ func (x *fastReflection_TSSPacketContent) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_TunnelPricesPacketData) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*TSSPacketContent) + x := input.Message.Interface().(*TunnelPricesPacketData) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -804,16 +2115,20 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if x.SigningId != 0 { - n += 1 + runtime.Sov(uint64(x.SigningId)) + if x.TunnelId != 0 { + n += 1 + runtime.Sov(uint64(x.TunnelId)) } - l = len(x.DestinationChainId) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) } - l = len(x.DestinationContractAddress) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) + if len(x.Prices) > 0 { + for _, e := range x.Prices { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.CreatedAt != 0 { + n += 1 + runtime.Sov(uint64(x.CreatedAt)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -825,7 +2140,7 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*TSSPacketContent) + x := input.Message.Interface().(*TunnelPricesPacketData) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -844,22 +2159,34 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.DestinationContractAddress) > 0 { - i -= len(x.DestinationContractAddress) - copy(dAtA[i:], x.DestinationContractAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DestinationContractAddress))) + if x.CreatedAt != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CreatedAt)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x20 } - if len(x.DestinationChainId) > 0 { - i -= len(x.DestinationChainId) - copy(dAtA[i:], x.DestinationChainId) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DestinationChainId))) + if len(x.Prices) > 0 { + for iNdEx := len(x.Prices) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Prices[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } - if x.SigningId != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.SigningId)) + if x.TunnelId != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.TunnelId)) i-- dAtA[i] = 0x8 } @@ -874,7 +2201,7 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*TSSPacketContent) + x := input.Message.Interface().(*TunnelPricesPacketData) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -906,17 +2233,17 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TSSPacketContent: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TunnelPricesPacketData: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TSSPacketContent: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TunnelPricesPacketData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SigningId", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TunnelId", wireType) } - x.SigningId = 0 + x.TunnelId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -926,16 +2253,16 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - x.SigningId |= uint64(b&0x7F) << shift + x.TunnelId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DestinationChainId", wireType) + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - var stringLen uint64 + x.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -945,29 +2272,16 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + x.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.DestinationChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -977,24 +2291,45 @@ func (x *fastReflection_TSSPacketContent) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.DestinationContractAddress = string(dAtA[iNdEx:postIndex]) + x.Prices = append(x.Prices, &v1beta1.Price{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Prices[len(x.Prices)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } iNdEx = postIndex + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + x.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1043,7 +2378,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// TSSRoute is the type for a TSS route +// TSSRoute represents a route for TSS packets and implements the RouteI interface. type TSSRoute struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1089,22 +2424,18 @@ func (x *TSSRoute) GetDestinationContractAddress() string { return "" } -// TSSPacketContent is the packet content for TSS -type TSSPacketContent struct { +// TSSPacketReceipt represents a receipt for a TSS packet and implements the PacketReceiptI interface. +type TSSPacketReceipt struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // signing_id is the signing ID SigningId uint64 `protobuf:"varint,1,opt,name=signing_id,json=signingId,proto3" json:"signing_id,omitempty"` - // destination_chain_id is the destination chain ID - DestinationChainId string `protobuf:"bytes,2,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"` - // destination_contract_address is the destination contract address - DestinationContractAddress string `protobuf:"bytes,3,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` } -func (x *TSSPacketContent) Reset() { - *x = TSSPacketContent{} +func (x *TSSPacketReceipt) Reset() { + *x = TSSPacketReceipt{} if protoimpl.UnsafeEnabled { mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1112,36 +2443,160 @@ func (x *TSSPacketContent) Reset() { } } -func (x *TSSPacketContent) String() string { +func (x *TSSPacketReceipt) String() string { return protoimpl.X.MessageStringOf(x) } -func (*TSSPacketContent) ProtoMessage() {} +func (*TSSPacketReceipt) ProtoMessage() {} -// Deprecated: Use TSSPacketContent.ProtoReflect.Descriptor instead. -func (*TSSPacketContent) Descriptor() ([]byte, []int) { +// Deprecated: Use TSSPacketReceipt.ProtoReflect.Descriptor instead. +func (*TSSPacketReceipt) Descriptor() ([]byte, []int) { return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{1} } -func (x *TSSPacketContent) GetSigningId() uint64 { +func (x *TSSPacketReceipt) GetSigningId() uint64 { if x != nil { return x.SigningId } return 0 } -func (x *TSSPacketContent) GetDestinationChainId() string { +// IBCRoute is the type for an IBC route +type IBCRoute struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // channel_id is the IBC channel ID + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (x *IBCRoute) Reset() { + *x = IBCRoute{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCRoute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCRoute) ProtoMessage() {} + +// Deprecated: Use IBCRoute.ProtoReflect.Descriptor instead. +func (*IBCRoute) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{2} +} + +func (x *IBCRoute) GetChannelId() string { if x != nil { - return x.DestinationChainId + return x.ChannelId } return "" } -func (x *TSSPacketContent) GetDestinationContractAddress() string { +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +type IBCPacketReceipt struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // sequence is representing the sequence of the IBC packet. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (x *IBCPacketReceipt) Reset() { + *x = IBCPacketReceipt{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IBCPacketReceipt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IBCPacketReceipt) ProtoMessage() {} + +// Deprecated: Use IBCPacketReceipt.ProtoReflect.Descriptor instead. +func (*IBCPacketReceipt) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{3} +} + +func (x *IBCPacketReceipt) GetSequence() uint64 { if x != nil { - return x.DestinationContractAddress + return x.Sequence } - return "" + return 0 +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +type TunnelPricesPacketData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // tunnel_id is the tunnel ID + TunnelId uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` + // sequence is representing the sequence of the tunnel packet. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []*v1beta1.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices,omitempty"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (x *TunnelPricesPacketData) Reset() { + *x = TunnelPricesPacketData{} + if protoimpl.UnsafeEnabled { + mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TunnelPricesPacketData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TunnelPricesPacketData) ProtoMessage() {} + +// Deprecated: Use TunnelPricesPacketData.ProtoReflect.Descriptor instead. +func (*TunnelPricesPacketData) Descriptor() ([]byte, []int) { + return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{4} +} + +func (x *TunnelPricesPacketData) GetTunnelId() uint64 { + if x != nil { + return x.TunnelId + } + return 0 +} + +func (x *TunnelPricesPacketData) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *TunnelPricesPacketData) GetPrices() []*v1beta1.Price { + if x != nil { + return x.Prices + } + return nil +} + +func (x *TunnelPricesPacketData) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 } var File_band_tunnel_v1beta1_route_proto protoreflect.FileDescriptor @@ -1153,7 +2608,9 @@ var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, - 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x01, 0x0a, 0x08, 0x54, 0x53, 0x53, 0x52, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x66, 0x65, + 0x65, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x66, 0x65, 0x65, 0x64, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x01, 0x0a, 0x08, 0x54, 0x53, 0x53, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x48, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x16, 0xe2, 0xde, 0x1f, 0x12, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, @@ -1163,40 +2620,51 @@ var file_band_tunnel_v1beta1_route_proto_rawDesc = []byte{ 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x3a, 0x0a, 0xca, 0xb4, 0x2d, 0x06, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x49, 0x22, 0x9e, 0x02, 0x0a, - 0x10, 0x54, 0x53, 0x53, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x3a, 0x0a, 0xca, 0xb4, 0x2d, 0x06, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x49, 0x22, 0x92, 0x01, 0x0a, + 0x10, 0x54, 0x53, 0x53, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12, 0x6a, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4b, 0xe2, 0xde, 0x1f, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x44, 0xfa, 0xde, 0x1f, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x78, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x74, 0x73, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, - 0x49, 0x44, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x48, 0x0a, - 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x16, 0xe2, 0xde, 0x1f, - 0x12, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, - 0x6e, 0x49, 0x44, 0x52, 0x12, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x1c, 0x64, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x64, - 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, - 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, - 0x61, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x42, 0xdf, 0x01, - 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, - 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x52, 0x6f, 0x75, 0x74, 0x65, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, - 0x6e, 0x64, 0x2f, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x3b, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, - 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x75, 0x6e, - 0x6e, 0x65, 0x6c, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x42, 0x61, - 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0xe2, 0x02, 0x1f, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x54, 0x75, 0x6e, 0x6e, - 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x44, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x3a, 0x12, 0xca, + 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, + 0x49, 0x22, 0x43, 0x0a, 0x08, 0x49, 0x42, 0x43, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x2c, 0x0a, + 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x0d, 0xe2, 0xde, 0x1f, 0x09, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, + 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x3a, 0x09, 0xca, 0xb4, 0x2d, + 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x22, 0x42, 0x0a, 0x10, 0x49, 0x42, 0x43, 0x50, 0x61, 0x63, + 0x6b, 0x65, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, + 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, + 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x22, 0xb7, 0x01, 0x0a, 0x16, 0x54, + 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, + 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, + 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, + 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, + 0x61, 0x6e, 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, + 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x42, 0xdf, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x6e, + 0x64, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x42, 0x0a, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x76, 0x33, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x42, + 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xca, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x42, 0x61, 0x6e, 0x64, 0x5c, + 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x42, 0x61, 0x6e, + 0x64, 0x3a, 0x3a, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1211,17 +2679,22 @@ func file_band_tunnel_v1beta1_route_proto_rawDescGZIP() []byte { return file_band_tunnel_v1beta1_route_proto_rawDescData } -var file_band_tunnel_v1beta1_route_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_band_tunnel_v1beta1_route_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_band_tunnel_v1beta1_route_proto_goTypes = []interface{}{ - (*TSSRoute)(nil), // 0: band.tunnel.v1beta1.TSSRoute - (*TSSPacketContent)(nil), // 1: band.tunnel.v1beta1.TSSPacketContent + (*TSSRoute)(nil), // 0: band.tunnel.v1beta1.TSSRoute + (*TSSPacketReceipt)(nil), // 1: band.tunnel.v1beta1.TSSPacketReceipt + (*IBCRoute)(nil), // 2: band.tunnel.v1beta1.IBCRoute + (*IBCPacketReceipt)(nil), // 3: band.tunnel.v1beta1.IBCPacketReceipt + (*TunnelPricesPacketData)(nil), // 4: band.tunnel.v1beta1.TunnelPricesPacketData + (*v1beta1.Price)(nil), // 5: band.feeds.v1beta1.Price } var file_band_tunnel_v1beta1_route_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 5, // 0: band.tunnel.v1beta1.TunnelPricesPacketData.prices:type_name -> band.feeds.v1beta1.Price + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_band_tunnel_v1beta1_route_proto_init() } @@ -1243,7 +2716,43 @@ func file_band_tunnel_v1beta1_route_proto_init() { } } file_band_tunnel_v1beta1_route_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TSSPacketContent); i { + switch v := v.(*TSSPacketReceipt); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_band_tunnel_v1beta1_route_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCRoute); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_band_tunnel_v1beta1_route_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IBCPacketReceipt); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_band_tunnel_v1beta1_route_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TunnelPricesPacketData); i { case 0: return &v.state case 1: @@ -1261,7 +2770,7 @@ func file_band_tunnel_v1beta1_route_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_band_tunnel_v1beta1_route_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/api/band/tunnel/v1beta1/tunnel.pulsar.go b/api/band/tunnel/v1beta1/tunnel.pulsar.go index 82a0cfcd8..f64c2e1b5 100644 --- a/api/band/tunnel/v1beta1/tunnel.pulsar.go +++ b/api/band/tunnel/v1beta1/tunnel.pulsar.go @@ -1793,14 +1793,14 @@ func (x *_TotalFees_1_list) IsValid() bool { } var ( - md_TotalFees protoreflect.MessageDescriptor - fd_TotalFees_total_packet_fee protoreflect.FieldDescriptor + md_TotalFees protoreflect.MessageDescriptor + fd_TotalFees_total_base_packet_fee protoreflect.FieldDescriptor ) func init() { file_band_tunnel_v1beta1_tunnel_proto_init() md_TotalFees = File_band_tunnel_v1beta1_tunnel_proto.Messages().ByName("TotalFees") - fd_TotalFees_total_packet_fee = md_TotalFees.Fields().ByName("total_packet_fee") + fd_TotalFees_total_base_packet_fee = md_TotalFees.Fields().ByName("total_base_packet_fee") } var _ protoreflect.Message = (*fastReflection_TotalFees)(nil) @@ -1868,9 +1868,9 @@ func (x *fastReflection_TotalFees) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_TotalFees) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.TotalPacketFee) != 0 { - value := protoreflect.ValueOfList(&_TotalFees_1_list{list: &x.TotalPacketFee}) - if !f(fd_TotalFees_total_packet_fee, value) { + if len(x.TotalBasePacketFee) != 0 { + value := protoreflect.ValueOfList(&_TotalFees_1_list{list: &x.TotalBasePacketFee}) + if !f(fd_TotalFees_total_base_packet_fee, value) { return } } @@ -1889,8 +1889,8 @@ func (x *fastReflection_TotalFees) Range(f func(protoreflect.FieldDescriptor, pr // a repeated field is populated if it is non-empty. func (x *fastReflection_TotalFees) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": - return len(x.TotalPacketFee) != 0 + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": + return len(x.TotalBasePacketFee) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TotalFees")) @@ -1907,8 +1907,8 @@ func (x *fastReflection_TotalFees) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TotalFees) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": - x.TotalPacketFee = nil + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": + x.TotalBasePacketFee = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TotalFees")) @@ -1925,11 +1925,11 @@ func (x *fastReflection_TotalFees) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_TotalFees) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": - if len(x.TotalPacketFee) == 0 { + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": + if len(x.TotalBasePacketFee) == 0 { return protoreflect.ValueOfList(&_TotalFees_1_list{}) } - listValue := &_TotalFees_1_list{list: &x.TotalPacketFee} + listValue := &_TotalFees_1_list{list: &x.TotalBasePacketFee} return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { @@ -1951,10 +1951,10 @@ func (x *fastReflection_TotalFees) Get(descriptor protoreflect.FieldDescriptor) // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TotalFees) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": lv := value.List() clv := lv.(*_TotalFees_1_list) - x.TotalPacketFee = *clv.list + x.TotalBasePacketFee = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TotalFees")) @@ -1975,11 +1975,11 @@ func (x *fastReflection_TotalFees) Set(fd protoreflect.FieldDescriptor, value pr // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TotalFees) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": - if x.TotalPacketFee == nil { - x.TotalPacketFee = []*v1beta1.Coin{} + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": + if x.TotalBasePacketFee == nil { + x.TotalBasePacketFee = []*v1beta1.Coin{} } - value := &_TotalFees_1_list{list: &x.TotalPacketFee} + value := &_TotalFees_1_list{list: &x.TotalBasePacketFee} return protoreflect.ValueOfList(value) default: if fd.IsExtension() { @@ -1994,7 +1994,7 @@ func (x *fastReflection_TotalFees) Mutable(fd protoreflect.FieldDescriptor) prot // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_TotalFees) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TotalFees.total_packet_fee": + case "band.tunnel.v1beta1.TotalFees.total_base_packet_fee": list := []*v1beta1.Coin{} return protoreflect.ValueOfList(&_TotalFees_1_list{list: &list}) default: @@ -2066,8 +2066,8 @@ func (x *fastReflection_TotalFees) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if len(x.TotalPacketFee) > 0 { - for _, e := range x.TotalPacketFee { + if len(x.TotalBasePacketFee) > 0 { + for _, e := range x.TotalBasePacketFee { l = options.Size(e) n += 1 + l + runtime.Sov(uint64(l)) } @@ -2101,9 +2101,9 @@ func (x *fastReflection_TotalFees) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.TotalPacketFee) > 0 { - for iNdEx := len(x.TotalPacketFee) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.TotalPacketFee[iNdEx]) + if len(x.TotalBasePacketFee) > 0 { + for iNdEx := len(x.TotalBasePacketFee) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.TotalBasePacketFee[iNdEx]) if err != nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2168,7 +2168,7 @@ func (x *fastReflection_TotalFees) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TotalPacketFee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TotalBasePacketFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2195,8 +2195,8 @@ func (x *fastReflection_TotalFees) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.TotalPacketFee = append(x.TotalPacketFee, &v1beta1.Coin{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.TotalPacketFee[len(x.TotalPacketFee)-1]); err != nil { + x.TotalBasePacketFee = append(x.TotalBasePacketFee, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.TotalBasePacketFee[len(x.TotalBasePacketFee)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex @@ -2389,14 +2389,14 @@ func (x *_Packet_6_list) IsValid() bool { } var ( - md_Packet protoreflect.MessageDescriptor - fd_Packet_tunnel_id protoreflect.FieldDescriptor - fd_Packet_sequence protoreflect.FieldDescriptor - fd_Packet_prices protoreflect.FieldDescriptor - fd_Packet_packet_content protoreflect.FieldDescriptor - fd_Packet_base_fee protoreflect.FieldDescriptor - fd_Packet_route_fee protoreflect.FieldDescriptor - fd_Packet_created_at protoreflect.FieldDescriptor + md_Packet protoreflect.MessageDescriptor + fd_Packet_tunnel_id protoreflect.FieldDescriptor + fd_Packet_sequence protoreflect.FieldDescriptor + fd_Packet_prices protoreflect.FieldDescriptor + fd_Packet_receipt protoreflect.FieldDescriptor + fd_Packet_base_fee protoreflect.FieldDescriptor + fd_Packet_route_fee protoreflect.FieldDescriptor + fd_Packet_created_at protoreflect.FieldDescriptor ) func init() { @@ -2405,7 +2405,7 @@ func init() { fd_Packet_tunnel_id = md_Packet.Fields().ByName("tunnel_id") fd_Packet_sequence = md_Packet.Fields().ByName("sequence") fd_Packet_prices = md_Packet.Fields().ByName("prices") - fd_Packet_packet_content = md_Packet.Fields().ByName("packet_content") + fd_Packet_receipt = md_Packet.Fields().ByName("receipt") fd_Packet_base_fee = md_Packet.Fields().ByName("base_fee") fd_Packet_route_fee = md_Packet.Fields().ByName("route_fee") fd_Packet_created_at = md_Packet.Fields().ByName("created_at") @@ -2494,9 +2494,9 @@ func (x *fastReflection_Packet) Range(f func(protoreflect.FieldDescriptor, proto return } } - if x.PacketContent != nil { - value := protoreflect.ValueOfMessage(x.PacketContent.ProtoReflect()) - if !f(fd_Packet_packet_content, value) { + if x.Receipt != nil { + value := protoreflect.ValueOfMessage(x.Receipt.ProtoReflect()) + if !f(fd_Packet_receipt, value) { return } } @@ -2539,8 +2539,8 @@ func (x *fastReflection_Packet) Has(fd protoreflect.FieldDescriptor) bool { return x.Sequence != uint64(0) case "band.tunnel.v1beta1.Packet.prices": return len(x.Prices) != 0 - case "band.tunnel.v1beta1.Packet.packet_content": - return x.PacketContent != nil + case "band.tunnel.v1beta1.Packet.receipt": + return x.Receipt != nil case "band.tunnel.v1beta1.Packet.base_fee": return len(x.BaseFee) != 0 case "band.tunnel.v1beta1.Packet.route_fee": @@ -2569,8 +2569,8 @@ func (x *fastReflection_Packet) Clear(fd protoreflect.FieldDescriptor) { x.Sequence = uint64(0) case "band.tunnel.v1beta1.Packet.prices": x.Prices = nil - case "band.tunnel.v1beta1.Packet.packet_content": - x.PacketContent = nil + case "band.tunnel.v1beta1.Packet.receipt": + x.Receipt = nil case "band.tunnel.v1beta1.Packet.base_fee": x.BaseFee = nil case "band.tunnel.v1beta1.Packet.route_fee": @@ -2605,8 +2605,8 @@ func (x *fastReflection_Packet) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Packet_3_list{list: &x.Prices} return protoreflect.ValueOfList(listValue) - case "band.tunnel.v1beta1.Packet.packet_content": - value := x.PacketContent + case "band.tunnel.v1beta1.Packet.receipt": + value := x.Receipt return protoreflect.ValueOfMessage(value.ProtoReflect()) case "band.tunnel.v1beta1.Packet.base_fee": if len(x.BaseFee) == 0 { @@ -2651,8 +2651,8 @@ func (x *fastReflection_Packet) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Packet_3_list) x.Prices = *clv.list - case "band.tunnel.v1beta1.Packet.packet_content": - x.PacketContent = value.Message().Interface().(*anypb.Any) + case "band.tunnel.v1beta1.Packet.receipt": + x.Receipt = value.Message().Interface().(*anypb.Any) case "band.tunnel.v1beta1.Packet.base_fee": lv := value.List() clv := lv.(*_Packet_5_list) @@ -2689,11 +2689,11 @@ func (x *fastReflection_Packet) Mutable(fd protoreflect.FieldDescriptor) protore } value := &_Packet_3_list{list: &x.Prices} return protoreflect.ValueOfList(value) - case "band.tunnel.v1beta1.Packet.packet_content": - if x.PacketContent == nil { - x.PacketContent = new(anypb.Any) + case "band.tunnel.v1beta1.Packet.receipt": + if x.Receipt == nil { + x.Receipt = new(anypb.Any) } - return protoreflect.ValueOfMessage(x.PacketContent.ProtoReflect()) + return protoreflect.ValueOfMessage(x.Receipt.ProtoReflect()) case "band.tunnel.v1beta1.Packet.base_fee": if x.BaseFee == nil { x.BaseFee = []*v1beta1.Coin{} @@ -2732,7 +2732,7 @@ func (x *fastReflection_Packet) NewField(fd protoreflect.FieldDescriptor) protor case "band.tunnel.v1beta1.Packet.prices": list := []*v1beta11.Price{} return protoreflect.ValueOfList(&_Packet_3_list{list: &list}) - case "band.tunnel.v1beta1.Packet.packet_content": + case "band.tunnel.v1beta1.Packet.receipt": m := new(anypb.Any) return protoreflect.ValueOfMessage(m.ProtoReflect()) case "band.tunnel.v1beta1.Packet.base_fee": @@ -2824,8 +2824,8 @@ func (x *fastReflection_Packet) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } - if x.PacketContent != nil { - l = options.Size(x.PacketContent) + if x.Receipt != nil { + l = options.Size(x.Receipt) n += 1 + l + runtime.Sov(uint64(l)) } if len(x.BaseFee) > 0 { @@ -2909,8 +2909,8 @@ func (x *fastReflection_Packet) ProtoMethods() *protoiface.Methods { dAtA[i] = 0x2a } } - if x.PacketContent != nil { - encoded, err := options.Marshal(x.PacketContent) + if x.Receipt != nil { + encoded, err := options.Marshal(x.Receipt) if err != nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -3072,7 +3072,7 @@ func (x *fastReflection_Packet) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 4: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PacketContent", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3099,10 +3099,10 @@ func (x *fastReflection_Packet) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - if x.PacketContent == nil { - x.PacketContent = &anypb.Any{} + if x.Receipt == nil { + x.Receipt = &anypb.Any{} } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.PacketContent); err != nil { + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Receipt); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex @@ -4350,17 +4350,72 @@ func (x *fastReflection_SignalDeviation) ProtoMethods() *protoiface.Methods { } } +var _ protoreflect.List = (*_TunnelSignatureOrder_2_list)(nil) + +type _TunnelSignatureOrder_2_list struct { + list *[]*v1beta11.Price +} + +func (x *_TunnelSignatureOrder_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_TunnelSignatureOrder_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_TunnelSignatureOrder_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta11.Price) + (*x.list)[i] = concreteValue +} + +func (x *_TunnelSignatureOrder_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta11.Price) + *x.list = append(*x.list, concreteValue) +} + +func (x *_TunnelSignatureOrder_2_list) AppendMutable() protoreflect.Value { + v := new(v1beta11.Price) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelSignatureOrder_2_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_TunnelSignatureOrder_2_list) NewElement() protoreflect.Value { + v := new(v1beta11.Price) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_TunnelSignatureOrder_2_list) IsValid() bool { + return x.list != nil +} + var ( - md_TunnelSignatureOrder protoreflect.MessageDescriptor - fd_TunnelSignatureOrder_tunnel_id protoreflect.FieldDescriptor - fd_TunnelSignatureOrder_sequence protoreflect.FieldDescriptor + md_TunnelSignatureOrder protoreflect.MessageDescriptor + fd_TunnelSignatureOrder_sequence protoreflect.FieldDescriptor + fd_TunnelSignatureOrder_prices protoreflect.FieldDescriptor + fd_TunnelSignatureOrder_created_at protoreflect.FieldDescriptor + fd_TunnelSignatureOrder_encoder protoreflect.FieldDescriptor ) func init() { file_band_tunnel_v1beta1_tunnel_proto_init() md_TunnelSignatureOrder = File_band_tunnel_v1beta1_tunnel_proto.Messages().ByName("TunnelSignatureOrder") - fd_TunnelSignatureOrder_tunnel_id = md_TunnelSignatureOrder.Fields().ByName("tunnel_id") fd_TunnelSignatureOrder_sequence = md_TunnelSignatureOrder.Fields().ByName("sequence") + fd_TunnelSignatureOrder_prices = md_TunnelSignatureOrder.Fields().ByName("prices") + fd_TunnelSignatureOrder_created_at = md_TunnelSignatureOrder.Fields().ByName("created_at") + fd_TunnelSignatureOrder_encoder = md_TunnelSignatureOrder.Fields().ByName("encoder") } var _ protoreflect.Message = (*fastReflection_TunnelSignatureOrder)(nil) @@ -4428,18 +4483,30 @@ func (x *fastReflection_TunnelSignatureOrder) Interface() protoreflect.ProtoMess // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_TunnelSignatureOrder) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.TunnelId != uint64(0) { - value := protoreflect.ValueOfUint64(x.TunnelId) - if !f(fd_TunnelSignatureOrder_tunnel_id, value) { - return - } - } if x.Sequence != uint64(0) { value := protoreflect.ValueOfUint64(x.Sequence) if !f(fd_TunnelSignatureOrder_sequence, value) { return } } + if len(x.Prices) != 0 { + value := protoreflect.ValueOfList(&_TunnelSignatureOrder_2_list{list: &x.Prices}) + if !f(fd_TunnelSignatureOrder_prices, value) { + return + } + } + if x.CreatedAt != int64(0) { + value := protoreflect.ValueOfInt64(x.CreatedAt) + if !f(fd_TunnelSignatureOrder_created_at, value) { + return + } + } + if x.Encoder != 0 { + value := protoreflect.ValueOfEnum((protoreflect.EnumNumber)(x.Encoder)) + if !f(fd_TunnelSignatureOrder_encoder, value) { + return + } + } } // Has reports whether a field is populated. @@ -4455,10 +4522,14 @@ func (x *fastReflection_TunnelSignatureOrder) Range(f func(protoreflect.FieldDes // a repeated field is populated if it is non-empty. func (x *fastReflection_TunnelSignatureOrder) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - return x.TunnelId != uint64(0) case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": return x.Sequence != uint64(0) + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + return len(x.Prices) != 0 + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + return x.CreatedAt != int64(0) + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + return x.Encoder != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4475,10 +4546,14 @@ func (x *fastReflection_TunnelSignatureOrder) Has(fd protoreflect.FieldDescripto // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TunnelSignatureOrder) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - x.TunnelId = uint64(0) case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": x.Sequence = uint64(0) + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + x.Prices = nil + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + x.CreatedAt = int64(0) + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + x.Encoder = 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4495,12 +4570,21 @@ func (x *fastReflection_TunnelSignatureOrder) Clear(fd protoreflect.FieldDescrip // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_TunnelSignatureOrder) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - value := x.TunnelId - return protoreflect.ValueOfUint64(value) case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": value := x.Sequence return protoreflect.ValueOfUint64(value) + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + if len(x.Prices) == 0 { + return protoreflect.ValueOfList(&_TunnelSignatureOrder_2_list{}) + } + listValue := &_TunnelSignatureOrder_2_list{list: &x.Prices} + return protoreflect.ValueOfList(listValue) + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + value := x.CreatedAt + return protoreflect.ValueOfInt64(value) + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + value := x.Encoder + return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(value)) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4521,10 +4605,16 @@ func (x *fastReflection_TunnelSignatureOrder) Get(descriptor protoreflect.FieldD // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TunnelSignatureOrder) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - x.TunnelId = value.Uint() case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": x.Sequence = value.Uint() + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + lv := value.List() + clv := lv.(*_TunnelSignatureOrder_2_list) + x.Prices = *clv.list + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + x.CreatedAt = value.Int() + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + x.Encoder = (v1beta11.Encoder)(value.Enum()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4545,10 +4635,18 @@ func (x *fastReflection_TunnelSignatureOrder) Set(fd protoreflect.FieldDescripto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_TunnelSignatureOrder) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - panic(fmt.Errorf("field tunnel_id of message band.tunnel.v1beta1.TunnelSignatureOrder is not mutable")) + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + if x.Prices == nil { + x.Prices = []*v1beta11.Price{} + } + value := &_TunnelSignatureOrder_2_list{list: &x.Prices} + return protoreflect.ValueOfList(value) case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": panic(fmt.Errorf("field sequence of message band.tunnel.v1beta1.TunnelSignatureOrder is not mutable")) + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + panic(fmt.Errorf("field created_at of message band.tunnel.v1beta1.TunnelSignatureOrder is not mutable")) + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + panic(fmt.Errorf("field encoder of message band.tunnel.v1beta1.TunnelSignatureOrder is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4562,10 +4660,15 @@ func (x *fastReflection_TunnelSignatureOrder) Mutable(fd protoreflect.FieldDescr // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_TunnelSignatureOrder) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "band.tunnel.v1beta1.TunnelSignatureOrder.tunnel_id": - return protoreflect.ValueOfUint64(uint64(0)) case "band.tunnel.v1beta1.TunnelSignatureOrder.sequence": return protoreflect.ValueOfUint64(uint64(0)) + case "band.tunnel.v1beta1.TunnelSignatureOrder.prices": + list := []*v1beta11.Price{} + return protoreflect.ValueOfList(&_TunnelSignatureOrder_2_list{list: &list}) + case "band.tunnel.v1beta1.TunnelSignatureOrder.created_at": + return protoreflect.ValueOfInt64(int64(0)) + case "band.tunnel.v1beta1.TunnelSignatureOrder.encoder": + return protoreflect.ValueOfEnum(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: band.tunnel.v1beta1.TunnelSignatureOrder")) @@ -4635,12 +4738,21 @@ func (x *fastReflection_TunnelSignatureOrder) ProtoMethods() *protoiface.Methods var n int var l int _ = l - if x.TunnelId != 0 { - n += 1 + runtime.Sov(uint64(x.TunnelId)) - } if x.Sequence != 0 { n += 1 + runtime.Sov(uint64(x.Sequence)) } + if len(x.Prices) > 0 { + for _, e := range x.Prices { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.CreatedAt != 0 { + n += 1 + runtime.Sov(uint64(x.CreatedAt)) + } + if x.Encoder != 0 { + n += 1 + runtime.Sov(uint64(x.Encoder)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -4670,13 +4782,34 @@ func (x *fastReflection_TunnelSignatureOrder) ProtoMethods() *protoiface.Methods i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.Sequence != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + if x.Encoder != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Encoder)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } - if x.TunnelId != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.TunnelId)) + if x.CreatedAt != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CreatedAt)) + i-- + dAtA[i] = 0x18 + } + if len(x.Prices) > 0 { + for iNdEx := len(x.Prices) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Prices[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) i-- dAtA[i] = 0x8 } @@ -4731,9 +4864,9 @@ func (x *fastReflection_TunnelSignatureOrder) ProtoMethods() *protoiface.Methods switch fieldNum { case 1: if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TunnelId", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - x.TunnelId = 0 + x.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -4743,16 +4876,50 @@ func (x *fastReflection_TunnelSignatureOrder) ProtoMethods() *protoiface.Methods } b := dAtA[iNdEx] iNdEx++ - x.TunnelId |= uint64(b&0x7F) << shift + x.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Prices = append(x.Prices, &v1beta11.Price{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Prices[len(x.Prices)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) } - x.Sequence = 0 + x.CreatedAt = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -4762,7 +4929,26 @@ func (x *fastReflection_TunnelSignatureOrder) ProtoMethods() *protoiface.Methods } b := dAtA[iNdEx] iNdEx++ - x.Sequence |= uint64(b&0x7F) << shift + x.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Encoder", wireType) + } + x.Encoder = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Encoder |= v1beta11.Encoder(b&0x7F) << shift if b < 0x80 { break } @@ -5003,8 +5189,8 @@ type TotalFees struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // total_packet_fee is the total packet fee collected - TotalPacketFee []*v1beta1.Coin `protobuf:"bytes,1,rep,name=total_packet_fee,json=totalPacketFee,proto3" json:"total_packet_fee,omitempty"` + // total_base_packet_fee is the total base packet fee collected by the tunnel + TotalBasePacketFee []*v1beta1.Coin `protobuf:"bytes,1,rep,name=total_base_packet_fee,json=totalBasePacketFee,proto3" json:"total_base_packet_fee,omitempty"` } func (x *TotalFees) Reset() { @@ -5027,9 +5213,9 @@ func (*TotalFees) Descriptor() ([]byte, []int) { return file_band_tunnel_v1beta1_tunnel_proto_rawDescGZIP(), []int{2} } -func (x *TotalFees) GetTotalPacketFee() []*v1beta1.Coin { +func (x *TotalFees) GetTotalBasePacketFee() []*v1beta1.Coin { if x != nil { - return x.TotalPacketFee + return x.TotalBasePacketFee } return nil } @@ -5046,8 +5232,8 @@ type Packet struct { Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` // prices is the list of prices information from feeds module. Prices []*v1beta11.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices,omitempty"` - // packet_content is the content of the packet that implements PacketContentI - PacketContent *anypb.Any `protobuf:"bytes,4,opt,name=packet_content,json=packetContent,proto3" json:"packet_content,omitempty"` + // receipt represents the confirmation of the packet delivery to the destination via the specified route. + Receipt *anypb.Any `protobuf:"bytes,4,opt,name=receipt,proto3" json:"receipt,omitempty"` // base_fee is the base fee of the packet BaseFee []*v1beta1.Coin `protobuf:"bytes,5,rep,name=base_fee,json=baseFee,proto3" json:"base_fee,omitempty"` // route_fee is the route fee of the packet @@ -5097,9 +5283,9 @@ func (x *Packet) GetPrices() []*v1beta11.Price { return nil } -func (x *Packet) GetPacketContent() *anypb.Any { +func (x *Packet) GetReceipt() *anypb.Any { if x != nil { - return x.PacketContent + return x.Receipt } return nil } @@ -5241,10 +5427,14 @@ type TunnelSignatureOrder struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // tunnel_id is the ID of the tunnel - TunnelId uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` // sequence is the sequence of the packet - Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []*v1beta11.Price `protobuf:"bytes,2,rep,name=prices,proto3" json:"prices,omitempty"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + // encoder is the mode of encoding price data. + Encoder v1beta11.Encoder `protobuf:"varint,4,opt,name=encoder,proto3,enum=band.feeds.v1beta1.Encoder" json:"encoder,omitempty"` } func (x *TunnelSignatureOrder) Reset() { @@ -5267,20 +5457,34 @@ func (*TunnelSignatureOrder) Descriptor() ([]byte, []int) { return file_band_tunnel_v1beta1_tunnel_proto_rawDescGZIP(), []int{6} } -func (x *TunnelSignatureOrder) GetTunnelId() uint64 { +func (x *TunnelSignatureOrder) GetSequence() uint64 { if x != nil { - return x.TunnelId + return x.Sequence } return 0 } -func (x *TunnelSignatureOrder) GetSequence() uint64 { +func (x *TunnelSignatureOrder) GetPrices() []*v1beta11.Price { if x != nil { - return x.Sequence + return x.Prices + } + return nil +} + +func (x *TunnelSignatureOrder) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt } return 0 } +func (x *TunnelSignatureOrder) GetEncoder() v1beta11.Encoder { + if x != nil { + return x.Encoder + } + return v1beta11.Encoder(0) +} + var File_band_tunnel_v1beta1_tunnel_proto protoreflect.FileDescriptor var file_band_tunnel_v1beta1_tunnel_proto_rawDesc = []byte{ @@ -5343,93 +5547,99 @@ var file_band_tunnel_v1beta1_tunnel_proto_rawDesc = []byte{ 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0x88, 0x01, - 0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x46, 0x65, 0x65, 0x73, 0x12, 0x75, 0x0a, 0x10, 0x74, - 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x65, 0x65, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, - 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, - 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, - 0x6e, 0x73, 0x52, 0x0e, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, - 0x65, 0x65, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0xca, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x63, - 0x6b, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, - 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x1a, - 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x70, 0x72, - 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x61, 0x6e, - 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, 0x69, - 0x63, 0x65, 0x73, 0x12, 0x4f, 0x0a, 0x0e, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x49, 0x52, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x12, 0x66, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, - 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, - 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, - 0x69, 0x6e, 0x73, 0x52, 0x07, 0x62, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x12, 0x68, 0x0a, 0x09, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, - 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, - 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x08, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x46, 0x65, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x07, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, - 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x09, - 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x64, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x12, 0x68, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, - 0x35, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, - 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x04, - 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0xca, 0x01, 0x0a, 0x0f, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x44, - 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xe2, 0xde, 0x1f, - 0x08, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x61, - 0x6c, 0x49, 0x64, 0x12, 0x42, 0x0a, 0x12, 0x73, 0x6f, 0x66, 0x74, 0x5f, 0x64, 0x65, 0x76, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x70, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, - 0x14, 0xe2, 0xde, 0x1f, 0x10, 0x53, 0x6f, 0x66, 0x74, 0x44, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x42, 0x50, 0x53, 0x52, 0x10, 0x73, 0x6f, 0x66, 0x74, 0x44, 0x65, 0x76, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x70, 0x73, 0x12, 0x42, 0x0a, 0x12, 0x68, 0x61, 0x72, 0x64, 0x5f, - 0x64, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x70, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x04, 0x42, 0x14, 0xe2, 0xde, 0x1f, 0x10, 0x48, 0x61, 0x72, 0x64, 0x44, 0x65, 0x76, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x50, 0x53, 0x52, 0x10, 0x68, 0x61, 0x72, 0x64, 0x44, - 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x70, 0x73, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, - 0x01, 0x22, 0x63, 0x0a, 0x14, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x09, 0x74, 0x75, 0x6e, - 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xe2, 0xde, - 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, - 0x65, 0x6c, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, - 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xe0, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x62, - 0x61, 0x6e, 0x64, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x42, 0x0b, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, - 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x75, 0x6e, - 0x6e, 0x65, 0x6c, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x75, 0x6e, 0x6e, - 0x65, 0x6c, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, 0xaa, - 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x56, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, - 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x42, 0x61, - 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, - 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0x91, 0x01, + 0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x46, 0x65, 0x65, 0x73, 0x12, 0x7e, 0x0a, 0x15, 0x74, + 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, + 0x5f, 0x66, 0x65, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x61, + 0x73, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x65, 0x65, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, + 0x01, 0x22, 0xbd, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x09, + 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, + 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x74, + 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, + 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x07, + 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x41, 0x6e, 0x79, 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, + 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x49, 0x52, 0x07, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, + 0x12, 0x66, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, + 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, + 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, + 0x07, 0x62, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x12, 0x68, 0x0a, 0x09, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x46, + 0x65, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, + 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x07, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x29, 0x0a, + 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x44, 0x52, 0x08, + 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x09, 0x64, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, + 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x12, 0x68, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x35, 0xc8, 0xde, 0x1f, + 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, + 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, + 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, + 0x22, 0xca, 0x01, 0x0a, 0x0f, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x76, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xe2, 0xde, 0x1f, 0x08, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x49, 0x44, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, + 0x42, 0x0a, 0x12, 0x73, 0x6f, 0x66, 0x74, 0x5f, 0x64, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x62, 0x70, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x14, 0xe2, 0xde, 0x1f, + 0x10, 0x53, 0x6f, 0x66, 0x74, 0x44, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x50, + 0x53, 0x52, 0x10, 0x73, 0x6f, 0x66, 0x74, 0x44, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x42, 0x70, 0x73, 0x12, 0x42, 0x0a, 0x12, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x65, 0x76, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x70, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, + 0x14, 0xe2, 0xde, 0x1f, 0x10, 0x48, 0x61, 0x72, 0x64, 0x44, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x50, 0x53, 0x52, 0x10, 0x68, 0x61, 0x72, 0x64, 0x44, 0x65, 0x76, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x70, 0x73, 0x3a, 0x04, 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0xc7, 0x01, + 0x0a, 0x14, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, + 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x35, 0x0a, 0x07, 0x65, 0x6e, + 0x63, 0x6f, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x62, 0x61, + 0x6e, 0x64, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x52, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, + 0x72, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xe0, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, + 0x62, 0x61, 0x6e, 0x64, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x42, 0x0b, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, + 0x61, 0x6e, 0x64, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x6e, 0x64, 0x2f, 0x74, 0x75, + 0x6e, 0x6e, 0x65, 0x6c, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x75, 0x6e, + 0x6e, 0x65, 0x6c, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x54, 0x58, + 0xaa, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x42, 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, + 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x42, + 0x61, 0x6e, 0x64, 0x5c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x15, 0x42, 0x61, 0x6e, 0x64, 0x3a, 0x3a, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x3a, 0x3a, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -5464,17 +5674,19 @@ var file_band_tunnel_v1beta1_tunnel_proto_depIdxs = []int32{ 5, // 2: band.tunnel.v1beta1.Tunnel.signal_deviations:type_name -> band.tunnel.v1beta1.SignalDeviation 9, // 3: band.tunnel.v1beta1.Tunnel.total_deposit:type_name -> cosmos.base.v1beta1.Coin 10, // 4: band.tunnel.v1beta1.LatestPrices.prices:type_name -> band.feeds.v1beta1.Price - 9, // 5: band.tunnel.v1beta1.TotalFees.total_packet_fee:type_name -> cosmos.base.v1beta1.Coin + 9, // 5: band.tunnel.v1beta1.TotalFees.total_base_packet_fee:type_name -> cosmos.base.v1beta1.Coin 10, // 6: band.tunnel.v1beta1.Packet.prices:type_name -> band.feeds.v1beta1.Price - 7, // 7: band.tunnel.v1beta1.Packet.packet_content:type_name -> google.protobuf.Any + 7, // 7: band.tunnel.v1beta1.Packet.receipt:type_name -> google.protobuf.Any 9, // 8: band.tunnel.v1beta1.Packet.base_fee:type_name -> cosmos.base.v1beta1.Coin 9, // 9: band.tunnel.v1beta1.Packet.route_fee:type_name -> cosmos.base.v1beta1.Coin 9, // 10: band.tunnel.v1beta1.Deposit.amount:type_name -> cosmos.base.v1beta1.Coin - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 10, // 11: band.tunnel.v1beta1.TunnelSignatureOrder.prices:type_name -> band.feeds.v1beta1.Price + 8, // 12: band.tunnel.v1beta1.TunnelSignatureOrder.encoder:type_name -> band.feeds.v1beta1.Encoder + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_band_tunnel_v1beta1_tunnel_proto_init() } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 020c29730..f2a3e82eb 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -68,6 +68,7 @@ import ( owasm "github.com/bandprotocol/go-owasm/api" + "github.com/bandprotocol/chain/v3/x/bandtss" bandtsskeeper "github.com/bandprotocol/chain/v3/x/bandtss/keeper" bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" bandbankkeeper "github.com/bandprotocol/chain/v3/x/bank/keeper" @@ -137,6 +138,7 @@ type AppKeepers struct { ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper ScopedOracleKeeper capabilitykeeper.ScopedKeeper + ScopedTunnelKeeper capabilitykeeper.ScopedKeeper } func NewAppKeeper( @@ -197,6 +199,7 @@ func NewAppKeeper( appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) appKeepers.ScopedOracleKeeper = appKeepers.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName) + appKeepers.ScopedTunnelKeeper = appKeepers.CapabilityKeeper.ScopeToModule(tunneltypes.ModuleName) // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating // their scoped modules in `NewApp` with `ScopeToModule` @@ -498,6 +501,9 @@ func NewAppKeeper( appKeepers.BankKeeper, appKeepers.FeedsKeeper, appKeepers.BandtssKeeper, + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.PortKeeper, + appKeepers.ScopedTunnelKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -505,7 +511,7 @@ func NewAppKeeper( tssContentRouter. AddRoute(tsstypes.RouterKey, tss.NewSignatureOrderHandler(*appKeepers.TSSKeeper)). AddRoute(oracletypes.RouterKey, oracle.NewSignatureOrderHandler(appKeepers.OracleKeeper)). - AddRoute(bandtsstypes.RouterKey, bandtsstypes.NewSignatureOrderHandler()). + AddRoute(bandtsstypes.RouterKey, bandtss.NewSignatureOrderHandler()). AddRoute(feedstypes.RouterKey, feeds.NewSignatureOrderHandler(appKeepers.FeedsKeeper)). AddRoute(tunneltypes.RouterKey, tunnel.NewSignatureOrderHandler(appKeepers.TunnelKeeper)) @@ -535,9 +541,13 @@ func NewAppKeeper( // Create Oracle Stack var oracleStack porttypes.IBCModule = oracle.NewIBCModule(appKeepers.OracleKeeper) + // Create Tunnel Stack + var tunnelStack porttypes.IBCModule = tunnel.NewIBCModule(appKeepers.TunnelKeeper) + ibcRouter := porttypes.NewRouter().AddRoute(icahosttypes.SubModuleName, icaHostStack). AddRoute(ibctransfertypes.ModuleName, transferStack). - AddRoute(oracletypes.ModuleName, oracleStack) + AddRoute(oracletypes.ModuleName, oracleStack). + AddRoute(tunneltypes.ModuleName, tunnelStack) appKeepers.IBCKeeper.SetRouter(ibcRouter) diff --git a/go.mod b/go.mod index 2fd773242..d06ef32b8 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,11 @@ go 1.22.3 require ( cosmossdk.io/api v0.7.6 - cosmossdk.io/client/v2 v2.0.0-beta.5 - cosmossdk.io/collections v0.4.0 + cosmossdk.io/client/v2 v2.0.0-beta.6 cosmossdk.io/core v0.11.2 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.4.1 - cosmossdk.io/math v1.3.0 + cosmossdk.io/math v1.4.0 cosmossdk.io/store v1.1.1 cosmossdk.io/tools/confix v0.1.2 cosmossdk.io/tools/rosetta v0.2.1-0.20230613133644-0a778132a60f @@ -17,7 +16,7 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/tx v0.13.5 cosmossdk.io/x/upgrade v0.1.4 - github.com/Masterminds/semver/v3 v3.3.0 + github.com/Masterminds/semver/v3 v3.3.1 github.com/bandprotocol/bothan/bothan-api/client/go-client v0.0.1-alpha.6 github.com/bandprotocol/go-owasm v0.3.1 github.com/bytecodealliance/wasmtime-go/v20 v20.0.0 @@ -32,7 +31,7 @@ require ( github.com/cosmos/ibc-go/v8 v8.5.2 github.com/cosmos/ics23/go v0.11.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 - github.com/ethereum/go-ethereum v1.14.8 + github.com/ethereum/go-ethereum v1.14.12 github.com/golang/protobuf v1.5.4 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -60,6 +59,7 @@ require ( cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.1.9 // indirect cloud.google.com/go/storage v1.41.0 // indirect + cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/x/circuit v0.1.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -71,7 +71,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect @@ -81,7 +81,7 @@ require ( github.com/cockroachdb/errors v1.11.3 // indirect github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect diff --git a/go.sum b/go.sum index 44ab96cce..b5ed7bddd 100644 --- a/go.sum +++ b/go.sum @@ -188,8 +188,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY= cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= -cosmossdk.io/client/v2 v2.0.0-beta.5 h1:0LVv3nEByn//hFDIrYLs2WvsEU3HodOelh4SDHnA/1I= -cosmossdk.io/client/v2 v2.0.0-beta.5/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as= +cosmossdk.io/client/v2 v2.0.0-beta.6 h1:CygEwABxbwFmqgLINBb3WGVwzaN4yRgB9ZtIGQzhRNQ= +cosmossdk.io/client/v2 v2.0.0-beta.6/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.2 h1:20PXbQxhWRKA83pSYW76OXrc1MI2E93flbMAGSVFlyc= @@ -200,8 +200,8 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= -cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= -cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= +cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= +cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4= @@ -232,8 +232,8 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= -github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= @@ -280,8 +280,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= @@ -345,8 +345,8 @@ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/e github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -451,8 +451,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.14.8 h1:NgOWvXS+lauK+zFukEvi85UmmsS/OkV0N23UZ1VTIig= -github.com/ethereum/go-ethereum v1.14.8/go.mod h1:TJhyuDq0JDppAkFXgqjwpdlQApywnu/m10kFPxh8vvs= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= diff --git a/grogu/signaller/signaller.go b/grogu/signaller/signaller.go index 4a6065986..11ccb47f0 100644 --- a/grogu/signaller/signaller.go +++ b/grogu/signaller/signaller.go @@ -240,16 +240,16 @@ func (s *Signaller) filterAndPrepareSignalPrices( continue } - if !s.isPriceValid(price, currentTime) { - continue - } - signalPrice, err := convertPriceData(price) if err != nil { s.logger.Debug("[Signaller] failed to parse price data: %v", err) continue } + if !s.isPriceValid(signalPrice, currentTime) { + continue + } + if s.isNonUrgentUnavailablePrices(signalPrice, currentTime.Unix()) { s.logger.Debug("[Signaller] non-urgent unavailable price: %v", signalPrice) continue @@ -278,38 +278,34 @@ func (s *Signaller) isNonUrgentUnavailablePrices( } func (s *Signaller) isPriceValid( - price *bothan.Price, + newPrice types.SignalPrice, now time.Time, ) bool { // Check if the price is supported and required to be submitted - feed, ok := s.signalIDToFeed[price.SignalId] + feed, ok := s.signalIDToFeed[newPrice.SignalID] if !ok { return false } // Get the last price submitted by the validator, if it doesn't exist, it is valid to be sent - valPrice, ok := s.signalIDToValidatorPrice[price.SignalId] + oldPrice, ok := s.signalIDToValidatorPrice[newPrice.SignalID] if !ok { return true } // If the last price exists, check if the price can be updated - if s.shouldUpdatePrice(feed, valPrice, price.Price, now) { - return true - } - - return false + return s.shouldUpdatePrice(feed, oldPrice, newPrice, now) } func (s *Signaller) shouldUpdatePrice( feed types.FeedWithDeviation, - valPrice types.ValidatorPrice, - newPrice uint64, + oldPrice types.ValidatorPrice, + newPrice types.SignalPrice, now time.Time, ) bool { // thresholdTime is the time when the price can be updated. // add TimeBuffer to make sure the thresholdTime is not too early. - thresholdTime := time.Unix(valPrice.Timestamp+s.params.CooldownTime+TimeBuffer, 0) + thresholdTime := time.Unix(oldPrice.Timestamp+s.params.CooldownTime+TimeBuffer, 0) if now.Before(thresholdTime) { return false @@ -319,7 +315,7 @@ func (s *Signaller) shouldUpdatePrice( assignedTime := calculateAssignedTime( s.valAddress, feed.Interval, - valPrice.Timestamp, + oldPrice.Timestamp, s.distributionOffsetPercentage, s.distributionStartPercentage, ) @@ -328,10 +324,10 @@ func (s *Signaller) shouldUpdatePrice( return true } - // Check if the price is deviated from the last submission, if it is, add it to the list of prices to update - if isDeviated(feed.DeviationBasisPoint, valPrice.Price, newPrice) { + if oldPrice.SignalPriceStatus != newPrice.Status { return true } - return false + // Check if the price is deviated from the last submission, if it is, add it to the list of prices to update + return isDeviated(feed.DeviationBasisPoint, oldPrice.Price, newPrice.Price) } diff --git a/grogu/signaller/signaller_test.go b/grogu/signaller/signaller_test.go index 93b669a45..8615ba0a6 100644 --- a/grogu/signaller/signaller_test.go +++ b/grogu/signaller/signaller_test.go @@ -1,6 +1,7 @@ package signaller import ( + "sort" "sync" "testing" "time" @@ -67,6 +68,12 @@ func (s *SignallerTestSuite) SetupTest() { Interval: 60, DeviationBasisPoint: 50, }, + { + SignalID: "signal2", + Power: 60000000000, + Interval: 60, + DeviationBasisPoint: 50, + }, }, }}, nil). AnyTimes() @@ -193,9 +200,14 @@ func (s *SignallerTestSuite) TestGetNonPendingSignalIDs() { // Update internal variables s.TestUpdateInternalVariables() + expectedSignalIDs := []string{"signal1", "signal2"} + signalIDs = s.Signaller.getNonPendingSignalIDs() s.Require().NotEmpty(signalIDs) - s.Require().Equal("signal1", signalIDs[0]) + + // sort signalIDs to compare + sort.Strings(signalIDs) + s.Require().Equal(expectedSignalIDs, signalIDs) } func (s *SignallerTestSuite) TestSignalPrices() { @@ -224,25 +236,18 @@ func (s *SignallerTestSuite) TestIsPriceValid() { // Update internal variables s.TestUpdateInternalVariables() - priceData := &bothan.Price{ - SignalId: "signal1", - Price: 10000, - Status: bothan.Status_STATUS_AVAILABLE, + priceData := feeds.SignalPrice{ + Status: feeds.SIGNAL_PRICE_STATUS_AVAILABLE, + Price: 10000, } - // Test with time before the assigned time - beforeAssignedTime := time.Unix(s.assignedTime.Unix()-1, 0) - isValid := s.Signaller.isPriceValid(priceData, beforeAssignedTime) - s.Require().False(isValid) + // Test with price is not required to be submitted + priceData.SignalID = "signal3" + s.Require().False(s.Signaller.isPriceValid(priceData, s.assignedTime)) - // Test with time at the assigned time - isValid = s.Signaller.isPriceValid(priceData, s.assignedTime) - s.Require().True(isValid) - - // Test with time at the start of the interval - startOfInterval := time.Unix(0, 0) - isValid = s.Signaller.isPriceValid(priceData, startOfInterval) - s.Require().False(isValid) + // Test with price is required to be submitted and not exist yet + priceData.SignalID = "signal2" + s.Require().True(s.Signaller.isPriceValid(priceData, s.assignedTime)) } func (s *SignallerTestSuite) TestShouldUpdatePrice() { @@ -256,46 +261,44 @@ func (s *SignallerTestSuite) TestShouldUpdatePrice() { } valPrice := feeds.ValidatorPrice{ - SignalID: "signal1", - Price: 10000, - Timestamp: 0, + SignalID: "signal1", + Price: 10000, + Timestamp: 0, + SignalPriceStatus: feeds.SIGNAL_PRICE_STATUS_AVAILABLE, } - // Test with new price positive deviation - thresholdTime := time.Unix(valPrice.Timestamp+s.Signaller.params.CooldownTime+TimeBuffer, 0) - newPrice := uint64(10050) - - shouldUpdate := s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, thresholdTime) - s.Require().True(shouldUpdate) - - // Test with new price negative deviation - newPrice = uint64(9950) - - shouldUpdate = s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, thresholdTime) - s.Require().True(shouldUpdate) - - // Test with new price within deviation - newPrice = uint64(10025) + newPrice := feeds.SignalPrice{ + Price: 10000, + Status: feeds.SIGNAL_PRICE_STATUS_AVAILABLE, + } - shouldUpdate = s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, thresholdTime) - s.Require().False(shouldUpdate) + thresholdTime := time.Unix(valPrice.Timestamp+s.Signaller.params.CooldownTime+TimeBuffer, 0) - // Test with new price outside deviation - newPrice = uint64(10075) + // Test case: Time before thresholdTime, should not update + s.Require().False(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, thresholdTime.Add(-time.Second))) - shouldUpdate = s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, thresholdTime) - s.Require().True(shouldUpdate) + // Test case: Time after thresholdTime and assignedTime + assignedTime := calculateAssignedTime( + s.Signaller.valAddress, + feed.Interval, + valPrice.Timestamp, + s.Signaller.distributionOffsetPercentage, + s.Signaller.distributionStartPercentage, + ) + s.Require().True(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, assignedTime.Add(time.Second))) - // Test with time before threshold time, price outside deviation - newPrice = uint64(10075) - beforeThresholdTime := time.Unix(valPrice.Timestamp+s.Signaller.params.CooldownTime, 0) + // Test case: SignalPriceStatus changed, should update + newPrice.Status = feeds.SIGNAL_PRICE_STATUS_AVAILABLE + s.Require().False(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, assignedTime.Add(-time.Second))) - shouldUpdate = s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, beforeThresholdTime) - s.Require().False(shouldUpdate) + newPrice.Status = feeds.SIGNAL_PRICE_STATUS_UNAVAILABLE + s.Require().True(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, assignedTime.Add(-time.Second))) - // Test with time at assigned time, price within deviation - newPrice = uint64(10025) + // Test case: Price deviated + newPrice.Status = feeds.SIGNAL_PRICE_STATUS_AVAILABLE + newPrice.Price = 11000 // More than deviationBasisPoint + s.Require().True(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, assignedTime.Add(-time.Second))) - shouldUpdate = s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, s.assignedTime) - s.Require().True(shouldUpdate) + newPrice.Price = 10025 // Within deviationBasisPoint + s.Require().False(s.Signaller.shouldUpdatePrice(feed, valPrice, newPrice, assignedTime.Add(-time.Second))) } diff --git a/grogu/signaller/utils.go b/grogu/signaller/utils.go index 5bf8d1936..5506cba80 100644 --- a/grogu/signaller/utils.go +++ b/grogu/signaller/utils.go @@ -17,7 +17,7 @@ import ( // exceeds a given threshold in basis points. // Parameters: -// - deviationBasisPoint: the allowable deviation in basis points (1/1000th) +// - deviationBasisPoint: the allowable deviation in basis points (1/10000th) // - oldPrice: the original price // - newPrice: the new price to compare against the original // @@ -31,6 +31,11 @@ import ( // original price and multiplying by 10000. // 3. Check if the calculated deviation meets or exceeds the allowable deviation. func isDeviated(deviationBasisPoint int64, oldPrice uint64, newPrice uint64) bool { + // If the old price is zero and the new price is non-zero, consider it a deviation + if oldPrice == 0 { + return newPrice != 0 + } + // Calculate the deviation diff := math.Abs(float64(newPrice) - float64(oldPrice)) dev := int64((diff * 10000) / float64(oldPrice)) diff --git a/grogu/signaller/utils_test.go b/grogu/signaller/utils_test.go index fde5ee997..4deedef2b 100644 --- a/grogu/signaller/utils_test.go +++ b/grogu/signaller/utils_test.go @@ -24,6 +24,9 @@ func TestIsDeviated(t *testing.T) { {"Below threshold", 100, 1000, 1001, false}, {"Exact threshold", 100, 1000, 1010, true}, {"Above threshold", 100, 1000, 1100, true}, + {"Zero old price", 100, 0, 1000, true}, + {"Zero new price", 100, 1000, 0, true}, + {"Zero old and new price", 100, 0, 0, false}, } for _, tt := range tests { diff --git a/pkg/ctxcache/ctx_cache.go b/pkg/ctxcache/ctx_cache.go deleted file mode 100644 index f503caed6..000000000 --- a/pkg/ctxcache/ctx_cache.go +++ /dev/null @@ -1,84 +0,0 @@ -package ctxcache - -// Borrowed from Osmosis -// https://github.com/osmosis-labs/osmosis/blob/62757d309957fa9e02e6fb0b5dc8caf1ca68e696/osmoutils/cache_ctx.go -// Wraps the execution of a function with a temporary context so that state changes can be discarded if an error occurs - -import ( - "errors" - "fmt" - "runtime" - "runtime/debug" - - "cosmossdk.io/store/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// This function lets you run the function f, but if theres an error or panic -// drop the state machine change and log the error. -// If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) -// Try to avoid usage of iterators in f. -// -// If its an out of gas panic, this function will also panic like in normal tx execution flow. -// This is still safe for beginblock / endblock code though, as they do not have out of gas panics. -func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error) { - // Add a panic safeguard - defer func() { - if recoveryError := recover(); recoveryError != nil { - if isErr, _ := IsOutOfGasError(recoveryError); isErr { - // We panic with the same error, to replicate the normal tx execution flow. - panic(recoveryError) - } else { - PrintPanicRecoveryError(ctx, recoveryError) - err = errors.New("panic occurred during execution") - } - } - }() - // makes a new cache context, which all state changes get wrapped inside of. - cacheCtx, write := ctx.CacheContext() - err = f(cacheCtx) - if err != nil { - ctx.Logger().Error(err.Error()) - } else { - // no error, write the output of f - write() - } - return err -} - -// Frustratingly, this has to return the error descriptor, not an actual error itself -// because the SDK errors here are not actually errors. (They don't implement error interface) -func IsOutOfGasError(err any) (bool, string) { - switch e := err.(type) { - case types.ErrorOutOfGas: - return true, e.Descriptor - case types.ErrorGasOverflow: - return true, e.Descriptor - default: - return false, "" - } -} - -// PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. -// If not emits them to stdout. -func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { - errStackTrace := string(debug.Stack()) - switch e := recoveryError.(type) { - case types.ErrorOutOfGas: - ctx.Logger().Debug("out of gas error inside panic recovery block: " + e.Descriptor) - return - case string: - ctx.Logger().Error("Recovering from (string) panic: " + e) - case runtime.Error: - ctx.Logger().Error("recovered (runtime.Error) panic: " + e.Error()) - case error: - ctx.Logger().Error("recovered (error) panic: " + e.Error()) - default: - ctx.Logger().Error("recovered (default) panic. Could not capture logs in ctx, see stdout") - fmt.Println("Recovering from panic ", recoveryError) - debug.PrintStack() - return - } - ctx.Logger().Error("stack trace: " + errStackTrace) -} diff --git a/proto/band/bandtss/v1beta1/genesis.proto b/proto/band/bandtss/v1beta1/genesis.proto index 6fffe2f85..bab577ed7 100644 --- a/proto/band/bandtss/v1beta1/genesis.proto +++ b/proto/band/bandtss/v1beta1/genesis.proto @@ -28,10 +28,11 @@ message Params { uint64 reward_percentage = 1 [(gogoproto.customname) = "RewardPercentage"]; // inactive_penalty_duration is the duration where a member cannot activate back after being set to inactive. google.protobuf.Duration inactive_penalty_duration = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; - // max_transition_duration is the maximum duration where the transition process waits - // since the start of the process until an incoming group replaces a current group. - google.protobuf.Duration max_transition_duration = 3 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; - // fee is the tokens that will be paid per signer. - repeated cosmos.base.v1beta1.Coin fee = 4 + // min_transition_duration is the minimum duration that the transition process waits before execution. + google.protobuf.Duration min_transition_duration = 3 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + // max_transition_duration is the maximum duration that the transition process waits before execution. + google.protobuf.Duration max_transition_duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + // fee_per_signer is the tokens that will be paid per signer. + repeated cosmos.base.v1beta1.Coin fee_per_signer = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } diff --git a/proto/band/tss/v1beta1/originator.proto b/proto/band/tss/v1beta1/originator.proto index e01aa4e54..ecf0cb000 100644 --- a/proto/band/tss/v1beta1/originator.proto +++ b/proto/band/tss/v1beta1/originator.proto @@ -29,8 +29,8 @@ message TunnelOriginator { string source_chain_id = 1 [(gogoproto.customname) = "SourceChainID"]; // tunnel_id is the tunnel ID that the request is originated from. uint64 tunnel_id = 2 [(gogoproto.customname) = "TunnelID"]; - // contract_address is the target address that the data should be relayed to. - string contract_address = 3; - // target_chain_id is the target chain ID that the data should be relayed to. - string target_chain_id = 4 [(gogoproto.customname) = "TargetChainID"]; + // destination_chain_id is the destination chain ID that the data should be relayed to. + string destination_chain_id = 3 [(gogoproto.customname) = "DestinationChainID"]; + // destination_contract_address is the destination address that the data should be relayed to. + string destination_contract_address = 4; } diff --git a/proto/band/tunnel/v1beta1/route.proto b/proto/band/tunnel/v1beta1/route.proto index 297d86209..3884b7086 100644 --- a/proto/band/tunnel/v1beta1/route.proto +++ b/proto/band/tunnel/v1beta1/route.proto @@ -4,10 +4,12 @@ package band.tunnel.v1beta1; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +import "band/feeds/v1beta1/feeds.proto"; + option go_package = "github.com/bandprotocol/chain/v3/x/tunnel/types"; option (gogoproto.equal_all) = true; -// TSSRoute is the type for a TSS route +// TSSRoute represents a route for TSS packets and implements the RouteI interface. message TSSRoute { option (cosmos_proto.implements_interface) = "RouteI"; @@ -17,17 +19,41 @@ message TSSRoute { string destination_contract_address = 2; } -// TSSPacketContent is the packet content for TSS -message TSSPacketContent { - option (cosmos_proto.implements_interface) = "PacketContentI"; +// TSSPacketReceipt represents a receipt for a TSS packet and implements the PacketReceiptI interface. +message TSSPacketReceipt { + option (cosmos_proto.implements_interface) = "PacketReceiptI"; // signing_id is the signing ID uint64 signing_id = 1 [ (gogoproto.customname) = "SigningID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/x/bandtss/types.SigningID" ]; - // destination_chain_id is the destination chain ID - string destination_chain_id = 2 [(gogoproto.customname) = "DestinationChainID"]; - // destination_contract_address is the destination contract address - string destination_contract_address = 3; +} + +// IBCRoute is the type for an IBC route +message IBCRoute { + option (cosmos_proto.implements_interface) = "Route"; + + // channel_id is the IBC channel ID + string channel_id = 1 [(gogoproto.customname) = "ChannelID"]; +} + +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +message IBCPacketReceipt { + option (cosmos_proto.implements_interface) = "PacketContentI"; + + // sequence is representing the sequence of the IBC packet. + uint64 sequence = 1; +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +message TunnelPricesPacketData { + // tunnel_id is the tunnel ID + uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"]; + // sequence is representing the sequence of the tunnel packet. + uint64 sequence = 2; + // prices is the list of prices information from feeds module. + repeated band.feeds.v1beta1.Price prices = 3 [(gogoproto.nullable) = false]; + // created_at is the timestamp when the packet is created + int64 created_at = 4; } diff --git a/proto/band/tunnel/v1beta1/tunnel.proto b/proto/band/tunnel/v1beta1/tunnel.proto index b7458a8fa..0970e4330 100644 --- a/proto/band/tunnel/v1beta1/tunnel.proto +++ b/proto/band/tunnel/v1beta1/tunnel.proto @@ -60,8 +60,8 @@ message LatestPrices { message TotalFees { option (gogoproto.equal) = true; - // total_packet_fee is the total packet fee collected - repeated cosmos.base.v1beta1.Coin total_packet_fee = 1 + // total_base_packet_fee is the total base packet fee collected by the tunnel + repeated cosmos.base.v1beta1.Coin total_base_packet_fee = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } @@ -73,8 +73,8 @@ message Packet { uint64 sequence = 2; // prices is the list of prices information from feeds module. repeated band.feeds.v1beta1.Price prices = 3 [(gogoproto.nullable) = false]; - // packet_content is the content of the packet that implements PacketContentI - google.protobuf.Any packet_content = 4 [(cosmos_proto.accepts_interface) = "PacketContentI"]; + // receipt represents the confirmation of the packet delivery to the destination via the specified route. + google.protobuf.Any receipt = 4 [(cosmos_proto.accepts_interface) = "PacketReceiptI"]; // base_fee is the base fee of the packet repeated cosmos.base.v1beta1.Coin base_fee = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; @@ -117,9 +117,12 @@ message SignalDeviation { message TunnelSignatureOrder { option (gogoproto.goproto_getters) = false; - // tunnel_id is the ID of the tunnel - uint64 tunnel_id = 1 [(gogoproto.customname) = "TunnelID"]; - // sequence is the sequence of the packet - uint64 sequence = 2; + uint64 sequence = 1; + // prices is the list of prices information from feeds module. + repeated band.feeds.v1beta1.Price prices = 2 [(gogoproto.nullable) = false]; + // created_at is the timestamp when the packet is created + int64 created_at = 3; + // encoder is the mode of encoding price data. + band.feeds.v1beta1.Encoder encoder = 4; } diff --git a/scripts/bothan/bothan-config.toml b/scripts/bothan/bothan-config.toml index 7a9ce34d6..b53586aee 100644 --- a/scripts/bothan/bothan-config.toml +++ b/scripts/bothan/bothan-config.toml @@ -11,11 +11,11 @@ endpoint = "https://gateway.pinata.cloud" authentication = "None" [store] -path = "$HOME/.bothan/data" +path = "/root/.bothan/data" [monitoring] endpoint = "https://bothan-monitoring.bandchain.org" -path = "$HOME/.bothan/keyring/broadcaster.info" +path = "/root/.bothan/keyring/broadcaster.info" enabled = false [manager.crypto] diff --git a/scripts/generate_genesis.sh b/scripts/generate_genesis.sh index f3d447b8f..5ccce6396 100755 --- a/scripts/generate_genesis.sh +++ b/scripts/generate_genesis.sh @@ -51,3 +51,5 @@ cat <<< $(jq --arg addr "$(bandd keys show requester -a --keyring-backend test)" # allow "uband" for restake cat <<< $(jq '.app_state.restake.params.allowed_denoms = ["uband"]' ~/.band/config/genesis.json) > ~/.band/config/genesis.json + +cat <<< $(jq '.app_state.bandtss.params.min_transition_duration = "60s"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json diff --git a/scripts/tunnel/create_ibc_tunnel.sh b/scripts/tunnel/create_ibc_tunnel.sh new file mode 100644 index 000000000..9a3474fb4 --- /dev/null +++ b/scripts/tunnel/create_ibc_tunnel.sh @@ -0,0 +1 @@ +bandd tx tunnel create-tunnel ibc channel-0 1 1uband 120 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain diff --git a/scripts/tunnel/create_tunnel.sh b/scripts/tunnel/create_tunnel.sh index 72646b450..01bce254b 100755 --- a/scripts/tunnel/create_tunnel.sh +++ b/scripts/tunnel/create_tunnel.sh @@ -1 +1 @@ -bandd tx tunnel create-tunnel tss eth 0xe00F1f85abDB2aF6760759547d450da68CE66Bb1 1 1uband 10 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain +bandd tx tunnel create-tunnel tss eth 0xe00F1f85abDB2aF6760759547d450da68CE66Bb1 1 1uband 60 ./scripts/tunnel/signal_deviations.json --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain diff --git a/scripts/tunnel/signal_deviations.json b/scripts/tunnel/signal_deviations.json index 370aba92c..caab898bb 100644 --- a/scripts/tunnel/signal_deviations.json +++ b/scripts/tunnel/signal_deviations.json @@ -1,12 +1,12 @@ { - "signal_deviations": [ - { - "signal_id": "CS:BTC-USD", - "deviation_bps": 2000 - }, - { - "signal_id": "CS:ETH-USD", - "deviation_bps": 4000 - } - ] + "signal_deviations": [ + { + "signal_id": "CS:BTC-USD", + "deviation_bps": 2000 + }, + { + "signal_id": "CS:ETH-USD", + "deviation_bps": 3000 + } + ] } diff --git a/scripts/tunnel/trigger_tunnel.sh b/scripts/tunnel/trigger_tunnel.sh new file mode 100644 index 000000000..7280dcb72 --- /dev/null +++ b/scripts/tunnel/trigger_tunnel.sh @@ -0,0 +1 @@ +bandd tx tunnel trigger-tunnel 1 --from requester --keyring-backend test --gas-prices 0.0025uband -y --chain-id bandchain diff --git a/x/bandtss/keeper/keeper.go b/x/bandtss/keeper/keeper.go index 7c0f34d67..dda170f06 100644 --- a/x/bandtss/keeper/keeper.go +++ b/x/bandtss/keeper/keeper.go @@ -56,6 +56,11 @@ func NewKeeper( } } +// GetAuthority returns the x/bandtss module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + // GetBandtssAccount returns the bandtss ModuleAccount func (k Keeper) GetBandtssAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) diff --git a/x/bandtss/keeper/keeper_member.go b/x/bandtss/keeper/keeper_member.go index 80f5dafe1..98a3adf66 100644 --- a/x/bandtss/keeper/keeper_member.go +++ b/x/bandtss/keeper/keeper_member.go @@ -51,11 +51,12 @@ func (k Keeper) ActivateMember(ctx sdk.Context, address sdk.AccAddress, groupID } if member.IsActive { - return types.ErrMemberAlreadyActive + return types.ErrMemberAlreadyActive.Wrapf("address %s is already active", address.String()) } - if member.Since.Add(k.GetParams(ctx).InactivePenaltyDuration).After(ctx.BlockTime()) { - return types.ErrTooSoonToActivate + penaltyEndTime := member.Since.Add(k.GetParams(ctx).InactivePenaltyDuration) + if penaltyEndTime.After(ctx.BlockTime()) { + return types.ErrPenaltyDurationNotElapsed.Wrapf("penalty end time: %s", penaltyEndTime) } member.IsActive = true @@ -99,7 +100,7 @@ func (k Keeper) AddMembers(ctx sdk.Context, groupID tss.GroupID) error { // AddMember adds a new member to the group and return error if already exists func (k Keeper) AddMember(ctx sdk.Context, address sdk.AccAddress, groupID tss.GroupID) error { if k.HasMember(ctx, address, groupID) { - return types.ErrMemberAlreadyExists.Wrapf("address : %v", address) + return types.ErrMemberAlreadyExists.Wrapf("address %s already exists", address.String()) } member := types.NewMember(address, groupID, true, ctx.BlockTime()) @@ -142,14 +143,16 @@ func (k Keeper) GetMember(ctx sdk.Context, address sdk.AccAddress, groupID tss.G // GetMembers retrieves all statuses of the store. func (k Keeper) GetMembers(ctx sdk.Context) []types.Member { - var members []types.Member iterator := k.GetMembersIterator(ctx) defer iterator.Close() + + var members []types.Member for ; iterator.Valid(); iterator.Next() { var status types.Member k.cdc.MustUnmarshal(iterator.Value(), &status) members = append(members, status) } + return members } diff --git a/x/bandtss/keeper/keeper_member_test.go b/x/bandtss/keeper/keeper_member_test.go index bc3b921bf..d1376dfb7 100644 --- a/x/bandtss/keeper/keeper_member_test.go +++ b/x/bandtss/keeper/keeper_member_test.go @@ -47,7 +47,7 @@ func (s *AppTestSuite) TestActivateMember() { s.Require().NoError(err) err = k.ActivateMember(ctx, address, groupCtx.GroupID) - s.Require().ErrorIs(err, types.ErrTooSoonToActivate) + s.Require().ErrorIs(err, types.ErrPenaltyDurationNotElapsed) // Failed case - no member err = k.ActivateMember(ctx, address, groupCtx.GroupID) diff --git a/x/bandtss/keeper/keeper_signing.go b/x/bandtss/keeper/keeper_signing.go index 78d61a6ba..3e529164e 100644 --- a/x/bandtss/keeper/keeper_signing.go +++ b/x/bandtss/keeper/keeper_signing.go @@ -3,10 +3,10 @@ package keeper import ( "fmt" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/kv" "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/bandtss/types" @@ -28,8 +28,8 @@ func (k Keeper) CreateDirectSigningRequest( func (k Keeper) CreateTunnelSigningRequest( ctx sdk.Context, tunnelID uint64, - destinationContractAddr string, destinationChainID string, + destinationContractAddr string, content tsstypes.Content, sender sdk.AccAddress, feeLimit sdk.Coins, @@ -37,8 +37,8 @@ func (k Keeper) CreateTunnelSigningRequest( originator := tsstypes.NewTunnelOriginator( ctx.ChainID(), tunnelID, - destinationContractAddr, destinationChainID, + destinationContractAddr, ) return k.createSigningRequest(ctx, &originator, content, sender, feeLimit) } @@ -59,14 +59,15 @@ func (k Keeper) createSigningRequest( // charged fee if necessary; If found any coins that exceed limit then return error feePerSigner := sdk.NewCoins() + totalFee := sdk.NewCoins() if sender.String() != k.authority && currentGroupID != 0 { currentGroup, err := k.tssKeeper.GetGroup(ctx, currentGroupID) if err != nil { return 0, err } - feePerSigner = k.GetParams(ctx).Fee - totalFee := feePerSigner.MulInt(math.NewInt(int64(currentGroup.Threshold))) + feePerSigner = k.GetParams(ctx).FeePerSigner + totalFee = feePerSigner.MulInt(math.NewInt(int64(currentGroup.Threshold))) for _, fc := range totalFee { limitAmt := feeLimit.AmountOf(fc.Denom) if fc.Amount.GT(limitAmt) { @@ -96,12 +97,28 @@ func (k Keeper) createSigningRequest( currentGroupSigningID = signingID } + // create signing request for incoming group if any. In case of error, emit event and continue + // the process, as the signing request for incoming group is optional. if incomingGroupID != 0 { - signingID, err := k.tssKeeper.RequestSigning(ctx, incomingGroupID, originator, content) + cacheCtx, writeFn := ctx.CacheContext() + signingID, err := k.tssKeeper.RequestSigning(cacheCtx, incomingGroupID, originator, content) if err != nil { - return 0, err + codespace, code, _ := errorsmod.ABCIInfo(err, false) + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeCreateSigningFailed, + sdk.NewAttribute(types.AttributeKeyGroupID, fmt.Sprintf("%d", incomingGroupID)), + sdk.NewAttribute(types.AttributeKeySigningErrReason, err.Error()), + sdk.NewAttribute(types.AttributeKeySigningErrCodespace, codespace), + sdk.NewAttribute(types.AttributeKeySigningErrCode, fmt.Sprintf("%d", code)), + )) + } else { + writeFn() + incomingGroupSigningID = signingID } - incomingGroupSigningID = signingID + } + + if currentGroupSigningID == 0 && incomingGroupSigningID == 0 { + return 0, types.ErrNoActiveGroup } // save signing info @@ -115,6 +132,7 @@ func (k Keeper) createSigningRequest( sdk.NewAttribute(types.AttributeKeyCurrentGroupSigningID, fmt.Sprintf("%d", currentGroupSigningID)), sdk.NewAttribute(types.AttributeKeyIncomingGroupID, fmt.Sprintf("%d", incomingGroupID)), sdk.NewAttribute(types.AttributeKeyIncomingGroupSigningID, fmt.Sprintf("%d", incomingGroupSigningID)), + sdk.NewAttribute(types.AttributeKeyTotalFee, totalFee.String()), ), ) @@ -133,16 +151,11 @@ func (k Keeper) GetSigningFee(ctx sdk.Context) (sdk.Coins, error) { return sdk.Coins{}, err } - feePerSigner := k.GetParams(ctx).Fee + feePerSigner := k.GetParams(ctx).FeePerSigner return feePerSigner.MulInt(math.NewIntFromUint64(group.Threshold)), nil } -func decodeSigningMappingKeyToSigningID(key []byte) tss.SigningID { - kv.AssertKeyLength(key, 9) - return tss.SigningID(sdk.BigEndianToUint64(key[1:])) -} - // ===================================== // Signing store // ===================================== diff --git a/x/bandtss/keeper/keeper_signing_test.go b/x/bandtss/keeper/keeper_signing_test.go index 34d6857fc..ba554cf57 100644 --- a/x/bandtss/keeper/keeper_signing_test.go +++ b/x/bandtss/keeper/keeper_signing_test.go @@ -71,6 +71,121 @@ func (s *KeeperTestSuite) TestCreateDirectSigningRequest() { }, expectErr: nil, }, + { + name: "test failed insufficient member in current group even normal incoming group", + preProcess: func(s *KeeperTestSuite) { + incomingGroupID := tss.GroupID(2) + transition := types.GroupTransition{ + SigningID: tss.SigningID(1), + Status: types.TRANSITION_STATUS_WAITING_EXECUTION, + CurrentGroupID: currentGroupID, + IncomingGroupID: incomingGroupID, + } + s.keeper.SetGroupTransition(s.ctx, transition) + s.keeper.SetCurrentGroup(s.ctx, types.NewCurrentGroup(currentGroupID, s.ctx.BlockTime())) + + s.tssKeeper.EXPECT().GetGroup(gomock.Any(), currentGroupID). + Return(currentGroup, nil). + AnyTimes() + + s.tssKeeper.EXPECT().RequestSigning(gomock.Any(), currentGroupID, gomock.Any(), content). + DoAndReturn(func( + ctx sdk.Context, + groupID tss.GroupID, + originator tsstypes.Originator, + content tsstypes.Content, + ) (tss.SigningID, error) { + ctx.KVStore(s.key).Set([]byte{0xff, 0xfe}, []byte("test")) + return tss.SigningID(0), tsstypes.ErrInsufficientSigners + }) + + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule( + gomock.Any(), + bandtesting.Alice.Address, + types.ModuleName, + sdk.NewCoins(sdk.NewInt64Coin("uband", 20)), + ).Return(nil) + }, + postCheck: func(s *KeeperTestSuite) { + s.Require().Equal([]byte("test"), s.ctx.KVStore(s.key).Get([]byte{0xff, 0xfe})) + }, + input: input{ + sender: bandtesting.Alice.Address, + feeLimit: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), + }, + expectErr: tsstypes.ErrInsufficientSigners, + }, + { + name: "test success with only current group; insufficient member on incoming group", + preProcess: func(s *KeeperTestSuite) { + incomingGroupID := tss.GroupID(2) + transition := types.GroupTransition{ + SigningID: tss.SigningID(1), + Status: types.TRANSITION_STATUS_WAITING_EXECUTION, + CurrentGroupID: currentGroupID, + IncomingGroupID: incomingGroupID, + } + s.keeper.SetGroupTransition(s.ctx, transition) + s.keeper.SetCurrentGroup(s.ctx, types.NewCurrentGroup(currentGroupID, s.ctx.BlockTime())) + + s.tssKeeper.EXPECT().GetGroup(gomock.Any(), currentGroupID). + Return(currentGroup, nil). + AnyTimes() + + s.tssKeeper.EXPECT().RequestSigning(gomock.Any(), currentGroupID, gomock.Any(), content). + DoAndReturn(func( + ctx sdk.Context, + groupID tss.GroupID, + originator tsstypes.Originator, + content tsstypes.Content, + ) (tss.SigningID, error) { + ctx.KVStore(s.key).Set([]byte{0xff, 0xfe}, []byte("test")) + return tss.SigningID(1), nil + }) + + s.tssKeeper.EXPECT().RequestSigning(gomock.Any(), incomingGroupID, gomock.Any(), content). + DoAndReturn(func( + ctx sdk.Context, + groupID tss.GroupID, + originator tsstypes.Originator, + content tsstypes.Content, + ) (tss.SigningID, error) { + ctx.KVStore(s.key).Set([]byte{0xff, 0xff}, []byte("test")) + return tss.SigningID(0), tsstypes.ErrInsufficientSigners + }) + + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule( + gomock.Any(), + bandtesting.Alice.Address, + types.ModuleName, + sdk.NewCoins(sdk.NewInt64Coin("uband", 20)), + ).Return(nil) + }, + postCheck: func(s *KeeperTestSuite) { + // check mapping of tss signingID -> bandtss signingID + actualMappedSigningID := s.keeper.GetSigningIDMapping(s.ctx, tss.SigningID(1)) + s.Require().Equal(types.SigningID(1), actualMappedSigningID) + + // check bandtssSigning + bandtssSigning, err := s.keeper.GetSigning(s.ctx, types.SigningID(1)) + s.Require().NoError(err) + s.Require().Equal(types.Signing{ + ID: types.SigningID(1), + FeePerSigner: sdk.NewCoins(sdk.NewInt64Coin("uband", 10)), + Requester: bandtesting.Alice.Address.String(), + CurrentGroupSigningID: tss.SigningID(1), + IncomingGroupSigningID: tss.SigningID(0), + }, bandtssSigning) + + s.Require().Equal([]byte("test"), s.ctx.KVStore(s.key).Get([]byte{0xff, 0xfe})) + s.Require().Nil(s.ctx.KVStore(s.key).Get([]byte{0xff, 0xff})) + }, + input: input{ + sender: bandtesting.Alice.Address, + feeLimit: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), + }, + expectErr: nil, + }, { name: "test success with both current and incoming group", preProcess: func(s *KeeperTestSuite) { @@ -219,7 +334,7 @@ func (s *KeeperTestSuite) TestCreateDirectSigningRequest() { name: "error: fee more than limit", preProcess: func(s *KeeperTestSuite) { params := s.keeper.GetParams(s.ctx) - params.Fee = sdk.NewCoins(sdk.NewInt64Coin("uband", 100)) + params.FeePerSigner = sdk.NewCoins(sdk.NewInt64Coin("uband", 100)) err := s.keeper.SetParams(s.ctx, params) s.Require().NoError(err) s.keeper.SetCurrentGroup(s.ctx, types.NewCurrentGroup(currentGroupID, s.ctx.BlockTime())) diff --git a/x/bandtss/keeper/keeper_test.go b/x/bandtss/keeper/keeper_test.go index 776df92bb..c605560e0 100644 --- a/x/bandtss/keeper/keeper_test.go +++ b/x/bandtss/keeper/keeper_test.go @@ -60,6 +60,7 @@ func (s *AppTestSuite) SetupTest() { dir := sdktestutil.GetTempDir(s.T()) s.app = bandtesting.SetupWithCustomHome(false, dir) s.ctx = s.app.BaseApp.NewUncachedContext(false, cmtproto.Header{ChainID: bandtesting.ChainID}) + s.ctx = s.ctx.WithBlockTime(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)) _, err := s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1}) s.Require().NoError(err) @@ -72,6 +73,12 @@ func (s *AppTestSuite) SetupTest() { s.msgSrvr = keeper.NewMsgServerImpl(s.app.BandtssKeeper) s.tssMsgSrvr = tsskeeper.NewMsgServerImpl(s.app.TSSKeeper) s.authority = authtypes.NewModuleAddress(govtypes.ModuleName) + + // for testing purpose, set the min transition duration to 1 second + params := s.app.BandtssKeeper.GetParams(s.ctx) + params.MinTransitionDuration = time.Second + err = s.app.BandtssKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) } func (s *AppTestSuite) CreateNewGroup( @@ -212,7 +219,7 @@ func (s *AppTestSuite) TestParams() { input: types.Params{ InactivePenaltyDuration: time.Duration(0), RewardPercentage: 0, - Fee: sdk.NewCoins(), + FeePerSigner: sdk.NewCoins(), }, expectErr: true, expectErrStr: "must be positive:", @@ -222,8 +229,9 @@ func (s *AppTestSuite) TestParams() { input: types.Params{ RewardPercentage: types.DefaultRewardPercentage, InactivePenaltyDuration: types.DefaultInactivePenaltyDuration, + MinTransitionDuration: types.DefaultMinTransitionDuration, MaxTransitionDuration: types.DefaultMaxTransitionDuration, - Fee: types.DefaultFee, + FeePerSigner: types.DefaultFeePerSigner, }, expectErr: false, }, diff --git a/x/bandtss/keeper/keeper_transition.go b/x/bandtss/keeper/keeper_transition.go index 19ae32c58..399d2697f 100644 --- a/x/bandtss/keeper/keeper_transition.go +++ b/x/bandtss/keeper/keeper_transition.go @@ -109,9 +109,12 @@ func (k Keeper) ExecuteGroupTransition(ctx sdk.Context, transition types.GroupTr // ValidateTransitionExecTime validate the transition execution time if it is // after the block time but not over the max duration. func (k Keeper) ValidateTransitionExecTime(ctx sdk.Context, execTime time.Time) error { - maxDuration := k.GetParams(ctx).MaxTransitionDuration - if execTime.Before(ctx.BlockTime()) || execTime.After(ctx.BlockTime().Add(maxDuration)) { - return types.ErrInvalidExecTime + params := k.GetParams(ctx) + minExecTime := ctx.BlockTime().Add(params.MinTransitionDuration) + maxExecTime := ctx.BlockTime().Add(params.MaxTransitionDuration) + + if execTime.Before(minExecTime) || execTime.After(maxExecTime) { + return types.ErrInvalidExecTime.Wrapf("exec time should be between %s and %s", minExecTime, maxExecTime) } return nil @@ -159,13 +162,11 @@ func (k Keeper) CreateTransitionSigning( currentGroupID := k.GetCurrentGroup(ctx).GroupID moduleAcc := k.GetBandtssAccount(ctx) - originator := &tsstypes.DirectOriginator{ - Requester: moduleAcc.GetAddress().String(), - } + originator := tsstypes.NewDirectOriginator(ctx.ChainID(), moduleAcc.GetAddress().String(), "") content := types.NewGroupTransitionSignatureOrder(groupPubKey, transitionTime) - signingID, err := k.tssKeeper.RequestSigning(ctx, currentGroupID, originator, content) + signingID, err := k.tssKeeper.RequestSigning(ctx, currentGroupID, &originator, content) if err != nil { return 0, err } diff --git a/x/bandtss/keeper/msg_server.go b/x/bandtss/keeper/msg_server.go index bdf02d8b1..f251e2bdb 100644 --- a/x/bandtss/keeper/msg_server.go +++ b/x/bandtss/keeper/msg_server.go @@ -27,8 +27,8 @@ func (k msgServer) TransitionGroup( goCtx context.Context, req *types.MsgTransitionGroup, ) (*types.MsgTransitionGroupResponse, error) { - if k.authority != req.Authority { - return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.authority, req.Authority) + if k.Keeper.GetAuthority() != req.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.Keeper.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) @@ -43,12 +43,12 @@ func (k msgServer) TransitionGroup( } // validate transition duration - if err := k.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { + if err := k.Keeper.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { return nil, err } // validate if transition is in progress - if err := k.ValidateTransitionInProgress(ctx); err != nil { + if err := k.Keeper.ValidateTransitionInProgress(ctx); err != nil { return nil, err } @@ -63,13 +63,13 @@ func (k msgServer) TransitionGroup( } // set new group transition - transition, err := k.SetNewGroupTransition(ctx, groupID, req.ExecTime, false) + transition, err := k.Keeper.SetNewGroupTransition(ctx, groupID, req.ExecTime, false) if err != nil { return nil, err } // emit an event for the group transition. - attrs := k.ExtractEventAttributesFromTransition(transition) + attrs := k.Keeper.ExtractEventAttributesFromTransition(transition) ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeGroupTransition, attrs...)) return &types.MsgTransitionGroupResponse{}, nil @@ -81,25 +81,25 @@ func (k msgServer) ForceTransitionGroup( goCtx context.Context, req *types.MsgForceTransitionGroup, ) (*types.MsgForceTransitionGroupResponse, error) { - if k.authority != req.Authority { - return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.authority, req.Authority) + if k.Keeper.GetAuthority() != req.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("expected %s got %s", k.Keeper.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) // validate transition duration - if err := k.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { + if err := k.Keeper.ValidateTransitionExecTime(ctx, req.ExecTime); err != nil { return nil, err } // validate if transition is in progress - if err := k.ValidateTransitionInProgress(ctx); err != nil { + if err := k.Keeper.ValidateTransitionInProgress(ctx); err != nil { return nil, err } // validate incoming group - currentGroupID := k.GetCurrentGroup(ctx).GroupID + currentGroupID := k.Keeper.GetCurrentGroup(ctx).GroupID if currentGroupID == req.IncomingGroupID { - return nil, types.ErrInvalidIncomingGroup.Wrap("incoming group is the same as the current group") + return nil, types.ErrInvalidGroupID.Wrap("incoming group is the same as the current group") } incomingGroup, err := k.tssKeeper.GetGroup(ctx, req.IncomingGroupID) @@ -111,18 +111,18 @@ func (k msgServer) ForceTransitionGroup( } // add members from new group. - if err := k.AddMembers(ctx, req.IncomingGroupID); err != nil { + if err := k.Keeper.AddMembers(ctx, req.IncomingGroupID); err != nil { return nil, err } // set new group transition - transition, err := k.SetNewGroupTransition(ctx, req.IncomingGroupID, req.ExecTime, true) + transition, err := k.Keeper.SetNewGroupTransition(ctx, req.IncomingGroupID, req.ExecTime, true) if err != nil { return nil, err } // emit an event for the group transition. - attrs := k.ExtractEventAttributesFromTransition(transition) + attrs := k.Keeper.ExtractEventAttributesFromTransition(transition) ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeGroupTransition, attrs...)) return &types.MsgForceTransitionGroupResponse{}, nil @@ -149,7 +149,7 @@ func (k msgServer) RequestSignature( } // Execute the handler to process the request. - _, err = k.CreateDirectSigningRequest(ctx, content, req.Memo, feePayer, req.FeeLimit) + _, err = k.Keeper.CreateDirectSigningRequest(ctx, content, req.Memo, feePayer, req.FeeLimit) if err != nil { return nil, err } @@ -166,7 +166,7 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivate) (*typ return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) } - if err = k.ActivateMember(ctx, sender, msg.GroupID); err != nil { + if err = k.Keeper.ActivateMember(ctx, sender, msg.GroupID); err != nil { return nil, err } @@ -174,11 +174,11 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivate) (*typ } // UpdateParams update the parameter of the module. -func (k Keeper) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, req *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", k.authority, @@ -187,7 +187,7 @@ func (k Keeper) UpdateParams( } ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/bandtss/keeper/msg_server_test.go b/x/bandtss/keeper/msg_server_test.go index 3db668f5e..97a2b8bf7 100644 --- a/x/bandtss/keeper/msg_server_test.go +++ b/x/bandtss/keeper/msg_server_test.go @@ -12,6 +12,7 @@ import ( "github.com/bandprotocol/chain/v3/pkg/tss" bandtesting "github.com/bandprotocol/chain/v3/testing" "github.com/bandprotocol/chain/v3/x/bandtss/types" + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" tunneltypes "github.com/bandprotocol/chain/v3/x/tunnel/types" ) @@ -117,7 +118,7 @@ func (s *AppTestSuite) TestFailTransitionGroup() { err := s.app.TSSKeeper.SetParams(ctx, tssParams) s.Require().NoError(err) }, - expectErr: tsstypes.ErrGroupSizeTooLarge, + expectErr: tsstypes.ErrGroupCreationFailed, }, { name: "duplicate members", @@ -145,7 +146,7 @@ func (s *AppTestSuite) TestFailTransitionGroup() { }, preProcess: func() {}, postProcess: func() {}, - expectErr: fmt.Errorf("threshold must be less than or equal to the members but more than zero"), + expectErr: types.ErrInvalidThreshold, }, } @@ -167,16 +168,14 @@ func (s *AppTestSuite) TestFailTransitionGroup() { } func (s *AppTestSuite) TestFailForceTransitionGroupInvalidExecTime() { - ctx, msgSrvr, _ := s.ctx, s.msgSrvr, s.app.TSSKeeper - _ = s.SetupNewGroup(5, 3) - group2Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group2Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) - maxTransitionDuration := s.app.BandtssKeeper.GetParams(ctx).MaxTransitionDuration - execTime := ctx.BlockTime().Add(10 * time.Minute).Add(maxTransitionDuration) + maxTransitionDuration := s.app.BandtssKeeper.GetParams(s.ctx).MaxTransitionDuration + execTime := s.ctx.BlockTime().Add(10 * time.Minute).Add(maxTransitionDuration) - _, err = msgSrvr.ForceTransitionGroup(ctx, &types.MsgForceTransitionGroup{ + _, err = s.msgSrvr.ForceTransitionGroup(s.ctx, &types.MsgForceTransitionGroup{ IncomingGroupID: group2Ctx.GroupID, ExecTime: execTime, Authority: s.authority.String(), @@ -185,21 +184,19 @@ func (s *AppTestSuite) TestFailForceTransitionGroupInvalidExecTime() { } func (s *AppTestSuite) TestFailForceTransitionGroupInvalidGroupStatus() { - ctx, msgSrvr, _ := s.ctx, s.msgSrvr, s.app.TSSKeeper - _ = s.SetupNewGroup(5, 3) - group2Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group2Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) - group2 := s.app.TSSKeeper.MustGetGroup(ctx, group2Ctx.GroupID) + group2 := s.app.TSSKeeper.MustGetGroup(s.ctx, group2Ctx.GroupID) group2.Status = tsstypes.GROUP_STATUS_FALLEN - s.app.TSSKeeper.SetGroup(ctx, group2) + s.app.TSSKeeper.SetGroup(s.ctx, group2) - s.app.BandtssKeeper.DeleteGroupTransition(ctx) + s.app.BandtssKeeper.DeleteGroupTransition(s.ctx) - _, err = msgSrvr.ForceTransitionGroup(ctx, &types.MsgForceTransitionGroup{ + _, err = s.msgSrvr.ForceTransitionGroup(s.ctx, &types.MsgForceTransitionGroup{ IncomingGroupID: group2Ctx.GroupID, - ExecTime: ctx.BlockTime().Add(10 * time.Minute), + ExecTime: s.ctx.BlockTime().Add(10 * time.Minute), Authority: s.authority.String(), }) s.Require().ErrorIs(err, types.ErrInvalidIncomingGroup) @@ -214,21 +211,21 @@ func (s *AppTestSuite) TestFailForceTransitionGroupInvalidGroupID() { ExecTime: ctx.BlockTime().Add(10 * time.Minute), Authority: s.authority.String(), }) - s.Require().ErrorIs(err, types.ErrInvalidIncomingGroup) + s.Require().ErrorIs(err, types.ErrInvalidGroupID) } func (s *AppTestSuite) TestFailForceTransitionGroupFromWaitingExecutionStatus() { - ctx, msgSrvr, _ := s.ctx, s.msgSrvr, s.app.TSSKeeper - group1Ctx := s.SetupNewGroup(5, 3) - group2Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group2Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) - s.app.BandtssKeeper.DeleteGroupTransition(ctx) + s.app.BandtssKeeper.DeleteGroupTransition(s.ctx) - group3Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group3Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) + ctx, msgSrvr, _ := s.ctx, s.msgSrvr, s.app.TSSKeeper + err = s.SignTransition(group1Ctx) s.Require().NoError(err) transition, found := s.app.BandtssKeeper.GetGroupTransition(ctx) @@ -276,29 +273,27 @@ func (s *AppTestSuite) TestFailForceTransitionGroupFromWaitingExecutionStatus() } func (s *AppTestSuite) TestSuccessForceTransitionGroupFromFallenStatus() { - ctx, msgSrvr, _ := s.ctx, s.msgSrvr, s.app.TSSKeeper - group1Ctx := s.SetupNewGroup(5, 3) - group2Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group2Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) - s.app.BandtssKeeper.DeleteGroupTransition(ctx) + s.app.BandtssKeeper.DeleteGroupTransition(s.ctx) - group3Ctx, err := s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + group3Ctx, err := s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) - s.app.BandtssKeeper.DeleteGroupTransition(ctx) + s.app.BandtssKeeper.DeleteGroupTransition(s.ctx) - _, err = msgSrvr.ForceTransitionGroup(ctx, &types.MsgForceTransitionGroup{ + _, err = s.msgSrvr.ForceTransitionGroup(s.ctx, &types.MsgForceTransitionGroup{ IncomingGroupID: group2Ctx.GroupID, - ExecTime: ctx.BlockTime().Add(10 * time.Minute), + ExecTime: s.ctx.BlockTime().Add(10 * time.Minute), Authority: s.authority.String(), }) s.Require().NoError(err) - transition, found := s.app.BandtssKeeper.GetGroupTransition(ctx) - g1 := s.app.TSSKeeper.MustGetGroup(ctx, group1Ctx.GroupID) - g2 := s.app.TSSKeeper.MustGetGroup(ctx, group2Ctx.GroupID) + transition, found := s.app.BandtssKeeper.GetGroupTransition(s.ctx) + g1 := s.app.TSSKeeper.MustGetGroup(s.ctx, group1Ctx.GroupID) + g2 := s.app.TSSKeeper.MustGetGroup(s.ctx, group2Ctx.GroupID) expectedTransition := types.GroupTransition{ Status: types.TRANSITION_STATUS_WAITING_EXECUTION, @@ -306,7 +301,7 @@ func (s *AppTestSuite) TestSuccessForceTransitionGroupFromFallenStatus() { CurrentGroupPubKey: g1.PubKey, IncomingGroupID: group2Ctx.GroupID, IncomingGroupPubKey: g2.PubKey, - ExecTime: ctx.BlockTime().Add(10 * time.Minute), + ExecTime: s.ctx.BlockTime().Add(10 * time.Minute), SigningID: tss.SigningID(0), IsForceTransition: true, } @@ -314,19 +309,19 @@ func (s *AppTestSuite) TestSuccessForceTransitionGroupFromFallenStatus() { s.Require().Equal(expectedTransition, transition) for _, acc := range group1Ctx.Accounts { - m, err := s.app.BandtssKeeper.GetMember(ctx, acc.Address, group1Ctx.GroupID) + m, err := s.app.BandtssKeeper.GetMember(s.ctx, acc.Address, group1Ctx.GroupID) s.Require().NoError(err) s.Require().True(m.IsActive) } for _, acc := range group2Ctx.Accounts { - m, err := s.app.BandtssKeeper.GetMember(ctx, acc.Address, group2Ctx.GroupID) + m, err := s.app.BandtssKeeper.GetMember(s.ctx, acc.Address, group2Ctx.GroupID) s.Require().NoError(err) s.Require().True(m.IsActive) } for _, acc := range group3Ctx.Accounts { - ok := s.app.BandtssKeeper.HasMember(ctx, acc.Address, group3Ctx.GroupID) + ok := s.app.BandtssKeeper.HasMember(s.ctx, acc.Address, group3Ctx.GroupID) s.Require().False(ok) } } @@ -436,7 +431,7 @@ func (s *AppTestSuite) TestSuccessRequestSignatureOnCurrentGroup() { group, err := s.app.TSSKeeper.GetGroup(ctx, groupCtx.GroupID) s.Require().NoError(err) - diff := k.GetParams(ctx).Fee.MulInt(math.NewInt(int64(group.Threshold))) + diff := k.GetParams(ctx).FeePerSigner.MulInt(math.NewInt(int64(group.Threshold))) s.Require().Equal(diff, balancesBefore.Sub(balancesAfter...)) s.Require().Equal(diff, balancesModuleAfter.Sub(balancesModuleBefore...)) @@ -471,7 +466,7 @@ func (s *AppTestSuite) TestFailRequestSignatureInternalMessage() { // test tunnel message. msg, err = types.NewMsgRequestSignature( - tunneltypes.NewTunnelSignatureOrder(1, 1), + tunneltypes.NewTunnelSignatureOrder(1, []feedstypes.Price{}, 1, feedstypes.ENCODER_FIXED_POINT_ABI), sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), bandtesting.FeePayer.Address.String(), ) @@ -525,21 +520,22 @@ func (s *AppTestSuite) TestSuccessRequestSignatureOnIncomingGroup() { } func (s *AppTestSuite) TestSuccessRequestSignatureOnBothGroups() { - ctx, msgSrvr := s.ctx, s.msgSrvr - - group1Ctx, err := s.CreateNewGroup(5, 3, ctx.BlockTime().Add(10*time.Minute)) + group1Ctx, err := s.CreateNewGroup(5, 3, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) err = s.ExecuteReplaceGroup() s.Require().NoError(err) - _, err = s.CreateNewGroup(3, 2, ctx.BlockTime().Add(10*time.Minute)) + + _, err = s.CreateNewGroup(3, 2, s.ctx.BlockTime().Add(10*time.Minute)) s.Require().NoError(err) err = s.SignTransition(group1Ctx) s.Require().NoError(err) - balancesBefore := s.app.BankKeeper.GetAllBalances(ctx, bandtesting.FeePayer.Address) + ctx, msgSrvr := s.ctx, s.msgSrvr + + balancesBefore := s.app.BankKeeper.GetAllBalances(s.ctx, bandtesting.FeePayer.Address) balancesModuleBefore := s.app.BankKeeper.GetAllBalances( - ctx, - s.app.BandtssKeeper.GetBandtssAccount(ctx).GetAddress(), + s.ctx, + s.app.BandtssKeeper.GetBandtssAccount(s.ctx).GetAddress(), ) msg, err := types.NewMsgRequestSignature( @@ -559,7 +555,7 @@ func (s *AppTestSuite) TestSuccessRequestSignatureOnBothGroups() { ) group1 := s.app.TSSKeeper.MustGetGroup(ctx, group1Ctx.GroupID) - diff := s.app.BandtssKeeper.GetParams(ctx).Fee.MulInt(math.NewInt(int64(group1.Threshold))) + diff := s.app.BandtssKeeper.GetParams(ctx).FeePerSigner.MulInt(math.NewInt(int64(group1.Threshold))) s.Require().Equal(diff, balancesBefore.Sub(balancesAfter...)) s.Require().Equal(diff, balancesModuleAfter.Sub(balancesModuleBefore...)) @@ -613,7 +609,7 @@ func (s *AppTestSuite) TestFailActivateNotPassDuration() { Sender: acc.Address.String(), GroupID: groupCtx.GroupID, }) - s.Require().ErrorIs(err, types.ErrTooSoonToActivate) + s.Require().ErrorIs(err, types.ErrPenaltyDurationNotElapsed) } } @@ -676,8 +672,9 @@ func (s *AppTestSuite) TestUpdateParams() { Params: types.Params{ RewardPercentage: types.DefaultRewardPercentage, InactivePenaltyDuration: types.DefaultInactivePenaltyDuration, + MinTransitionDuration: types.DefaultMinTransitionDuration, MaxTransitionDuration: types.DefaultMaxTransitionDuration, - Fee: types.DefaultFee, + FeePerSigner: types.DefaultFeePerSigner, }, }, expectErr: false, diff --git a/x/bandtss/keeper/tss_callback.go b/x/bandtss/keeper/tss_callback.go index 67dcf80fa..4777d4fec 100644 --- a/x/bandtss/keeper/tss_callback.go +++ b/x/bandtss/keeper/tss_callback.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/bandprotocol/chain/v3/pkg/ctxcache" "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/bandtss/types" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" @@ -46,18 +45,15 @@ func (cb TSSCallback) OnGroupCreationCompleted(ctx sdk.Context, groupID tss.Grou transition.Status = types.TRANSITION_STATUS_WAITING_EXECUTION } else { - var signingID tss.SigningID - createSigningFunc := func(ctx sdk.Context) (err error) { - signingID, err = cb.k.CreateTransitionSigning(ctx, group.PubKey, transition.ExecTime) - return err - } - // create a signing request for transition. If the signing request is failed, // revert changes and set the transition status to fallen. - if err := ctxcache.ApplyFuncIfNoError(ctx, createSigningFunc); err != nil { + cacheCtx, writeFn := ctx.CacheContext() + signingID, err := cb.k.CreateTransitionSigning(cacheCtx, group.PubKey, transition.ExecTime) + if err != nil { codespace, code, _ := errorsmod.ABCIInfo(err, false) ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeCreateSigningFailed, + sdk.NewAttribute(types.AttributeKeyGroupID, fmt.Sprintf("%d", groupID)), sdk.NewAttribute(types.AttributeKeySigningErrReason, err.Error()), sdk.NewAttribute(types.AttributeKeySigningErrCodespace, codespace), sdk.NewAttribute(types.AttributeKeySigningErrCode, fmt.Sprintf("%d", code)), @@ -66,6 +62,7 @@ func (cb TSSCallback) OnGroupCreationCompleted(ctx sdk.Context, groupID tss.Grou cb.k.EndGroupTransitionProcess(ctx, transition, false) return } + writeFn() transition.Status = types.TRANSITION_STATUS_WAITING_SIGN transition.SigningID = signingID diff --git a/x/bandtss/keeper/tss_callback_test.go b/x/bandtss/keeper/tss_callback_test.go index 300e2b257..303e9353e 100644 --- a/x/bandtss/keeper/tss_callback_test.go +++ b/x/bandtss/keeper/tss_callback_test.go @@ -849,6 +849,59 @@ func (s *KeeperTestSuite) TestCallbackOnGroupCreationComplete() { s.Require().Equal(tss.GroupID(1), s.keeper.GetCurrentGroup(s.ctx).GroupID) + for _, member := range members { + ok := s.keeper.HasMember(s.ctx, sdk.MustAccAddressFromBech32(member.Address), tss.GroupID(2)) + s.Require().False(ok) + } + }, + }, + { + name: "existing current group id but insufficient member", + input: 2, + preProcess: func(s *KeeperTestSuite) { + s.tssKeeper.EXPECT().MustGetGroup(gomock.Any(), tss.GroupID(2)). + Return(tsstypes.Group{ + ID: 2, + ModuleOwner: types.ModuleName, + Status: tsstypes.GROUP_STATUS_ACTIVE, + PubKey: []byte("pubkey-2"), + }) + s.keeper.SetGroupTransition(s.ctx, types.GroupTransition{ + SigningID: tss.SigningID(1), + Status: types.TRANSITION_STATUS_CREATING_GROUP, + CurrentGroupID: tss.GroupID(1), + CurrentGroupPubKey: tss.Point([]byte("pubkey")), + IncomingGroupID: tss.GroupID(2), + ExecTime: s.ctx.BlockTime().Add(10 * time.Minute), + }) + s.keeper.SetCurrentGroup(s.ctx, types.NewCurrentGroup(1, s.ctx.BlockTime())) + s.accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), types.ModuleName).Return( + s.moduleAcc, + ) + + s.tssKeeper.EXPECT().RequestSigning( + gomock.Any(), + tss.GroupID(1), + gomock.Any(), + types.NewGroupTransitionSignatureOrder( + tss.Point([]byte("pubkey-2")), + s.ctx.BlockTime().Add(10*time.Minute), + ), + ).DoAndReturn(func( + ctx sdk.Context, + groupID tss.GroupID, + originator tsstypes.Originator, + content tsstypes.Content, + ) (tss.SigningID, error) { + ctx.KVStore(s.key).Set([]byte{0xff, 0xfe}, []byte("test")) + return tss.SigningID(0), tsstypes.ErrInsufficientSigners + }) + }, + postCheck: func(s *KeeperTestSuite) { + _, found := s.keeper.GetGroupTransition(s.ctx) + s.Require().False(found) + s.Require().Nil(s.ctx.KVStore(s.key).Get([]byte{0xff, 0xfe})) + for _, member := range members { ok := s.keeper.HasMember(s.ctx, sdk.MustAccAddressFromBech32(member.Address), tss.GroupID(2)) s.Require().False(ok) diff --git a/x/bandtss/tss_handler.go b/x/bandtss/tss_handler.go new file mode 100644 index 000000000..bc32667a0 --- /dev/null +++ b/x/bandtss/tss_handler.go @@ -0,0 +1,37 @@ +package bandtss + +import ( + "bytes" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bandprotocol/chain/v3/x/bandtss/types" + tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" +) + +const GroupTransitionMsgPrefix = "\x61\xb9\xb7\x41" // tss.Hash([]byte("Transition"))[:4] + +// NewSignatureOrderHandler implements the Handler interface for tss module-based +// request signatures (ie. TextSignatureOrder) +func NewSignatureOrderHandler() tsstypes.Handler { + return func(ctx sdk.Context, content tsstypes.Content) ([]byte, error) { + switch c := content.(type) { + case *types.GroupTransitionSignatureOrder: + return bytes.Join( + [][]byte{ + []byte(GroupTransitionMsgPrefix), + c.PubKey, + sdk.Uint64ToBigEndian(uint64(c.TransitionTime.Unix())), + }, + []byte(""), + ), nil + + default: + return nil, sdkerrors.ErrUnknownRequest.Wrapf( + "unrecognized tss request signature message type: %s", + c.OrderType(), + ) + } + } +} diff --git a/x/bandtss/tss_handler_test.go b/x/bandtss/tss_handler_test.go new file mode 100644 index 000000000..ebcf4f644 --- /dev/null +++ b/x/bandtss/tss_handler_test.go @@ -0,0 +1,14 @@ +package bandtss_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bandprotocol/chain/v3/pkg/tss" + "github.com/bandprotocol/chain/v3/x/bandtss" +) + +func TestEncoderPrefix(t *testing.T) { + require.Equal(t, []byte(bandtss.GroupTransitionMsgPrefix), tss.Hash([]byte("Transition"))[:4]) +} diff --git a/x/bandtss/types/constructors.go b/x/bandtss/types/constructors.go index a0d9ed77d..83100a0d4 100644 --- a/x/bandtss/types/constructors.go +++ b/x/bandtss/types/constructors.go @@ -4,7 +4,6 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/bandprotocol/chain/v3/pkg/tss" ) @@ -58,11 +57,11 @@ func NewMember( // Validate performs basic validation of member information. func (m Member) Validate() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid member address: %s", err) + return ErrInvalidMember.Wrapf("invalid member address: %s", err) } if m.GroupID == 0 { - return ErrInvalidGroupID.Wrap("group id is 0") + return ErrInvalidMember.Wrap("group id cannot be 0") } return nil diff --git a/x/bandtss/types/errors.go b/x/bandtss/types/errors.go index d687f5636..94c939e9f 100644 --- a/x/bandtss/types/errors.go +++ b/x/bandtss/types/errors.go @@ -4,21 +4,21 @@ import errorsmod "cosmossdk.io/errors" // x/bandtss module sentinel errors var ( - ErrInvalidStatus = errorsmod.Register(ModuleName, 2, "invalid status") - ErrTooSoonToActivate = errorsmod.Register(ModuleName, 3, "too soon to activate") - ErrFeeExceedsLimit = errorsmod.Register(ModuleName, 4, "fee exceeds limit") - ErrNoCurrentGroup = errorsmod.Register(ModuleName, 5, "no current group") - ErrTransitionInProgress = errorsmod.Register(ModuleName, 6, "group transition is in progress") - ErrInvalidExecTime = errorsmod.Register(ModuleName, 7, "invalid exec time") - ErrSigningNotFound = errorsmod.Register(ModuleName, 8, "signing not found") - ErrMemberNotFound = errorsmod.Register(ModuleName, 9, "member not found") - ErrMemberAlreadyExists = errorsmod.Register(ModuleName, 10, "member already exists") - ErrMemberAlreadyActive = errorsmod.Register(ModuleName, 11, "member already active") - ErrMemberDuplicate = errorsmod.Register(ModuleName, 12, "duplicated member found within the list") - ErrInvalidSigningThreshold = errorsmod.Register(ModuleName, 13, "invalid signing threshold number") - ErrContentNotAllowed = errorsmod.Register(ModuleName, 14, "content not allowed") - ErrInvalidIncomingGroup = errorsmod.Register(ModuleName, 15, "invalid incoming group") - ErrNoActiveGroup = errorsmod.Register(ModuleName, 16, "no active group supported") - ErrNoIncomingGroup = errorsmod.Register(ModuleName, 17, "no incoming group") - ErrInvalidGroupID = errorsmod.Register(ModuleName, 18, "invalid group ID") + ErrPenaltyDurationNotElapsed = errorsmod.Register(ModuleName, 2, "not allowed to activate due to penalty duration") + ErrFeeExceedsLimit = errorsmod.Register(ModuleName, 3, "fee exceeds limit") + ErrNoCurrentGroup = errorsmod.Register(ModuleName, 4, "no current group") + ErrTransitionInProgress = errorsmod.Register(ModuleName, 5, "group transition is in progress") + ErrInvalidExecTime = errorsmod.Register(ModuleName, 6, "invalid exec time") + ErrSigningNotFound = errorsmod.Register(ModuleName, 7, "signing not found") + ErrMemberNotFound = errorsmod.Register(ModuleName, 8, "member not found") + ErrMemberAlreadyExists = errorsmod.Register(ModuleName, 9, "member already exists") + ErrMemberAlreadyActive = errorsmod.Register(ModuleName, 10, "member already active") + ErrMemberDuplicated = errorsmod.Register(ModuleName, 11, "duplicated member found within the list") + ErrInvalidThreshold = errorsmod.Register(ModuleName, 12, "invalid threshold number") + ErrContentNotAllowed = errorsmod.Register(ModuleName, 13, "content not allowed") + ErrInvalidIncomingGroup = errorsmod.Register(ModuleName, 14, "invalid incoming group") + ErrNoActiveGroup = errorsmod.Register(ModuleName, 15, "no active group supported") + ErrNoIncomingGroup = errorsmod.Register(ModuleName, 16, "no incoming group") + ErrInvalidGroupID = errorsmod.Register(ModuleName, 17, "invalid group ID") + ErrInvalidMember = errorsmod.Register(ModuleName, 18, "invalid member") ) diff --git a/x/bandtss/types/events.go b/x/bandtss/types/events.go index 5ebafea01..6f82651dc 100644 --- a/x/bandtss/types/events.go +++ b/x/bandtss/types/events.go @@ -22,8 +22,8 @@ const ( AttributeKeyCurrentGroupPubKey = "current_group_pub_key" AttributeKeyRandomAddress = "random_address" AttributeKeySignature = "signature" - - AttributeKeySigningErrReason = "signing_error_reason" - AttributeKeySigningErrCode = "signing_error_code" - AttributeKeySigningErrCodespace = "signing_error_codespace" + AttributeKeyTotalFee = "total_fee" + AttributeKeySigningErrReason = "signing_error_reason" + AttributeKeySigningErrCode = "signing_error_code" + AttributeKeySigningErrCodespace = "signing_error_codespace" ) diff --git a/x/bandtss/types/genesis.pb.go b/x/bandtss/types/genesis.pb.go index a55745149..857dc5c65 100644 --- a/x/bandtss/types/genesis.pb.go +++ b/x/bandtss/types/genesis.pb.go @@ -100,11 +100,12 @@ type Params struct { RewardPercentage uint64 `protobuf:"varint,1,opt,name=reward_percentage,json=rewardPercentage,proto3" json:"reward_percentage,omitempty"` // inactive_penalty_duration is the duration where a member cannot activate back after being set to inactive. InactivePenaltyDuration time.Duration `protobuf:"bytes,2,opt,name=inactive_penalty_duration,json=inactivePenaltyDuration,proto3,stdduration" json:"inactive_penalty_duration"` - // max_transition_duration is the maximum duration where the transition process waits - // since the start of the process until an incoming group replaces a current group. - MaxTransitionDuration time.Duration `protobuf:"bytes,3,opt,name=max_transition_duration,json=maxTransitionDuration,proto3,stdduration" json:"max_transition_duration"` - // fee is the tokens that will be paid per signer. - Fee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=fee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee"` + // min_transition_duration is the minimum duration that the transition process waits before execution. + MinTransitionDuration time.Duration `protobuf:"bytes,3,opt,name=min_transition_duration,json=minTransitionDuration,proto3,stdduration" json:"min_transition_duration"` + // max_transition_duration is the maximum duration that the transition process waits before execution. + MaxTransitionDuration time.Duration `protobuf:"bytes,4,opt,name=max_transition_duration,json=maxTransitionDuration,proto3,stdduration" json:"max_transition_duration"` + // fee_per_signer is the tokens that will be paid per signer. + FeePerSigner github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=fee_per_signer,json=feePerSigner,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee_per_signer"` } func (m *Params) Reset() { *m = Params{} } @@ -154,6 +155,13 @@ func (m *Params) GetInactivePenaltyDuration() time.Duration { return 0 } +func (m *Params) GetMinTransitionDuration() time.Duration { + if m != nil { + return m.MinTransitionDuration + } + return 0 +} + func (m *Params) GetMaxTransitionDuration() time.Duration { if m != nil { return m.MaxTransitionDuration @@ -161,9 +169,9 @@ func (m *Params) GetMaxTransitionDuration() time.Duration { return 0 } -func (m *Params) GetFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Params) GetFeePerSigner() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.Fee + return m.FeePerSigner } return nil } @@ -178,38 +186,39 @@ func init() { } var fileDescriptor_3fe6a4345855d3c9 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x6b, 0x13, 0x41, - 0x14, 0xc7, 0xb3, 0x49, 0x88, 0x32, 0x56, 0xa8, 0x4b, 0xa4, 0x49, 0x91, 0xdd, 0x92, 0x53, 0x2f, - 0xce, 0xb4, 0xf6, 0x56, 0xbc, 0xb8, 0x0a, 0x05, 0xa1, 0x10, 0x56, 0x4f, 0x8a, 0x2c, 0xb3, 0x93, - 0xd7, 0xed, 0x60, 0x76, 0x66, 0x99, 0x99, 0x8d, 0xe9, 0x7f, 0xe1, 0xd1, 0xa3, 0x67, 0xff, 0x92, - 0x1e, 0x7b, 0xd3, 0x53, 0x2b, 0xc9, 0xc5, 0x93, 0x7f, 0x83, 0xcc, 0xec, 0x8f, 0x16, 0x89, 0xe0, - 0x25, 0x3f, 0xe6, 0x7d, 0xde, 0x67, 0xbf, 0xb3, 0xef, 0xa1, 0x49, 0x4a, 0xc5, 0x8c, 0xd8, 0x0f, - 0xa3, 0x35, 0x59, 0x1c, 0xa6, 0x60, 0xe8, 0x21, 0xc9, 0x40, 0x80, 0xe6, 0x1a, 0x17, 0x4a, 0x1a, - 0xe9, 0x0f, 0x6d, 0x19, 0xd7, 0x0c, 0xae, 0x99, 0xdd, 0x61, 0x26, 0x33, 0xe9, 0x00, 0x62, 0x7f, - 0x55, 0xec, 0x6e, 0x90, 0x49, 0x99, 0xcd, 0x81, 0xb8, 0x7f, 0x69, 0x79, 0x46, 0x66, 0xa5, 0xa2, - 0x86, 0x4b, 0xd1, 0xd4, 0x99, 0xd4, 0xb9, 0xd4, 0x24, 0xa5, 0x1a, 0xda, 0xc7, 0x31, 0xc9, 0x9b, - 0xfa, 0xe6, 0x3c, 0xcd, 0xb3, 0x1d, 0x33, 0xf9, 0xee, 0xa1, 0xad, 0x93, 0x2a, 0xe1, 0x1b, 0x43, - 0x0d, 0xf8, 0xc7, 0x68, 0x50, 0x50, 0x45, 0x73, 0x3d, 0xf2, 0xf6, 0xbc, 0xfd, 0x07, 0xcf, 0x9e, - 0xe0, 0x4d, 0x89, 0xf1, 0xd4, 0x31, 0x51, 0xff, 0xf2, 0x3a, 0xec, 0xc4, 0x75, 0x87, 0xff, 0x1c, - 0xdd, 0xcb, 0x21, 0x4f, 0x41, 0xe9, 0x51, 0x77, 0xaf, 0xf7, 0xef, 0xe6, 0x53, 0x07, 0xd5, 0xcd, - 0x4d, 0x8b, 0x7f, 0x8a, 0x1e, 0xb2, 0x52, 0x29, 0x10, 0x26, 0xc9, 0x94, 0x2c, 0x8b, 0x51, 0xcf, - 0x05, 0x98, 0x6c, 0x76, 0xbc, 0xac, 0xd0, 0x13, 0x4b, 0xd6, 0xa6, 0x2d, 0x76, 0xe7, 0x6c, 0xf2, - 0xbb, 0x8b, 0x06, 0x55, 0x4a, 0xff, 0x05, 0x7a, 0xa4, 0xe0, 0x13, 0x55, 0xb3, 0xa4, 0x00, 0xc5, - 0x40, 0x18, 0x9a, 0x81, 0xbb, 0x5e, 0x3f, 0x1a, 0xae, 0xae, 0xc3, 0xed, 0xd8, 0x15, 0xa7, 0x6d, - 0x2d, 0xde, 0x56, 0x7f, 0x9d, 0xf8, 0x09, 0x1a, 0x73, 0x41, 0x99, 0xe1, 0x0b, 0x48, 0x0a, 0x10, - 0x74, 0x6e, 0x2e, 0x92, 0x66, 0x1c, 0xa3, 0xae, 0x0b, 0x3a, 0xc6, 0xd5, 0xbc, 0x70, 0x33, 0x2f, - 0xfc, 0xaa, 0x06, 0xa2, 0xfb, 0x36, 0xdf, 0x97, 0x9b, 0xd0, 0x8b, 0x77, 0x1a, 0xcb, 0xb4, 0x92, - 0x34, 0x88, 0xff, 0x1e, 0xed, 0xe4, 0x74, 0x99, 0x18, 0x45, 0x85, 0xe6, 0xf6, 0xe4, 0x56, 0xdf, - 0xfb, 0x7f, 0xfd, 0xe3, 0x9c, 0x2e, 0xdf, 0xb6, 0x8a, 0x56, 0xfe, 0x01, 0xf5, 0xce, 0x00, 0x46, - 0x7d, 0x37, 0x94, 0x31, 0xae, 0xf6, 0x06, 0xdb, 0xbd, 0xb9, 0x7d, 0x9f, 0x92, 0x8b, 0xe8, 0xc0, - 0x8a, 0xbe, 0xdd, 0x84, 0xfb, 0x19, 0x37, 0xe7, 0x65, 0x8a, 0x99, 0xcc, 0x49, 0xbd, 0x64, 0xd5, - 0xd7, 0x53, 0x3d, 0xfb, 0x48, 0xcc, 0x45, 0x01, 0xda, 0x35, 0xe8, 0xd8, 0x7a, 0x8f, 0xfb, 0xbf, - 0xbe, 0x86, 0x5e, 0xf4, 0xfa, 0x72, 0x15, 0x78, 0x57, 0xab, 0xc0, 0xfb, 0xb9, 0x0a, 0xbc, 0xcf, - 0xeb, 0xa0, 0x73, 0xb5, 0x0e, 0x3a, 0x3f, 0xd6, 0x41, 0xe7, 0xdd, 0xc1, 0x1d, 0x9d, 0x9d, 0xa3, - 0xbb, 0x01, 0x93, 0x73, 0xc2, 0xce, 0x29, 0x17, 0x64, 0x71, 0x44, 0x96, 0xed, 0x9a, 0x3a, 0x79, - 0x3a, 0x70, 0xc8, 0xd1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xab, 0xe5, 0x3b, 0x53, 0x03, - 0x00, 0x00, + // 505 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xe3, 0x26, 0x04, 0xb4, 0x04, 0x54, 0xac, 0xa0, 0x26, 0x15, 0xb2, 0xab, 0x9c, 0x7a, + 0x61, 0xb7, 0xa5, 0xb7, 0x8a, 0x0b, 0x06, 0xa9, 0x12, 0x52, 0xa5, 0xc8, 0xe5, 0x04, 0x07, 0x6b, + 0xed, 0x4c, 0xdc, 0x15, 0xf1, 0xae, 0xd9, 0x5d, 0x87, 0xf4, 0x2d, 0x38, 0x72, 0xe4, 0xcc, 0x93, + 0xf4, 0xd8, 0x1b, 0x9c, 0x1a, 0x94, 0x5c, 0x78, 0x0c, 0xb4, 0x6b, 0x3b, 0x2d, 0xc8, 0x48, 0x70, + 0xf1, 0x9f, 0x99, 0x6f, 0x7e, 0xf3, 0xad, 0x67, 0x8c, 0x46, 0x31, 0xe5, 0x13, 0x62, 0x2e, 0x5a, + 0x29, 0x32, 0x3f, 0x8c, 0x41, 0xd3, 0x43, 0x92, 0x02, 0x07, 0xc5, 0x14, 0xce, 0xa5, 0xd0, 0xc2, + 0xed, 0x9b, 0x34, 0xae, 0x34, 0xb8, 0xd2, 0xec, 0xf6, 0x53, 0x91, 0x0a, 0x2b, 0x20, 0xe6, 0xa9, + 0xd4, 0xee, 0x7a, 0xa9, 0x10, 0xe9, 0x0c, 0x88, 0x7d, 0x8b, 0x8b, 0x29, 0x99, 0x14, 0x92, 0x6a, + 0x26, 0x78, 0x9d, 0x4f, 0x84, 0xca, 0x84, 0x22, 0x31, 0x55, 0xb0, 0x69, 0x97, 0x08, 0x56, 0xe7, + 0x9b, 0xfd, 0xd4, 0xbd, 0xad, 0x66, 0xf4, 0xcd, 0x41, 0xbd, 0x93, 0xd2, 0xe1, 0x99, 0xa6, 0x1a, + 0xdc, 0x63, 0xd4, 0xcd, 0xa9, 0xa4, 0x99, 0x1a, 0x38, 0x7b, 0xce, 0xfe, 0xfd, 0x67, 0x4f, 0x70, + 0x93, 0x63, 0x3c, 0xb6, 0x9a, 0xa0, 0x73, 0x79, 0xed, 0xb7, 0xc2, 0xaa, 0xc2, 0x7d, 0x8e, 0xee, + 0x66, 0x90, 0xc5, 0x20, 0xd5, 0x60, 0x6b, 0xaf, 0xfd, 0xf7, 0xe2, 0x53, 0x2b, 0xaa, 0x8a, 0xeb, + 0x12, 0xf7, 0x14, 0x3d, 0x48, 0x0a, 0x29, 0x81, 0xeb, 0x28, 0x95, 0xa2, 0xc8, 0x07, 0x6d, 0x6b, + 0x60, 0xd4, 0xcc, 0x78, 0x59, 0x4a, 0x4f, 0x8c, 0xb2, 0x22, 0xf5, 0x92, 0x5b, 0xb1, 0xd1, 0xb2, + 0x8d, 0xba, 0xa5, 0x4b, 0xf7, 0x05, 0x7a, 0x24, 0xe1, 0x23, 0x95, 0x93, 0x28, 0x07, 0x99, 0x00, + 0xd7, 0x34, 0x05, 0x7b, 0xbc, 0x4e, 0xd0, 0x5f, 0x5d, 0xfb, 0xdb, 0xa1, 0x4d, 0x8e, 0x37, 0xb9, + 0x70, 0x5b, 0xfe, 0x11, 0x71, 0x23, 0x34, 0x64, 0x9c, 0x26, 0x9a, 0xcd, 0x21, 0xca, 0x81, 0xd3, + 0x99, 0xbe, 0x88, 0xea, 0x71, 0x0c, 0xb6, 0xac, 0xd1, 0x21, 0x2e, 0xe7, 0x85, 0xeb, 0x79, 0xe1, + 0x57, 0x95, 0x20, 0xb8, 0x67, 0xfc, 0x7d, 0x5e, 0xfa, 0x4e, 0xb8, 0x53, 0x53, 0xc6, 0x25, 0xa4, + 0x96, 0xb8, 0xef, 0xd0, 0x4e, 0xc6, 0x78, 0xa4, 0x25, 0xe5, 0x8a, 0x99, 0xc8, 0x0d, 0xbe, 0xfd, + 0xef, 0xf8, 0xc7, 0x19, 0xe3, 0x6f, 0x36, 0x88, 0xdf, 0xe0, 0x74, 0xd1, 0x08, 0xef, 0xfc, 0x0f, + 0x9c, 0x2e, 0x1a, 0xe0, 0x1f, 0xd0, 0xc3, 0x29, 0x98, 0xaf, 0x22, 0x23, 0xc5, 0x52, 0x0e, 0x72, + 0x70, 0xc7, 0x0e, 0x7f, 0x88, 0xcb, 0xfd, 0xc4, 0x66, 0x3f, 0x6f, 0xe6, 0x26, 0x18, 0x0f, 0x0e, + 0x0c, 0xf3, 0xeb, 0xd2, 0xdf, 0x4f, 0x99, 0x3e, 0x2f, 0x62, 0x9c, 0x88, 0x8c, 0x54, 0xcb, 0x5c, + 0xde, 0x9e, 0xaa, 0xc9, 0x7b, 0xa2, 0x2f, 0x72, 0x50, 0xb6, 0x40, 0x85, 0xbd, 0x29, 0xc0, 0x18, + 0xe4, 0x99, 0x6d, 0x70, 0xdc, 0xf9, 0xf9, 0xc5, 0x77, 0x82, 0xd7, 0x97, 0x2b, 0xcf, 0xb9, 0x5a, + 0x79, 0xce, 0x8f, 0x95, 0xe7, 0x7c, 0x5a, 0x7b, 0xad, 0xab, 0xb5, 0xd7, 0xfa, 0xbe, 0xf6, 0x5a, + 0x6f, 0x0f, 0x6e, 0x71, 0xcd, 0xe2, 0xd8, 0x53, 0x25, 0x62, 0x46, 0x92, 0x73, 0xca, 0x38, 0x99, + 0x1f, 0x91, 0xc5, 0xe6, 0xbf, 0xb0, 0x5d, 0xe2, 0xae, 0x95, 0x1c, 0xfd, 0x0a, 0x00, 0x00, 0xff, + 0xff, 0xe9, 0x4e, 0xb2, 0x50, 0xc4, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -237,14 +246,17 @@ func (this *Params) Equal(that interface{}) bool { if this.InactivePenaltyDuration != that1.InactivePenaltyDuration { return false } + if this.MinTransitionDuration != that1.MinTransitionDuration { + return false + } if this.MaxTransitionDuration != that1.MaxTransitionDuration { return false } - if len(this.Fee) != len(that1.Fee) { + if len(this.FeePerSigner) != len(that1.FeePerSigner) { return false } - for i := range this.Fee { - if !this.Fee[i].Equal(&that1.Fee[i]) { + for i := range this.FeePerSigner { + if !this.FeePerSigner[i].Equal(&that1.FeePerSigner[i]) { return false } } @@ -327,10 +339,10 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Fee) > 0 { - for iNdEx := len(m.Fee) - 1; iNdEx >= 0; iNdEx-- { + if len(m.FeePerSigner) > 0 { + for iNdEx := len(m.FeePerSigner) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Fee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.FeePerSigner[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -338,7 +350,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.MaxTransitionDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MaxTransitionDuration):]) @@ -348,14 +360,22 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n3 i = encodeVarintGenesis(dAtA, i, uint64(n3)) i-- - dAtA[i] = 0x1a - n4, err4 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.InactivePenaltyDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.InactivePenaltyDuration):]) + dAtA[i] = 0x22 + n4, err4 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.MinTransitionDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MinTransitionDuration):]) if err4 != nil { return 0, err4 } i -= n4 i = encodeVarintGenesis(dAtA, i, uint64(n4)) i-- + dAtA[i] = 0x1a + n5, err5 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.InactivePenaltyDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.InactivePenaltyDuration):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintGenesis(dAtA, i, uint64(n5)) + i-- dAtA[i] = 0x12 if m.RewardPercentage != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.RewardPercentage)) @@ -406,10 +426,12 @@ func (m *Params) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.InactivePenaltyDuration) n += 1 + l + sovGenesis(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MinTransitionDuration) + n += 1 + l + sovGenesis(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MaxTransitionDuration) n += 1 + l + sovGenesis(uint64(l)) - if len(m.Fee) > 0 { - for _, e := range m.Fee { + if len(m.FeePerSigner) > 0 { + for _, e := range m.FeePerSigner { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -655,6 +677,39 @@ func (m *Params) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinTransitionDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.MinTransitionDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxTransitionDuration", wireType) } @@ -687,9 +742,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FeePerSigner", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -716,8 +771,8 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Fee = append(m.Fee, types.Coin{}) - if err := m.Fee[len(m.Fee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.FeePerSigner = append(m.FeePerSigner, types.Coin{}) + if err := m.FeePerSigner[len(m.FeePerSigner)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/bandtss/types/msgs.go b/x/bandtss/types/msgs.go index c79e2275e..444b416ef 100644 --- a/x/bandtss/types/msgs.go +++ b/x/bandtss/types/msgs.go @@ -62,7 +62,7 @@ func (m MsgTransitionGroup) ValidateBasic() error { existed := make(map[string]bool) for _, member := range m.Members { if existed[member] { - return ErrMemberDuplicate + return ErrMemberDuplicated.Wrapf("member %s is duplicated", member) } existed[member] = true } @@ -72,10 +72,15 @@ func (m MsgTransitionGroup) ValidateBasic() error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) } - // Validate threshold must be less than or equal to members but more than zero - if m.Threshold > uint64(len(m.Members)) || m.Threshold <= 0 { - return ErrInvalidSigningThreshold.Wrapf( - "threshold must be less than or equal to the members but more than zero", + // Validate threshold must be less than or equal to members but not zero + if m.Threshold == 0 { + return ErrInvalidThreshold.Wrap("threshold must be greater than zero") + } + if m.Threshold > uint64(len(m.Members)) { + return ErrInvalidThreshold.Wrapf( + "threshold (%d) must be less than or equal to the number of members (%d)", + m.Threshold, + len(m.Members), ) } diff --git a/x/bandtss/types/params.go b/x/bandtss/types/params.go index 6ebba4127..6c0eb1dab 100644 --- a/x/bandtss/types/params.go +++ b/x/bandtss/types/params.go @@ -9,29 +9,31 @@ import ( ) const ( - DefaultInactivePenaltyDuration time.Duration = time.Minute * 10 // 10 minutes - DefaultMaxTransitionDuration time.Duration = time.Hour * 120 // 5 days + DefaultInactivePenaltyDuration time.Duration = time.Minute * 10 // 10 minutes + DefaultMinTransitionDuration time.Duration = time.Hour * 24 // 1 days + DefaultMaxTransitionDuration time.Duration = time.Hour * 24 * 7 // 7 days // compute the bandtss reward following the allocation to Oracle. If the Oracle reward amounts to 70%, // the bandtss reward will be determined from the remaining 10%, which is 10% * 30% = 3%. DefaultRewardPercentage = uint64(10) ) -// DefaultFee is the default value for the signing request fee -// The value is ["10uband"] -var DefaultFee = sdk.NewCoins(sdk.NewInt64Coin("uband", 10)) +// DefaultFeePerSigner is the default value for the signing request fee. The value is ["10uband"] +var DefaultFeePerSigner = sdk.NewCoins(sdk.NewInt64Coin("uband", 10)) // NewParams creates a new Params instance func NewParams( rewardPercentage uint64, inactivePenaltyDuration time.Duration, + minTransitionDuration time.Duration, maxTransitionDuration time.Duration, - fee sdk.Coins, + feePerSigner sdk.Coins, ) Params { return Params{ RewardPercentage: rewardPercentage, InactivePenaltyDuration: inactivePenaltyDuration, + MinTransitionDuration: minTransitionDuration, MaxTransitionDuration: maxTransitionDuration, - Fee: fee, + FeePerSigner: feePerSigner, } } @@ -40,8 +42,9 @@ func DefaultParams() Params { return NewParams( DefaultRewardPercentage, DefaultInactivePenaltyDuration, + DefaultMinTransitionDuration, DefaultMaxTransitionDuration, - DefaultFee, + DefaultFeePerSigner, ) } @@ -55,13 +58,17 @@ func (p Params) Validate() error { return err } + if err := validateTimeDuration("min transition duration")(p.MinTransitionDuration); err != nil { + return err + } + if err := validateUint64("reward percentage", false)(p.RewardPercentage); err != nil { return err } // Validate fee - if !p.Fee.IsValid() { - return sdkerrors.ErrInvalidCoins.Wrap(p.Fee.String()) + if !p.FeePerSigner.IsValid() { + return sdkerrors.ErrInvalidCoins.Wrap(p.FeePerSigner.String()) } return nil diff --git a/x/bandtss/types/signature_order.go b/x/bandtss/types/signature_order.go index c8cdfb172..db9b27e72 100644 --- a/x/bandtss/types/signature_order.go +++ b/x/bandtss/types/signature_order.go @@ -1,23 +1,14 @@ package types import ( - "bytes" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/bandprotocol/chain/v3/pkg/tss" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" ) // GroupTransitionPath is the reserved path for transition group msg const GroupTransitionPath = "transition" -// GroupTransitionMsgPrefix is the prefix for transition group msg. -// The value is tss.Hash([]byte("transition"))[:4] -var GroupTransitionMsgPrefix = tss.Hash([]byte(GroupTransitionPath))[:4] - // Implements SignatureRequest Interface var _ tsstypes.Content = &GroupTransitionSignatureOrder{} @@ -44,27 +35,3 @@ func (rs *GroupTransitionSignatureOrder) IsInternal() bool { return true } // ValidateBasic performs no-op for this type func (rs *GroupTransitionSignatureOrder) ValidateBasic() error { return nil } - -// NewSignatureOrderHandler implements the Handler interface for tss module-based -// request signatures (ie. TextSignatureOrder) -func NewSignatureOrderHandler() tsstypes.Handler { - return func(ctx sdk.Context, content tsstypes.Content) ([]byte, error) { - switch c := content.(type) { - case *GroupTransitionSignatureOrder: - return bytes.Join( - [][]byte{ - GroupTransitionMsgPrefix, - c.PubKey, - sdk.Uint64ToBigEndian(uint64(c.TransitionTime.Unix())), - }, - []byte(""), - ), nil - - default: - return nil, sdkerrors.ErrUnknownRequest.Wrapf( - "unrecognized tss request signature message type: %s", - c.OrderType(), - ) - } - } -} diff --git a/x/feeds/keeper/msg_server.go b/x/feeds/keeper/msg_server.go index 805745d57..a72f0074f 100644 --- a/x/feeds/keeper/msg_server.go +++ b/x/feeds/keeper/msg_server.go @@ -24,7 +24,7 @@ func NewMsgServerImpl(k Keeper) types.MsgServer { } // Vote votes signals. -func (ms msgServer) Vote( +func (k msgServer) Vote( goCtx context.Context, msg *types.MsgVote, ) (*types.MsgVoteResponse, error) { @@ -36,7 +36,7 @@ func (ms msgServer) Vote( return nil, err } - maxCurrentFeeds := ms.GetParams(ctx).MaxCurrentFeeds + maxCurrentFeeds := k.Keeper.GetParams(ctx).MaxCurrentFeeds // check if the number of submitted signals exceeds the maximum allowed feeds if uint64(len(msg.Signals)) > maxCurrentFeeds { @@ -47,13 +47,13 @@ func (ms msgServer) Vote( } // lock the voter's power equal to the sum of the signal powers - err = ms.LockVoterPower(ctx, voter, msg.Signals) + err = k.Keeper.LockVoterPower(ctx, voter, msg.Signals) if err != nil { return nil, err } // RegisterNewSignals deletes previous signals and registers new signals then returns feed power differences - signalIDToPowerDiff := ms.UpdateVoteAndReturnPowerDiff(ctx, voter, msg.Signals) + signalIDToPowerDiff := k.Keeper.UpdateVoteAndReturnPowerDiff(ctx, voter, msg.Signals) // sort keys to guarantee order of signalIDToPowerDiff iteration keys := make([]string, 0, len(signalIDToPowerDiff)) @@ -68,7 +68,7 @@ func (ms msgServer) Vote( powerDiff := signalIDToPowerDiff[signalID] // retrieve the total power of the current signal ID from the store - signalTotalPower, err := ms.GetSignalTotalPower(ctx, signalID) + signalTotalPower, err := k.Keeper.GetSignalTotalPower(ctx, signalID) if err != nil { // initialize a new signal with zero power if the signal ID does not exist signalTotalPower = types.NewSignal( @@ -86,7 +86,7 @@ func (ms msgServer) Vote( } // save the updated signal total power back to the store - ms.SetSignalTotalPower(ctx, signalTotalPower) + k.Keeper.SetSignalTotalPower(ctx, signalTotalPower) } // return an empty response indicating success @@ -94,7 +94,7 @@ func (ms msgServer) Vote( } // SubmitSignalPrices submits new validator prices. -func (ms msgServer) SubmitSignalPrices( +func (k msgServer) SubmitSignalPrices( goCtx context.Context, msg *types.MsgSubmitSignalPrices, ) (*types.MsgSubmitSignalPricesResponse, error) { @@ -102,8 +102,8 @@ func (ms msgServer) SubmitSignalPrices( blockTime := ctx.BlockTime().Unix() blockHeight := ctx.BlockHeight() - params := ms.GetParams(ctx) - currentFeeds := ms.GetCurrentFeeds(ctx) + params := k.Keeper.GetParams(ctx) + currentFeeds := k.Keeper.GetCurrentFeeds(ctx) // check if the number of signal prices exceeds the length of current feeds if len(msg.SignalPrices) > len(currentFeeds.Feeds) { @@ -116,7 +116,7 @@ func (ms msgServer) SubmitSignalPrices( } // check if the validator is required to send prices - if err := ms.ValidateValidatorRequiredToSend(ctx, val); err != nil { + if err := k.Keeper.ValidateValidatorRequiredToSend(ctx, val); err != nil { return nil, err } @@ -137,7 +137,7 @@ func (ms msgServer) SubmitSignalPrices( newValidatorPrices := make([]types.ValidatorPrice, len(currentFeedsMap)) // fill new validator latest price with latest submitted price - prevValPrices, err := ms.GetValidatorPriceList(ctx, val) + prevValPrices, err := k.Keeper.GetValidatorPriceList(ctx, val) if err == nil { for _, p := range prevValPrices.ValidatorPrices { idx, ok := currentFeedsMap[p.SignalID] @@ -171,7 +171,7 @@ func (ms msgServer) SubmitSignalPrices( emitEventSubmitSignalPrice(ctx, val, newValidatorPrices[idx]) } - if err := ms.SetValidatorPriceList(ctx, val, newValidatorPrices); err != nil { + if err := k.Keeper.SetValidatorPriceList(ctx, val, newValidatorPrices); err != nil { return nil, err } @@ -179,14 +179,14 @@ func (ms msgServer) SubmitSignalPrices( } // UpdateReferenceSourceConfig updates reference source configuration. -func (ms msgServer) UpdateReferenceSourceConfig( +func (k msgServer) UpdateReferenceSourceConfig( goCtx context.Context, msg *types.MsgUpdateReferenceSourceConfig, ) (*types.MsgUpdateReferenceSourceConfigResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check if the request is from the admin - admin := ms.GetParams(ctx).Admin + admin := k.Keeper.GetParams(ctx).Admin if admin != msg.Admin { return nil, types.ErrInvalidSigner.Wrapf( "invalid admin; expected %s, got %s", @@ -196,7 +196,7 @@ func (ms msgServer) UpdateReferenceSourceConfig( } // update the reference source configuration - if err := ms.SetReferenceSourceConfig(ctx, msg.ReferenceSourceConfig); err != nil { + if err := k.Keeper.SetReferenceSourceConfig(ctx, msg.ReferenceSourceConfig); err != nil { return nil, err } @@ -206,23 +206,23 @@ func (ms msgServer) UpdateReferenceSourceConfig( } // UpdateParams updates the feeds module params. -func (ms msgServer) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, msg *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check if the request is from the authority - if ms.GetAuthority() != msg.Authority { + if k.Keeper.GetAuthority() != msg.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - ms.GetAuthority(), + k.Keeper.GetAuthority(), msg.Authority, ) } // update the parameters - if err := ms.SetParams(ctx, msg.Params); err != nil { + if err := k.Keeper.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/feeds/tss_handler.go b/x/feeds/tss_handler.go index 0a38ffbcd..14313180b 100644 --- a/x/feeds/tss_handler.go +++ b/x/feeds/tss_handler.go @@ -23,7 +23,7 @@ func NewSignatureOrderHandler(k keeper.Keeper) tsstypes.Handler { prices := k.GetPrices(ctx, c.SignalIDs) - return types.EncodeTss(prices, ctx.BlockTime().Unix(), c.Encoder) + return types.EncodeTSS(prices, ctx.BlockTime().Unix(), c.Encoder) default: return nil, sdkerrors.ErrUnknownRequest.Wrapf( "unrecognized tss request signature type: %s", diff --git a/x/feeds/types/encoding_tss.go b/x/feeds/types/encoding_tss.go index 8b04e23e8..5a547f3e8 100644 --- a/x/feeds/types/encoding_tss.go +++ b/x/feeds/types/encoding_tss.go @@ -25,20 +25,20 @@ var ( } ) -// TssPrice represents the price data to be encoded for encoding abi -type TssPrice struct { +// TSSPrice represents the price data to be encoded for encoding abi +type TSSPrice struct { SignalID [32]byte Price uint64 } -// NewTssPrice creates a new EncodingPrice instance -func NewTssPrice(signalID [32]byte, price uint64) TssPrice { - return TssPrice{SignalID: signalID, Price: price} +// NewTSSPrice creates a new EncodingPrice instance +func NewTSSPrice(signalID [32]byte, price uint64) TSSPrice { + return TSSPrice{SignalID: signalID, Price: price} } -// ToTssTickPrices converts a list of prices to TssPrice -func ToTssPrices(prices []Price) ([]TssPrice, error) { - tssPrices := make([]TssPrice, 0, len(prices)) +// ToTSSPrices converts a list of prices to TSSPrice +func ToTSSPrices(prices []Price) ([]TSSPrice, error) { + tssPrices := make([]TSSPrice, 0, len(prices)) for _, price := range prices { signalID, err := StringToBytes32(price.SignalID) @@ -46,15 +46,15 @@ func ToTssPrices(prices []Price) ([]TssPrice, error) { return nil, ErrInvalidSignal.Wrapf("invalid signal id %s: %s", price.SignalID, err) } - tssPrices = append(tssPrices, NewTssPrice(signalID, price.Price)) + tssPrices = append(tssPrices, NewTSSPrice(signalID, price.Price)) } return tssPrices, nil } -// ToTssTickPrices converts a list of prices to TssPrice with price converted to tick -func ToTssTickPrices(prices []Price) ([]TssPrice, error) { - tssPrices := make([]TssPrice, 0, len(prices)) +// ToTSSTickPrices converts a list of prices to TSSPrice with price converted to tick +func ToTSSTickPrices(prices []Price) ([]TSSPrice, error) { + tssPrices := make([]TSSPrice, 0, len(prices)) for _, price := range prices { signalID, err := StringToBytes32(price.SignalID) @@ -70,17 +70,17 @@ func ToTssTickPrices(prices []Price) ([]TssPrice, error) { } } - tssPrices = append(tssPrices, NewTssPrice(signalID, p)) + tssPrices = append(tssPrices, NewTSSPrice(signalID, p)) } return tssPrices, nil } -// EncodeTss encodes the feed prices to tss message -func EncodeTss(prices []Price, timestamp int64, encoder Encoder) ([]byte, error) { +// EncodeTSS encodes the feed prices to tss message +func EncodeTSS(prices []Price, timestamp int64, encoder Encoder) ([]byte, error) { switch encoder { case ENCODER_FIXED_POINT_ABI: - tssPrices, err := ToTssPrices(prices) + tssPrices, err := ToTSSPrices(prices) if err != nil { return nil, err } @@ -92,7 +92,7 @@ func EncodeTss(prices []Price, timestamp int64, encoder Encoder) ([]byte, error) return append([]byte(EncoderFixedPointABIPrefix), bz...), nil case ENCODER_TICK_ABI: - tssTickPrices, err := ToTssTickPrices(prices) + tssTickPrices, err := ToTSSTickPrices(prices) if err != nil { return nil, err } diff --git a/x/feeds/types/encoding_tss_test.go b/x/feeds/types/encoding_tss_test.go index 100d4c3de..dd08e23b0 100644 --- a/x/feeds/types/encoding_tss_test.go +++ b/x/feeds/types/encoding_tss_test.go @@ -20,7 +20,7 @@ func TestPriceEncoderEncodingABI(t *testing.T) { {SignalID: "testSignal", Price: 100, Status: types.PRICE_STATUS_AVAILABLE}, } - result, err := types.EncodeTss(prices, 123456789, types.ENCODER_FIXED_POINT_ABI) + result, err := types.EncodeTSS(prices, 123456789, types.ENCODER_FIXED_POINT_ABI) require.NoError(t, err) expected := "cba0ad5a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000746573745369676e616c0000000000000000000000000000000000000000000000000000000000000064" @@ -32,14 +32,14 @@ func TestTickPriceEncoderEncodingABI(t *testing.T) { {SignalID: "testSignal", Price: 1e10, Status: types.PRICE_STATUS_AVAILABLE}, } - result, err := types.EncodeTss(prices, 123456789, types.ENCODER_TICK_ABI) + result, err := types.EncodeTSS(prices, 123456789, types.ENCODER_TICK_ABI) require.NoError(t, err) expected := "db99b2b3000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000746573745369676e616c00000000000000000000000000000000000000000000000000000000000459f3" require.Equal(t, expected, hex.EncodeToString(result)) } -func TestTssTick(t *testing.T) { +func TestTSSTick(t *testing.T) { signalIDAtom, err := types.StringToBytes32("CS:ATOM-USD") require.NoError(t, err) @@ -50,7 +50,7 @@ func TestTssTick(t *testing.T) { testCases := []struct { name string prices []types.Price - expectResult []types.TssPrice + expectResult []types.TSSPrice expectError error }{ { @@ -69,7 +69,7 @@ func TestTssTick(t *testing.T) { Status: types.PRICE_STATUS_AVAILABLE, }, }, - expectResult: []types.TssPrice{ + expectResult: []types.TSSPrice{ {SignalID: signalIDAtom, Price: 1e10}, {SignalID: signalIDBand, Price: 1e8}, }, @@ -91,7 +91,7 @@ func TestTssTick(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - encoderPrices, err := types.ToTssPrices(tc.prices) + encoderPrices, err := types.ToTSSPrices(tc.prices) // Check the result if tc.expectError != nil { @@ -104,7 +104,7 @@ func TestTssTick(t *testing.T) { } } -func TestToTssTickPrices(t *testing.T) { +func TestToTSSTickPrices(t *testing.T) { signalIDAtom, err := types.StringToBytes32("CS:ATOM-USD") require.NoError(t, err) @@ -116,7 +116,7 @@ func TestToTssTickPrices(t *testing.T) { name string prices []types.Price encoder types.Encoder - expectResult []types.TssPrice + expectResult []types.TSSPrice expectError error }{ { @@ -136,7 +136,7 @@ func TestToTssTickPrices(t *testing.T) { }, }, encoder: types.ENCODER_TICK_ABI, - expectResult: []types.TssPrice{ + expectResult: []types.TSSPrice{ {SignalID: signalIDAtom, Price: 285171}, {SignalID: signalIDBand, Price: 239116}, }, @@ -159,7 +159,7 @@ func TestToTssTickPrices(t *testing.T) { }, }, encoder: types.ENCODER_FIXED_POINT_ABI, - expectResult: []types.TssPrice{ + expectResult: []types.TSSPrice{ {SignalID: signalIDAtom, Price: 0}, {SignalID: signalIDBand, Price: 239116}, }, @@ -180,7 +180,7 @@ func TestToTssTickPrices(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - encoderPrices, err := types.ToTssTickPrices(tc.prices) + encoderPrices, err := types.ToTSSTickPrices(tc.prices) // Check the result if tc.expectError != nil { diff --git a/x/feeds/types/signature_order.go b/x/feeds/types/signature_order.go index 050fc0a0f..4e4de77e6 100644 --- a/x/feeds/types/signature_order.go +++ b/x/feeds/types/signature_order.go @@ -4,7 +4,7 @@ import tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" // signature order types const ( - SignatureOrderTypeFeeds = "Feeds" + SignatureOrderTypeFeeds = "feeds" ) // Implements Content Interface @@ -18,7 +18,7 @@ func NewFeedSignatureOrder(signalIDs []string, encoder Encoder) *FeedsSignatureO // OrderRoute returns the order router key func (f *FeedsSignatureOrder) OrderRoute() string { return RouterKey } -// OrderType returns type of signature order that should be "Feeds" +// OrderType returns type of signature order that should be "feeds" func (f *FeedsSignatureOrder) OrderType() string { return SignatureOrderTypeFeeds } diff --git a/x/oracle/ibc_module.go b/x/oracle/ibc_module.go index ca7dbf72c..02a2766c6 100644 --- a/x/oracle/ibc_module.go +++ b/x/oracle/ibc_module.go @@ -143,7 +143,7 @@ func (im IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, - _ string, + counterpartyChannelID string, counterpartyVersion string, ) error { if counterpartyVersion != types.Version { diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index e8c634505..5ff8807aa 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -45,6 +45,7 @@ type KeeperTestSuite struct { rollingseedKeeper *oracletestutil.MockRollingseedKeeper bandtssKeeper *oracletestutil.MockBandtssKeeper + key storetypes.StoreKey queryClient types.QueryClient msgServer types.MsgServer @@ -74,6 +75,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.rollingseedKeeper = oracletestutil.NewMockRollingseedKeeper(ctrl) suite.bandtssKeeper = oracletestutil.NewMockBandtssKeeper(ctrl) + suite.key = key suite.homeDir = testutil.GetTempDir(suite.T()) suite.fileDir = filepath.Join(suite.homeDir, "files") diff --git a/x/oracle/keeper/result.go b/x/oracle/keeper/result.go index 0379b223a..5cd8933c9 100644 --- a/x/oracle/keeper/result.go +++ b/x/oracle/keeper/result.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - ctxcache "github.com/bandprotocol/chain/v3/pkg/ctxcache" + bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" "github.com/bandprotocol/chain/v3/x/oracle/types" ) @@ -81,40 +81,57 @@ func (k Keeper) ResolveSuccess( return } - // handle signing content - createSigningFunc := func(ctx sdk.Context) error { - signingID, err := k.bandtssKeeper.CreateDirectSigningRequest( - ctx, - types.NewOracleResultSignatureOrder(id, encoder), - "", - sdk.MustAccAddressFromBech32(requester), - feeLimit, - ) - if err != nil { - return err - } + signingID, err := k.safeCreateSigning(ctx, id, requester, feeLimit, encoder) + if err != nil { + k.handleCreateSigningFailed(ctx, id, event, err) + return + } - // save signing result and emit an event. - signingResult := &types.SigningResult{ - SigningID: signingID, - } - k.SetSigningResult(ctx, id, *signingResult) + // save signing result and emit an event. + signingResult := &types.SigningResult{ + SigningID: signingID, + } + k.SetSigningResult(ctx, id, *signingResult) - event = event.AppendAttributes( - sdk.NewAttribute(types.AttributeKeySigningID, fmt.Sprintf("%d", signingID)), - ) + event = event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeySigningID, fmt.Sprintf("%d", signingID)), + ) + ctx.EventManager().EmitEvent(event) +} - return nil +// safeCreateSigning creates a signing request for the given request ID. +func (k Keeper) safeCreateSigning( + ctx sdk.Context, + id types.RequestID, + requester string, + feeLimit sdk.Coins, + encoder types.Encoder, +) (signingID bandtsstypes.SigningID, err error) { + defer func() { + if r := recover(); r != nil { + ctx.Logger().Error(fmt.Sprintf("Panic recovered: %v", r)) + err = types.ErrCreateSigningPanic + } + }() + + cacheCtx, writeFn := ctx.CacheContext() + signingID, err = k.bandtssKeeper.CreateDirectSigningRequest( + cacheCtx, + types.NewOracleResultSignatureOrder(id, encoder), + "", + sdk.MustAccAddressFromBech32(requester), + feeLimit, + ) + if err != nil { + return 0, err } - if err := ctxcache.ApplyFuncIfNoError(ctx, createSigningFunc); err != nil { - k.handleCreateSigningFailed(ctx, id, event, err) - return - } + writeFn() - ctx.EventManager().EmitEvent(event) + return signingID, nil } +// handleCreateSigningFailed handles the failure of creating a signing request by sett. func (k Keeper) handleCreateSigningFailed( ctx sdk.Context, id types.RequestID, diff --git a/x/oracle/keeper/result_test.go b/x/oracle/keeper/result_test.go index 799a8f673..f09bedf37 100644 --- a/x/oracle/keeper/result_test.go +++ b/x/oracle/keeper/result_test.go @@ -1,10 +1,14 @@ package keeper_test import ( + "go.uber.org/mock/gomock" + sdk "github.com/cosmos/cosmos-sdk/types" bandtesting "github.com/bandprotocol/chain/v3/testing" + bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" "github.com/bandprotocol/chain/v3/x/oracle/types" + tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" ) func (suite *KeeperTestSuite) TestResultBasicFunctions() { @@ -69,6 +73,132 @@ func (suite *KeeperTestSuite) TestResolveSuccess() { )}, ctx.EventManager().Events()) } +func (suite *KeeperTestSuite) TestResolveSuccessButInsufficientMember() { + ctx := suite.ctx + k := suite.oracleKeeper + require := suite.Require() + request := defaultRequest() + request.TSSEncoder = types.ENCODER_FULL_ABI + + k.SetRequest(ctx, 42, request) // See report_test.go + k.SetReport(ctx, 42, types.NewReport(validators[0].Address, true, nil)) + + suite.bandtssKeeper.EXPECT().CreateDirectSigningRequest( + gomock.Any(), + types.NewOracleResultSignatureOrder(42, types.ENCODER_FULL_ABI), + "", + sdk.MustAccAddressFromBech32(request.Requester), + request.FeeLimit, + ).DoAndReturn(func( + ctx sdk.Context, + content *types.OracleResultSignatureOrder, + memo string, + sender sdk.AccAddress, + feeLimit sdk.Coins, + ) (bandtsstypes.SigningID, error) { + ctx.KVStore(suite.key).Set([]byte{0xff, 0xff}, []byte("test")) + return 0, tsstypes.ErrInsufficientSigners + }) + + k.ResolveSuccess( + ctx, + 42, + request.Requester, + request.FeeLimit, + basicResult, + 1234, + request.TSSEncoder, + ) + + result := k.MustGetResult(ctx, 42) + require.Equal(types.RESOLVE_STATUS_SUCCESS, result.ResolveStatus) + require.Equal(basicResult, result.Result) + require.Equal(sdk.Events{ + sdk.NewEvent( + types.EventTypeHandleRequestSignFail, + sdk.NewAttribute(types.AttributeKeyID, "42"), + sdk.NewAttribute(types.AttributeKeyReason, "insufficient members for signing message"), + ), + sdk.NewEvent( + types.EventTypeResolve, + sdk.NewAttribute(types.AttributeKeyID, "42"), + sdk.NewAttribute(types.AttributeKeyResolveStatus, "1"), + sdk.NewAttribute(types.AttributeKeyResult, "42415349435f524553554c54"), // BASIC_RESULT + sdk.NewAttribute(types.AttributeKeyGasUsed, "1234"), + sdk.NewAttribute(types.AttributeKeySigningErrCodespace, "tss"), + sdk.NewAttribute(types.AttributeKeySigningErrCode, "22"), + ), + }, ctx.EventManager().Events()) + + // Check the signing request is saved correctly. + require.Nil(ctx.KVStore(suite.key).Get([]byte{0xff, 0xff})) + signingResult, err := k.GetSigningResult(ctx, 42) + require.NoError(err) + require.Equal(types.SigningResult{ + SigningID: 0, + ErrorCodespace: "tss", + ErrorCode: 22, + }, signingResult) +} + +func (suite *KeeperTestSuite) TestResolveSuccessAndGetSigningID() { + ctx := suite.ctx + k := suite.oracleKeeper + require := suite.Require() + request := defaultRequest() + request.TSSEncoder = types.ENCODER_FULL_ABI + + k.SetRequest(ctx, 42, request) // See report_test.go + k.SetReport(ctx, 42, types.NewReport(validators[0].Address, true, nil)) + + suite.bandtssKeeper.EXPECT().CreateDirectSigningRequest( + gomock.Any(), + types.NewOracleResultSignatureOrder(42, types.ENCODER_FULL_ABI), + "", + sdk.MustAccAddressFromBech32(request.Requester), + request.FeeLimit, + ).DoAndReturn(func( + ctx sdk.Context, + content *types.OracleResultSignatureOrder, + memo string, + sender sdk.AccAddress, + feeLimit sdk.Coins, + ) (bandtsstypes.SigningID, error) { + ctx.KVStore(suite.key).Set([]byte{0xff, 0xff}, []byte("test")) + return bandtsstypes.SigningID(1), nil + }) + + k.ResolveSuccess( + ctx, + 42, + request.Requester, + request.FeeLimit, + basicResult, + 1234, + request.TSSEncoder, + ) + + result := k.MustGetResult(ctx, 42) + require.Equal(types.RESOLVE_STATUS_SUCCESS, result.ResolveStatus) + require.Equal(basicResult, result.Result) + require.Equal(sdk.Events{ + sdk.NewEvent( + types.EventTypeResolve, + sdk.NewAttribute(types.AttributeKeyID, "42"), + sdk.NewAttribute(types.AttributeKeyResolveStatus, "1"), + sdk.NewAttribute(types.AttributeKeyResult, "42415349435f524553554c54"), // BASIC_RESULT + sdk.NewAttribute(types.AttributeKeyGasUsed, "1234"), + sdk.NewAttribute(types.AttributeKeySigningID, "1"), + ), + }, ctx.EventManager().Events()) + + // Check the signing request is saved correctly. + require.Equal([]byte("test"), ctx.KVStore(suite.key).Get([]byte{0xff, 0xff})) + signingResult, err := k.GetSigningResult(ctx, 42) + require.NoError(err) + require.Equal(types.SigningResult{SigningID: 1}, signingResult) +} + func (suite *KeeperTestSuite) TestResolveFailure() { ctx := suite.ctx k := suite.oracleKeeper diff --git a/x/oracle/tss_handler.go b/x/oracle/tss_handler.go index 8e1910757..be79a781a 100644 --- a/x/oracle/tss_handler.go +++ b/x/oracle/tss_handler.go @@ -4,22 +4,15 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - tsslib "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/oracle/keeper" "github.com/bandprotocol/chain/v3/x/oracle/types" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" ) -var ( - // EncoderProtoPrefix is the prefix for proto encoding type - // The value is tss.Hash([]byte("proto"))[:4] - EncoderProtoPrefix = tsslib.Hash([]byte("proto"))[:4] - // EncoderFullABIPrefix is the prefix for full ABI encoding type - // The value is tss.Hash([]byte("fullABI"))[:4] - EncoderFullABIPrefix = tsslib.Hash([]byte("fullABI"))[:4] - // EncoderPartialABIPrefix is the prefix for partial ABI encoding type - // The value is tss.Hash([]byte("partialABI"))[:4] - EncoderPartialABIPrefix = tsslib.Hash([]byte("partialABI"))[:4] +const ( + EncoderProtoPrefix = "\x01\xe2\xad\xb3" // tss.Hash([]byte("Proto"))[:4] + EncoderFullABIPrefix = "\x45\xb4\xe7\xea" // tss.Hash([]byte("FullABI"))[:4] + EncoderPartialABIPrefix = "\x7b\xae\x7c\xd8" // tss.Hash([]byte("PartialABI"))[:4] ) // NewSignatureOrderHandler creates a tss handler to handle oracle result signature order @@ -39,21 +32,21 @@ func NewSignatureOrderHandler(k keeper.Keeper) tsstypes.Handler { return nil, err } - return append(EncoderProtoPrefix, bz...), nil + return append([]byte(EncoderProtoPrefix), bz...), nil case types.ENCODER_FULL_ABI: bz, err := result.PackFullABI() if err != nil { return nil, err } - return append(EncoderFullABIPrefix, bz...), nil + return append([]byte(EncoderFullABIPrefix), bz...), nil case types.ENCODER_PARTIAL_ABI: bz, err := result.PackPartialABI() if err != nil { return nil, err } - return append(EncoderPartialABIPrefix, bz...), nil + return append([]byte(EncoderPartialABIPrefix), bz...), nil default: return nil, sdkerrors.ErrUnknownRequest.Wrapf( "unrecognized encoder type: %d", diff --git a/x/oracle/tss_handler_test.go b/x/oracle/tss_handler_test.go new file mode 100644 index 000000000..2f2d04782 --- /dev/null +++ b/x/oracle/tss_handler_test.go @@ -0,0 +1,16 @@ +package oracle_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/bandprotocol/chain/v3/pkg/tss" + "github.com/bandprotocol/chain/v3/x/oracle" +) + +func TestEncoderPrefix(t *testing.T) { + require.Equal(t, []byte(oracle.EncoderProtoPrefix), tss.Hash([]byte("Proto"))[:4]) + require.Equal(t, []byte(oracle.EncoderFullABIPrefix), tss.Hash([]byte("FullABI"))[:4]) + require.Equal(t, []byte(oracle.EncoderPartialABIPrefix), tss.Hash([]byte("PartialABI"))[:4]) +} diff --git a/x/oracle/types/error.go b/x/oracle/types/error.go index 8d3eb7dd0..b88be2fb4 100644 --- a/x/oracle/types/error.go +++ b/x/oracle/types/error.go @@ -52,6 +52,7 @@ var ( ErrSigningResultNotFound = errorsmod.Register(ModuleName, 46, "signing result not found") ErrInvalidRequestID = errorsmod.Register(ModuleName, 47, "invalid request id") ErrInvalidOracleEncoder = errorsmod.Register(ModuleName, 48, "invalid oracle encoder") + ErrCreateSigningPanic = errorsmod.Register(ModuleName, 49, "panic in creating tss signing") ) // WrapMaxError wraps an error message with additional info of the current and max values. diff --git a/x/oracle/types/signature_order.go b/x/oracle/types/signature_order.go index 518484dc4..1c104ea7f 100644 --- a/x/oracle/types/signature_order.go +++ b/x/oracle/types/signature_order.go @@ -4,7 +4,7 @@ import tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" // signature order types const ( - SignatureOrderTypeOracleResult = "OracleResult" + SignatureOrderTypeOracle = "oracle" ) // Implements Content Interface @@ -18,9 +18,9 @@ func NewOracleResultSignatureOrder(rid RequestID, encoder Encoder) *OracleResult // OrderRoute returns the order router key func (o *OracleResultSignatureOrder) OrderRoute() string { return RouterKey } -// OrderType returns type of signature order that should be "OracleResult" +// OrderType returns type of signature order that should be "oracle" func (o *OracleResultSignatureOrder) OrderType() string { - return SignatureOrderTypeOracleResult + return SignatureOrderTypeOracle } // IsInternal returns false for OracleResultSignatureOrder (allow user to submit this content type). diff --git a/x/restake/keeper/msg_server.go b/x/restake/keeper/msg_server.go index 476a5fd37..2a0bbdd56 100644 --- a/x/restake/keeper/msg_server.go +++ b/x/restake/keeper/msg_server.go @@ -35,7 +35,7 @@ func (k msgServer) Stake( // check if all coins are allowed denom coins. allowedDenom := make(map[string]bool) - for _, denom := range k.GetParams(ctx).AllowedDenoms { + for _, denom := range k.Keeper.GetParams(ctx).AllowedDenoms { allowedDenom[denom] = true } @@ -50,9 +50,9 @@ func (k msgServer) Stake( return nil, err } - stake := k.GetStake(ctx, addr) + stake := k.Keeper.GetStake(ctx, addr) stake.Coins = stake.Coins.Add(msg.Coins...) - k.SetStake(ctx, stake) + k.Keeper.SetStake(ctx, stake) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -79,25 +79,25 @@ func (k msgServer) Unstake( // reduce staked coins. return error if unstake more than staked coins var isNeg bool - stake := k.GetStake(ctx, addr) + stake := k.Keeper.GetStake(ctx, addr) stake.Coins, isNeg = stake.Coins.SafeSub(msg.Coins...) if isNeg { return nil, types.ErrStakeNotEnough } if !stake.Coins.IsZero() { - k.SetStake(ctx, stake) + k.Keeper.SetStake(ctx, stake) } else { - k.DeleteStake(ctx, addr) + k.Keeper.DeleteStake(ctx, addr) } - totalPower, err := k.GetTotalPower(ctx, addr) + totalPower, err := k.Keeper.GetTotalPower(ctx, addr) if err != nil { return nil, err } // check if total power is still more than locked power after unstaking. - if !k.isValidPower(ctx, addr, totalPower) { + if !k.Keeper.isValidPower(ctx, addr, totalPower) { return nil, types.ErrUnableToUnstake.Wrap("power is locked") } @@ -124,15 +124,15 @@ func (k msgServer) UpdateParams( ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if k.GetAuthority() != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - k.GetAuthority(), + k.Keeper.GetAuthority(), req.Authority, ) } - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/tss/keeper/grpc_query.go b/x/tss/keeper/grpc_query.go index 2e2b3ff75..2f2c0425e 100644 --- a/x/tss/keeper/grpc_query.go +++ b/x/tss/keeper/grpc_query.go @@ -136,7 +136,7 @@ func (q queryServer) DE(goCtx context.Context, req *types.QueryDERequest) (*type return nil }) if err != nil { - return nil, types.ErrInvalidArgument.Wrapf("paginate: %v", err) + return nil, status.Error(codes.Internal, err.Error()) } return &types.QueryDEResponse{ diff --git a/x/tss/keeper/keeper_de.go b/x/tss/keeper/keeper_de.go index 5cd2689be..82483ff47 100644 --- a/x/tss/keeper/keeper_de.go +++ b/x/tss/keeper/keeper_de.go @@ -15,9 +15,11 @@ import ( // them into the queue. It returns an error if the DE size exceeds the maximum limit. func (k Keeper) EnqueueDEs(ctx sdk.Context, address sdk.AccAddress, des []types.DE) error { deQueue := k.GetDEQueue(ctx, address) - cnt := deQueue.Tail - deQueue.Head - if cnt+uint64(len(des)) > k.GetParams(ctx).MaxDESize { - return types.ErrDEReachMaxLimit.Wrapf("DE size exceeds %d", k.GetParams(ctx).MaxDESize) + total := deQueue.Tail - deQueue.Head + uint64(len(des)) + + maxDESize := k.GetParams(ctx).MaxDESize + if total > maxDESize { + return types.ErrDELimitExceeded.Wrapf("DE size exceeds %d; total %d", maxDESize, total) } for i, de := range des { @@ -34,7 +36,7 @@ func (k Keeper) EnqueueDEs(ctx sdk.Context, address sdk.AccAddress, des []types. func (k Keeper) DequeueDE(ctx sdk.Context, address sdk.AccAddress) (types.DE, error) { deQueue := k.GetDEQueue(ctx, address) if deQueue.Head >= deQueue.Tail { - return types.DE{}, types.ErrDENotFound.Wrapf("DE not found for address %s", address) + return types.DE{}, types.ErrDENotFound.Wrapf("no existing DE for address %s", address) } de, err := k.GetDE(ctx, address, deQueue.Head) diff --git a/x/tss/keeper/keeper_group.go b/x/tss/keeper/keeper_group.go index 1036003b3..340eff957 100644 --- a/x/tss/keeper/keeper_group.go +++ b/x/tss/keeper/keeper_group.go @@ -46,9 +46,25 @@ func (k Keeper) CreateGroup( ) (tss.GroupID, error) { // Validate group size groupSize := uint64(len(members)) + if groupSize == 0 { + return 0, types.ErrGroupCreationFailed.Wrapf("group size must be greater than 0") + } + maxGroupSize := k.GetParams(ctx).MaxGroupSize if groupSize > maxGroupSize { - return 0, types.ErrGroupSizeTooLarge.Wrap(fmt.Sprintf("group size exceeds %d", maxGroupSize)) + return 0, types.ErrGroupCreationFailed.Wrapf( + "the given group size (%d) exceeds the limit (%d)", groupSize, maxGroupSize, + ) + } + + // Validate duplicate members + seenAddresses := make(map[string]bool) + for _, addr := range members { + if seenAddresses[addr.String()] { + return 0, types.ErrInvalidGroup.Wrapf("duplicate member address: %s", addr) + } + + seenAddresses[addr.String()] = true } // add new group @@ -132,7 +148,7 @@ func (k Keeper) GetGroupResponse( func (k Keeper) GetGroup(ctx sdk.Context, groupID tss.GroupID) (types.Group, error) { bz := ctx.KVStore(k.storeKey).Get(types.GroupStoreKey(groupID)) if bz == nil { - return types.Group{}, types.ErrGroupNotFound.Wrapf("failed to get group with groupID: %d", groupID) + return types.Group{}, types.ErrGroupNotFound.Wrapf("failed to get groupID: %d", groupID) } var group types.Group @@ -161,9 +177,10 @@ func (k Keeper) GetGroupsIterator(ctx sdk.Context) dbm.Iterator { // GetGroups retrieves all group of the store. func (k Keeper) GetGroups(ctx sdk.Context) []types.Group { - var groups []types.Group iterator := k.GetGroupsIterator(ctx) defer iterator.Close() + + var groups []types.Group for ; iterator.Valid(); iterator.Next() { var group types.Group k.cdc.MustUnmarshal(iterator.Value(), &group) diff --git a/x/tss/keeper/keeper_group_round1.go b/x/tss/keeper/keeper_group_round1.go index ff7b724ad..9abe83714 100644 --- a/x/tss/keeper/keeper_group_round1.go +++ b/x/tss/keeper/keeper_group_round1.go @@ -27,8 +27,9 @@ func (k Keeper) AddCoefficientCommits( total, err := tss.SumPoints(points...) if err != nil { - return err + return types.ErrAddCoeffCommit.Wrapf("failed to sum points: %s", err) } + k.SetAccumulatedCommit(ctx, groupID, uint64(i), total) } @@ -49,7 +50,7 @@ func (k Keeper) ValidateRound1Info( // Get dkg-context dkgContext, err := k.GetDKGContext(ctx, group.ID) if err != nil { - return types.ErrDKGContextNotFound.Wrap("dkg-context is not found") + return err } // Verify one time signature @@ -60,7 +61,7 @@ func (k Keeper) ValidateRound1Info( round1Info.OneTimePubKey, ) if err != nil { - return types.ErrVerifyOneTimeSignatureFailed.Wrap(err.Error()) + return types.ErrVerifyOneTimeSignatureFailed.Wrapf("failed to verify one time signature: %v", err) } // Verify A0 signature @@ -71,7 +72,7 @@ func (k Keeper) ValidateRound1Info( round1Info.CoefficientCommits[0], ) if err != nil { - return types.ErrVerifyA0SignatureFailed.Wrap(err.Error()) + return types.ErrVerifyA0SignatureFailed.Wrapf("failed to verify A0 signature: %v", err) } return nil @@ -105,11 +106,12 @@ func (k Keeper) GetRound1Info(ctx sdk.Context, groupID tss.GroupID, memberID tss bz := ctx.KVStore(k.storeKey).Get(types.Round1InfoStoreKey(groupID, memberID)) if bz == nil { return types.Round1Info{}, types.ErrRound1InfoNotFound.Wrapf( - "failed to get round1Info with groupID: %d and memberID %d", + "failed to get round1Info for groupID: %d and memberID %d", groupID, memberID, ) } + var r1 types.Round1Info k.cdc.MustUnmarshal(bz, &r1) return r1, nil @@ -122,14 +124,16 @@ func (k Keeper) GetRound1InfoIterator(ctx sdk.Context, groupID tss.GroupID) dbm. // GetRound1Infos retrieves round1Infos for a group from the store. func (k Keeper) GetRound1Infos(ctx sdk.Context, groupID tss.GroupID) []types.Round1Info { - var round1Infos []types.Round1Info iterator := k.GetRound1InfoIterator(ctx, groupID) defer iterator.Close() + + var round1Infos []types.Round1Info for ; iterator.Valid(); iterator.Next() { var round1Info types.Round1Info k.cdc.MustUnmarshal(iterator.Value(), &round1Info) round1Infos = append(round1Infos, round1Info) } + return round1Infos } @@ -183,12 +187,14 @@ func (k Keeper) GetAccumulatedCommit(ctx sdk.Context, groupID tss.GroupID, index // GetAllAccumulatedCommits retrieves all accumulated commits of a group from the store. func (k Keeper) GetAllAccumulatedCommits(ctx sdk.Context, groupID tss.GroupID) tss.Points { - var commits tss.Points iterator := k.GetAccumulatedCommitIterator(ctx, groupID) defer iterator.Close() + + var commits tss.Points for ; iterator.Valid(); iterator.Next() { commits = append(commits, iterator.Value()) } + return commits } diff --git a/x/tss/keeper/keeper_group_round2.go b/x/tss/keeper/keeper_group_round2.go index c1219bba3..5b9afcb7f 100644 --- a/x/tss/keeper/keeper_group_round2.go +++ b/x/tss/keeper/keeper_group_round2.go @@ -44,6 +44,7 @@ func (k Keeper) GetRound2Info(ctx sdk.Context, groupID tss.GroupID, memberID tss memberID, ) } + var r2 types.Round2Info k.cdc.MustUnmarshal(bz, &r2) return r2, nil @@ -85,13 +86,15 @@ func (k Keeper) GetRound2InfoIterator(ctx sdk.Context, groupID tss.GroupID) dbm. // GetRound2Infos retrieves all round2Info for a given group from the store. func (k Keeper) GetRound2Infos(ctx sdk.Context, groupID tss.GroupID) []types.Round2Info { - var round2Infos []types.Round2Info iterator := k.GetRound2InfoIterator(ctx, groupID) defer iterator.Close() + + var round2Infos []types.Round2Info for ; iterator.Valid(); iterator.Next() { var round2Info types.Round2Info k.cdc.MustUnmarshal(iterator.Value(), &round2Info) round2Infos = append(round2Infos, round2Info) } + return round2Infos } diff --git a/x/tss/keeper/keeper_group_round3.go b/x/tss/keeper/keeper_group_round3.go index cceccdd62..b20957366 100644 --- a/x/tss/keeper/keeper_group_round3.go +++ b/x/tss/keeper/keeper_group_round3.go @@ -113,7 +113,7 @@ func (k Keeper) VerifyComplaint( ) if err != nil { return types.ErrComplainFailed.Wrapf( - "failed to complaint member: %d with groupID: %d; %s", + "failed to complaint member: %d with groupID: %d; %v", complaint.Respondent, groupID, err, @@ -147,7 +147,7 @@ func (k Keeper) VerifyOwnPubKeySignature( err = tss.VerifyOwnPubKeySignature(memberID, dkgContext, ownPubKeySig, member.PubKey) if err != nil { return types.ErrConfirmFailed.Wrapf( - "failed to verify own public key with memberID: %d; %s", + "failed to verify own public key with memberID: %d; %v", memberID, err, ) @@ -210,6 +210,7 @@ func (k Keeper) GetComplaintsWithStatus( memberID, ) } + var c types.ComplaintsWithStatus k.cdc.MustUnmarshal(bz, &c) return c, nil @@ -225,14 +226,16 @@ func (k Keeper) GetComplainsWithStatusIterator(ctx sdk.Context, groupID tss.Grou // GetAllComplainsWithStatus retrieves all complaints with status for a given group from the store. func (k Keeper) GetAllComplainsWithStatus(ctx sdk.Context, groupID tss.GroupID) []types.ComplaintsWithStatus { - var cs []types.ComplaintsWithStatus iterator := k.GetComplainsWithStatusIterator(ctx, groupID) defer iterator.Close() + + var cs []types.ComplaintsWithStatus for ; iterator.Valid(); iterator.Next() { var c types.ComplaintsWithStatus k.cdc.MustUnmarshal(iterator.Value(), &c) cs = append(cs, c) } + return cs } @@ -292,6 +295,7 @@ func (k Keeper) GetConfirm( memberID, ) } + var c types.Confirm k.cdc.MustUnmarshal(bz, &c) return c, nil @@ -304,14 +308,16 @@ func (k Keeper) GetConfirmIterator(ctx sdk.Context, groupID tss.GroupID) dbm.Ite // GetConfirms retrieves all confirm for a given group from the store. func (k Keeper) GetConfirms(ctx sdk.Context, groupID tss.GroupID) []types.Confirm { - var cs []types.Confirm iterator := k.GetConfirmIterator(ctx, groupID) defer iterator.Close() + + var cs []types.Confirm for ; iterator.Valid(); iterator.Next() { var c types.Confirm k.cdc.MustUnmarshal(iterator.Value(), &c) cs = append(cs, c) } + return cs } diff --git a/x/tss/keeper/keeper_member.go b/x/tss/keeper/keeper_member.go index 277c54cad..00536a635 100644 --- a/x/tss/keeper/keeper_member.go +++ b/x/tss/keeper/keeper_member.go @@ -8,7 +8,6 @@ import ( storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/bandprotocol/chain/v3/pkg/bandrng" "github.com/bandprotocol/chain/v3/pkg/tss" @@ -27,35 +26,31 @@ func (k Keeper) GetMemberByAddress( } for _, member := range members { - if member.IsAddress(address) { + if member.Address == address { return member, nil } } return types.Member{}, types.ErrMemberNotFound.Wrapf( - "failed to get member with groupID: %d and address: %s", - groupID, - address, + "failed to get member address %s from groupID %d", address, groupID, ) } -// GetAvailableMembers retrieves all active members of a group from the store. -func (k Keeper) GetAvailableMembers(ctx sdk.Context, groupID tss.GroupID) ([]types.Member, error) { - var availableMembers []types.Member +// GetAvailableMembers retrieves all members in the given group that are active and have an existing DE. +func (k Keeper) GetAvailableMembers(ctx sdk.Context, groupID tss.GroupID) []types.Member { iterator := k.GetGroupMembersIterator(ctx, groupID) defer iterator.Close() + + var availableMembers []types.Member for ; iterator.Valid(); iterator.Next() { var member types.Member k.cdc.MustUnmarshal(iterator.Value(), &member) + if !member.IsActive { continue } - acc, err := sdk.AccAddressFromBech32(member.Address) - if err != nil { - return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid account address: %s", err) - } - + acc := sdk.MustAccAddressFromBech32(member.Address) if !k.HasDE(ctx, acc) { continue } @@ -63,10 +58,7 @@ func (k Keeper) GetAvailableMembers(ctx sdk.Context, groupID tss.GroupID) ([]typ availableMembers = append(availableMembers, member) } - if len(availableMembers) == 0 { - return nil, types.ErrNoActiveMember.Wrapf("no active member in groupID: %d", groupID) - } - return availableMembers, nil + return availableMembers } // GetRandomMembers select a random members from the given group for a signing process. @@ -83,14 +75,14 @@ func (k Keeper) GetRandomMembers( } // Get available members - members, err := k.GetAvailableMembers(ctx, groupID) - if err != nil { - return nil, err - } - + members := k.GetAvailableMembers(ctx, groupID) members_size := uint64(len(members)) if group.Threshold > members_size { - return nil, types.ErrInsufficientActiveMembers + return nil, types.ErrInsufficientSigners.Wrapf( + "the number of required signers %d is greater than available members %d", + group.Threshold, + members_size, + ) } // Create a deterministic random number generator (DRBG) using the rolling seed, signingID, and chain ID. @@ -100,7 +92,7 @@ func (k Keeper) GetRandomMembers( []byte(ctx.ChainID()), ) if err != nil { - return nil, types.ErrBadDrbgInitialization.Wrap(err.Error()) + return nil, types.ErrBadDrbgInitialization.Wrapf("fail to get rng: %v", err) } var selected []types.Member @@ -138,11 +130,9 @@ func (k Keeper) ValidateMemberID( return err } - if !member.IsAddress(address) { - return types.ErrMemberNotAuthorized.Wrapf( - "memberID %d address %s is not match in this group", - memberID, - address, + if member.Address != address { + return types.ErrInvalidMember.Wrapf( + "memberID %d doesn't match with address %s in groupID %d", memberID, address, groupID, ) } @@ -259,25 +249,29 @@ func (k Keeper) GetGroupMembersIterator(ctx sdk.Context, groupID tss.GroupID) db // GetGroupMembers retrieves all members of a group from the store. func (k Keeper) GetGroupMembers(ctx sdk.Context, groupID tss.GroupID) ([]types.Member, error) { - var members []types.Member iterator := k.GetGroupMembersIterator(ctx, groupID) defer iterator.Close() + + var members []types.Member for ; iterator.Valid(); iterator.Next() { var member types.Member k.cdc.MustUnmarshal(iterator.Value(), &member) members = append(members, member) } + if len(members) == 0 { return nil, types.ErrMemberNotFound.Wrapf("failed to get members with groupID: %d", groupID) } + return members, nil } // GetMembers retrieves all members from store. func (k Keeper) GetMembers(ctx sdk.Context) []types.Member { - var members []types.Member iterator := storetypes.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.MemberStoreKeyPrefix) defer iterator.Close() + + var members []types.Member for ; iterator.Valid(); iterator.Next() { var member types.Member k.cdc.MustUnmarshal(iterator.Value(), &member) diff --git a/x/tss/keeper/keeper_member_test.go b/x/tss/keeper/keeper_member_test.go index e64c50514..829972ebf 100644 --- a/x/tss/keeper/keeper_member_test.go +++ b/x/tss/keeper/keeper_member_test.go @@ -150,7 +150,7 @@ func (s *KeeperTestSuite) TestGetRandomMembersInsufficientActiveMembers() { } _, err = k.GetRandomMembers(ctx, tss.GroupID(1), []byte("test_nonce")) - s.Require().ErrorIs(err, types.ErrInsufficientActiveMembers) + s.Require().ErrorIs(err, types.ErrInsufficientSigners) } func (s *KeeperTestSuite) TestGetRandomMembersNoActiveMember() { @@ -169,5 +169,5 @@ func (s *KeeperTestSuite) TestGetRandomMembersNoActiveMember() { } _, err = k.GetRandomMembers(ctx, tss.GroupID(1), []byte("test_nonce")) - s.Require().ErrorIs(err, types.ErrNoActiveMember) + s.Require().ErrorIs(err, types.ErrInsufficientSigners) } diff --git a/x/tss/keeper/keeper_signing.go b/x/tss/keeper/keeper_signing.go index f2e10077a..b130c90d6 100644 --- a/x/tss/keeper/keeper_signing.go +++ b/x/tss/keeper/keeper_signing.go @@ -22,10 +22,17 @@ func (k Keeper) RequestSigning( return 0, err } + // validate originator + params := k.GetParams(ctx) + if err := originator.Validate(params); err != nil { + return 0, err + } + // convert content to bytes if !k.contentRouter.HasRoute(content.OrderRoute()) { - return 0, types.ErrNoSignatureOrderHandlerExists.Wrap(content.OrderRoute()) + return 0, types.ErrHandlerNotFound.Wrapf("order route not found: %s", content.OrderRoute()) } + handler := k.contentRouter.GetRoute(content.OrderRoute()) contentMsg, err := handler(ctx, content) if err != nil { @@ -35,7 +42,7 @@ func (k Keeper) RequestSigning( // convert originator to bytes originatorBz, err := originator.Encode() if err != nil { - return 0, types.ErrEncodeOriginatorFailed + return 0, types.ErrEncodeOriginatorFailed.Wrapf("failed to encode originator: %v", err) } // create signing object @@ -44,6 +51,18 @@ func (k Keeper) RequestSigning( return 0, err } + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeCreateSigning, + sdk.NewAttribute(types.AttributeKeySigningID, fmt.Sprintf("%d", signingID)), + sdk.NewAttribute(types.AttributeKeyGroupID, fmt.Sprintf("%d", groupID)), + sdk.NewAttribute(types.AttributeKeyContentType, sdk.MsgTypeURL(content)), + sdk.NewAttribute(types.AttributeKeyContent, content.String()), + sdk.NewAttribute(types.AttributeKeyOriginatorType, sdk.MsgTypeURL(originator)), + sdk.NewAttribute(types.AttributeKeyOriginator, originator.String()), + sdk.NewAttribute(types.AttributeKeyEncodedOriginator, hex.EncodeToString(originatorBz)), + sdk.NewAttribute(types.AttributeKeyMessage, hex.EncodeToString(contentMsg)), + )) + // initiate new signing round if err = k.InitiateNewSigningRound(ctx, signingID); err != nil { return 0, err @@ -84,7 +103,9 @@ func (k Keeper) AssignMembersForSigning( assignedMembers.PubEs(), ) if err != nil { - return types.AssignedMembers{}, err + return types.AssignedMembers{}, types.ErrCreateSigningFailed.Wrapf( + "failed to compute commitment: %v", err, + ) } // Compute binding factor and public nonce of each assigned member @@ -92,8 +113,11 @@ func (k Keeper) AssignMembersForSigning( // Compute binding factor assignedMembers[i].BindingFactor, err = tss.ComputeOwnBindingFactor(member.MemberID, msg, commitment) if err != nil { - return types.AssignedMembers{}, err + return types.AssignedMembers{}, types.ErrCreateSigningFailed.Wrapf( + "failed to compute binding factor: %v", err, + ) } + // Compute own public nonce assignedMembers[i].PubNonce, err = tss.ComputeOwnPubNonce( member.PubD, @@ -101,7 +125,9 @@ func (k Keeper) AssignMembersForSigning( assignedMembers[i].BindingFactor, ) if err != nil { - return types.AssignedMembers{}, err + return types.AssignedMembers{}, types.ErrCreateSigningFailed.Wrapf( + "failed to compute own public nonce: %v", err, + ) } } @@ -125,7 +151,7 @@ func (k Keeper) CreateSigning( return 0, err } if group.Status != types.GROUP_STATUS_ACTIVE { - return 0, types.ErrGroupIsNotActive.Wrap("group status is not active") + return 0, types.ErrGroupIsNotActive.Wrapf("the status of groupID %d is not active", groupID) } // set new signing object @@ -159,7 +185,7 @@ func (k Keeper) InitiateNewSigningRound(ctx sdk.Context, signingID tss.SigningID signing.CurrentAttempt += 1 params := k.GetParams(ctx) if signing.CurrentAttempt > params.MaxSigningAttempt { - return types.ErrMaxSigningAttemptReached.Wrapf("signingID %d", signingID) + return types.ErrMaxSigningAttemptExceeded.Wrapf("signing ID %d reaches max attempt", signingID) } // assigned members within the context of the group. @@ -175,7 +201,7 @@ func (k Keeper) InitiateNewSigningRound(ctx sdk.Context, signingID tss.SigningID // Compute group public nonce for this signing groupPubNonce, err := tss.ComputeGroupPublicNonce(assignedMembers.PubNonces()...) if err != nil { - return err + return types.ErrCreateSigningFailed.Wrapf("failed to compute group public nonce: %v", err) } expiredHeight := uint64(ctx.BlockHeight()) + params.SigningPeriod @@ -196,7 +222,6 @@ func (k Keeper) InitiateNewSigningRound(ctx sdk.Context, signingID tss.SigningID types.EventTypeRequestSignature, sdk.NewAttribute(types.AttributeKeyGroupID, fmt.Sprintf("%d", signing.GroupID)), sdk.NewAttribute(types.AttributeKeySigningID, fmt.Sprintf("%d", signing.ID)), - sdk.NewAttribute(types.AttributeKeyMessage, hex.EncodeToString(signing.Message)), sdk.NewAttribute(types.AttributeKeyGroupPubNonce, hex.EncodeToString(signing.GroupPubNonce)), sdk.NewAttribute(types.AttributeKeyAttempt, fmt.Sprintf("%d", signing.CurrentAttempt)), ) diff --git a/x/tss/keeper/keeper_signing_endblock.go b/x/tss/keeper/keeper_signing_endblock.go index 05c0dd962..5e544ec16 100644 --- a/x/tss/keeper/keeper_signing_endblock.go +++ b/x/tss/keeper/keeper_signing_endblock.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/bandprotocol/chain/v3/pkg/ctxcache" "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/tss/types" ) @@ -26,16 +25,15 @@ func (k Keeper) HandleSigningEndBlock(ctx sdk.Context) { // check expired signing timeoutSigningIDs := k.HandleExpiredSignings(ctx) - // retry every failed and expired signings. + // retry every failed and expired signings; rollback and handle failed signing + // if any error occurred. retrySigningIDs = append(retrySigningIDs, timeoutSigningIDs...) for _, sid := range retrySigningIDs { - initiateNewSigningRound := func(ctx sdk.Context) error { - return k.InitiateNewSigningRound(ctx, sid) - } - - // try initiate new signing round; rollback and handle failed signing if any error occurred. - if err := ctxcache.ApplyFuncIfNoError(ctx, initiateNewSigningRound); err != nil { + cacheCtx, writeFn := ctx.CacheContext() + if err := k.InitiateNewSigningRound(cacheCtx, sid); err != nil { k.HandleFailedSigning(ctx, sid, err.Error()) + } else { + writeFn() } } } @@ -150,11 +148,11 @@ func (k Keeper) AggregatePartialSignatures(ctx sdk.Context, signingID tss.Signin sig, err := tss.CombineSignatures(partialSigs...) if err != nil { - return err + return types.ErrInvalidSignature.Wrapf("failed to combine partial signatures: %v", err) } if err = tss.VerifyGroupSigningSignature(signing.GroupPubKey, signing.Message, sig); err != nil { - return err + return types.ErrInvalidSignature.Wrapf("failed to verify group signature: %v", err) } // Set signing with signature and success status diff --git a/x/tss/keeper/keeper_signing_endblock_test.go b/x/tss/keeper/keeper_signing_endblock_test.go index b738aae25..c63a49d10 100644 --- a/x/tss/keeper/keeper_signing_endblock_test.go +++ b/x/tss/keeper/keeper_signing_endblock_test.go @@ -36,10 +36,17 @@ func (s *KeeperTestSuite) TestAggregatePartialSignatures() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")) + + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) @@ -70,10 +77,17 @@ func (s *KeeperTestSuite) TestHandleFailedSigning() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")) + + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) @@ -126,10 +140,16 @@ func (s *KeeperTestSuite) TestHandleSigningEndblockMembersSubmitSignature() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")).AnyTimes() + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) @@ -194,10 +214,16 @@ func (s *KeeperTestSuite) TestHandleSigningEndblockTimeoutSigning() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")).AnyTimes() + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) @@ -240,10 +266,16 @@ func (s *KeeperTestSuite) TestHandleSigningEndblockFailAggregate() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")).AnyTimes() + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) @@ -312,10 +344,16 @@ func (s *KeeperTestSuite) TestHandleSigningEndblockFailAggregateAndExpired() { s.rollingseedKeeper.EXPECT().GetRollingSeed(gomock.Any()). Return([]byte("RandomStringThatShouldBeLongEnough")).AnyTimes() + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, groupCtx.GroupID, - &types.DirectOriginator{}, + &originator, &types.TextSignatureOrder{Message: []byte("test")}, ) s.Require().NoError(err) diff --git a/x/tss/keeper/keeper_signing_partial_signature.go b/x/tss/keeper/keeper_signing_partial_signature.go index ec028ddce..9f7d17a18 100644 --- a/x/tss/keeper/keeper_signing_partial_signature.go +++ b/x/tss/keeper/keeper_signing_partial_signature.go @@ -89,8 +89,8 @@ func (k Keeper) GetPartialSignature( func (k Keeper) DeletePartialSignatures(ctx sdk.Context, signingID tss.SigningID, attempt uint64) { prefixKey := types.PartialSignaturesStoreKey(signingID, attempt) iterator := storetypes.KVStorePrefixIterator(ctx.KVStore(k.storeKey), prefixKey) - defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { ctx.KVStore(k.storeKey).Delete(iterator.Key()) } @@ -112,12 +112,14 @@ func (k Keeper) GetPartialSignatureBySigningAttemptIterator( // GetPartialSignatures retrieves all partial signatures for a specific signing ID of // the specific attempt from the store. func (k Keeper) GetPartialSignatures(ctx sdk.Context, signingID tss.SigningID, attempt uint64) tss.Signatures { - var pzs tss.Signatures iterator := k.GetPartialSignatureBySigningAttemptIterator(ctx, signingID, attempt) defer iterator.Close() + + var pzs tss.Signatures for ; iterator.Valid(); iterator.Next() { pzs = append(pzs, iterator.Value()) } + return pzs } @@ -128,10 +130,10 @@ func (k Keeper) GetPartialSignaturesWithKey( signingID tss.SigningID, attempt uint64, ) []types.PartialSignature { - var partialSigs []types.PartialSignature iterator := k.GetPartialSignatureBySigningAttemptIterator(ctx, signingID, attempt) - defer iterator.Close() + + var partialSigs []types.PartialSignature for ; iterator.Valid(); iterator.Next() { memberID := types.MemberIDFromPartialSignatureStoreKey(iterator.Key()) sig := iterator.Value() diff --git a/x/tss/keeper/keeper_signing_test.go b/x/tss/keeper/keeper_signing_test.go index 95afba360..615370c56 100644 --- a/x/tss/keeper/keeper_signing_test.go +++ b/x/tss/keeper/keeper_signing_test.go @@ -144,7 +144,7 @@ func (s *KeeperTestSuite) TestInitiateNewSigningRoundOverMaxAttempt() { k.SetSigning(ctx, signing) err = k.InitiateNewSigningRound(ctx, signingID) - s.Require().ErrorIs(err, types.ErrMaxSigningAttemptReached) + s.Require().ErrorIs(err, types.ErrMaxSigningAttemptExceeded) } func (s *KeeperTestSuite) TestRequestSigning() { @@ -159,7 +159,14 @@ func (s *KeeperTestSuite) TestRequestSigning() { // Create a new request for the request signature content := types.NewTextSignatureOrder([]byte("example")) - signingID, err := k.RequestSigning(ctx, groupID, &types.DirectOriginator{}, content) + + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + + signingID, err := k.RequestSigning(ctx, groupID, &originator, content) s.Require().NoError(err) signing, err := k.GetSigning(ctx, signingID) diff --git a/x/tss/keeper/msg_server.go b/x/tss/keeper/msg_server.go index cb98beca3..699a1a54e 100644 --- a/x/tss/keeper/msg_server.go +++ b/x/tss/keeper/msg_server.go @@ -37,35 +37,39 @@ func (k msgServer) SubmitDKGRound1( memberID := req.Round1Info.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } if group.Status != types.GROUP_STATUS_ROUND_1 { - return nil, types.ErrInvalidStatus.Wrap("group status is not round 1") + return nil, types.ErrInvalidGroupStatus.Wrapf("the status of groupID %d is not round 1", groupID) } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check previous submit - if k.HasRound1Info(ctx, groupID, req.Round1Info.MemberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit round 1") + if k.Keeper.HasRound1Info(ctx, groupID, req.Round1Info.MemberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit round 1 message", + memberID, + groupID, + ) } - if err := k.ValidateRound1Info(ctx, group, req.Round1Info); err != nil { + if err := k.Keeper.ValidateRound1Info(ctx, group, req.Round1Info); err != nil { return nil, err } // Add commits to calculate accumulated commits for each index - if err = k.AddCoefficientCommits(ctx, groupID, req.Round1Info.CoefficientCommits); err != nil { - return nil, types.ErrAddCoeffCommit.Wrap(err.Error()) + if err = k.Keeper.AddCoefficientCommits(ctx, groupID, req.Round1Info.CoefficientCommits); err != nil { + return nil, err } // Add round 1 info - k.AddRound1Info(ctx, groupID, req.Round1Info) + k.Keeper.AddRound1Info(ctx, groupID, req.Round1Info) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -81,9 +85,9 @@ func (k msgServer) SubmitDKGRound1( ) // Add to the pending process group if members submit their information. - count := k.GetRound1InfoCount(ctx, groupID) + count := k.Keeper.GetRound1InfoCount(ctx, groupID) if count == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgSubmitDKGRound1Response{}, nil @@ -103,22 +107,26 @@ func (k msgServer) SubmitDKGRound2( memberID := req.Round2Info.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } if group.Status != types.GROUP_STATUS_ROUND_2 { - return nil, types.ErrInvalidStatus.Wrap("group status is not round 2") + return nil, types.ErrInvalidGroupStatus.Wrapf("the status of groupID %d is not round 2", groupID) } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check previous submit - if k.HasRound2Info(ctx, groupID, memberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit round 2") + if k.Keeper.HasRound2Info(ctx, groupID, memberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit round 2 message", + memberID, + groupID, + ) } // Check encrypted secret shares length @@ -127,12 +135,12 @@ func (k msgServer) SubmitDKGRound2( } // Update member public key of the group. - if err := k.UpdateMemberPubKey(ctx, groupID, memberID); err != nil { + if err := k.Keeper.UpdateMemberPubKey(ctx, groupID, memberID); err != nil { return nil, err } // Add round 2 info - k.AddRound2Info(ctx, groupID, req.Round2Info) + k.Keeper.AddRound2Info(ctx, groupID, req.Round2Info) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -145,9 +153,9 @@ func (k msgServer) SubmitDKGRound2( ) // Add to the pending process group if members submit their information. - count := k.GetRound2InfoCount(ctx, groupID) + count := k.Keeper.GetRound2InfoCount(ctx, groupID) if count == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgSubmitDKGRound2Response{}, nil @@ -162,43 +170,51 @@ func (k msgServer) Complain(goCtx context.Context, req *types.MsgComplain) (*typ memberID := req.Complaints[0].Complainant // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } if group.Status != types.GROUP_STATUS_ROUND_3 { - return nil, types.ErrInvalidStatus.Wrap("group status is not round 3") + return nil, types.ErrInvalidGroupStatus.Wrapf("the status of groupID %d is not round 3", groupID) } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check already confirm or complain - if k.HasConfirm(ctx, groupID, memberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit confirm") + if k.Keeper.HasConfirm(ctx, groupID, memberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit confirm message", + memberID, + groupID, + ) } - if k.HasComplaintsWithStatus(ctx, groupID, memberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit complaint") + if k.Keeper.HasComplaintsWithStatus(ctx, groupID, memberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit complaint message", + memberID, + groupID, + ) } // Verify complaint if fail to verify, mark complainant as malicious instead. - complaintsWithStatus, err := k.ProcessComplaint(ctx, req.Complaints, groupID, req.Sender) + complaintsWithStatus, err := k.Keeper.ProcessComplaint(ctx, req.Complaints, groupID, req.Sender) if err != nil { return nil, err } // Add complain with status - k.AddComplaintsWithStatus(ctx, groupID, types.ComplaintsWithStatus{ + k.Keeper.AddComplaintsWithStatus(ctx, groupID, types.ComplaintsWithStatus{ MemberID: memberID, ComplaintsWithStatus: complaintsWithStatus, }) // Add to the pending process group if everyone sends confirm or complain already - confirmComplainCount := k.GetConfirmComplainCount(ctx, groupID) + confirmComplainCount := k.Keeper.GetConfirmComplainCount(ctx, groupID) if confirmComplainCount == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgComplainResponse{}, nil @@ -217,34 +233,42 @@ func (k msgServer) Confirm( memberID := req.MemberID // Get group and check group status - group, err := k.GetGroup(ctx, groupID) + group, err := k.Keeper.GetGroup(ctx, groupID) if err != nil { return nil, err } if group.Status != types.GROUP_STATUS_ROUND_3 { - return nil, types.ErrInvalidStatus.Wrap("group status is not round 3") + return nil, types.ErrInvalidGroupStatus.Wrapf("the status of groupID %d is not round 3", groupID) } // Validate memberID - if err := k.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { + if err := k.Keeper.ValidateMemberID(ctx, groupID, memberID, req.Sender); err != nil { return nil, err } // Check already confirm or complain - if k.HasConfirm(ctx, groupID, memberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit confirm") + if k.Keeper.HasConfirm(ctx, groupID, memberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit confirm message", + memberID, + groupID, + ) } - if k.HasComplaintsWithStatus(ctx, groupID, memberID) { - return nil, types.ErrMemberAlreadySubmit.Wrap("this member already submit complaint") + if k.Keeper.HasComplaintsWithStatus(ctx, groupID, memberID) { + return nil, types.ErrMemberAlreadySubmit.Wrapf( + "memberID %d in group ID %d already submit complaint message", + memberID, + groupID, + ) } // Verify OwnPubKeySig - if err := k.VerifyOwnPubKeySignature(ctx, groupID, memberID, req.OwnPubKeySig); err != nil { + if err := k.Keeper.VerifyOwnPubKeySignature(ctx, groupID, memberID, req.OwnPubKeySig); err != nil { return nil, err } // Add confirm - k.AddConfirm(ctx, groupID, types.NewConfirm(memberID, req.OwnPubKeySig)) + k.Keeper.AddConfirm(ctx, groupID, types.NewConfirm(memberID, req.OwnPubKeySig)) // Emit event confirm success ctx.EventManager().EmitEvent( @@ -258,9 +282,9 @@ func (k msgServer) Confirm( ) // Add to the pending process group if everyone sends confirm or complain already - confirmComplainCount := k.GetConfirmComplainCount(ctx, groupID) + confirmComplainCount := k.Keeper.GetConfirmComplainCount(ctx, groupID) if confirmComplainCount == group.Size_ { - k.AddPendingProcessGroup(ctx, groupID) + k.Keeper.AddPendingProcessGroup(ctx, groupID) } return &types.MsgConfirmResponse{}, nil @@ -278,7 +302,7 @@ func (k msgServer) SubmitDEs(goCtx context.Context, req *types.MsgSubmitDEs) (*t return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid account address: %s", err) } - err = k.EnqueueDEs(ctx, member, req.DEs) + err = k.Keeper.EnqueueDEs(ctx, member, req.DEs) if err != nil { return nil, err } @@ -297,17 +321,17 @@ func (k msgServer) SubmitSignature( ctx := sdk.UnwrapSDKContext(goCtx) // Get signing and check signing is still waiting for signature - signing, err := k.GetSigning(ctx, req.SigningID) + signing, err := k.Keeper.GetSigning(ctx, req.SigningID) if err != nil { return nil, err } if signing.Status != types.SIGNING_STATUS_WAITING { return nil, types.ErrSigningAlreadySuccess.Wrapf( - "signing ID: %d is not in waiting state", req.SigningID, + "signing ID: %d is already success", req.SigningID, ) } - sa, err := k.GetSigningAttempt(ctx, req.SigningID, signing.CurrentAttempt) + sa, err := k.Keeper.GetSigningAttempt(ctx, req.SigningID, signing.CurrentAttempt) if err != nil { return nil, err } @@ -317,14 +341,14 @@ func (k msgServer) SubmitSignature( am, found := assignedMembers.FindAssignedMember(req.MemberID) if !found || am.Address != req.Signer { return nil, types.ErrMemberNotAssigned.Wrapf( - "member ID/Address: %d is not in assigned members", req.MemberID, + "member ID %d is not in assigned members", req.MemberID, ) } // Check member is already signed - if k.HasPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID) { + if k.Keeper.HasPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID) { return nil, types.ErrAlreadySigned.Wrapf( - "member ID: %d is already signed on signing ID: %d", + "member ID %d already signed on signing ID: %d", req.MemberID, req.SigningID, ) @@ -332,8 +356,8 @@ func (k msgServer) SubmitSignature( // Verify signature R if !assignedMembers.VerifySignatureR(req.MemberID, req.Signature.R()) { - return nil, types.ErrPubNonceNotEqualToSigR.Wrapf( - "public nonce from member ID: %d is not equal signature r", + return nil, types.ErrSubmitSigningSignatureFailed.Wrapf( + "public nonce from member ID %d is not equal signature r", req.MemberID, ) } @@ -341,7 +365,9 @@ func (k msgServer) SubmitSignature( // Compute lagrange coefficient lagrange, err := tss.ComputeLagrangeCoefficient(req.MemberID, assignedMembers.MemberIDs()) if err != nil { - return nil, types.ErrInvalidArgument.Wrap(err.Error()) + return nil, types.ErrSubmitSigningSignatureFailed.Wrapf( + "failed to compute lagrange coefficient: %v", err, + ) } // Verify signing signature @@ -353,16 +379,18 @@ func (k msgServer) SubmitSignature( req.Signature, am.PubKey, ); err != nil { - return nil, types.ErrVerifySigningSigFailed.Wrap(err.Error()) + return nil, types.ErrSubmitSigningSignatureFailed.Wrapf( + "failed to verify signing signature: %v", err, + ) } // Add partial signature - k.AddPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID, req.Signature) + k.Keeper.AddPartialSignature(ctx, req.SigningID, sa.Attempt, req.MemberID, req.Signature) // Check if the threshold is met, if so, add to the pending process signing. - sigCount := k.GetPartialSignatureCount(ctx, req.SigningID, sa.Attempt) + sigCount := k.Keeper.GetPartialSignatureCount(ctx, req.SigningID, sa.Attempt) if sigCount == uint64(len(assignedMembers)) { - k.AddPendingProcessSigning(ctx, req.SigningID) + k.Keeper.AddPendingProcessSigning(ctx, req.SigningID) } ctx.EventManager().EmitEvent( @@ -383,20 +411,20 @@ func (k msgServer) SubmitSignature( } // UpdateParams update parameter of the module. -func (k Keeper) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, req *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { - if k.authority != req.Authority { + if k.Keeper.GetAuthority() != req.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - k.authority, + k.Keeper.GetAuthority(), req.Authority, ) } ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.SetParams(ctx, req.Params); err != nil { + if err := k.Keeper.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/tss/keeper/msg_server_test.go b/x/tss/keeper/msg_server_test.go index 67a604939..fa84025d0 100644 --- a/x/tss/keeper/msg_server_test.go +++ b/x/tss/keeper/msg_server_test.go @@ -446,7 +446,7 @@ func (s *KeeperTestSuite) TestFailedSubmitDEsReq() { } }, func() {}, - types.ErrDEReachMaxLimit, + types.ErrDELimitExceeded, }, } @@ -561,10 +561,16 @@ func (s *KeeperTestSuite) TestSuccessSubmitSignatureReq() { // Setup group to GROUP_STATUS_ACTIVE s.SetupWithPreparedTestCase(i, types.GROUP_STATUS_ACTIVE) + originator := types.NewDirectOriginator( + "targetChain", + "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", + "test", + ) + signingID, err := k.RequestSigning( ctx, tc.Group.ID, - &types.DirectOriginator{}, + &originator, types.NewTextSignatureOrder([]byte("msg")), ) s.Require().NoError(err) diff --git a/x/tss/tss_handler.go b/x/tss/tss_handler.go index 7c9b93692..a8976d82f 100644 --- a/x/tss/tss_handler.go +++ b/x/tss/tss_handler.go @@ -4,14 +4,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/tss/keeper" "github.com/bandprotocol/chain/v3/x/tss/types" ) -// TextMsgPrefix is the constant prefix for signing request on text msg. -// The value is tss.Hash([]byte("Text"))[:4] -var TextMsgPrefix = tss.Hash([]byte("Text"))[:4] +const TextMsgPrefix = "\xb1\xf7\x60\x16" // tss.Hash([]byte("Text"))[:4] // NewSignatureOrderHandler implements the Handler interface for tss module-based // request signatures (ie. TextSignatureOrder) @@ -26,8 +23,7 @@ func NewSignatureOrderHandler(k keeper.Keeper) types.Handler { ) } - return append(TextMsgPrefix, c.Message...), nil - + return append([]byte(TextMsgPrefix), c.Message...), nil default: return nil, sdkerrors.ErrUnknownRequest.Wrapf( "unrecognized tss request signature message type: %s", diff --git a/x/tss/tss_handler_test.go b/x/tss/tss_handler_test.go new file mode 100644 index 000000000..0c9328cc6 --- /dev/null +++ b/x/tss/tss_handler_test.go @@ -0,0 +1,14 @@ +package tss_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + tsslib "github.com/bandprotocol/chain/v3/pkg/tss" + "github.com/bandprotocol/chain/v3/x/tss" +) + +func TestEncoderPrefix(t *testing.T) { + require.Equal(t, []byte(tss.TextMsgPrefix), tsslib.Hash([]byte("Text"))[:4]) +} diff --git a/x/tss/types/codec.go b/x/tss/types/codec.go index 59d0fdfae..5348b906a 100644 --- a/x/tss/types/codec.go +++ b/x/tss/types/codec.go @@ -19,7 +19,12 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgSubmitSignature{}, "tss/MsgSubmitSignature") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "tss/MsgUpdateParams") + cdc.RegisterInterface((*Originator)(nil), nil) + cdc.RegisterInterface((*Content)(nil), nil) + cdc.RegisterConcrete(&TextSignatureOrder{}, "tss/TextSignatureOrder", nil) + cdc.RegisterConcrete(&DirectOriginator{}, "tss/DirectOriginator", nil) + cdc.RegisterConcrete(&TunnelOriginator{}, "tss/TunnelOriginator", nil) cdc.RegisterConcrete(Params{}, "tss/Params", nil) } @@ -42,5 +47,11 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &TextSignatureOrder{}, ) + registry.RegisterInterface( + "tss.v1beta1.Originator", + (*Originator)(nil), + &DirectOriginator{}, &TunnelOriginator{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/tss/types/constructors.go b/x/tss/types/constructors.go index 1ec703111..ff8047e00 100644 --- a/x/tss/types/constructors.go +++ b/x/tss/types/constructors.go @@ -35,16 +35,40 @@ func NewGroup( // Validate performs basic validation of group information. func (g Group) Validate() error { + // validate group id if g.ID == 0 { - return ErrInvalidGroup.Wrap("group id is 0") + return ErrInvalidGroup.Wrap("group id cannot be 0") } + // validate group size if g.Threshold > g.Size_ { - return ErrInvalidGroup.Wrap("group threshold is invalid") + return ErrInvalidGroup.Wrapf("group threshold (%d) is more than the group size (%d)", g.Threshold, g.Size_) } - if g.PubKey != nil && g.PubKey.Validate() != nil { - return ErrInvalidGroup.Wrap("group public key is invalid") + // validate group public key + if g.PubKey == nil { + return ErrInvalidGroup.Wrap("group public key must not be nil") + } + if err := g.PubKey.Validate(); err != nil { + return ErrInvalidGroup.Wrapf("group public key is invalid: %v", err) + } + + // validate group status + if _, ok := GroupStatus_name[int32(g.Status)]; !ok { + return ErrInvalidGroup.Wrapf("invalid group status: %d", g.Status) + } + if g.Status == GROUP_STATUS_UNSPECIFIED { + return ErrInvalidGroup.Wrap("group status cannot be unspecified") + } + + // validate created height + if g.CreatedHeight == 0 { + return ErrInvalidGroup.Wrap("created height cannot be 0") + } + + // validate module owner + if g.ModuleOwner == "" { + return ErrInvalidGroup.Wrap("module owner cannot be empty") } return nil @@ -73,26 +97,31 @@ func NewRound1Info( // Validate performs basic validation of round-1 group creation information. func (r Round1Info) Validate() error { + // Validate member ID + if r.MemberID == 0 { + return ErrInvalidMember.Wrap("member id cannot be 0") + } + // Validate coefficients commit for _, c := range r.CoefficientCommits { if err := c.Validate(); err != nil { - return ErrInvalidCoefficientCommit.Wrapf("invalid coefficient commit: %s", err) + return ErrInvalidCoefficientCommit.Wrapf("invalid coefficient commit: %v", err) } } // Validate one time pub key if err := r.OneTimePubKey.Validate(); err != nil { - return ErrInvalidPublicKey.Wrapf("invalid one-time public key: %s", err) + return ErrInvalidPublicKey.Wrapf("invalid one-time public key: %v", err) } // Validate a0 signature if err := r.A0Signature.Validate(); err != nil { - return ErrInvalidSignature.Wrapf("invalid a0 signature: %s", err) + return ErrInvalidSignature.Wrapf("invalid a0 signature: %v", err) } // Validate one time signature if err := r.OneTimeSignature.Validate(); err != nil { - return ErrInvalidSignature.Wrapf("invalid one-time signature: %s", err) + return ErrInvalidSignature.Wrapf("invalid one-time signature: %v", err) } return nil @@ -116,12 +145,12 @@ func NewRound2Info( // Validate performs basic validation of round-2 group creation information. func (r Round2Info) Validate() error { if r.MemberID == 0 { - return ErrInvalidMember.Wrap("member id is 0") + return ErrInvalidMember.Wrap("member id cannot be 0") } for i, ess := range r.EncryptedSecretShares { if err := ess.Validate(); err != nil { - return ErrInvalidSecretShare.Wrapf("encrypted secret shares at index %d: %s", i, err) + return ErrInvalidSecretShare.Wrapf("encrypted secret shares at index %d: %v", i, err) } } @@ -162,11 +191,11 @@ func NewComplaint( // Validate performs basic validation of complaint information. func (c Complaint) Validate() error { if c.Complainant == 0 { - return ErrInvalidMember.Wrap("complainant is 0") + return ErrInvalidComplaint.Wrap("complainant cannot be 0") } if c.Respondent == 0 { - return ErrInvalidMember.Wrap("respondent is 0") + return ErrInvalidComplaint.Wrap("respondent cannot be 0") } if c.Complainant == c.Respondent { @@ -174,11 +203,11 @@ func (c Complaint) Validate() error { } if err := c.KeySym.Validate(); err != nil { - return ErrInvalidComplaint.Wrapf("invalid symmetric key: %s", err) + return ErrInvalidComplaint.Wrapf("invalid symmetric key: %v", err) } if err := c.Signature.Validate(); err != nil { - return ErrInvalidComplaint.Wrapf("invalid signature: %s", err) + return ErrInvalidComplaint.Wrapf("invalid signature: %v", err) } return nil @@ -211,11 +240,11 @@ func NewDE(pubD tss.Point, pubE tss.Point) DE { // Validate performs basic validation of de information. func (d DE) Validate() error { if err := d.PubD.Validate(); err != nil { - return ErrInvalidDE.Wrapf("invalid pub d") + return ErrInvalidDE.Wrap("invalid pub d") } if err := d.PubE.Validate(); err != nil { - return ErrInvalidDE.Wrapf("invalid pub e") + return ErrInvalidDE.Wrap("invalid pub e") } return nil diff --git a/x/tss/types/constructors_test.go b/x/tss/types/constructors_test.go index a0e54ab82..df411e06a 100644 --- a/x/tss/types/constructors_test.go +++ b/x/tss/types/constructors_test.go @@ -40,7 +40,7 @@ func TestValidateGroup(t *testing.T) { CreatedHeight: 1, ModuleOwner: "module", }, - nil, + types.ErrInvalidGroup, }, { "invalid public key", diff --git a/x/tss/types/content.go b/x/tss/types/content.go index 149664d73..ef265b221 100644 --- a/x/tss/types/content.go +++ b/x/tss/types/content.go @@ -76,7 +76,7 @@ func wrapHandler(path string, handler Handler) Handler { return func(ctx sdk.Context, req Content) ([]byte, error) { msg, err := handler(ctx, req) if err != nil { - return nil, ErrHandleSignatureOrderFailed.Wrap(err.Error()) + return nil, ErrHandleSignatureOrderFailed.Wrapf("failed to handle signature order: %v", err) } selector := tsslib.Hash([]byte(path))[:4] diff --git a/x/tss/types/errors.go b/x/tss/types/errors.go index 8fdb4b566..d0e323a11 100644 --- a/x/tss/types/errors.go +++ b/x/tss/types/errors.go @@ -4,66 +4,55 @@ import errorsmod "cosmossdk.io/errors" // x/tss module sentinel errors var ( - ErrGroupSizeTooLarge = errorsmod.Register(ModuleName, 2, "group size is too large") - ErrGroupNotFound = errorsmod.Register(ModuleName, 3, "group not found") - ErrMemberNotFound = errorsmod.Register(ModuleName, 4, "member not found") - ErrNoActiveMember = errorsmod.Register(ModuleName, 5, "no active member in this group") - ErrMemberAlreadySubmit = errorsmod.Register(ModuleName, 6, "member is already submit message") - ErrRound1InfoNotFound = errorsmod.Register(ModuleName, 7, "round 1 info not found") - ErrDKGContextNotFound = errorsmod.Register(ModuleName, 8, "dkg context not found") - ErrMemberNotAuthorized = errorsmod.Register( - ModuleName, - 9, - "member is not authorized for this group", - ) - ErrInvalidStatus = errorsmod.Register(ModuleName, 10, "invalid status") - ErrVerifyOneTimeSignatureFailed = errorsmod.Register(ModuleName, 11, "failed to verify one time signature") - ErrVerifyA0SignatureFailed = errorsmod.Register(ModuleName, 12, "failed to verify a0 signature") - ErrAddCoeffCommit = errorsmod.Register(ModuleName, 13, "failed to add coefficient commit") - ErrInvalidLengthCoeffCommits = errorsmod.Register( - ModuleName, - 14, - "coefficients commit length is invalid", - ) - ErrRound2InfoNotFound = errorsmod.Register(ModuleName, 15, "round 2 info not found") + ErrGroupCreationFailed = errorsmod.Register(ModuleName, 2, "fail to create group") + ErrGroupNotFound = errorsmod.Register(ModuleName, 3, "group not found") + ErrMemberNotFound = errorsmod.Register(ModuleName, 4, "member not found") + ErrMemberAlreadySubmit = errorsmod.Register(ModuleName, 5, "member is already submit message") + ErrRound1InfoNotFound = errorsmod.Register(ModuleName, 6, "round 1 info not found") + ErrDKGContextNotFound = errorsmod.Register(ModuleName, 7, "dkg context not found") + ErrInvalidGroupStatus = errorsmod.Register(ModuleName, 8, "invalid group status") + ErrVerifyOneTimeSignatureFailed = errorsmod.Register(ModuleName, 9, "failed to verify one time signature") + ErrVerifyA0SignatureFailed = errorsmod.Register(ModuleName, 10, "failed to verify a0 signature") + ErrAddCoeffCommit = errorsmod.Register(ModuleName, 11, "failed to add coefficient commit") + ErrInvalidLengthCoeffCommits = errorsmod.Register(ModuleName, 12, "coefficients commit length is invalid") + ErrRound2InfoNotFound = errorsmod.Register(ModuleName, 13, "round 2 info not found") ErrInvalidLengthEncryptedSecretShares = errorsmod.Register( ModuleName, - 16, + 14, "encrypted secret shares length is invalid", ) - ErrComputeOwnPubKeyFailed = errorsmod.Register(ModuleName, 17, "failed to compute own public key") - ErrComplainFailed = errorsmod.Register(ModuleName, 18, "failed to complain") - ErrConfirmFailed = errorsmod.Register(ModuleName, 19, "failed to confirm") - ErrConfirmNotFound = errorsmod.Register(ModuleName, 20, "confirm not found") - ErrComplaintsWithStatusNotFound = errorsmod.Register(ModuleName, 21, "complaints with status not found") - ErrDENotFound = errorsmod.Register(ModuleName, 22, "DE not found") - ErrGroupIsNotActive = errorsmod.Register(ModuleName, 23, "group is not active") - ErrInsufficientActiveMembers = errorsmod.Register(ModuleName, 24, "insufficient active members for signing") - ErrBadDrbgInitialization = errorsmod.Register(ModuleName, 25, "bad drbg initialization") - ErrPartialSignatureNotFound = errorsmod.Register(ModuleName, 26, "partial signature not found") - ErrInvalidArgument = errorsmod.Register(ModuleName, 27, "invalid argument") - ErrSigningNotFound = errorsmod.Register(ModuleName, 28, "signing not found") - ErrAlreadySigned = errorsmod.Register(ModuleName, 29, "already signed") - ErrSigningAlreadySuccess = errorsmod.Register(ModuleName, 30, "signing already success") - ErrPubNonceNotEqualToSigR = errorsmod.Register(ModuleName, 31, "public nonce not equal to signature r") - ErrMemberNotAssigned = errorsmod.Register(ModuleName, 32, "member is not assigned") - ErrVerifySigningSigFailed = errorsmod.Register(ModuleName, 33, "failed to verify signing signature") - ErrDEReachMaxLimit = errorsmod.Register(ModuleName, 34, "the number of existing DEs reach the limit") - ErrHandleSignatureOrderFailed = errorsmod.Register(ModuleName, 35, "failed to handle signature order") - ErrNoSignatureOrderHandlerExists = errorsmod.Register(ModuleName, 36, "no handler exists for signature order type") - ErrInvalidCoefficientCommit = errorsmod.Register(ModuleName, 37, "invalid coefficient commit") - ErrInvalidPublicKey = errorsmod.Register(ModuleName, 38, "invalid public key") - ErrInvalidSignature = errorsmod.Register(ModuleName, 39, "invalid signature") - ErrInvalidSecretShare = errorsmod.Register(ModuleName, 40, "invalid secret share") - ErrInvalidComplaint = errorsmod.Register(ModuleName, 41, "invalid complaint") - ErrInvalidSymmetricKey = errorsmod.Register(ModuleName, 42, "invalid symmetric key") - ErrInvalidDE = errorsmod.Register(ModuleName, 43, "invalid DE") - ErrMaxSigningAttemptReached = errorsmod.Register(ModuleName, 44, "max signing attempt reached") - ErrEncodeOriginatorFailed = errorsmod.Register(ModuleName, 45, "failed to encode originator") - ErrInvalidMemo = errorsmod.Register(ModuleName, 46, "invalid memo") - ErrInvalidMessage = errorsmod.Register(ModuleName, 47, "invalid message") - ErrSigningAttemptNotFound = errorsmod.Register(ModuleName, 48, "signing attempt not found") - ErrInvalidMember = errorsmod.Register(ModuleName, 49, "invalid member") - ErrInvalidGroup = errorsmod.Register(ModuleName, 50, "invalid group") - ErrInvalidSigning = errorsmod.Register(ModuleName, 51, "invalid signing") + ErrComputeOwnPubKeyFailed = errorsmod.Register(ModuleName, 15, "failed to compute own public key") + ErrComplainFailed = errorsmod.Register(ModuleName, 16, "failed to complain") + ErrConfirmFailed = errorsmod.Register(ModuleName, 17, "failed to confirm") + ErrConfirmNotFound = errorsmod.Register(ModuleName, 18, "confirm not found") + ErrComplaintsWithStatusNotFound = errorsmod.Register(ModuleName, 19, "complaints with status not found") + ErrDENotFound = errorsmod.Register(ModuleName, 20, "DE not found") + ErrGroupIsNotActive = errorsmod.Register(ModuleName, 21, "group is not active") + ErrInsufficientSigners = errorsmod.Register(ModuleName, 22, "insufficient members for signing message") + ErrBadDrbgInitialization = errorsmod.Register(ModuleName, 23, "bad drbg initialization") + ErrPartialSignatureNotFound = errorsmod.Register(ModuleName, 24, "partial signature not found") + ErrSubmitSignatureFailed = errorsmod.Register(ModuleName, 25, "fail to submit signature") + ErrSigningNotFound = errorsmod.Register(ModuleName, 26, "signing not found") + ErrAlreadySigned = errorsmod.Register(ModuleName, 27, "already signed") + ErrSigningAlreadySuccess = errorsmod.Register(ModuleName, 28, "signing already success") + ErrMemberNotAssigned = errorsmod.Register(ModuleName, 29, "member is not assigned") + ErrSubmitSigningSignatureFailed = errorsmod.Register(ModuleName, 30, "failed to submit signing signature") + ErrDELimitExceeded = errorsmod.Register(ModuleName, 31, "the number of DEs exceeds the limit") + ErrHandleSignatureOrderFailed = errorsmod.Register(ModuleName, 32, "failed to handle signature order") + ErrHandlerNotFound = errorsmod.Register(ModuleName, 33, "handler not found") + ErrInvalidCoefficientCommit = errorsmod.Register(ModuleName, 34, "invalid coefficient commit") + ErrInvalidPublicKey = errorsmod.Register(ModuleName, 35, "invalid public key") + ErrInvalidSignature = errorsmod.Register(ModuleName, 36, "invalid signature") + ErrInvalidSecretShare = errorsmod.Register(ModuleName, 37, "invalid secret share") + ErrInvalidComplaint = errorsmod.Register(ModuleName, 38, "invalid complaint") + ErrInvalidDE = errorsmod.Register(ModuleName, 39, "invalid DE") + ErrMaxSigningAttemptExceeded = errorsmod.Register(ModuleName, 40, "signing attempt exceeds the limit") + ErrEncodeOriginatorFailed = errorsmod.Register(ModuleName, 41, "failed to encode originator") + ErrInvalidOriginator = errorsmod.Register(ModuleName, 42, "invalid originator") + ErrInvalidMessage = errorsmod.Register(ModuleName, 43, "invalid message") + ErrSigningAttemptNotFound = errorsmod.Register(ModuleName, 44, "signing attempt not found") + ErrInvalidMember = errorsmod.Register(ModuleName, 45, "invalid member") + ErrInvalidGroup = errorsmod.Register(ModuleName, 46, "invalid group") + ErrInvalidSigning = errorsmod.Register(ModuleName, 47, "invalid signing") + ErrCreateSigningFailed = errorsmod.Register(ModuleName, 48, "failed to create signing") ) diff --git a/x/tss/types/events.go b/x/tss/types/events.go index a6c3fef06..a91757d9b 100644 --- a/x/tss/types/events.go +++ b/x/tss/types/events.go @@ -13,33 +13,39 @@ const ( EventTypeRound3Success = "round3_success" EventTypeRound3Failed = "round3_failed" EventTypeRequestSignature = "request_signature" + EventTypeCreateSigning = "create_signing_request" EventTypeSigningSuccess = "signing_success" EventTypeSigningFailed = "signing_failed" EventTypeSubmitSignature = "submit_signature" - AttributeKeyGroupID = "group_id" - AttributeKeyMemberID = "member_id" - AttributeKeyAddress = "address" - AttributeKeySize = "size" - AttributeKeyThreshold = "threshold" - AttributeKeyPubKey = "pub_key" - AttributeKeyStatus = "status" - AttributeKeyDKGContext = "dkg_context" - AttributeKeyModuleOwner = "module_owner" - AttributeKeyRound1Info = "round1_info" - AttributeKeyRound2Info = "round2_info" - AttributeKeyComplainantID = "complainant_id" - AttributeKeyRespondentID = "respondent_id" - AttributeKeyKeySym = "key_sym" - AttributeKeySignature = "signature" - AttributeKeyOwnPubKeySig = "own_pub_key_sig" - AttributeKeySigningID = "signing_id" - AttributeKeyReason = "reason" - AttributeKeyMessage = "message" - AttributeKeyGroupPubNonce = "group_pub_nonce" - AttributeKeyAttempt = "attempt" - AttributeKeyPubNonce = "pub_nonce" - AttributeKeyBindingFactor = "binding_factor" - AttributeKeyPubD = "pub_d" - AttributeKeyPubE = "pub_e" + AttributeKeyGroupID = "group_id" + AttributeKeyMemberID = "member_id" + AttributeKeyAddress = "address" + AttributeKeySize = "size" + AttributeKeyThreshold = "threshold" + AttributeKeyPubKey = "pub_key" + AttributeKeyStatus = "status" + AttributeKeyDKGContext = "dkg_context" + AttributeKeyModuleOwner = "module_owner" + AttributeKeyRound1Info = "round1_info" + AttributeKeyRound2Info = "round2_info" + AttributeKeyComplainantID = "complainant_id" + AttributeKeyRespondentID = "respondent_id" + AttributeKeyKeySym = "key_sym" + AttributeKeySignature = "signature" + AttributeKeyOwnPubKeySig = "own_pub_key_sig" + AttributeKeySigningID = "signing_id" + AttributeKeyReason = "reason" + AttributeKeyMessage = "message" + AttributeKeyGroupPubNonce = "group_pub_nonce" + AttributeKeyAttempt = "attempt" + AttributeKeyPubNonce = "pub_nonce" + AttributeKeyBindingFactor = "binding_factor" + AttributeKeyPubD = "pub_d" + AttributeKeyPubE = "pub_e" + AttributeKeyContent = "content" + AttributeKeyContentType = "content_type" + AttributeKeyOriginator = "originator" + AttributeKeyOriginatorType = "originator_type" + AttributeKeyEncodedOriginator = "encoded_originator" ) diff --git a/x/tss/types/genesis.go b/x/tss/types/genesis.go index 0fddffd68..724606e8f 100644 --- a/x/tss/types/genesis.go +++ b/x/tss/types/genesis.go @@ -41,7 +41,7 @@ func (gs GenesisState) Validate() error { } // validate group information. - groupSizes := make(map[tss.GroupID]int) + groupSizes := make(map[tss.GroupID]uint64) for _, group := range gs.Groups { if _, ok := groupSizes[group.ID]; ok { return fmt.Errorf("duplicate group ID %d", group.ID) @@ -51,20 +51,36 @@ func (gs GenesisState) Validate() error { return err } - groupSizes[group.ID] = int(group.Size_) + groupSizes[group.ID] = group.Size_ } // all members must belong to an existing group. - memberCounts := make(map[tss.GroupID]int) + memberCounts := make(map[tss.GroupID]uint64) + seenMemberIDGroups := make(map[string]bool) + seenMemberAddressGroups := make(map[string]bool) for _, member := range gs.Members { - if _, ok := groupSizes[member.GroupID]; !ok { - return fmt.Errorf("invalid group ID %d for member %s", member.GroupID, member.Address) - } - if err := member.Validate(); err != nil { return err } + if size, ok := groupSizes[member.GroupID]; !ok || uint64(member.ID) > size { + return fmt.Errorf("invalid group ID %d for member %d", member.GroupID, member.ID) + } + + // validate duplicate member ID in the same group. + memberIDGroupKey := fmt.Sprintf("%d-%d", member.ID, member.GroupID) + if seenMemberIDGroups[memberIDGroupKey] { + return fmt.Errorf("duplicate member ID %d in group ID %d", member.ID, member.GroupID) + } + seenMemberIDGroups[memberIDGroupKey] = true + + // validate duplicate member address in the same group. + memberAddressGroupKey := fmt.Sprintf("%s-%d", member.Address, member.GroupID) + if seenMemberAddressGroups[memberAddressGroupKey] { + return fmt.Errorf("duplicate member Address %s in group ID %d", member.Address, member.GroupID) + } + seenMemberAddressGroups[memberAddressGroupKey] = true + memberCounts[member.GroupID]++ } diff --git a/x/tss/types/genesis_test.go b/x/tss/types/genesis_test.go index 68b980b40..b4c50cd24 100644 --- a/x/tss/types/genesis_test.go +++ b/x/tss/types/genesis_test.go @@ -86,6 +86,32 @@ func TestGenesisStateValidate(t *testing.T) { }, true, }, + { + "invalid genesisState - duplicate member ID", + types.GenesisState{ + Params: types.DefaultParams(), + Groups: []types.Group{validGroups[0]}, + Members: []types.Member{ + {ID: 1, GroupID: 1, Address: validMemberAddrs[0], PubKey: validTssPoint}, + {ID: 1, GroupID: 1, Address: validMemberAddrs[1], PubKey: validTssPoint}, + }, + DEs: validDEs, + }, + true, + }, + { + "invalid genesisState - duplicate member Address", + types.GenesisState{ + Params: types.DefaultParams(), + Groups: []types.Group{validGroups[0]}, + Members: []types.Member{ + {ID: 1, GroupID: 1, Address: validMemberAddrs[0], PubKey: validTssPoint}, + {ID: 2, GroupID: 1, Address: validMemberAddrs[0], PubKey: validTssPoint}, + }, + DEs: validDEs, + }, + true, + }, { "invalid genesisState - duplicate group", types.GenesisState{ diff --git a/x/tss/types/member.go b/x/tss/types/member.go index 3303dec6c..253004456 100644 --- a/x/tss/types/member.go +++ b/x/tss/types/member.go @@ -2,7 +2,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/bandprotocol/chain/v3/pkg/tss" ) @@ -29,29 +28,24 @@ func NewMember( // Validate performs basic validation of group information. func (m Member) Validate() error { if m.ID == 0 { - return ErrInvalidMember.Wrap("group id is 0") + return ErrInvalidMember.Wrap("member id cannot be 0") } if m.GroupID == 0 { - return ErrInvalidMember.Wrap("group threshold is invalid") + return ErrInvalidMember.Wrap("group id cannot be 0") } if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid member address: %s", err) + return ErrInvalidMember.Wrapf("invalid member address: %v", err) } if err := m.PubKey.Validate(); err != nil { - return ErrInvalidPublicKey.Wrapf("invalid member public key: %s", err) + return ErrInvalidMember.Wrapf("invalid member public key: %v", err) } return nil } -// IsAddress checks if the address of the Member matches the given address -func (m Member) IsAddress(address string) bool { - return m.Address == address -} - // Members represents a slice of Member values. type Members []Member diff --git a/x/tss/types/member_test.go b/x/tss/types/member_test.go index 22f46273c..5d95cb1d6 100644 --- a/x/tss/types/member_test.go +++ b/x/tss/types/member_test.go @@ -9,41 +9,6 @@ import ( "github.com/bandprotocol/chain/v3/x/tss/types" ) -func TestVerify(t *testing.T) { - // Define test cases - testCases := []struct { - name string - member types.Member - address string - expectedMatch bool - }{ - { - name: "MatchingAddress", - member: types.Member{ - Address: "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", - }, - address: "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", - expectedMatch: true, - }, - { - name: "NonMatchingAddress", - member: types.Member{ - Address: "band1p40yh3zkmhcv0ecqp3mcazy83sa57rgjp07dun", - }, - address: "band1m5lq9u533qaya4q3nfyl6ulzqkpkhge9q8tpzs", - expectedMatch: false, - }, - } - - // Run the test cases - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - result := tc.member.IsAddress(tc.address) - require.Equal(t, tc.expectedMatch, result) - }) - } -} - func TestGetIDs(t *testing.T) { // Define test cases testCases := []struct { diff --git a/x/tss/types/msgs.go b/x/tss/types/msgs.go index af3b78efd..fdc8a5c17 100644 --- a/x/tss/types/msgs.go +++ b/x/tss/types/msgs.go @@ -44,12 +44,12 @@ func NewMsgSubmitDKGRound1(groupID tss.GroupID, round1Info Round1Info, sender st func (m MsgSubmitDKGRound1) ValidateBasic() error { // Validate group ID if m.GroupID == 0 { - return ErrInvalidGroup.Wrap("group id is 0") + return ErrInvalidGroup.Wrap("group id cannot be 0") } // Validate member address if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) + return sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) } if err := m.Round1Info.Validate(); err != nil { @@ -76,7 +76,7 @@ func NewMsgSubmitDKGRound2(groupID tss.GroupID, round2Info Round2Info, sender st func (m MsgSubmitDKGRound2) ValidateBasic() error { // Validate group ID if m.GroupID == 0 { - return ErrInvalidGroup.Wrap("group id is 0") + return ErrInvalidGroup.Wrap("group id cannot be 0") } // Validate member address @@ -108,7 +108,7 @@ func NewMsgComplain(groupID tss.GroupID, complaints []Complaint, sender string) func (m MsgComplain) ValidateBasic() error { // Validate group ID if m.GroupID == 0 { - return ErrInvalidGroup.Wrap("group id is 0") + return ErrInvalidGroup.Wrap("group id cannot be 0") } // Validate member address @@ -161,12 +161,12 @@ func NewMsgConfirm( func (m MsgConfirm) ValidateBasic() error { // Validate member ID if m.MemberID == 0 { - return ErrInvalidMember.Wrap("member id is 0") + return ErrInvalidMember.Wrap("member id cannot be 0") } // Validate group ID if m.GroupID == 0 { - return ErrInvalidGroup.Wrap("group id is 0") + return ErrInvalidGroup.Wrap("group id cannot be 0") } // Validate own pub key sig @@ -234,12 +234,12 @@ func NewMsgSubmitSignature( func (m MsgSubmitSignature) ValidateBasic() error { // Validate member ID if m.SigningID == 0 { - return ErrInvalidSigning.Wrap("signing id is 0") + return ErrInvalidSigning.Wrap("signing id cannot be 0") } // Validate member ID if m.MemberID == 0 { - return ErrInvalidMember.Wrap("member id is 0") + return ErrInvalidMember.Wrap("member id cannot be 0") } // Validate member address diff --git a/x/tss/types/originator.go b/x/tss/types/originator.go index 4d67d4613..afd879920 100644 --- a/x/tss/types/originator.go +++ b/x/tss/types/originator.go @@ -13,13 +13,11 @@ import ( var ( _ Originator = &DirectOriginator{} _ Originator = &TunnelOriginator{} +) - // DirectOriginatorPrefix is the prefix for the originator from direct signing request. - // The value is tss.Hash([]byte("directOriginatorPrefix"))[:4] - DirectOriginatorPrefix = tss.Hash([]byte("directOriginatorPrefix"))[:4] - // TunnelOriginatorPrefix is the prefix for the originator from tunnel module. - // The value is tss.Hash([]byte("tunnelOriginatorPrefix"))[:4] - TunnelOriginatorPrefix = tss.Hash([]byte("tunnelOriginatorPrefix"))[:4] +const ( + DirectOriginatorPrefix = "\xb3\x9f\xa5\xd2" // tss.Hash([]byte("DirectOriginator"))[:4] + TunnelOriginatorPrefix = "\x72\xeb\xe8\x3d" // tss.Hash([]byte("TunnelOriginator"))[:4] ) // Originator is the interface for identifying the metadata of the message. The hashed of the @@ -46,8 +44,16 @@ func NewDirectOriginator(sourceChainID, requester, memo string) DirectOriginator // Validate checks the validity of the originator. func (o DirectOriginator) Validate(p Params) error { + if o.SourceChainID == "" { + return ErrInvalidOriginator.Wrap("source chain ID cannot be empty") + } + + if o.Requester == "" { + return ErrInvalidOriginator.Wrap("requester cannot be empty") + } + if uint64(len(o.Memo)) > p.MaxMemoLength { - return ErrInvalidMemo + return ErrInvalidOriginator.Wrapf("memo length exceeds maximum length of %d", p.MaxMemoLength) } return nil @@ -56,7 +62,7 @@ func (o DirectOriginator) Validate(p Params) error { // Encode encodes the originator into a byte array. func (o DirectOriginator) Encode() ([]byte, error) { bz := bytes.Join([][]byte{ - DirectOriginatorPrefix, + []byte(DirectOriginatorPrefix), tss.Hash([]byte(o.SourceChainID)), tss.Hash([]byte(o.Requester)), tss.Hash([]byte(o.Memo)), @@ -73,29 +79,46 @@ func (o DirectOriginator) Encode() ([]byte, error) { func NewTunnelOriginator( sourceChainID string, tunnelID uint64, - contractAddress, targetChainID string, + destinationChainID string, + destinationContractAddress string, ) TunnelOriginator { return TunnelOriginator{ - SourceChainID: sourceChainID, - TunnelID: tunnelID, - ContractAddress: contractAddress, - TargetChainID: targetChainID, + SourceChainID: sourceChainID, + TunnelID: tunnelID, + DestinationChainID: destinationChainID, + DestinationContractAddress: destinationContractAddress, } } // Validate checks the validity of the originator. func (o TunnelOriginator) Validate(p Params) error { + if o.SourceChainID == "" { + return ErrInvalidOriginator.Wrap("source chain ID cannot be empty") + } + + if o.TunnelID == 0 { + return ErrInvalidOriginator.Wrap("tunnel ID cannot be zero") + } + + if o.DestinationContractAddress == "" { + return ErrInvalidOriginator.Wrap("destination contract address cannot be empty") + } + + if o.DestinationChainID == "" { + return ErrInvalidOriginator.Wrap("destination chain ID cannot be empty") + } + return nil } // Encode encodes the originator into a byte array. func (o TunnelOriginator) Encode() ([]byte, error) { bz := bytes.Join([][]byte{ - TunnelOriginatorPrefix, + []byte(TunnelOriginatorPrefix), tss.Hash([]byte(o.SourceChainID)), sdk.Uint64ToBigEndian(o.TunnelID), - tss.Hash([]byte(o.ContractAddress)), - tss.Hash([]byte(o.TargetChainID)), + tss.Hash([]byte(o.DestinationChainID)), + tss.Hash([]byte(o.DestinationContractAddress)), }, []byte("")) return bz, nil diff --git a/x/tss/types/originator.pb.go b/x/tss/types/originator.pb.go index b162b96c7..aa0841349 100644 --- a/x/tss/types/originator.pb.go +++ b/x/tss/types/originator.pb.go @@ -96,10 +96,10 @@ type TunnelOriginator struct { SourceChainID string `protobuf:"bytes,1,opt,name=source_chain_id,json=sourceChainId,proto3" json:"source_chain_id,omitempty"` // tunnel_id is the tunnel ID that the request is originated from. TunnelID uint64 `protobuf:"varint,2,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` - // contract_address is the target address that the data should be relayed to. - ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - // target_chain_id is the target chain ID that the data should be relayed to. - TargetChainID string `protobuf:"bytes,4,opt,name=target_chain_id,json=targetChainId,proto3" json:"target_chain_id,omitempty"` + // destination_chain_id is the destination chain ID that the data should be relayed to. + DestinationChainID string `protobuf:"bytes,3,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"` + // destination_contract_address is the destination address that the data should be relayed to. + DestinationContractAddress string `protobuf:"bytes,4,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` } func (m *TunnelOriginator) Reset() { *m = TunnelOriginator{} } @@ -149,16 +149,16 @@ func (m *TunnelOriginator) GetTunnelID() uint64 { return 0 } -func (m *TunnelOriginator) GetContractAddress() string { +func (m *TunnelOriginator) GetDestinationChainID() string { if m != nil { - return m.ContractAddress + return m.DestinationChainID } return "" } -func (m *TunnelOriginator) GetTargetChainID() string { +func (m *TunnelOriginator) GetDestinationContractAddress() string { if m != nil { - return m.TargetChainID + return m.DestinationContractAddress } return "" } @@ -171,29 +171,31 @@ func init() { func init() { proto.RegisterFile("band/tss/v1beta1/originator.proto", fileDescriptor_220839966f1ace88) } var fileDescriptor_220839966f1ace88 = []byte{ - // 350 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xc1, 0x4e, 0xc2, 0x40, - 0x10, 0x86, 0xa9, 0x12, 0x03, 0x1b, 0x91, 0xda, 0x78, 0x40, 0x62, 0x8a, 0x72, 0xd2, 0x44, 0xbb, - 0x21, 0x9c, 0xf4, 0x26, 0x12, 0x13, 0x4e, 0x26, 0xc8, 0xc9, 0x4b, 0xb3, 0xdd, 0x6e, 0x4a, 0x13, - 0xda, 0xc5, 0xdd, 0x29, 0xd1, 0xa7, 0xd0, 0x87, 0xf1, 0x21, 0x8c, 0x27, 0x8e, 0x9e, 0x88, 0x29, - 0x77, 0x9f, 0xc1, 0xec, 0x2e, 0x52, 0xe2, 0xd9, 0xdb, 0xcc, 0x7c, 0xff, 0xcc, 0xfc, 0x9b, 0x59, - 0x74, 0x12, 0x90, 0x34, 0xc4, 0x20, 0x25, 0x9e, 0x75, 0x02, 0x06, 0xa4, 0x83, 0xb9, 0x88, 0xa3, - 0x38, 0x25, 0xc0, 0x85, 0x37, 0x15, 0x1c, 0xb8, 0x63, 0x2b, 0x89, 0x07, 0x52, 0x7a, 0x2b, 0x49, - 0xf3, 0x20, 0xe2, 0x11, 0xd7, 0x10, 0xab, 0xc8, 0xe8, 0x9a, 0x87, 0x94, 0xcb, 0x84, 0x4b, 0xdf, - 0x00, 0x93, 0x18, 0xd4, 0x7e, 0xb1, 0x90, 0xdd, 0x8f, 0x05, 0xa3, 0x70, 0xb7, 0x9e, 0xee, 0x5c, - 0xa2, 0xba, 0xe4, 0x99, 0xa0, 0xcc, 0xa7, 0x63, 0x12, 0xa7, 0x7e, 0x1c, 0x36, 0xac, 0x63, 0xeb, - 0xb4, 0xda, 0xdb, 0xcf, 0x17, 0xad, 0xda, 0xbd, 0x46, 0x37, 0x8a, 0x0c, 0xfa, 0xc3, 0x9a, 0xdc, - 0x48, 0x43, 0xe7, 0x08, 0x55, 0x05, 0x7b, 0xcc, 0x98, 0x04, 0x26, 0x1a, 0x5b, 0xaa, 0x69, 0x58, - 0x14, 0x1c, 0x07, 0x95, 0x13, 0x96, 0xf0, 0xc6, 0xb6, 0x06, 0x3a, 0xbe, 0xda, 0xfb, 0x78, 0xbb, - 0x40, 0xc5, 0xf2, 0xf6, 0xb7, 0x85, 0xec, 0x51, 0x96, 0xa6, 0x6c, 0xf2, 0x3f, 0x8e, 0xce, 0x50, - 0x15, 0xf4, 0x38, 0xd5, 0xa4, 0x1c, 0x95, 0x7b, 0xbb, 0xf9, 0xa2, 0x55, 0x31, 0x3b, 0x06, 0xfd, - 0x61, 0xc5, 0x60, 0x2d, 0xb5, 0x29, 0x4f, 0x41, 0x10, 0x0a, 0x3e, 0x09, 0x43, 0xc1, 0xa4, 0x5c, - 0x59, 0xad, 0xff, 0xd6, 0xaf, 0x4d, 0x59, 0x19, 0x02, 0x22, 0x22, 0x06, 0x85, 0xa1, 0x72, 0x61, - 0x68, 0xa4, 0xd1, 0xda, 0x10, 0x6c, 0xa4, 0xe1, 0xdf, 0x07, 0xf7, 0x6e, 0xdf, 0x73, 0xd7, 0x9a, - 0xe7, 0xae, 0xf5, 0x95, 0xbb, 0xd6, 0xeb, 0xd2, 0x2d, 0xcd, 0x97, 0x6e, 0xe9, 0x73, 0xe9, 0x96, - 0x1e, 0xce, 0xa3, 0x18, 0xc6, 0x59, 0xe0, 0x51, 0x9e, 0x60, 0x75, 0x6a, 0x7d, 0x32, 0xca, 0x27, - 0x58, 0xef, 0xc4, 0xb3, 0x2e, 0x7e, 0xd2, 0x1f, 0x04, 0x9e, 0xa7, 0x4c, 0x06, 0x3b, 0x1a, 0x77, - 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x23, 0x57, 0xf4, 0xba, 0x39, 0x02, 0x00, 0x00, + // 369 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x41, 0x4f, 0xfa, 0x30, + 0x18, 0xc6, 0x19, 0x7f, 0xf2, 0x0f, 0x34, 0xa2, 0xd8, 0x10, 0x33, 0x09, 0x19, 0xca, 0x49, 0x13, + 0x5d, 0x43, 0x38, 0xe9, 0x49, 0xe7, 0x62, 0xe4, 0x64, 0x82, 0x9e, 0xbc, 0x2c, 0xdb, 0xda, 0x8c, + 0x25, 0x6c, 0xc5, 0xb6, 0x23, 0xfa, 0x29, 0xf4, 0xe0, 0x47, 0xf1, 0x43, 0x18, 0x4f, 0x1c, 0x3d, + 0x11, 0x33, 0xbe, 0x88, 0x69, 0x8b, 0x0e, 0x39, 0x7b, 0x6b, 0xfb, 0x7b, 0xde, 0xf7, 0x79, 0xf2, + 0xf6, 0x05, 0xfb, 0x81, 0x9f, 0x62, 0x24, 0x38, 0x47, 0xd3, 0x5e, 0x40, 0x84, 0xdf, 0x43, 0x94, + 0xc5, 0x51, 0x9c, 0xfa, 0x82, 0x32, 0x7b, 0xc2, 0xa8, 0xa0, 0xb0, 0x21, 0x25, 0xb6, 0xe0, 0xdc, + 0x5e, 0x4a, 0x5a, 0xcd, 0x88, 0x46, 0x54, 0x41, 0x24, 0x4f, 0x5a, 0xd7, 0xda, 0x0d, 0x29, 0x4f, + 0x28, 0xf7, 0x34, 0xd0, 0x17, 0x8d, 0xba, 0x4f, 0x06, 0x68, 0xb8, 0x31, 0x23, 0xa1, 0xb8, 0xfe, + 0xe9, 0x0e, 0x4f, 0xc0, 0x16, 0xa7, 0x19, 0x0b, 0x89, 0x17, 0x8e, 0xfc, 0x38, 0xf5, 0x62, 0x6c, + 0x1a, 0x7b, 0xc6, 0x41, 0xcd, 0xd9, 0xce, 0xe7, 0x9d, 0xfa, 0x8d, 0x42, 0x17, 0x92, 0x0c, 0xdc, + 0x61, 0x9d, 0xaf, 0x5c, 0x31, 0x6c, 0x83, 0x1a, 0x23, 0xf7, 0x19, 0xe1, 0x82, 0x30, 0xb3, 0x2c, + 0x8b, 0x86, 0xc5, 0x03, 0x84, 0xa0, 0x92, 0x90, 0x84, 0x9a, 0xff, 0x14, 0x50, 0xe7, 0xd3, 0xcd, + 0xf7, 0xd7, 0x63, 0x50, 0x98, 0x77, 0x5f, 0xca, 0xa0, 0x71, 0x9b, 0xa5, 0x29, 0x19, 0xff, 0x4d, + 0xa2, 0x43, 0x50, 0x13, 0xaa, 0x9d, 0x2c, 0x92, 0x89, 0x2a, 0xce, 0x46, 0x3e, 0xef, 0x54, 0xb5, + 0xc7, 0xc0, 0x1d, 0x56, 0x35, 0x1e, 0x60, 0x78, 0x05, 0x9a, 0x98, 0x70, 0x21, 0x3d, 0x63, 0x9a, + 0x16, 0x56, 0x2a, 0xae, 0xb3, 0x93, 0xcf, 0x3b, 0xd0, 0x2d, 0xf8, 0xb7, 0x1f, 0xc4, 0xeb, 0x6f, + 0x18, 0x9e, 0x81, 0xf6, 0xaf, 0x4e, 0x34, 0x15, 0xcc, 0x0f, 0x85, 0xe7, 0x63, 0xcc, 0x08, 0xe7, + 0x66, 0x45, 0x0d, 0xa0, 0xb5, 0x5a, 0xb9, 0x94, 0x9c, 0x6b, 0xc5, 0xfa, 0x58, 0x9c, 0xcb, 0xb7, + 0xdc, 0x32, 0x66, 0xb9, 0x65, 0x7c, 0xe6, 0x96, 0xf1, 0xbc, 0xb0, 0x4a, 0xb3, 0x85, 0x55, 0xfa, + 0x58, 0x58, 0xa5, 0xbb, 0xa3, 0x28, 0x16, 0xa3, 0x2c, 0xb0, 0x43, 0x9a, 0x20, 0xb9, 0x10, 0xea, + 0x63, 0x43, 0x3a, 0x46, 0x2a, 0x3f, 0x9a, 0xf6, 0xd1, 0x83, 0x5a, 0x23, 0xf1, 0x38, 0x21, 0x3c, + 0xf8, 0xaf, 0x70, 0xff, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x99, 0x9c, 0xcb, 0xbf, 0x5f, 0x02, 0x00, + 0x00, } func (m *DirectOriginator) Marshal() (dAtA []byte, err error) { @@ -260,17 +262,17 @@ func (m *TunnelOriginator) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TargetChainID) > 0 { - i -= len(m.TargetChainID) - copy(dAtA[i:], m.TargetChainID) - i = encodeVarintOriginator(dAtA, i, uint64(len(m.TargetChainID))) + if len(m.DestinationContractAddress) > 0 { + i -= len(m.DestinationContractAddress) + copy(dAtA[i:], m.DestinationContractAddress) + i = encodeVarintOriginator(dAtA, i, uint64(len(m.DestinationContractAddress))) i-- dAtA[i] = 0x22 } - if len(m.ContractAddress) > 0 { - i -= len(m.ContractAddress) - copy(dAtA[i:], m.ContractAddress) - i = encodeVarintOriginator(dAtA, i, uint64(len(m.ContractAddress))) + if len(m.DestinationChainID) > 0 { + i -= len(m.DestinationChainID) + copy(dAtA[i:], m.DestinationChainID) + i = encodeVarintOriginator(dAtA, i, uint64(len(m.DestinationChainID))) i-- dAtA[i] = 0x1a } @@ -334,11 +336,11 @@ func (m *TunnelOriginator) Size() (n int) { if m.TunnelID != 0 { n += 1 + sovOriginator(uint64(m.TunnelID)) } - l = len(m.ContractAddress) + l = len(m.DestinationChainID) if l > 0 { n += 1 + l + sovOriginator(uint64(l)) } - l = len(m.TargetChainID) + l = len(m.DestinationContractAddress) if l > 0 { n += 1 + l + sovOriginator(uint64(l)) } @@ -579,7 +581,7 @@ func (m *TunnelOriginator) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DestinationChainID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -607,11 +609,11 @@ func (m *TunnelOriginator) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ContractAddress = string(dAtA[iNdEx:postIndex]) + m.DestinationChainID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TargetChainID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -639,7 +641,7 @@ func (m *TunnelOriginator) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TargetChainID = string(dAtA[iNdEx:postIndex]) + m.DestinationContractAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/tss/types/originator_test.go b/x/tss/types/originator_test.go index b83f8a82c..913ab80dc 100644 --- a/x/tss/types/originator_test.go +++ b/x/tss/types/originator_test.go @@ -6,9 +6,15 @@ import ( "github.com/stretchr/testify/require" + "github.com/bandprotocol/chain/v3/pkg/tss" "github.com/bandprotocol/chain/v3/x/tss/types" ) +func TestOriginatorPrefix(t *testing.T) { + require.Equal(t, []byte(types.DirectOriginatorPrefix), tss.Hash([]byte("DirectOriginator"))[:4]) + require.Equal(t, []byte(types.TunnelOriginatorPrefix), tss.Hash([]byte("TunnelOriginator"))[:4]) +} + func TestEncodeTunnelOriginator(t *testing.T) { // Define test cases testCases := []struct { @@ -22,14 +28,14 @@ func TestEncodeTunnelOriginator(t *testing.T) { originator: types.NewTunnelOriginator( "bandchain", 256, - "0x5662ac531A2737C3dB8901E982B43327a2fDe2ae", "BSC", + "0x5662ac531A2737C3dB8901E982B43327a2fDe2ae", ), - expected: "a466d313" + + expected: "72ebe83d" + "0e1ac2c4a50a82aa49717691fc1ae2e5fa68eff45bd8576b0f2be7a0850fa7c6" + "0000000000000100" + - "1b791f9b381ec74bd523be18b5d02eacfc1811c3817f87e7981664ccabe31e00" + - "4602a37e2aeaf2820d53eaeb5ab645d0d45172d006889d176509ed9e7cfa6144", + "4602a37e2aeaf2820d53eaeb5ab645d0d45172d006889d176509ed9e7cfa6144" + + "1b791f9b381ec74bd523be18b5d02eacfc1811c3817f87e7981664ccabe31e00", }, } @@ -58,7 +64,7 @@ func TestEncodeDirectOriginator(t *testing.T) { "band10d07y265gmmuvt4z0w9aw880jnsr700jrdn8wm", "test", ), - expected: "3c839c26" + + expected: "b39fa5d2" + "0e1ac2c4a50a82aa49717691fc1ae2e5fa68eff45bd8576b0f2be7a0850fa7c6" + "ae646b8a6bc479924298c56a0f6beed904198e60195eb75460970c0bf879010e" + "9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658", diff --git a/x/tss/types/signature_order.go b/x/tss/types/signature_order.go index f4f49dd47..a78e2e845 100644 --- a/x/tss/types/signature_order.go +++ b/x/tss/types/signature_order.go @@ -15,7 +15,7 @@ func NewTextSignatureOrder(msg []byte) *TextSignatureOrder { // OrderRoute returns the order router key func (rs *TextSignatureOrder) OrderRoute() string { return RouterKey } -// OrderType of TextSignatureOrder is "Text" +// OrderType of TextSignatureOrder is "text" func (rs *TextSignatureOrder) OrderType() string { return SignatureOrderTypeText } diff --git a/x/tunnel/README.md b/x/tunnel/README.md index 0b83c87cb..66fe1429b 100644 --- a/x/tunnel/README.md +++ b/x/tunnel/README.md @@ -114,16 +114,20 @@ A Packet is the data unit produced and sent to the destination chain based on th ```go type Packet struct { - // tunnel_id is the tunnel ID - TunnelID uint64 - // sequence is representing the sequence of the tunnel packet. - Sequence uint64 - // signal_prices is the list of signal prices - Prices []feedstypes.Price - // packet_content is the content of the packet that implements PacketContentI - PacketContent *types1.Any - // created_at is the timestamp when the packet is created - CreatedAt int64 + // tunnel_id is the tunnel ID + TunnelID uint64 + // sequence is representing the sequence of the tunnel packet. + Sequence uint64 + // prices is the list of prices information from feeds module. + Prices []feedstypes.Price + // receipt represents the confirmation of the packet delivery to the destination via the specified route. + Receipt *codectypes.Any + // base_fee is the base fee of the packet + BaseFee sdk.Coins + // route_fee is the route fee of the packet + RouteFee sdk.Coins + // created_at is the timestamp when the packet is created + CreatedAt int64 } ``` diff --git a/x/tunnel/abci.go b/x/tunnel/abci.go index d13ecfa3a..51753b489 100644 --- a/x/tunnel/abci.go +++ b/x/tunnel/abci.go @@ -10,10 +10,5 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) error { // Produce packets for all tunnels that are active and have passed the interval time trigger // or deviated from the last price to destination route. // Error should not happen here since the tunnel is already validated. - err := k.ProduceActiveTunnelPackets(ctx) - if err != nil { - return err - } - - return nil + return k.ProduceActiveTunnelPackets(ctx) } diff --git a/x/tunnel/client/cli/tx.go b/x/tunnel/client/cli/tx.go index 530d1e902..97b93c4d3 100644 --- a/x/tunnel/client/cli/tx.go +++ b/x/tunnel/client/cli/tx.go @@ -46,7 +46,7 @@ func GetTxCmdCreateTunnel() *cobra.Command { } // add create tunnel subcommands - txCmd.AddCommand(GetTxCmdCreateTSSTunnel()) + txCmd.AddCommand(GetTxCmdCreateTSSTunnel(), GetTxCmdCreateIBCTunnel()) return txCmd } @@ -111,6 +111,57 @@ func GetTxCmdCreateTSSTunnel() *cobra.Command { return cmd } +func GetTxCmdCreateIBCTunnel() *cobra.Command { + cmd := &cobra.Command{ + Use: "ibc [channel-id] [encoder] [initial-deposit] [interval] [signalInfos-json-file]", + Short: "Create a new IBC tunnel", + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + encoder, err := strconv.ParseInt(args[1], 10, 32) + if err != nil { + return err + } + + initialDeposit, err := sdk.ParseCoinsNormalized(args[2]) + if err != nil { + return err + } + + interval, err := strconv.ParseUint(args[3], 10, 64) + if err != nil { + return err + } + + signalInfos, err := parseSignalDeviations(args[4]) + if err != nil { + return err + } + + msg, err := types.NewMsgCreateIBCTunnel( + signalInfos.ToSignalDeviations(), + interval, + args[0], + feedstypes.Encoder(encoder), + initialDeposit, + clientCtx.GetFromAddress(), + ) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + func GetTxCmdUpdateAndResetTunnel() *cobra.Command { cmd := &cobra.Command{ Use: "update-and-reset-tunnel [tunnel-id] [interval] [signalDeviations-json-file] ", @@ -206,7 +257,7 @@ func GetTxCmdDeactivate() *cobra.Command { func GetTxCmdTriggerTunnel() *cobra.Command { cmd := &cobra.Command{ - Use: "trigger [tunnel-id]", + Use: "trigger-tunnel [tunnel-id]", Short: "Trigger a tunnel to generate a new packet", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/tunnel/client/cli/util.go b/x/tunnel/client/cli/util.go index c1a9e8d09..b2b35059e 100644 --- a/x/tunnel/client/cli/util.go +++ b/x/tunnel/client/cli/util.go @@ -13,7 +13,7 @@ type SignalDeviations struct { SignalDeviations []SignalDeviation `json:"signal_deviations"` } -// Note: SignalDeviation represents the signal information without soft deviation, which may be utilized in the future for deviation adjustments +// SignalDeviation represents the signal information without soft deviation, which may be utilized in the future for deviation adjustments type SignalDeviation struct { SignalID string `json:"signal_id"` DeviationBPS uint64 `json:"deviation_bps"` diff --git a/x/tunnel/ibc_module.go b/x/tunnel/ibc_module.go new file mode 100644 index 000000000..a3ce72660 --- /dev/null +++ b/x/tunnel/ibc_module.go @@ -0,0 +1,298 @@ +package tunnel + +import ( + "math" + "strings" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bandprotocol/chain/v3/x/tunnel/keeper" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +var ( + _ porttypes.IBCModule = (*IBCModule)(nil) + _ porttypes.PacketDataUnmarshaler = (*IBCModule)(nil) + _ porttypes.UpgradableModule = (*IBCModule)(nil) +) + +// IBCModule implements the ICS26 interface for tunnel given the tunnel keeper. +type IBCModule struct { + keeper keeper.Keeper +} + +// NewIBCModule creates a new IBCModule given the keeper +func NewIBCModule(keeper keeper.Keeper) IBCModule { + return IBCModule{ + keeper: keeper, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (im IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + err := ValidateTunnelChannelParams(ctx, im.keeper, order, portID, channelID) + if err != nil { + return "", err + } + + // If version is empty, set it to the current version + if strings.TrimSpace(version) == "" { + version = types.Version + } + + if version != types.Version { + return "", types.ErrInvalidVersion.Wrapf("got %s, expected %s", version, types.Version) + } + + // openInit must claim the channelCapability that IBC passes into the callback + if err := im.keeper.ClaimCapability(ctx, channelCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + + return version, nil +} + +// OnChanOpenTry implements the IBCModule interface +func (im IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + err := ValidateTunnelChannelParams(ctx, im.keeper, order, portID, channelID) + if err != nil { + return "", err + } + + if counterpartyVersion != types.Version { + return "", types.ErrInvalidVersion.Wrapf( + "invalid counterparty version: got: %s, expected %s", + counterpartyVersion, + types.Version, + ) + } + + // module may have already claimed capability in OnChanOpenInit in the case of crossing hellos + // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) + // If module can already authenticate the capability then module already owns it so we don't need to claim + // Otherwise, module does not have channel capability and we must claim it from IBC + if !im.keeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { + // Only claim channel capability passed back by IBC module if we do not already own it + if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + } + + return types.Version, nil +} + +// OnChanOpenAck implements the IBCModule interface +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + if counterpartyVersion != types.Version { + return types.ErrInvalidVersion.Wrapf( + "invalid counterparty version: %s, expected %s", + counterpartyVersion, + types.Version, + ) + } + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (im IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Disallow user-initiated channel closing for tunnel channels + return sdkerrors.ErrInvalidRequest.Wrap("user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (im IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface +func (im IBCModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + // Disallow incoming packets for tunnel channels + ack := channeltypes.NewErrorAcknowledgement( + sdkerrors.ErrInvalidRequest.Wrap("tunnel does not accept incoming packets"), + ) + return ack +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (im IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + // do nothing for out-going packet + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (im IBCModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + // do nothing for out-going packet + return nil +} + +// OnChanUpgradeInit implements the IBCModule interface +func (im IBCModule) OnChanUpgradeInit( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + proposedVersion string, +) (string, error) { + if err := ValidateTunnelChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { + return "", err + } + + if proposedVersion != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, proposedVersion) + } + + return proposedVersion, nil +} + +// OnChanUpgradeTry implements the IBCModule interface +func (im IBCModule) OnChanUpgradeTry( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + counterpartyVersion string, +) (string, error) { + if err := ValidateTunnelChannelParams(ctx, im.keeper, proposedOrder, portID, channelID); err != nil { + return "", err + } + + if counterpartyVersion != types.Version { + return "", errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, counterpartyVersion) + } + + return counterpartyVersion, nil +} + +// OnChanUpgradeAck implements the IBCModule interface +func (IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { + if counterpartyVersion != types.Version { + return errorsmod.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, counterpartyVersion) + } + + return nil +} + +// OnChanUpgradeOpen implements the IBCModule interface +func (IBCModule) OnChanUpgradeOpen( + ctx sdk.Context, + portID, channelID string, + proposedOrder channeltypes.Order, + proposedConnectionHops []string, + proposedVersion string, +) { +} + +// UnmarshalPacketData attempts to unmarshal the provided packet data bytes +// into a TunnelPricesPacketData. This function implements the optional +// PacketDataUnmarshaler interface required for ADR 008 support. +func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { + var packetData types.TunnelPricesPacketData + if err := types.ModuleCdc.UnmarshalJSON(bz, &packetData); err != nil { + return nil, err + } + + return packetData, nil +} + +// ValidateTunnelChannelParams does validation of a newly created tunnel channel. A tunnel +// channel must be ORDERED, use the correct port (by default 'tunnel'), and use the current +// supported version. Only 2^32 channels are allowed to be created. +func ValidateTunnelChannelParams( + ctx sdk.Context, + keeper keeper.Keeper, + order channeltypes.Order, + portID string, + channelID string, +) error { + // NOTE: for escrow address security only 2^32 channels are allowed to be created + // Issue: https://github.com/cosmos/cosmos-sdk/issues/7737 + channelSequence, err := channeltypes.ParseChannelSequence(channelID) + if err != nil { + return err + } + if channelSequence > uint64(math.MaxUint32) { + return types.ErrMaxTunnelChannels.Wrapf( + "channel sequence %d is greater than max allowed tunnel channels %d", + channelSequence, + uint64(math.MaxUint32), + ) + } + if order != channeltypes.ORDERED { + return channeltypes.ErrInvalidChannelOrdering.Wrapf( + "expected %s channel, got %s", + channeltypes.ORDERED, + order, + ) + } + + // Require portID is the portID tunnel module is bound to + boundPort := keeper.GetPort(ctx) + if boundPort != portID { + return porttypes.ErrInvalidPort.Wrapf("invalid port: %s, expected %s", portID, boundPort) + } + + return nil +} diff --git a/x/tunnel/ibc_module_test.go b/x/tunnel/ibc_module_test.go new file mode 100644 index 000000000..4629de174 --- /dev/null +++ b/x/tunnel/ibc_module_test.go @@ -0,0 +1,63 @@ +package tunnel_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestPacketDataUnmarshalerInterface(t *testing.T) { + var ( + data []byte + expPacketData types.TunnelPricesPacketData + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "invalid packet data", + func() { + data = []byte("invalid packet data") + }, + false, + }, + { + "all good", + func() { + expPacketData = types.TunnelPricesPacketData{ + TunnelID: 1, + Sequence: 1, + Prices: []feedstypes.Price{ + {Status: feedstypes.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "BTC", Price: 50000}, + }, + CreatedAt: 1633024800, + } + data = expPacketData.GetBytes() + }, + true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tc.malleate() + + packetData, err := tunnel.IBCModule{}.UnmarshalPacketData(data) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, expPacketData, packetData) + } else { + require.Error(t, err) + require.Nil(t, packetData) + } + }) + } +} diff --git a/x/tunnel/keeper/genesis.go b/x/tunnel/keeper/genesis.go index 90056fcea..0ec18744d 100644 --- a/x/tunnel/keeper/genesis.go +++ b/x/tunnel/keeper/genesis.go @@ -29,7 +29,19 @@ func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) { k.SetTunnel(ctx, t) k.SetLatestPrices(ctx, types.NewLatestPrices(t.ID, []feedstypes.Price{}, 0)) if t.IsActive { - k.ActiveTunnelID(ctx, t.ID) + k.SetActiveTunnelID(ctx, t.ID) + } + } + + k.SetPort(ctx, types.PortID) + // only try to bind to port if it is not already bound, since we may already own + // port capability from capability InitGenesis + if !k.IsBound(ctx, types.PortID) { + // tunnel module binds to the tunnel port on InitChain + // and claims the returned capability + err := k.BindPort(ctx, types.PortID) + if err != nil { + panic(fmt.Sprintf("could not claim port capability: %v", err)) } } diff --git a/x/tunnel/keeper/genesis_test.go b/x/tunnel/keeper/genesis_test.go index 64c2e01fe..50c3fd599 100644 --- a/x/tunnel/keeper/genesis_test.go +++ b/x/tunnel/keeper/genesis_test.go @@ -1,11 +1,11 @@ package keeper_test import ( - "testing" - - "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,109 +16,16 @@ import ( "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -func TestValidateGenesis(t *testing.T) { - cases := map[string]struct { - genesis *types.GenesisState - requireErr bool - errMsg string - }{ - "length of tunnels does not match tunnel count": { - genesis: &types.GenesisState{ - TunnelCount: 2, - Tunnels: []types.Tunnel{ - {ID: 1}, - }, - }, - requireErr: true, - errMsg: "length of tunnels does not match tunnel count", - }, - "tunnel count mismatch in tunnels": { - genesis: &types.GenesisState{ - TunnelCount: 1, - Tunnels: []types.Tunnel{ - {ID: 3}, - }, - }, - requireErr: true, - errMsg: "tunnel count mismatch in tunnels", - }, - "invalid total fees": { - genesis: &types.GenesisState{ - TunnelCount: 1, - Tunnels: []types.Tunnel{ - {ID: 1}, - }, - TotalFees: types.TotalFees{ - TotalPacketFee: sdk.Coins{ - {Denom: "uband", Amount: sdkmath.NewInt(-100)}, - }, // Invalid coin - }, - }, - requireErr: true, - errMsg: "invalid total fees", - }, - "deposits mismatch total deposit for tunnel": { - genesis: &types.GenesisState{ - TunnelCount: 1, - Tunnels: []types.Tunnel{ - {ID: 1, TotalDeposit: sdk.NewCoins()}, - }, - TotalFees: types.TotalFees{}, - Deposits: []types.Deposit{ - { - TunnelID: 1, - Depositor: sdk.AccAddress("account1").String(), - Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), - }, - }, - }, - requireErr: true, - errMsg: "deposits mismatch total deposit for tunnel", - }, - "all good": { - genesis: &types.GenesisState{ - TunnelCount: 2, - Tunnels: []types.Tunnel{ - {ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))}, - {ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))}, - }, - TotalFees: types.TotalFees{ - TotalPacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), - }, - Deposits: []types.Deposit{ - { - TunnelID: 1, - Depositor: sdk.AccAddress("account1").String(), - Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), - }, - { - TunnelID: 2, - Depositor: sdk.AccAddress("account2").String(), - Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), - }, - }, - Params: types.DefaultParams(), - }, - requireErr: false, - }, - } - - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - err := types.ValidateGenesis(*tc.genesis) - if tc.requireErr { - require.Error(t, err) - require.Contains(t, err.Error(), tc.errMsg) - } else { - require.NoError(t, err) - } - }) - } -} - func (s *KeeperTestSuite) TestInitExportGenesis() { ctx, k := s.ctx, s.keeper + s.scopedKeeper.EXPECT().GetCapability(ctx, host.PortPath(types.PortID)).Return(nil, false).AnyTimes() + s.scopedKeeper.EXPECT(). + ClaimCapability(ctx, &capabilitytypes.Capability{Index: 0}, host.PortPath(types.PortID)). + Return(nil). + AnyTimes() + s.portKeeper.EXPECT().BindPort(ctx, types.PortID).Return(&capabilitytypes.Capability{Index: 0}).AnyTimes() + s.accountKeeper.EXPECT(). GetModuleAccount(ctx, gomock.Any()). Return(sdk.AccountI(&authtypes.ModuleAccount{ @@ -140,7 +47,7 @@ func (s *KeeperTestSuite) TestInitExportGenesis() { {ID: 1}, }, TotalFees: types.TotalFees{ - TotalPacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), + TotalBasePacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))), }, } diff --git a/x/tunnel/keeper/grpc_query_test.go b/x/tunnel/keeper/grpc_query_test.go index 800d0e339..ec1c48a94 100644 --- a/x/tunnel/keeper/grpc_query_test.go +++ b/x/tunnel/keeper/grpc_query_test.go @@ -72,22 +72,16 @@ func (s *KeeperTestSuite) TestGRPCQueryPackets() { TunnelID: 2, Sequence: 1, } - err = packet1.SetPacketContent(&types.TSSPacketContent{ - SigningID: 1, - DestinationChainID: r.DestinationChainID, - DestinationContractAddress: r.DestinationContractAddress, + err = packet1.SetReceipt(&types.TSSPacketReceipt{ + SigningID: 1, }) s.Require().NoError(err) - err = packet2.SetPacketContent(&types.TSSPacketContent{ - SigningID: 2, - DestinationChainID: r.DestinationChainID, - DestinationContractAddress: r.DestinationContractAddress, + err = packet2.SetReceipt(&types.TSSPacketReceipt{ + SigningID: 2, }) s.Require().NoError(err) - err = packet3.SetPacketContent(&types.TSSPacketContent{ - SigningID: 3, - DestinationChainID: r.DestinationChainID, - DestinationContractAddress: r.DestinationContractAddress, + err = packet3.SetReceipt(&types.TSSPacketReceipt{ + SigningID: 3, }) s.Require().NoError(err) @@ -125,10 +119,8 @@ func (s *KeeperTestSuite) TestGRPCQueryPacket() { TunnelID: 1, Sequence: 1, } - err = packet1.SetPacketContent(&types.TSSPacketContent{ - SigningID: 1, - DestinationChainID: r.DestinationChainID, - DestinationContractAddress: r.DestinationContractAddress, + err = packet1.SetReceipt(&types.TSSPacketReceipt{ + SigningID: 1, }) s.Require().NoError(err) k.SetPacket(ctx, packet1) @@ -137,11 +129,7 @@ func (s *KeeperTestSuite) TestGRPCQueryPacket() { TunnelID: 1, Sequence: 2, } - err = packet2.SetPacketContent(&types.TSSPacketContent{ - SigningID: 2, - DestinationChainID: r.DestinationChainID, - DestinationContractAddress: r.DestinationContractAddress, - }) + err = packet2.SetReceipt(&types.TSSPacketReceipt{}) s.Require().NoError(err) k.SetPacket(ctx, packet2) diff --git a/x/tunnel/keeper/helper.go b/x/tunnel/keeper/helper.go index 199e96ca3..79e239939 100644 --- a/x/tunnel/keeper/helper.go +++ b/x/tunnel/keeper/helper.go @@ -1,12 +1,23 @@ package keeper import ( + "math" + sdkmath "cosmossdk.io/math" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" "github.com/bandprotocol/chain/v3/x/tunnel/types" ) +// CreatePricesMap creates a map of prices with signal ID as the key +func CreatePricesMap(prices []feedstypes.Price) map[string]feedstypes.Price { + pricesMap := make(map[string]feedstypes.Price, len(prices)) + for _, p := range prices { + pricesMap[p.SignalID] = p + } + return pricesMap +} + // GenerateNewPrices generates new prices based on the current prices and signal deviations. func GenerateNewPrices( signalDeviations []types.SignalDeviation, @@ -46,3 +57,17 @@ func GenerateNewPrices( return []feedstypes.Price{} } } + +// calculateDeviationBPS calculates the deviation between the old price and +// the new price in basis points, i.e., |(newPrice - oldPrice)| * 10000 / oldPrice +func calculateDeviationBPS(oldPrice, newPrice sdkmath.Int) sdkmath.Int { + if newPrice.Equal(oldPrice) { + return sdkmath.ZeroInt() + } + + if oldPrice.IsZero() { + return sdkmath.NewInt(math.MaxInt64) + } + + return newPrice.Sub(oldPrice).Abs().MulRaw(10000).Quo(oldPrice) +} diff --git a/x/tunnel/keeper/keeper.go b/x/tunnel/keeper/keeper.go index ae10531dc..42ec95246 100644 --- a/x/tunnel/keeper/keeper.go +++ b/x/tunnel/keeper/keeper.go @@ -3,6 +3,9 @@ package keeper import ( "fmt" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -20,6 +23,9 @@ type Keeper struct { bankKeeper types.BankKeeper feedsKeeper types.FeedsKeeper bandtssKeeper types.BandtssKeeper + ics4Wrapper types.ICS4Wrapper + portKeeper types.PortKeeper + scopedKeeper types.ScopedKeeper authority string } @@ -32,6 +38,9 @@ func NewKeeper( bankKeeper types.BankKeeper, feedsKeeper types.FeedsKeeper, bandtssKeeper types.BandtssKeeper, + ics4Wrapper types.ICS4Wrapper, + portKeeper types.PortKeeper, + scopedKeeper types.ScopedKeeper, authority string, ) Keeper { // ensure tunnel module account is set @@ -51,10 +60,54 @@ func NewKeeper( bankKeeper: bankKeeper, feedsKeeper: feedsKeeper, bandtssKeeper: bandtssKeeper, + ics4Wrapper: ics4Wrapper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, authority: authority, } } +// GetAuthority returns the x/tunnel module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// IsBound checks if the module is already bound to the desired port +func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { + _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) + return ok +} + +// BindPort defines a wrapper function for the tunnel Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + cap := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, cap, host.PortPath(portID)) +} + +// GetPort returns the portID for the tunnel module. Used in ExportGenesis +func (k Keeper) GetPort(ctx sdk.Context) string { + store := ctx.KVStore(k.storeKey) + return string(store.Get(types.PortKey)) +} + +// SetPort sets the portID for the tunnel module. Used in InitGenesis +func (k Keeper) SetPort(ctx sdk.Context, portID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PortKey, []byte(portID)) +} + +// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function +func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) +} + +// ClaimCapability allows the tunnel module that can claim a capability that IBC module +// passes to it +func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} + // GetTunnelAccount returns the tunnel ModuleAccount func (k Keeper) GetTunnelAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) diff --git a/x/tunnel/keeper/keeper_latest_prices.go b/x/tunnel/keeper/keeper_latest_prices.go index feb41e30b..88de54c75 100644 --- a/x/tunnel/keeper/keeper_latest_prices.go +++ b/x/tunnel/keeper/keeper_latest_prices.go @@ -26,15 +26,6 @@ func (k Keeper) GetLatestPrices(ctx sdk.Context, tunnelID uint64) (types.LatestP return latestPrices, nil } -// MustGetLatestPrices retrieves the latest prices by its tunnel ID. Panics if the prices does not exist. -func (k Keeper) MustGetLatestPrices(ctx sdk.Context, tunnelID uint64) types.LatestPrices { - latestPrices, err := k.GetLatestPrices(ctx, tunnelID) - if err != nil { - panic(err) - } - return latestPrices -} - // GetAllLatestPrices gets all the latest prices from the store func (k Keeper) GetAllLatestPrices(ctx sdk.Context) []types.LatestPrices { var allLatestPrices []types.LatestPrices diff --git a/x/tunnel/keeper/keeper_packet.go b/x/tunnel/keeper/keeper_packet.go index 11ac1a784..404760fe8 100644 --- a/x/tunnel/keeper/keeper_packet.go +++ b/x/tunnel/keeper/keeper_packet.go @@ -2,19 +2,16 @@ package keeper import ( "fmt" - "math" sdkerrors "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/bandprotocol/chain/v3/pkg/ctxcache" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -// DeductBaseFee deducts the base fee from fee payer's account. +// DeductBasePacketFee deducts the base packet fee from the fee payer of the packet func (k Keeper) DeductBasePacketFee(ctx sdk.Context, feePayer sdk.AccAddress) error { basePacketFee := k.GetParams(ctx).BasePacketFee if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, feePayer, types.ModuleName, basePacketFee); err != nil { @@ -23,7 +20,7 @@ func (k Keeper) DeductBasePacketFee(ctx sdk.Context, feePayer sdk.AccAddress) er // update total fees totalFees := k.GetTotalFees(ctx) - totalFees.TotalPacketFee = totalFees.TotalPacketFee.Add(basePacketFee...) + totalFees.TotalBasePacketFee = totalFees.TotalBasePacketFee.Add(basePacketFee...) k.SetTotalFees(ctx, totalFees) return nil } @@ -46,15 +43,6 @@ func (k Keeper) GetPacket(ctx sdk.Context, tunnelID uint64, sequence uint64) (ty return packet, nil } -// MustGetPacket retrieves a packet by its tunnel ID and packet ID and panics if the packet does not exist -func (k Keeper) MustGetPacket(ctx sdk.Context, tunnelID uint64, sequence uint64) types.Packet { - packet, err := k.GetPacket(ctx, tunnelID, sequence) - if err != nil { - panic(err) - } - return packet -} - // ProduceActiveTunnelPackets generates packets and sends packets to the destination route for all active tunnels func (k Keeper) ProduceActiveTunnelPackets(ctx sdk.Context) error { // get active tunnel IDs @@ -63,31 +51,9 @@ func (k Keeper) ProduceActiveTunnelPackets(ctx sdk.Context) error { prices := k.feedsKeeper.GetAllPrices(ctx) pricesMap := CreatePricesMap(prices) - // create new packet if possible for active tunnels. If not enough fund, deactivate the tunnel. + // create new packet. If failed to produce packet, emit an event. for _, id := range ids { - // check if the tunnel has enough fund to create a packet - // error should not happen here since the tunnel is already validated - ok, err := k.HasEnoughFundToCreatePacket(ctx, id) - if err != nil { - return err - } - if !ok { - // deactivate the tunnel if not enough fund - // error should not happen here since the tunnel is already validated - err := k.DeactivateTunnel(ctx, id) - if err != nil { - return err - } - - continue - } - - producePacketFunc := func(ctx sdk.Context) error { - return k.ProducePacket(ctx, id, pricesMap) - } - - // Produce a packet. If error, emits an event. - if err := ctxcache.ApplyFuncIfNoError(ctx, producePacketFunc); err != nil { + if err := k.ProduceActiveTunnelPacket(ctx, id, pricesMap); err != nil { ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeProducePacketFail, sdk.NewAttribute(types.AttributeKeyTunnelID, fmt.Sprintf("%d", id)), @@ -99,6 +65,33 @@ func (k Keeper) ProduceActiveTunnelPackets(ctx sdk.Context) error { return nil } +// ProduceActiveTunnelPacket generates a packet and sends it to the destination route for the given tunnel ID. +// If not enough fund, deactivate the tunnel. +func (k Keeper) ProduceActiveTunnelPacket( + ctx sdk.Context, + tunnelID uint64, + pricesMap map[string]feedstypes.Price, +) (err error) { + // Check if the tunnel has enough fund to create a packet and deactivate the tunnel if not + // enough fund. Error should not happen here since the tunnel is already validated. + ok, err := k.HasEnoughFundToCreatePacket(ctx, tunnelID) + if err != nil { + return err + } + if !ok { + return k.DeactivateTunnel(ctx, tunnelID) + } + + // Produce a packet. If produce packet successfully, update the context state. + cacheCtx, writeFn := ctx.CacheContext() + if err := k.ProducePacket(cacheCtx, tunnelID, pricesMap); err != nil { + return err + } + writeFn() + + return nil +} + // ProducePacket generates a packet and sends it to the destination route func (k Keeper) ProducePacket( ctx sdk.Context, @@ -177,12 +170,13 @@ func (k Keeper) CreatePacket( return types.Packet{}, sdkerrors.Wrapf(err, "failed to deduct base packet fee for tunnel %d", tunnel.ID) } - // get the route fee - route, ok := tunnel.Route.GetCachedValue().(types.RouteI) - if !ok { - return types.Packet{}, types.ErrInvalidRoute + // get the route + route, err := tunnel.GetRouteValue() + if err != nil { + return types.Packet{}, err } + // get the route fee routeFee, err := k.GetRouteFee(ctx, route) if err != nil { return types.Packet{}, err @@ -206,23 +200,39 @@ func (k Keeper) CreatePacket( } // SendPacket sends a packet to the destination route -func (k Keeper) SendPacket(ctx sdk.Context, packet types.Packet) error { +func (k Keeper) SendPacket(ctx sdk.Context, packet types.Packet) (err error) { + defer func() { + if r := recover(); r != nil { + ctx.Logger().Error(fmt.Sprintf("Panic recovered: %v", r)) + err = types.ErrSendPacketPanic + return + } + }() + tunnel, err := k.GetTunnel(ctx, packet.TunnelID) if err != nil { return err } - // get the packet content, which is the information receiving after - // sending packet to the destination route - var content types.PacketContentI - switch r := tunnel.Route.GetCachedValue().(type) { + // get the route + route, err := tunnel.GetRouteValue() + if err != nil { + return err + } + + // send packet to the destination route and get the route result + var receipt types.PacketReceiptI + switch r := route.(type) { case *types.TSSRoute: - content, err = k.SendTSSPacket( + receipt, err = k.SendTSSPacket( ctx, r, packet, + tunnel.Encoder, sdk.MustAccAddressFromBech32(tunnel.FeePayer), ) + case *types.IBCRoute: + receipt, err = k.SendIBCPacket(ctx, r, packet, tunnel.Interval) default: return types.ErrInvalidRoute.Wrapf("no route found for tunnel ID: %d", tunnel.ID) } @@ -231,35 +241,17 @@ func (k Keeper) SendPacket(ctx sdk.Context, packet types.Packet) error { return err } - // set the packet content - if err := packet.SetPacketContent(content); err != nil { - return sdkerrors.Wrapf(err, "failed to set packet content for tunnel ID: %d", tunnel.ID) + // set the receipt to the packet + if err := packet.SetReceipt(receipt); err != nil { + return sdkerrors.Wrapf( + err, + "failed to set packet receipt for tunnel %d, sequence %d", + packet.TunnelID, + packet.Sequence, + ) } k.SetPacket(ctx, packet) return nil } - -// calculateDeviationBPS calculates the deviation between the old price and -// the new price in basis points, i.e., |(newPrice - oldPrice)| * 10000 / oldPrice -func calculateDeviationBPS(oldPrice, newPrice sdkmath.Int) sdkmath.Int { - if newPrice.Equal(oldPrice) { - return sdkmath.ZeroInt() - } - - if oldPrice.IsZero() { - return sdkmath.NewInt(math.MaxInt64) - } - - return newPrice.Sub(oldPrice).Abs().MulRaw(10000).Quo(oldPrice) -} - -// CreatePricesMap creates a map of prices with signal ID as the key -func CreatePricesMap(prices []feedstypes.Price) map[string]feedstypes.Price { - pricesMap := make(map[string]feedstypes.Price, len(prices)) - for _, p := range prices { - pricesMap[p.SignalID] = p - } - return pricesMap -} diff --git a/x/tunnel/keeper/keeper_packet_ibc.go b/x/tunnel/keeper/keeper_packet_ibc.go new file mode 100644 index 000000000..21d449cfb --- /dev/null +++ b/x/tunnel/keeper/keeper_packet_ibc.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +// SendIBCPacket sends IBC packet +func (k Keeper) SendIBCPacket( + ctx sdk.Context, + route *types.IBCRoute, + packet types.Packet, + interval uint64, +) (types.PacketReceiptI, error) { + // retrieve the dynamic capability for this channel + channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(types.PortID, route.ChannelID)) + if !ok { + return nil, types.ErrChannelCapabilityNotFound + } + + // create the tunnel prices packet data bytes + packetBytes := types.NewTunnelPricesPacketData( + packet.TunnelID, + packet.Sequence, + packet.Prices, + packet.CreatedAt, + ).GetBytes() + + // send packet to IBC, authenticating with channelCap + sequence, err := k.ics4Wrapper.SendPacket( + ctx, + channelCap, + types.PortID, + route.ChannelID, + clienttypes.NewHeight(0, 0), + uint64(ctx.BlockTime().UnixNano())+interval*uint64(time.Second), + packetBytes, + ) + if err != nil { + return nil, err + } + + return types.NewIBCPacketReceipt(sequence), nil +} diff --git a/x/tunnel/keeper/keeper_packet_ibc_test.go b/x/tunnel/keeper/keeper_packet_ibc_test.go new file mode 100644 index 000000000..c39489446 --- /dev/null +++ b/x/tunnel/keeper/keeper_packet_ibc_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "time" + + "go.uber.org/mock/gomock" + + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func (s *KeeperTestSuite) TestSendIBCPacket() { + ctx, k := s.ctx, s.keeper + + route := &types.IBCRoute{ + ChannelID: "channel-0", + } + packet := types.Packet{ + TunnelID: 1, + Sequence: 1, + Prices: []feedstypes.Price{}, + CreatedAt: time.Now().Unix(), + } + interval := uint64(60) + + s.scopedKeeper.EXPECT().GetCapability(ctx, gomock.Any()).Return(&capabilitytypes.Capability{}, true) + s.icsWrapper.EXPECT(). + SendPacket(ctx, gomock.Any(), types.PortID, route.ChannelID, clienttypes.NewHeight(0, 0), uint64(ctx.BlockTime().UnixNano())+interval*uint64(time.Second), gomock.Any()). + Return(uint64(1), nil) + + content, err := k.SendIBCPacket(ctx, route, packet, interval) + s.Require().NoError(err) + + packetReceipt, ok := content.(*types.IBCPacketReceipt) + s.Require().True(ok) + s.Require().Equal(uint64(1), packetReceipt.Sequence) +} diff --git a/x/tunnel/keeper/keeper_packet_test.go b/x/tunnel/keeper/keeper_packet_test.go index 9290c857b..8a58784be 100644 --- a/x/tunnel/keeper/keeper_packet_test.go +++ b/x/tunnel/keeper/keeper_packet_test.go @@ -33,7 +33,7 @@ func (s *KeeperTestSuite) TestDeductBasePacketFee() { // validate the total fees are updated totalFee := k.GetTotalFees(ctx) - s.Require().Equal(basePacketFee, totalFee.TotalPacketFee) + s.Require().Equal(basePacketFee, totalFee.TotalBasePacketFee) } func (s *KeeperTestSuite) TestGetSetPacket() { @@ -139,8 +139,8 @@ func (s *KeeperTestSuite) TestProducePacket() { s.bandtssKeeper.EXPECT().CreateTunnelSigningRequest( gomock.Any(), uint64(1), - "0x1234567890abcdef", "chain-1", + "0x1234567890abcdef", gomock.Any(), feePayer, sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(20))), @@ -201,8 +201,8 @@ func (s *KeeperTestSuite) TestProduceActiveTunnelPackets() { s.bandtssKeeper.EXPECT().CreateTunnelSigningRequest( gomock.Any(), uint64(1), - "0x", "chain-1", + "0x", gomock.Any(), feePayer, sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(20))), diff --git a/x/tunnel/keeper/keeper_packet_tss.go b/x/tunnel/keeper/keeper_packet_tss.go index ed0efdc65..8326558c1 100644 --- a/x/tunnel/keeper/keeper_packet_tss.go +++ b/x/tunnel/keeper/keeper_packet_tss.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" "github.com/bandprotocol/chain/v3/x/tunnel/types" ) @@ -11,16 +12,22 @@ func (k Keeper) SendTSSPacket( ctx sdk.Context, route *types.TSSRoute, packet types.Packet, + encoder feedstypes.Encoder, feePayer sdk.AccAddress, -) (packetContent types.PacketContentI, err error) { - content := types.NewTunnelSignatureOrder(packet.TunnelID, packet.Sequence) +) (receipt types.PacketReceiptI, err error) { + content := types.NewTunnelSignatureOrder( + packet.Sequence, + packet.Prices, + packet.CreatedAt, + encoder, + ) - // Sign TSS packet + // try signing TSS packet, if success, write the context. signingID, err := k.bandtssKeeper.CreateTunnelSigningRequest( ctx, packet.TunnelID, - route.DestinationContractAddress, route.DestinationChainID, + route.DestinationContractAddress, content, feePayer, packet.RouteFee, @@ -29,12 +36,5 @@ func (k Keeper) SendTSSPacket( return nil, err } - // Set the packet content - tssPacketContent := types.NewTSSPacketContent( - signingID, - route.DestinationChainID, - route.DestinationContractAddress, - ) - - return &tssPacketContent, nil + return types.NewTSSPacketReceipt(signingID), nil } diff --git a/x/tunnel/keeper/keeper_packet_tss_test.go b/x/tunnel/keeper/keeper_packet_tss_test.go index bf0c64af0..429c61d07 100644 --- a/x/tunnel/keeper/keeper_packet_tss_test.go +++ b/x/tunnel/keeper/keeper_packet_tss_test.go @@ -31,23 +31,28 @@ func (s *KeeperTestSuite) TestSendTSSPacket() { time.Now().Unix(), ) + // Mock the TSS keeper and set the state for checking later s.bandtssKeeper.EXPECT().CreateTunnelSigningRequest( gomock.Any(), uint64(1), - "0x1234567890abcdef", "chain-1", + "0x1234567890abcdef", gomock.Any(), bandtesting.Alice.Address, sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(20))), ).Return(bandtsstypes.SigningID(1), nil) // Send the TSS packet - content, err := k.SendTSSPacket(ctx, &route, packet, bandtesting.Alice.Address) + content, err := k.SendTSSPacket( + ctx, + &route, + packet, + feedstypes.ENCODER_FIXED_POINT_ABI, + bandtesting.Alice.Address, + ) s.Require().NoError(err) - packetContent, ok := content.(*types.TSSPacketContent) + packetReceipt, ok := content.(*types.TSSPacketReceipt) s.Require().True(ok) - s.Require().Equal("chain-1", packetContent.DestinationChainID) - s.Require().Equal("0x1234567890abcdef", packetContent.DestinationContractAddress) - s.Require().Equal(bandtsstypes.SigningID(1), packetContent.SigningID) + s.Require().Equal(bandtsstypes.SigningID(1), packetReceipt.SigningID) } diff --git a/x/tunnel/keeper/keeper_test.go b/x/tunnel/keeper/keeper_test.go index e02ddacf3..38ba3f120 100644 --- a/x/tunnel/keeper/keeper_test.go +++ b/x/tunnel/keeper/keeper_test.go @@ -36,11 +36,15 @@ type KeeperTestSuite struct { keeper keeper.Keeper queryServer types.QueryServer msgServer types.MsgServer + storeKey storetypes.StoreKey accountKeeper *testutil.MockAccountKeeper bankKeeper *testutil.MockBankKeeper feedsKeeper *testutil.MockFeedsKeeper bandtssKeeper *testutil.MockBandtssKeeper + icsWrapper *testutil.MockICS4Wrapper + portKeeper *testutil.MockPortKeeper + scopedKeeper *testutil.MockScopedKeeper ctx sdk.Context authority sdk.AccAddress @@ -60,11 +64,15 @@ func (s *KeeperTestSuite) reset() { bankKeeper := testutil.NewMockBankKeeper(ctrl) feedsKeeper := testutil.NewMockFeedsKeeper(ctrl) bandtssKeeper := testutil.NewMockBandtssKeeper(ctrl) + icsWrapper := testutil.NewMockICS4Wrapper(ctrl) + portKeeper := testutil.NewMockPortKeeper(ctrl) + scopedKeeper := testutil.NewMockScopedKeeper(ctrl) authority := authtypes.NewModuleAddress(govtypes.ModuleName) accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(authority).AnyTimes() + s.storeKey = key s.keeper = keeper.NewKeeper( encCfg.Codec.(codec.BinaryCodec), key, @@ -72,6 +80,9 @@ func (s *KeeperTestSuite) reset() { bankKeeper, feedsKeeper, bandtssKeeper, + icsWrapper, + portKeeper, + scopedKeeper, authority.String(), ) s.queryServer = keeper.NewQueryServer(s.keeper) @@ -80,6 +91,10 @@ func (s *KeeperTestSuite) reset() { s.bankKeeper = bankKeeper s.feedsKeeper = feedsKeeper s.bandtssKeeper = bandtssKeeper + s.icsWrapper = icsWrapper + s.portKeeper = portKeeper + s.scopedKeeper = scopedKeeper + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now().UTC()}) s.authority = authority diff --git a/x/tunnel/keeper/keeper_tunnel.go b/x/tunnel/keeper/keeper_tunnel.go index e5e59e810..1f5c4dfff 100644 --- a/x/tunnel/keeper/keeper_tunnel.go +++ b/x/tunnel/keeper/keeper_tunnel.go @@ -166,13 +166,13 @@ func (k Keeper) GetTunnels(ctx sdk.Context) []types.Tunnel { return tunnels } -// ActiveTunnelID sets the active tunnel ID in the store -func (k Keeper) ActiveTunnelID(ctx sdk.Context, tunnelID uint64) { +// SetActiveTunnelID sets the active tunnel ID in the store +func (k Keeper) SetActiveTunnelID(ctx sdk.Context, tunnelID uint64) { ctx.KVStore(k.storeKey).Set(types.ActiveTunnelIDStoreKey(tunnelID), []byte{0x01}) } -// DeactivateTunnelID deactivates the tunnel ID in the store -func (k Keeper) DeactivateTunnelID(ctx sdk.Context, tunnelID uint64) { +// DeleteActiveTunnelID deletes the active tunnel ID from the store +func (k Keeper) DeleteActiveTunnelID(ctx sdk.Context, tunnelID uint64) { ctx.KVStore(k.storeKey).Delete(types.ActiveTunnelIDStoreKey(tunnelID)) } @@ -203,7 +203,7 @@ func (k Keeper) ActivateTunnel(ctx sdk.Context, tunnelID uint64) error { } // add the tunnel ID to the active tunnel IDs - k.ActiveTunnelID(ctx, tunnelID) + k.SetActiveTunnelID(ctx, tunnelID) // set the last interval timestamp to the current block time tunnel.IsActive = true @@ -226,7 +226,7 @@ func (k Keeper) DeactivateTunnel(ctx sdk.Context, tunnelID uint64) error { } // remove the tunnel ID from the active tunnel IDs - k.DeactivateTunnelID(ctx, tunnelID) + k.DeleteActiveTunnelID(ctx, tunnelID) // set the last interval timestamp to the current block time tunnel.IsActive = false @@ -266,11 +266,10 @@ func (k Keeper) HasEnoughFundToCreatePacket(ctx sdk.Context, tunnelID uint64) (b } // get the route fee from the tunnel - route, ok := tunnel.Route.GetCachedValue().(types.RouteI) - if !ok { - return false, types.ErrInvalidRoute + route, err := tunnel.GetRouteValue() + if err != nil { + return false, err } - routeFee, err := k.GetRouteFee(ctx, route) if err != nil { return false, err @@ -327,6 +326,8 @@ func (k Keeper) GetRouteFee(ctx sdk.Context, route types.RouteI) (sdk.Coins, err switch route.(type) { case *types.TSSRoute: return k.bandtssKeeper.GetSigningFee(ctx) + case *types.IBCRoute: + return sdk.Coins{}, nil default: return sdk.Coins{}, types.ErrInvalidRoute } diff --git a/x/tunnel/keeper/keeper_tunnel_test.go b/x/tunnel/keeper/keeper_tunnel_test.go index 7160d70c6..7d4b53799 100644 --- a/x/tunnel/keeper/keeper_tunnel_test.go +++ b/x/tunnel/keeper/keeper_tunnel_test.go @@ -159,7 +159,7 @@ func (s *KeeperTestSuite) TestGetActiveTunnelIDs() { activeTunnelIDs := []uint64{1, 2, 3} for _, id := range activeTunnelIDs { - k.ActiveTunnelID(ctx, id) + k.SetActiveTunnelID(ctx, id) } retrievedIDs := k.GetActiveTunnelIDs(ctx) @@ -249,7 +249,7 @@ func (s *KeeperTestSuite) TestDeactivateTunnel() { func (s *KeeperTestSuite) TestGetSetTotalFees() { ctx, k := s.ctx, s.keeper - totalFees := types.TotalFees{TotalPacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))} + totalFees := types.TotalFees{TotalBasePacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))} k.SetTotalFees(ctx, totalFees) retrievedFees := k.GetTotalFees(ctx) diff --git a/x/tunnel/keeper/msg_server.go b/x/tunnel/keeper/msg_server.go index 9bdf286f4..caa4b5917 100644 --- a/x/tunnel/keeper/msg_server.go +++ b/x/tunnel/keeper/msg_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "errors" "fmt" sdkerrors "cosmossdk.io/errors" @@ -25,21 +24,21 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } // CreateTunnel creates a new tunnel. -func (ms msgServer) CreateTunnel( +func (k msgServer) CreateTunnel( goCtx context.Context, msg *types.MsgCreateTunnel, ) (*types.MsgCreateTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := k.Keeper.GetParams(ctx) // validate signal infos and interval - if err := types.ValidateSignalDeviations(msg.SignalDeviations, params); err != nil { + if err := types.ValidateSignalDeviations(msg.SignalDeviations, params.MaxSignals, params.MaxDeviationBPS, params.MinDeviationBPS); err != nil { return nil, err } // validate interval - if err := types.ValidateInterval(msg.Interval, params); err != nil { + if err := types.ValidateInterval(msg.Interval, params.MaxInterval, params.MinInterval); err != nil { return nil, err } @@ -48,13 +47,13 @@ func (ms msgServer) CreateTunnel( return nil, err } - route, ok := msg.Route.GetCachedValue().(types.RouteI) - if !ok { - return nil, errors.New("cannot create tunnel, failed to convert proto Any to routeI") + route, err := msg.GetRouteValue() + if err != nil { + return nil, err } // add a new tunnel - tunnel, err := ms.Keeper.AddTunnel( + tunnel, err := k.Keeper.AddTunnel( ctx, route, msg.Encoder, @@ -68,7 +67,7 @@ func (ms msgServer) CreateTunnel( // Deposit the initial deposit to the tunnel if !msg.InitialDeposit.IsZero() { - if err := ms.Keeper.DepositToTunnel(ctx, tunnel.ID, creator, msg.InitialDeposit); err != nil { + if err := k.Keeper.DepositToTunnel(ctx, tunnel.ID, creator, msg.InitialDeposit); err != nil { return nil, err } } @@ -79,25 +78,25 @@ func (ms msgServer) CreateTunnel( } // UpdateAndResetTunnel edits a tunnel and reset latest price interval. -func (ms msgServer) UpdateAndResetTunnel( +func (k msgServer) UpdateAndResetTunnel( goCtx context.Context, msg *types.MsgUpdateAndResetTunnel, ) (*types.MsgUpdateAndResetTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := ms.Keeper.GetParams(ctx) + params := k.Keeper.GetParams(ctx) // validate signal infos and interval - if err := types.ValidateSignalDeviations(msg.SignalDeviations, params); err != nil { + if err := types.ValidateSignalDeviations(msg.SignalDeviations, params.MaxSignals, params.MaxDeviationBPS, params.MinDeviationBPS); err != nil { return nil, err } // validate interval - if err := types.ValidateInterval(msg.Interval, params); err != nil { + if err := types.ValidateInterval(msg.Interval, params.MaxInterval, params.MinInterval); err != nil { return nil, err } - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -106,7 +105,7 @@ func (ms msgServer) UpdateAndResetTunnel( return nil, types.ErrInvalidTunnelCreator.Wrapf("creator %s, tunnelID %d", msg.Creator, msg.TunnelID) } - err = ms.Keeper.UpdateAndResetTunnel(ctx, msg.TunnelID, msg.SignalDeviations, msg.Interval) + err = k.Keeper.UpdateAndResetTunnel(ctx, msg.TunnelID, msg.SignalDeviations, msg.Interval) if err != nil { return nil, err } @@ -115,13 +114,13 @@ func (ms msgServer) UpdateAndResetTunnel( } // Activate activates a tunnel. -func (ms msgServer) Activate( +func (k msgServer) Activate( goCtx context.Context, msg *types.MsgActivate, ) (*types.MsgActivateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -136,7 +135,7 @@ func (ms msgServer) Activate( return nil, types.ErrAlreadyActive.Wrapf("tunnelID %d", msg.TunnelID) } - if err := ms.Keeper.ActivateTunnel(ctx, msg.TunnelID); err != nil { + if err := k.Keeper.ActivateTunnel(ctx, msg.TunnelID); err != nil { return nil, err } @@ -144,13 +143,13 @@ func (ms msgServer) Activate( } // Deactivate deactivates a tunnel. -func (ms msgServer) Deactivate( +func (k msgServer) Deactivate( goCtx context.Context, msg *types.MsgDeactivate, ) (*types.MsgDeactivateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -163,7 +162,7 @@ func (ms msgServer) Deactivate( return nil, types.ErrAlreadyInactive.Wrapf("tunnelID %d", msg.TunnelID) } - if err := ms.Keeper.DeactivateTunnel(ctx, msg.TunnelID); err != nil { + if err := k.Keeper.DeactivateTunnel(ctx, msg.TunnelID); err != nil { return nil, err } @@ -171,13 +170,13 @@ func (ms msgServer) Deactivate( } // TriggerTunnel manually triggers a tunnel. -func (ms msgServer) TriggerTunnel( +func (k msgServer) TriggerTunnel( goCtx context.Context, msg *types.MsgTriggerTunnel, ) (*types.MsgTriggerTunnelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - tunnel, err := ms.Keeper.GetTunnel(ctx, msg.TunnelID) + tunnel, err := k.Keeper.GetTunnel(ctx, msg.TunnelID) if err != nil { return nil, err } @@ -194,7 +193,7 @@ func (ms msgServer) TriggerTunnel( return nil, types.ErrInactiveTunnel.Wrapf("tunnelID %d", msg.TunnelID) } - ok, err := ms.Keeper.HasEnoughFundToCreatePacket(ctx, tunnel.ID) + ok, err := k.Keeper.HasEnoughFundToCreatePacket(ctx, tunnel.ID) if err != nil { return nil, err } @@ -204,20 +203,20 @@ func (ms msgServer) TriggerTunnel( } signalIDs := tunnel.GetSignalIDs() - prices := ms.Keeper.feedsKeeper.GetPrices(ctx, signalIDs) + prices := k.Keeper.feedsKeeper.GetPrices(ctx, signalIDs) // create a new packet - packet, err := ms.CreatePacket(ctx, tunnel.ID, prices) + packet, err := k.Keeper.CreatePacket(ctx, tunnel.ID, prices) if err != nil { return nil, err } // send packet - if err := ms.SendPacket(ctx, packet); err != nil { + if err := k.Keeper.SendPacket(ctx, packet); err != nil { return nil, sdkerrors.Wrapf(err, "failed to create packet for tunnel %d", tunnel.ID) } - latestPrices, err := ms.GetLatestPrices(ctx, tunnel.ID) + latestPrices, err := k.Keeper.GetLatestPrices(ctx, tunnel.ID) if err != nil { return nil, err } @@ -225,7 +224,7 @@ func (ms msgServer) TriggerTunnel( // update latest price info. latestPrices.LastInterval = ctx.BlockTime().Unix() latestPrices.UpdatePrices(packet.Prices) - ms.SetLatestPrices(ctx, latestPrices) + k.Keeper.SetLatestPrices(ctx, latestPrices) ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeTriggerTunnel, @@ -237,7 +236,7 @@ func (ms msgServer) TriggerTunnel( } // DepositToTunnel adds deposit to the tunnel. -func (ms msgServer) DepositToTunnel( +func (k msgServer) DepositToTunnel( goCtx context.Context, msg *types.MsgDepositToTunnel, ) (*types.MsgDepositToTunnelResponse, error) { @@ -248,7 +247,7 @@ func (ms msgServer) DepositToTunnel( return nil, err } - if err := ms.Keeper.DepositToTunnel(ctx, msg.TunnelID, depositor, msg.Amount); err != nil { + if err := k.Keeper.DepositToTunnel(ctx, msg.TunnelID, depositor, msg.Amount); err != nil { return nil, err } @@ -256,7 +255,7 @@ func (ms msgServer) DepositToTunnel( } // WithdrawFromTunnel withdraws deposit from the tunnel. -func (ms msgServer) WithdrawFromTunnel( +func (k msgServer) WithdrawFromTunnel( goCtx context.Context, msg *types.MsgWithdrawFromTunnel, ) (*types.MsgWithdrawFromTunnelResponse, error) { @@ -268,7 +267,7 @@ func (ms msgServer) WithdrawFromTunnel( } // Withdraw the deposit from the tunnel - if err := ms.Keeper.WithdrawFromTunnel(ctx, msg.TunnelID, msg.Amount, withdrawer); err != nil { + if err := k.Keeper.WithdrawFromTunnel(ctx, msg.TunnelID, msg.Amount, withdrawer); err != nil { return nil, err } @@ -276,21 +275,21 @@ func (ms msgServer) WithdrawFromTunnel( } // UpdateParams updates the module params. -func (ms msgServer) UpdateParams( +func (k msgServer) UpdateParams( goCtx context.Context, msg *types.MsgUpdateParams, ) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if ms.authority != msg.Authority { + if k.Keeper.GetAuthority() != msg.Authority { return nil, govtypes.ErrInvalidSigner.Wrapf( "invalid authority; expected %s, got %s", - ms.authority, + k.Keeper.GetAuthority(), msg.Authority, ) } - if err := ms.SetParams(ctx, msg.Params); err != nil { + if err := k.Keeper.SetParams(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/tunnel/keeper/msg_server_test.go b/x/tunnel/keeper/msg_server_test.go index f69c52a37..135bc655e 100644 --- a/x/tunnel/keeper/msg_server_test.go +++ b/x/tunnel/keeper/msg_server_test.go @@ -500,8 +500,8 @@ func (s *KeeperTestSuite) TestMsgTriggerTunnel() { s.bandtssKeeper.EXPECT().CreateTunnelSigningRequest( gomock.Any(), uint64(1), - "0x1234567890abcdef", "chain-1", + "0x1234567890abcdef", gomock.Any(), feePayer, sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(20))), diff --git a/x/tunnel/testutil/expected_keepers_mocks.go b/x/tunnel/testutil/expected_keepers_mocks.go index 870207627..46d935254 100644 --- a/x/tunnel/testutil/expected_keepers_mocks.go +++ b/x/tunnel/testutil/expected_keepers_mocks.go @@ -17,6 +17,8 @@ import ( types0 "github.com/bandprotocol/chain/v3/x/feeds/types" types1 "github.com/bandprotocol/chain/v3/x/tss/types" types2 "github.com/cosmos/cosmos-sdk/types" + types3 "github.com/cosmos/ibc-go/modules/capability/types" + types4 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" gomock "go.uber.org/mock/gomock" ) @@ -204,6 +206,150 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } +// MockICS4Wrapper is a mock of ICS4Wrapper interface. +type MockICS4Wrapper struct { + ctrl *gomock.Controller + recorder *MockICS4WrapperMockRecorder + isgomock struct{} +} + +// MockICS4WrapperMockRecorder is the mock recorder for MockICS4Wrapper. +type MockICS4WrapperMockRecorder struct { + mock *MockICS4Wrapper +} + +// NewMockICS4Wrapper creates a new mock instance. +func NewMockICS4Wrapper(ctrl *gomock.Controller) *MockICS4Wrapper { + mock := &MockICS4Wrapper{ctrl: ctrl} + mock.recorder = &MockICS4WrapperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockICS4Wrapper) EXPECT() *MockICS4WrapperMockRecorder { + return m.recorder +} + +// SendPacket mocks base method. +func (m *MockICS4Wrapper) SendPacket(ctx types2.Context, chanCap *types3.Capability, sourcePort, sourceChannel string, timeoutHeight types4.Height, timeoutTimestamp uint64, data []byte) (uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendPacket", ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SendPacket indicates an expected call of SendPacket. +func (mr *MockICS4WrapperMockRecorder) SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendPacket", reflect.TypeOf((*MockICS4Wrapper)(nil).SendPacket), ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) +} + +// MockPortKeeper is a mock of PortKeeper interface. +type MockPortKeeper struct { + ctrl *gomock.Controller + recorder *MockPortKeeperMockRecorder + isgomock struct{} +} + +// MockPortKeeperMockRecorder is the mock recorder for MockPortKeeper. +type MockPortKeeperMockRecorder struct { + mock *MockPortKeeper +} + +// NewMockPortKeeper creates a new mock instance. +func NewMockPortKeeper(ctrl *gomock.Controller) *MockPortKeeper { + mock := &MockPortKeeper{ctrl: ctrl} + mock.recorder = &MockPortKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPortKeeper) EXPECT() *MockPortKeeperMockRecorder { + return m.recorder +} + +// BindPort mocks base method. +func (m *MockPortKeeper) BindPort(ctx types2.Context, portID string) *types3.Capability { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindPort", ctx, portID) + ret0, _ := ret[0].(*types3.Capability) + return ret0 +} + +// BindPort indicates an expected call of BindPort. +func (mr *MockPortKeeperMockRecorder) BindPort(ctx, portID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindPort", reflect.TypeOf((*MockPortKeeper)(nil).BindPort), ctx, portID) +} + +// MockScopedKeeper is a mock of ScopedKeeper interface. +type MockScopedKeeper struct { + ctrl *gomock.Controller + recorder *MockScopedKeeperMockRecorder + isgomock struct{} +} + +// MockScopedKeeperMockRecorder is the mock recorder for MockScopedKeeper. +type MockScopedKeeperMockRecorder struct { + mock *MockScopedKeeper +} + +// NewMockScopedKeeper creates a new mock instance. +func NewMockScopedKeeper(ctrl *gomock.Controller) *MockScopedKeeper { + mock := &MockScopedKeeper{ctrl: ctrl} + mock.recorder = &MockScopedKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockScopedKeeper) EXPECT() *MockScopedKeeperMockRecorder { + return m.recorder +} + +// AuthenticateCapability mocks base method. +func (m *MockScopedKeeper) AuthenticateCapability(ctx types2.Context, cap *types3.Capability, name string) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AuthenticateCapability", ctx, cap, name) + ret0, _ := ret[0].(bool) + return ret0 +} + +// AuthenticateCapability indicates an expected call of AuthenticateCapability. +func (mr *MockScopedKeeperMockRecorder) AuthenticateCapability(ctx, cap, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthenticateCapability", reflect.TypeOf((*MockScopedKeeper)(nil).AuthenticateCapability), ctx, cap, name) +} + +// ClaimCapability mocks base method. +func (m *MockScopedKeeper) ClaimCapability(ctx types2.Context, cap *types3.Capability, name string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ClaimCapability", ctx, cap, name) + ret0, _ := ret[0].(error) + return ret0 +} + +// ClaimCapability indicates an expected call of ClaimCapability. +func (mr *MockScopedKeeperMockRecorder) ClaimCapability(ctx, cap, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClaimCapability", reflect.TypeOf((*MockScopedKeeper)(nil).ClaimCapability), ctx, cap, name) +} + +// GetCapability mocks base method. +func (m *MockScopedKeeper) GetCapability(ctx types2.Context, name string) (*types3.Capability, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCapability", ctx, name) + ret0, _ := ret[0].(*types3.Capability) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetCapability indicates an expected call of GetCapability. +func (mr *MockScopedKeeperMockRecorder) GetCapability(ctx, name any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCapability", reflect.TypeOf((*MockScopedKeeper)(nil).GetCapability), ctx, name) +} + // MockFeedsKeeper is a mock of FeedsKeeper interface. type MockFeedsKeeper struct { ctrl *gomock.Controller @@ -281,18 +427,18 @@ func (m *MockBandtssKeeper) EXPECT() *MockBandtssKeeperMockRecorder { } // CreateTunnelSigningRequest mocks base method. -func (m *MockBandtssKeeper) CreateTunnelSigningRequest(ctx types2.Context, tunnelID uint64, destinationContractAddr, destinationChainID string, content types1.Content, sender types2.AccAddress, feeLimit types2.Coins) (types.SigningID, error) { +func (m *MockBandtssKeeper) CreateTunnelSigningRequest(ctx types2.Context, tunnelID uint64, destinationChainID, destinationContractAddr string, content types1.Content, sender types2.AccAddress, feeLimit types2.Coins) (types.SigningID, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateTunnelSigningRequest", ctx, tunnelID, destinationContractAddr, destinationChainID, content, sender, feeLimit) + ret := m.ctrl.Call(m, "CreateTunnelSigningRequest", ctx, tunnelID, destinationChainID, destinationContractAddr, content, sender, feeLimit) ret0, _ := ret[0].(types.SigningID) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateTunnelSigningRequest indicates an expected call of CreateTunnelSigningRequest. -func (mr *MockBandtssKeeperMockRecorder) CreateTunnelSigningRequest(ctx, tunnelID, destinationContractAddr, destinationChainID, content, sender, feeLimit any) *gomock.Call { +func (mr *MockBandtssKeeperMockRecorder) CreateTunnelSigningRequest(ctx, tunnelID, destinationChainID, destinationContractAddr, content, sender, feeLimit any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTunnelSigningRequest", reflect.TypeOf((*MockBandtssKeeper)(nil).CreateTunnelSigningRequest), ctx, tunnelID, destinationContractAddr, destinationChainID, content, sender, feeLimit) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTunnelSigningRequest", reflect.TypeOf((*MockBandtssKeeper)(nil).CreateTunnelSigningRequest), ctx, tunnelID, destinationChainID, destinationContractAddr, content, sender, feeLimit) } // GetSigningFee mocks base method. diff --git a/x/tunnel/tss_handler.go b/x/tunnel/tss_handler.go index e62748d97..5b7453550 100644 --- a/x/tunnel/tss_handler.go +++ b/x/tunnel/tss_handler.go @@ -14,26 +14,11 @@ func NewSignatureOrderHandler(k keeper.Keeper) tsstypes.Handler { return func(ctx sdk.Context, content tsstypes.Content) ([]byte, error) { switch c := content.(type) { case *types.TunnelSignatureOrder: - tunnel, err := k.GetTunnel(ctx, c.TunnelID) - if err != nil { - return nil, err - } - - route, ok := tunnel.Route.GetCachedValue().(*types.TSSRoute) - if !ok { - return nil, types.ErrInvalidRoute.Wrap("invalid route type; expect TSSRoute type") - } - - packet, err := k.GetPacket(ctx, c.TunnelID, c.Sequence) - if err != nil { - return nil, err - } - - return types.EncodeTss( - packet, - route.DestinationChainID, - route.DestinationContractAddress, - tunnel.Encoder, + return types.EncodeTSS( + c.Sequence, + c.Prices, + c.CreatedAt, + c.Encoder, ) default: return nil, sdkerrors.ErrUnknownRequest.Wrapf( diff --git a/x/tunnel/types/codec.go b/x/tunnel/types/codec.go index f878023e2..da8e3b7a8 100644 --- a/x/tunnel/types/codec.go +++ b/x/tunnel/types/codec.go @@ -29,8 +29,12 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*RouteI)(nil), nil) cdc.RegisterConcrete(&TSSRoute{}, "tunnel/TSSRoute", nil) - cdc.RegisterInterface((*PacketContentI)(nil), nil) - cdc.RegisterConcrete(&TSSPacketContent{}, "tunnel/TSSPacketContent", nil) + cdc.RegisterConcrete(&IBCRoute{}, "tunnel/IBCRoute", nil) + + cdc.RegisterInterface((*PacketReceiptI)(nil), nil) + cdc.RegisterConcrete(&TSSPacketReceipt{}, "tunnel/TSSPacketReceipt", nil) + cdc.RegisterConcrete(&IBCPacketReceipt{}, "tunnel/IBCPacketReceipt", nil) + cdc.RegisterConcrete(Params{}, "tunnel/Params", nil) } @@ -52,12 +56,13 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { "tunnel.v1beta1.RouteI", (*RouteI)(nil), &TSSRoute{}, + &IBCRoute{}, ) registry.RegisterInterface( - "tunnel.v1beta1.PacketContentI", - (*PacketContentI)(nil), - &TSSPacketContent{}, + "tunnel.v1beta1.PacketReceiptI", + (*PacketReceiptI)(nil), + &TSSPacketReceipt{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/tunnel/types/encoding_tss.go b/x/tunnel/types/encoding_tss.go index 805b05a2a..f55a26efe 100644 --- a/x/tunnel/types/encoding_tss.go +++ b/x/tunnel/types/encoding_tss.go @@ -8,12 +8,9 @@ import ( var ( packetABI, _ = abi.NewType("tuple", "result", []abi.ArgumentMarshaling{ - {Name: "TunnelID", Type: "uint64"}, {Name: "Sequence", Type: "uint64"}, - {Name: "DestinationChainID", Type: "string"}, - {Name: "DestinationContractAddress", Type: "string"}, { - Name: "TssPrices", + Name: "TSSPrices", Type: "tuple[]", InternalType: "struct Prices[]", Components: []abi.ArgumentMarshaling{ @@ -29,57 +26,41 @@ var ( } ) -// TssPacket represents the Packet that will be used for encoding a tss message. -type TssPacket struct { - TunnelID uint64 - Sequence uint64 - DestinationChainID string - DestinationContractAddress string - TssPrices []feedstypes.TssPrice - CreatedAt int64 +// TSSPacket represents the Packet that will be used for encoding a tss message. +type TSSPacket struct { + Sequence uint64 + TSSPrices []feedstypes.TSSPrice + CreatedAt int64 } -// NewTssPacket returns a new TssPacket object -func NewTssPacket( - tunnelID uint64, +// NewTSSPacket returns a new TssPacket object +func NewTSSPacket( sequence uint64, - destinationChainID string, - destinationContractAddress string, - tssPrices []feedstypes.TssPrice, + tssPrices []feedstypes.TSSPrice, createdAt int64, -) TssPacket { - return TssPacket{ - TunnelID: tunnelID, - Sequence: sequence, - DestinationChainID: destinationChainID, - DestinationContractAddress: destinationContractAddress, - TssPrices: tssPrices, - CreatedAt: createdAt, +) TSSPacket { + return TSSPacket{ + Sequence: sequence, + TSSPrices: tssPrices, + CreatedAt: createdAt, } } -// EncodeTss encodes the packet to tss message -func EncodeTss( - packet Packet, - destinationChainID string, - destinationContractAddress string, +// EncodeTSS encodes the packet to tss message +func EncodeTSS( + sequence uint64, + prices []feedstypes.Price, + createdAt int64, encoder feedstypes.Encoder, ) ([]byte, error) { switch encoder { case feedstypes.ENCODER_FIXED_POINT_ABI: - tssPrices, err := feedstypes.ToTssPrices(packet.Prices) + tssPrices, err := feedstypes.ToTSSPrices(prices) if err != nil { return nil, err } - tssPacket := NewTssPacket( - packet.TunnelID, - packet.Sequence, - destinationChainID, - destinationContractAddress, - tssPrices, - packet.CreatedAt, - ) + tssPacket := NewTSSPacket(sequence, tssPrices, createdAt) bz, err := packetArgs.Pack(&tssPacket) if err != nil { @@ -88,18 +69,12 @@ func EncodeTss( return append([]byte(feedstypes.EncoderFixedPointABIPrefix), bz...), nil case feedstypes.ENCODER_TICK_ABI: - tssPrices, err := feedstypes.ToTssTickPrices(packet.Prices) + tssPrices, err := feedstypes.ToTSSTickPrices(prices) if err != nil { return nil, err } - tssPacket := NewTssPacket( - packet.TunnelID, - packet.Sequence, - destinationChainID, - destinationContractAddress, - tssPrices, - packet.CreatedAt, - ) + + tssPacket := NewTSSPacket(sequence, tssPrices, createdAt) bz, err := packetArgs.Pack(&tssPacket) if err != nil { diff --git a/x/tunnel/types/encoding_tss_test.go b/x/tunnel/types/encoding_tss_test.go index 267618f12..0c23a1268 100644 --- a/x/tunnel/types/encoding_tss_test.go +++ b/x/tunnel/types/encoding_tss_test.go @@ -10,35 +10,22 @@ import ( "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -func TestEncodeTssFixedPrice(t *testing.T) { - packet := types.Packet{ - TunnelID: 1, - Sequence: 3, - Prices: []feedstypes.Price{{SignalID: "signal_01", Price: 2, Status: feedstypes.PRICE_STATUS_AVAILABLE}}, - CreatedAt: 123, - } - +func TestEncodeTSSFixedPrice(t *testing.T) { expectedMsg := ("cba0ad5a" + "0000000000000000000000000000000000000000000000000000000000000020" + - "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000003" + - "00000000000000000000000000000000000000000000000000000000000000c0" + - "0000000000000000000000000000000000000000000000000000000000000100" + - "0000000000000000000000000000000000000000000000000000000000000160" + + "0000000000000000000000000000000000000000000000000000000000000060" + "000000000000000000000000000000000000000000000000000000000000007b" + - "0000000000000000000000000000000000000000000000000000000000000003" + - "6574680000000000000000000000000000000000000000000000000000000000" + - "000000000000000000000000000000000000000000000000000000000000002a" + - "307865303046316638356162444232614636373630373539353437643435306461363843453636426231" + - "00000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000001" + "00000000000000000000000000000000000000000000007369676e616c5f3031" + "0000000000000000000000000000000000000000000000000000000000000002") - msg, err := types.EncodeTss( - packet, - "eth", - "0xe00F1f85abDB2aF6760759547d450da68CE66Bb1", + msg, err := types.EncodeTSS( + 3, + []feedstypes.Price{ + {SignalID: "signal_01", Price: 2, Status: feedstypes.PRICE_STATUS_AVAILABLE}, + }, + 123, feedstypes.ENCODER_FIXED_POINT_ABI, ) require.NoError(t, err) @@ -46,35 +33,22 @@ func TestEncodeTssFixedPrice(t *testing.T) { require.Equal(t, expectedMsg, hex.EncodeToString(msg)) } -func TestEncodeTick(t *testing.T) { - packet := types.Packet{ - TunnelID: 1, - Sequence: 3, - Prices: []feedstypes.Price{{SignalID: "signal_01", Price: 2, Status: feedstypes.PRICE_STATUS_AVAILABLE}}, - CreatedAt: 123, - } - +func TestEncodeTSSTick(t *testing.T) { expectedMsg := ("db99b2b3" + "0000000000000000000000000000000000000000000000000000000000000020" + - "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000003" + - "00000000000000000000000000000000000000000000000000000000000000c0" + - "0000000000000000000000000000000000000000000000000000000000000100" + - "0000000000000000000000000000000000000000000000000000000000000160" + + "0000000000000000000000000000000000000000000000000000000000000060" + "000000000000000000000000000000000000000000000000000000000000007b" + - "0000000000000000000000000000000000000000000000000000000000000003" + - "6574680000000000000000000000000000000000000000000000000000000000" + - "000000000000000000000000000000000000000000000000000000000000002a" + - "307865303046316638356162444232614636373630373539353437643435306461363843453636426231" + - "00000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000001" + "00000000000000000000000000000000000000000000007369676e616c5f3031" + "000000000000000000000000000000000000000000000000000000000000f188") - msg, err := types.EncodeTss( - packet, - "eth", - "0xe00F1f85abDB2aF6760759547d450da68CE66Bb1", + msg, err := types.EncodeTSS( + 3, + []feedstypes.Price{ + {SignalID: "signal_01", Price: 2, Status: feedstypes.PRICE_STATUS_AVAILABLE}, + }, + 123, feedstypes.ENCODER_TICK_ABI, ) require.NoError(t, err) diff --git a/x/tunnel/types/errors.go b/x/tunnel/types/errors.go index 12bed8de4..def2cc6f3 100644 --- a/x/tunnel/types/errors.go +++ b/x/tunnel/types/errors.go @@ -6,24 +6,28 @@ import ( // x/tunnel module sentinel errors var ( - ErrInvalidGenesis = errorsmod.Register(ModuleName, 2, "invalid genesis") - ErrMaxSignalsExceeded = errorsmod.Register(ModuleName, 3, "max signals exceeded") - ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range") - ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range") - ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found") - ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found") - ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found") - ErrNoPacketContent = errorsmod.Register(ModuleName, 9, "no packet content") - ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel") - ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist") - ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route") - ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel") - ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active") - ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive") - ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom") - ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found") - ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit") - ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund") - ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found") - ErrInvalidEncoder = errorsmod.Register(ModuleName, 21, "invalid encoder mode") + ErrInvalidGenesis = errorsmod.Register(ModuleName, 2, "invalid genesis") + ErrMaxSignalsExceeded = errorsmod.Register(ModuleName, 3, "max signals exceeded") + ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range") + ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range") + ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found") + ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found") + ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found") + ErrNoPacketReceipt = errorsmod.Register(ModuleName, 9, "no packet receipt") + ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel") + ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist") + ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route") + ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel") + ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active") + ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive") + ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom") + ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found") + ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit") + ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund") + ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found") + ErrInvalidVersion = errorsmod.Register(ModuleName, 21, "invalid version") + ErrChannelCapabilityNotFound = errorsmod.Register(ModuleName, 22, "channel capability not found") + ErrMaxTunnelChannels = errorsmod.Register(ModuleName, 23, "max tunnel channels exceeded") + ErrInvalidEncoder = errorsmod.Register(ModuleName, 24, "invalid encoder") + ErrSendPacketPanic = errorsmod.Register(ModuleName, 25, "panic in sending packet") ) diff --git a/x/tunnel/types/expected_keepers.go b/x/tunnel/types/expected_keepers.go index c0727e3f5..ad0a83a65 100644 --- a/x/tunnel/types/expected_keepers.go +++ b/x/tunnel/types/expected_keepers.go @@ -3,6 +3,9 @@ package types import ( "context" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + sdk "github.com/cosmos/cosmos-sdk/types" bandtsstypes "github.com/bandprotocol/chain/v3/x/bandtss/types" @@ -39,6 +42,28 @@ type BankKeeper interface { ) error } +type ICS4Wrapper interface { + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight ibcclienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) +} + +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability +} + +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} + type FeedsKeeper interface { GetAllPrices(ctx sdk.Context) (prices []feedstypes.Price) GetPrices(ctx sdk.Context, signalIDs []string) (prices []feedstypes.Price) @@ -48,12 +73,11 @@ type BandtssKeeper interface { CreateTunnelSigningRequest( ctx sdk.Context, tunnelID uint64, - destinationContractAddr string, destinationChainID string, + destinationContractAddr string, content tsstypes.Content, sender sdk.AccAddress, feeLimit sdk.Coins, ) (bandtsstypes.SigningID, error) - GetSigningFee(ctx sdk.Context) (sdk.Coins, error) } diff --git a/x/tunnel/types/genesis.go b/x/tunnel/types/genesis.go index 6ad6afcb4..d2cfc4020 100644 --- a/x/tunnel/types/genesis.go +++ b/x/tunnel/types/genesis.go @@ -78,8 +78,3 @@ func ValidateGenesis(data GenesisState) error { return data.Params.Validate() } - -// Total returns the total fees -func (tf TotalFees) Total() sdk.Coins { - return tf.TotalPacketFee -} diff --git a/x/tunnel/types/genesis_test.go b/x/tunnel/types/genesis_test.go index e5d192e33..0c4be3579 100644 --- a/x/tunnel/types/genesis_test.go +++ b/x/tunnel/types/genesis_test.go @@ -62,7 +62,7 @@ func TestValidateGenesis(t *testing.T) { { TunnelID: 3, Depositor: "addr1", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), }, // Non-existent tunnel ID }, }, @@ -81,12 +81,12 @@ func TestValidateGenesis(t *testing.T) { { TunnelID: 1, Depositor: "addr1", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), }, { TunnelID: 1, Depositor: "addr1", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), }, // Duplicate deposit }, }, @@ -98,14 +98,14 @@ func TestValidateGenesis(t *testing.T) { Params: types.DefaultParams(), TunnelCount: 2, Tunnels: []types.Tunnel{ - {ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("stake", 100))}, - {ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("stake", 200))}, + {ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("uband", 100))}, + {ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("uband", 200))}, }, Deposits: []types.Deposit{ { TunnelID: 1, Depositor: "addr1", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 50)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 50)), }, }, }, @@ -117,19 +117,19 @@ func TestValidateGenesis(t *testing.T) { Params: types.DefaultParams(), TunnelCount: 2, Tunnels: []types.Tunnel{ - {ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("stake", 100))}, - {ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("stake", 200))}, + {ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("uband", 100))}, + {ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewInt64Coin("uband", 200))}, }, Deposits: []types.Deposit{ { TunnelID: 1, Depositor: "addr1", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), }, { TunnelID: 2, Depositor: "addr2", - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 200)), + Amount: sdk.NewCoins(sdk.NewInt64Coin("uband", 200)), }, }, }, diff --git a/x/tunnel/types/keys.go b/x/tunnel/types/keys.go index a2b8dca32..736f69215 100644 --- a/x/tunnel/types/keys.go +++ b/x/tunnel/types/keys.go @@ -42,6 +42,9 @@ var ( // params store keys ParamsKey = []byte{0x90} + + // PortKey defines the key to store the port ID in store + PortKey = []byte{0xf0} ) // TunnelStoreKey returns the key to retrieve a specific tunnel from the store. diff --git a/x/tunnel/types/latest_prices.go b/x/tunnel/types/latest_prices.go index a7205d507..7d688f3c4 100644 --- a/x/tunnel/types/latest_prices.go +++ b/x/tunnel/types/latest_prices.go @@ -1,8 +1,6 @@ package types import ( - fmt "fmt" - feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" ) @@ -19,19 +17,6 @@ func NewLatestPrices( } } -// Validate validates the latest prices. -func (l LatestPrices) Validate() error { - if l.TunnelID == 0 { - return fmt.Errorf("tunnel ID cannot be 0") - } - - if l.LastInterval < 0 { - return fmt.Errorf("last interval cannot be negative") - } - - return nil -} - // UpdatePrices updates prices in the latest prices. func (l *LatestPrices) UpdatePrices(newPrices []feedstypes.Price) { pricesIndex := make(map[string]int) diff --git a/x/tunnel/types/latest_prices_test.go b/x/tunnel/types/latest_prices_test.go index 3f3b8492d..9d63895d4 100644 --- a/x/tunnel/types/latest_prices_test.go +++ b/x/tunnel/types/latest_prices_test.go @@ -9,45 +9,6 @@ import ( "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -func TestLatestPrices_Validate(t *testing.T) { - examplePrices := []feedstypes.Price{ - feedstypes.NewPrice(feedstypes.PRICE_STATUS_AVAILABLE, "signal1", 100, 0), - } - - cases := map[string]struct { - latestPrices types.LatestPrices - expErr bool - expErrMsg string - }{ - "valid latest prices": { - latestPrices: types.NewLatestPrices(1, examplePrices, 10), - expErr: false, - }, - "invalid tunnel ID": { - latestPrices: types.NewLatestPrices(0, examplePrices, 10), - expErr: true, - expErrMsg: "tunnel ID cannot be 0", - }, - "negative last interval": { - latestPrices: types.NewLatestPrices(1, examplePrices, -1), - expErr: true, - expErrMsg: "last interval cannot be negative", - }, - } - - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - err := tc.latestPrices.Validate() - if tc.expErr { - require.Error(t, err) - require.Contains(t, err.Error(), tc.expErrMsg) - } else { - require.NoError(t, err) - } - }) - } -} - func TestLatestPrices_UpdatePrices(t *testing.T) { initialPrices := []feedstypes.Price{ {Status: feedstypes.PRICE_STATUS_AVAILABLE, SignalID: "signal1", Price: 100}, diff --git a/x/tunnel/types/msgs.go b/x/tunnel/types/msgs.go index 84cc07c34..002e7ca0b 100644 --- a/x/tunnel/types/msgs.go +++ b/x/tunnel/types/msgs.go @@ -63,6 +63,33 @@ func NewMsgCreateTSSTunnel( return m, nil } +// NewMsgCreateTunnel creates a new MsgCreateTunnel instance. +func NewMsgCreateIBCTunnel( + signalDeviations []SignalDeviation, + interval uint64, + channelID string, + encoder feedstypes.Encoder, + deposit sdk.Coins, + creator sdk.AccAddress, +) (*MsgCreateTunnel, error) { + r := NewIBCRoute(channelID) + m, err := NewMsgCreateTunnel(signalDeviations, interval, r, encoder, deposit, creator) + if err != nil { + return nil, err + } + + return m, nil +} + +// GetRouteValue returns the route of the tunnel. +func (m MsgCreateTunnel) GetRouteValue() (RouteI, error) { + r, ok := m.Route.GetCachedValue().(RouteI) + if !ok { + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (RouteI)(nil), m.Route.GetCachedValue()) + } + return r, nil +} + // ValidateBasic does a sanity check on the provided data func (m MsgCreateTunnel) ValidateBasic() error { // creator address must be valid @@ -80,9 +107,9 @@ func (m MsgCreateTunnel) ValidateBasic() error { } // route must be valid - r, ok := m.Route.GetCachedValue().(RouteI) - if !ok { - return sdkerrors.ErrPackAny.Wrapf("cannot unpack route") + r, err := m.GetRouteValue() + if err != nil { + return err } if err := r.ValidateBasic(); err != nil { return err @@ -107,16 +134,6 @@ func (m MsgCreateTunnel) UnpackInterfaces(unpacker types.AnyUnpacker) error { return unpacker.UnpackAny(m.Route, &route) } -// GetTunnelRoute returns the route of the tunnel. -func (m MsgCreateTunnel) GetTunnelRoute() RouteI { - route, ok := m.Route.GetCachedValue().(RouteI) - if !ok { - return nil - } - - return route -} - // NewMsgUpdateAndResetTunnel creates a new MsgUpdateAndResetTunnel instance. func NewMsgUpdateAndResetTunnel( tunnelID uint64, diff --git a/x/tunnel/types/msgs_test.go b/x/tunnel/types/msgs_test.go index 80049f267..43d25017c 100644 --- a/x/tunnel/types/msgs_test.go +++ b/x/tunnel/types/msgs_test.go @@ -130,7 +130,7 @@ func TestMsgTriggerTunnel_ValidateBasic(t *testing.T) { func TestMsgWithdrawFromTunnel_ValidateBasic(t *testing.T) { // Valid withdrawer - amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) + amount := sdk.NewCoins(sdk.NewInt64Coin("uband", 100)) msg := types.NewMsgWithdrawFromTunnel(1, amount, validDepositor.String()) err := msg.ValidateBasic() require.NoError(t, err) diff --git a/x/tunnel/types/packet.go b/x/tunnel/types/packet.go index 8b3d3599c..066243c58 100644 --- a/x/tunnel/types/packet.go +++ b/x/tunnel/types/packet.go @@ -1,8 +1,13 @@ package types import ( + "fmt" + + proto "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" ) @@ -18,39 +23,48 @@ func NewPacket( createdAt int64, ) Packet { return Packet{ - TunnelID: tunnelID, - Sequence: sequence, - Prices: prices, - PacketContent: nil, - BaseFee: baseFee, - RouteFee: routeFee, - CreatedAt: createdAt, + TunnelID: tunnelID, + Sequence: sequence, + Prices: prices, + Receipt: nil, + BaseFee: baseFee, + RouteFee: routeFee, + CreatedAt: createdAt, } } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (p Packet) UnpackInterfaces(unpacker types.AnyUnpacker) error { - var packetContent PacketContentI - return unpacker.UnpackAny(p.PacketContent, &packetContent) + var receipt PacketReceiptI + return unpacker.UnpackAny(p.Receipt, &receipt) } -// SetPacketContent sets the packet content of the packet. -func (p *Packet) SetPacketContent(packetContent PacketContentI) error { - any, err := types.NewAnyWithValue(packetContent) +// SetReceipt sets the packet's receipt. +func (p *Packet) SetReceipt(receipt PacketReceiptI) error { + msg, ok := receipt.(proto.Message) + if !ok { + return fmt.Errorf("can't proto marshal %T", msg) + } + + any, err := types.NewAnyWithValue(receipt) if err != nil { return err } - p.PacketContent = any + p.Receipt = any return nil } -// GetContent returns the content of the packet. -func (p Packet) GetContent() (PacketContentI, error) { - packetContent, ok := p.PacketContent.GetCachedValue().(PacketContentI) +// GetReceiptValue returns the packet's receipt. +func (p Packet) GetReceiptValue() (PacketReceiptI, error) { + r, ok := p.Receipt.GetCachedValue().(PacketReceiptI) if !ok { - return nil, ErrNoPacketContent.Wrapf("tunnelID: %d, sequence: %d", p.TunnelID, p.Sequence) + return nil, sdkerrors.ErrInvalidType.Wrapf( + "expected %T, got %T", + (PacketReceiptI)(nil), + p.Receipt.GetCachedValue(), + ) } - return packetContent, nil + return r, nil } diff --git a/x/tunnel/types/packet_content.go b/x/tunnel/types/packet_content.go deleted file mode 100644 index a6f9c8221..000000000 --- a/x/tunnel/types/packet_content.go +++ /dev/null @@ -1,8 +0,0 @@ -package types - -import "github.com/cosmos/gogoproto/proto" - -// PacketContentI defines the interface for packet content. -type PacketContentI interface { - proto.Message -} diff --git a/x/tunnel/types/packet_receipt.go b/x/tunnel/types/packet_receipt.go new file mode 100644 index 000000000..5ab313a28 --- /dev/null +++ b/x/tunnel/types/packet_receipt.go @@ -0,0 +1,8 @@ +package types + +import "github.com/cosmos/gogoproto/proto" + +// PacketReceiptI defines an interface for confirming the delivery of a packet to its destination via the specified route. +type PacketReceiptI interface { + proto.Message +} diff --git a/x/tunnel/types/packet_test.go b/x/tunnel/types/packet_test.go index 6d757c132..6dad984e3 100644 --- a/x/tunnel/types/packet_test.go +++ b/x/tunnel/types/packet_test.go @@ -10,34 +10,23 @@ import ( "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -func TestPacket_SetPacketContent(t *testing.T) { +func TestGetSetPacketReceipt(t *testing.T) { packet := types.NewPacket(1, 1, nil, nil, nil, 0) - packetContent := &types.TSSPacketContent{DestinationChainID: "chain-1", DestinationContractAddress: "contract-1"} + receipt := &types.TSSPacketReceipt{SigningID: 1} - err := packet.SetPacketContent(packetContent) - require.NoError(t, err) - require.NotNil(t, packet.PacketContent) - require.Equal(t, packetContent, packet.PacketContent.GetCachedValue()) -} - -func TestPacket_GetContent(t *testing.T) { - packet := types.NewPacket(1, 1, nil, nil, nil, 0) - packetContent := &types.TSSPacketContent{DestinationChainID: "chain-1", DestinationContractAddress: "contract-1"} - - err := packet.SetPacketContent(packetContent) + err := packet.SetReceipt(receipt) require.NoError(t, err) - content, err := packet.GetContent() + receiptValue, err := packet.GetReceiptValue() require.NoError(t, err) - require.NotNil(t, content) - require.Equal(t, packetContent, content) + require.Equal(t, receipt, receiptValue) } -func TestPacket_UnpackInterfaces(t *testing.T) { +func TestPacketUnpackInterfaces(t *testing.T) { packet := types.NewPacket(1, 1, nil, nil, nil, 0) - packetContent := &types.TSSPacketContent{DestinationChainID: "chain-1", DestinationContractAddress: "contract-1"} + packetResult := &types.TSSPacketReceipt{SigningID: 1} - err := packet.SetPacketContent(packetContent) + err := packet.SetReceipt(packetResult) require.NoError(t, err) unpacker := codectypes.NewInterfaceRegistry() diff --git a/x/tunnel/types/params.go b/x/tunnel/types/params.go index 369e66cb7..faaa4925f 100644 --- a/x/tunnel/types/params.go +++ b/x/tunnel/types/params.go @@ -32,7 +32,7 @@ func NewParams( MinDeposit: minDeposit, MinInterval: minInterval, MaxInterval: maxInterval, - MinDeviationBPS: minInterval, + MinDeviationBPS: minDeviationBPS, MaxDeviationBPS: maxDeviationBPS, MaxSignals: maxSignals, BasePacketFee: basePacketFee, diff --git a/x/tunnel/types/route.pb.go b/x/tunnel/types/route.pb.go index 9fc16ebc3..fede1d5b9 100644 --- a/x/tunnel/types/route.pb.go +++ b/x/tunnel/types/route.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" github_com_bandprotocol_chain_v3_x_bandtss_types "github.com/bandprotocol/chain/v3/x/bandtss/types" + types "github.com/bandprotocol/chain/v3/x/feeds/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -25,7 +26,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// TSSRoute is the type for a TSS route +// TSSRoute represents a route for TSS packets and implements the RouteI interface. type TSSRoute struct { // destination_chain_id is the destination chain ID DestinationChainID string `protobuf:"bytes,1,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"` @@ -80,28 +81,24 @@ func (m *TSSRoute) GetDestinationContractAddress() string { return "" } -// TSSPacketContent is the packet content for TSS -type TSSPacketContent struct { +// TSSPacketReceipt represents a receipt for a TSS packet and implements the PacketReceiptI interface. +type TSSPacketReceipt struct { // signing_id is the signing ID SigningID github_com_bandprotocol_chain_v3_x_bandtss_types.SigningID `protobuf:"varint,1,opt,name=signing_id,json=signingId,proto3,casttype=github.com/bandprotocol/chain/v3/x/bandtss/types.SigningID" json:"signing_id,omitempty"` - // destination_chain_id is the destination chain ID - DestinationChainID string `protobuf:"bytes,2,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"` - // destination_contract_address is the destination contract address - DestinationContractAddress string `protobuf:"bytes,3,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"` } -func (m *TSSPacketContent) Reset() { *m = TSSPacketContent{} } -func (m *TSSPacketContent) String() string { return proto.CompactTextString(m) } -func (*TSSPacketContent) ProtoMessage() {} -func (*TSSPacketContent) Descriptor() ([]byte, []int) { +func (m *TSSPacketReceipt) Reset() { *m = TSSPacketReceipt{} } +func (m *TSSPacketReceipt) String() string { return proto.CompactTextString(m) } +func (*TSSPacketReceipt) ProtoMessage() {} +func (*TSSPacketReceipt) Descriptor() ([]byte, []int) { return fileDescriptor_543238289d94b7a6, []int{1} } -func (m *TSSPacketContent) XXX_Unmarshal(b []byte) error { +func (m *TSSPacketReceipt) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *TSSPacketContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *TSSPacketReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_TSSPacketContent.Marshal(b, m, deterministic) + return xxx_messageInfo_TSSPacketReceipt.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -111,71 +108,235 @@ func (m *TSSPacketContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *TSSPacketContent) XXX_Merge(src proto.Message) { - xxx_messageInfo_TSSPacketContent.Merge(m, src) +func (m *TSSPacketReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_TSSPacketReceipt.Merge(m, src) } -func (m *TSSPacketContent) XXX_Size() int { +func (m *TSSPacketReceipt) XXX_Size() int { return m.Size() } -func (m *TSSPacketContent) XXX_DiscardUnknown() { - xxx_messageInfo_TSSPacketContent.DiscardUnknown(m) +func (m *TSSPacketReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_TSSPacketReceipt.DiscardUnknown(m) } -var xxx_messageInfo_TSSPacketContent proto.InternalMessageInfo +var xxx_messageInfo_TSSPacketReceipt proto.InternalMessageInfo -func (m *TSSPacketContent) GetSigningID() github_com_bandprotocol_chain_v3_x_bandtss_types.SigningID { +func (m *TSSPacketReceipt) GetSigningID() github_com_bandprotocol_chain_v3_x_bandtss_types.SigningID { if m != nil { return m.SigningID } return 0 } -func (m *TSSPacketContent) GetDestinationChainID() string { +// IBCRoute is the type for an IBC route +type IBCRoute struct { + // channel_id is the IBC channel ID + ChannelID string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +} + +func (m *IBCRoute) Reset() { *m = IBCRoute{} } +func (m *IBCRoute) String() string { return proto.CompactTextString(m) } +func (*IBCRoute) ProtoMessage() {} +func (*IBCRoute) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{2} +} +func (m *IBCRoute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCRoute.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 *IBCRoute) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCRoute.Merge(m, src) +} +func (m *IBCRoute) XXX_Size() int { + return m.Size() +} +func (m *IBCRoute) XXX_DiscardUnknown() { + xxx_messageInfo_IBCRoute.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCRoute proto.InternalMessageInfo + +func (m *IBCRoute) GetChannelID() string { if m != nil { - return m.DestinationChainID + return m.ChannelID } return "" } -func (m *TSSPacketContent) GetDestinationContractAddress() string { +// IBCPacketReceipt represents a receipt for a IBC packet and implements the PacketReceiptI interface. +type IBCPacketReceipt struct { + // sequence is representing the sequence of the IBC packet. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *IBCPacketReceipt) Reset() { *m = IBCPacketReceipt{} } +func (m *IBCPacketReceipt) String() string { return proto.CompactTextString(m) } +func (*IBCPacketReceipt) ProtoMessage() {} +func (*IBCPacketReceipt) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{3} +} +func (m *IBCPacketReceipt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCPacketReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCPacketReceipt.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 *IBCPacketReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCPacketReceipt.Merge(m, src) +} +func (m *IBCPacketReceipt) XXX_Size() int { + return m.Size() +} +func (m *IBCPacketReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_IBCPacketReceipt.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCPacketReceipt proto.InternalMessageInfo + +func (m *IBCPacketReceipt) GetSequence() uint64 { if m != nil { - return m.DestinationContractAddress + return m.Sequence } - return "" + return 0 +} + +// TunnelPricesPacketData represents the IBC packet payload for the tunnel packet. +type TunnelPricesPacketData struct { + // tunnel_id is the tunnel ID + TunnelID uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` + // sequence is representing the sequence of the tunnel packet. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []types.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (m *TunnelPricesPacketData) Reset() { *m = TunnelPricesPacketData{} } +func (m *TunnelPricesPacketData) String() string { return proto.CompactTextString(m) } +func (*TunnelPricesPacketData) ProtoMessage() {} +func (*TunnelPricesPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_543238289d94b7a6, []int{4} +} +func (m *TunnelPricesPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TunnelPricesPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TunnelPricesPacketData.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 *TunnelPricesPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_TunnelPricesPacketData.Merge(m, src) +} +func (m *TunnelPricesPacketData) XXX_Size() int { + return m.Size() +} +func (m *TunnelPricesPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_TunnelPricesPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_TunnelPricesPacketData proto.InternalMessageInfo + +func (m *TunnelPricesPacketData) GetTunnelID() uint64 { + if m != nil { + return m.TunnelID + } + return 0 +} + +func (m *TunnelPricesPacketData) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *TunnelPricesPacketData) GetPrices() []types.Price { + if m != nil { + return m.Prices + } + return nil +} + +func (m *TunnelPricesPacketData) GetCreatedAt() int64 { + if m != nil { + return m.CreatedAt + } + return 0 } func init() { proto.RegisterType((*TSSRoute)(nil), "band.tunnel.v1beta1.TSSRoute") - proto.RegisterType((*TSSPacketContent)(nil), "band.tunnel.v1beta1.TSSPacketContent") + proto.RegisterType((*TSSPacketReceipt)(nil), "band.tunnel.v1beta1.TSSPacketReceipt") + proto.RegisterType((*IBCRoute)(nil), "band.tunnel.v1beta1.IBCRoute") + proto.RegisterType((*IBCPacketReceipt)(nil), "band.tunnel.v1beta1.IBCPacketReceipt") + proto.RegisterType((*TunnelPricesPacketData)(nil), "band.tunnel.v1beta1.TunnelPricesPacketData") } func init() { proto.RegisterFile("band/tunnel/v1beta1/route.proto", fileDescriptor_543238289d94b7a6) } var fileDescriptor_543238289d94b7a6 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x4a, 0xcc, 0x4b, - 0xd1, 0x2f, 0x29, 0xcd, 0xcb, 0x4b, 0xcd, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, - 0x2f, 0xca, 0x2f, 0x2d, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x06, 0x29, 0xd0, - 0x83, 0x28, 0xd0, 0x83, 0x2a, 0x90, 0x92, 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x07, 0x2b, - 0xd1, 0x87, 0x70, 0x20, 0xea, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0x21, 0xe2, 0x20, 0x16, 0x44, - 0x54, 0x69, 0x11, 0x23, 0x17, 0x47, 0x48, 0x70, 0x70, 0x10, 0xc8, 0x60, 0x21, 0x0f, 0x2e, 0x91, - 0x94, 0xd4, 0xe2, 0x92, 0xcc, 0xbc, 0xc4, 0x92, 0xcc, 0xfc, 0xbc, 0xf8, 0xe4, 0x8c, 0xc4, 0xcc, - 0xbc, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xb1, 0x47, 0xf7, 0xe4, 0x85, - 0x5c, 0x10, 0xf2, 0xce, 0x20, 0x69, 0x4f, 0x97, 0x20, 0xa1, 0x14, 0x74, 0xb1, 0x14, 0x21, 0x07, - 0x2e, 0x19, 0x14, 0x93, 0xf2, 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, - 0x52, 0x8b, 0x8b, 0x25, 0x98, 0x40, 0x26, 0x06, 0x49, 0x21, 0xeb, 0x84, 0x2a, 0x71, 0x84, 0xa8, - 0xb0, 0xe2, 0x3a, 0xb5, 0x45, 0x97, 0x0d, 0xec, 0x2c, 0x4f, 0xa5, 0x79, 0x4c, 0x5c, 0x02, 0x21, - 0xc1, 0xc1, 0x01, 0x89, 0xc9, 0xd9, 0xa9, 0x25, 0x20, 0x85, 0xa9, 0x79, 0x25, 0x42, 0x59, 0x5c, - 0x5c, 0xc5, 0x99, 0xe9, 0x79, 0x99, 0x79, 0xe9, 0x30, 0x27, 0xb2, 0x38, 0x79, 0x3f, 0xba, 0x27, - 0xcf, 0x19, 0x0c, 0x11, 0xf5, 0x74, 0xf9, 0x75, 0x4f, 0xde, 0x2a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, - 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x14, 0x5e, 0x60, 0x4f, 0x27, 0xe7, 0xe7, 0xe8, 0x83, 0xfd, - 0xa6, 0x5f, 0x66, 0xac, 0x5f, 0x01, 0x16, 0x2f, 0x29, 0x2e, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, - 0xd6, 0x83, 0xeb, 0x0e, 0xe2, 0x84, 0x1a, 0xef, 0x99, 0x82, 0x33, 0x60, 0x98, 0xa8, 0x1e, 0x30, - 0xcc, 0x04, 0x03, 0x46, 0xe8, 0xd4, 0x16, 0x5d, 0x3e, 0x94, 0xa0, 0xf0, 0x74, 0xf2, 0x5d, 0xf1, - 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, - 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0x89, 0x08, - 0x04, 0x68, 0x42, 0x03, 0x87, 0x41, 0x12, 0x1b, 0x58, 0x85, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, - 0xad, 0xb3, 0xc7, 0x86, 0x84, 0x02, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xc1, 0x6e, 0x13, 0x3d, + 0x10, 0xc7, 0xb3, 0x4d, 0xbe, 0x28, 0xeb, 0x0f, 0x50, 0x65, 0xaa, 0x2a, 0x8d, 0x60, 0x37, 0xca, + 0x29, 0x48, 0x64, 0xad, 0xd2, 0x03, 0x52, 0x4e, 0x74, 0x93, 0x03, 0x16, 0x42, 0xaa, 0x36, 0x39, + 0x71, 0x89, 0x1c, 0xdb, 0x24, 0x0b, 0xad, 0x1d, 0xd6, 0x4e, 0x05, 0x6f, 0x81, 0x78, 0x04, 0x4e, + 0x3c, 0x40, 0x24, 0x5e, 0xa1, 0xca, 0xa9, 0x47, 0x4e, 0x11, 0xda, 0xbc, 0x05, 0x27, 0x64, 0x7b, + 0x49, 0xba, 0x9c, 0xb8, 0xad, 0xff, 0xf3, 0xf3, 0xfc, 0x67, 0xc6, 0xb3, 0x20, 0x9c, 0x12, 0xc1, + 0x90, 0x5e, 0x0a, 0xc1, 0x2f, 0xd1, 0xf5, 0xe9, 0x94, 0x6b, 0x72, 0x8a, 0x32, 0xb9, 0xd4, 0x3c, + 0x5a, 0x64, 0x52, 0x4b, 0xf8, 0xd0, 0x00, 0x91, 0x03, 0xa2, 0x02, 0x68, 0x9d, 0x50, 0xa9, 0xae, + 0xa4, 0x9a, 0x58, 0x04, 0xb9, 0x83, 0xe3, 0x5b, 0x47, 0x33, 0x39, 0x93, 0x4e, 0x37, 0x5f, 0x85, + 0x1a, 0x58, 0x9b, 0xb7, 0x9c, 0x33, 0xb5, 0x73, 0xb1, 0x27, 0x17, 0xef, 0x7c, 0xf5, 0x40, 0x63, + 0x3c, 0x1a, 0x25, 0xc6, 0x18, 0xbe, 0x04, 0x47, 0x8c, 0x2b, 0x9d, 0x0a, 0xa2, 0x53, 0x29, 0x26, + 0x74, 0x4e, 0x52, 0x31, 0x49, 0x59, 0xd3, 0x6b, 0x7b, 0x5d, 0x3f, 0x3e, 0xce, 0x37, 0x21, 0x1c, + 0xee, 0xe3, 0x03, 0x13, 0xc6, 0xc3, 0x04, 0xb2, 0xbf, 0x35, 0x06, 0x5f, 0x80, 0x47, 0xa5, 0x4c, + 0x52, 0xe8, 0x8c, 0x50, 0x3d, 0x21, 0x8c, 0x65, 0x5c, 0xa9, 0xe6, 0x81, 0xc9, 0x98, 0xb4, 0xee, + 0xde, 0x2c, 0x90, 0x73, 0x47, 0xf4, 0xc1, 0x7a, 0xd5, 0xab, 0xdb, 0xb2, 0x70, 0xe7, 0x8b, 0x07, + 0x0e, 0xc7, 0xa3, 0xd1, 0x05, 0xa1, 0xef, 0xb9, 0x4e, 0x38, 0xe5, 0xe9, 0x42, 0xc3, 0x77, 0x00, + 0xa8, 0x74, 0x26, 0x52, 0x31, 0xfb, 0x53, 0x62, 0x2d, 0x7e, 0x95, 0x6f, 0x42, 0x7f, 0xe4, 0x54, + 0x3c, 0xfc, 0xb5, 0x09, 0xfb, 0xb3, 0x54, 0xcf, 0x97, 0xd3, 0x88, 0xca, 0x2b, 0x64, 0x26, 0x61, + 0x9b, 0xa6, 0xf2, 0x12, 0xd9, 0xde, 0xd0, 0xf5, 0x19, 0xfa, 0x68, 0x75, 0xad, 0x14, 0xd2, 0x9f, + 0x16, 0x5c, 0x45, 0xbb, 0xdb, 0x89, 0x5f, 0xa4, 0xc7, 0xac, 0x0f, 0xd7, 0xab, 0xde, 0x83, 0x92, + 0x3d, 0xee, 0x0c, 0x40, 0x03, 0xc7, 0x03, 0x37, 0xb8, 0xa7, 0x00, 0xd0, 0x39, 0x31, 0x2f, 0xb5, + 0x1f, 0xd7, 0x7d, 0x53, 0xcb, 0xc0, 0xa9, 0x26, 0x5b, 0x01, 0x60, 0xd6, 0xf7, 0xd7, 0xab, 0xde, + 0x7f, 0xf6, 0x62, 0x27, 0x06, 0x87, 0x38, 0x1e, 0x94, 0x1b, 0x6b, 0x81, 0x86, 0xe2, 0x1f, 0x96, + 0x5c, 0x50, 0xee, 0xda, 0x4a, 0x76, 0xe7, 0xbb, 0x85, 0x98, 0x81, 0x71, 0xa1, 0x71, 0xe7, 0xbb, + 0x07, 0x8e, 0xc7, 0x76, 0x4d, 0x2e, 0xb2, 0x94, 0x72, 0xe5, 0xc2, 0x43, 0xa2, 0x09, 0x7c, 0x02, + 0x7c, 0xb7, 0x40, 0xfb, 0x11, 0xdd, 0xcb, 0x37, 0x61, 0xc3, 0xe1, 0x78, 0x98, 0x34, 0x5c, 0x18, + 0xb3, 0x92, 0xeb, 0x41, 0xd9, 0x15, 0x3e, 0x07, 0xf5, 0x85, 0x4d, 0xdd, 0xac, 0xb6, 0xab, 0xdd, + 0xff, 0x9f, 0x9d, 0x44, 0x76, 0x37, 0xdd, 0x1e, 0x15, 0x5b, 0x15, 0x59, 0xf3, 0xb8, 0x76, 0xb3, + 0x09, 0x2b, 0x49, 0x81, 0xc3, 0xc7, 0x00, 0xd0, 0x8c, 0x13, 0xcd, 0xd9, 0x84, 0xe8, 0x66, 0xad, + 0xed, 0x75, 0xab, 0x89, 0x5f, 0x28, 0xe7, 0x3a, 0x7e, 0xfd, 0x2d, 0x0f, 0xbc, 0x9b, 0x3c, 0xf0, + 0x6e, 0xf3, 0xc0, 0xfb, 0x99, 0x07, 0xde, 0xe7, 0x6d, 0x50, 0xb9, 0xdd, 0x06, 0x95, 0x1f, 0xdb, + 0xa0, 0xf2, 0x06, 0xfd, 0xc3, 0xdb, 0x15, 0xff, 0x8f, 0x7d, 0xba, 0x69, 0xdd, 0x12, 0x67, 0xbf, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x67, 0x73, 0xe8, 0xaf, 0x5b, 0x03, 0x00, 0x00, } func (this *TSSRoute) Equal(that interface{}) bool { @@ -205,14 +366,14 @@ func (this *TSSRoute) Equal(that interface{}) bool { } return true } -func (this *TSSPacketContent) Equal(that interface{}) bool { +func (this *TSSPacketReceipt) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*TSSPacketContent) + that1, ok := that.(*TSSPacketReceipt) if !ok { - that2, ok := that.(TSSPacketContent) + that2, ok := that.(TSSPacketReceipt) if ok { that1 = &that2 } else { @@ -227,10 +388,90 @@ func (this *TSSPacketContent) Equal(that interface{}) bool { if this.SigningID != that1.SigningID { return false } - if this.DestinationChainID != that1.DestinationChainID { + return true +} +func (this *IBCRoute) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCRoute) + if !ok { + that2, ok := that.(IBCRoute) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { return false } - if this.DestinationContractAddress != that1.DestinationContractAddress { + if this.ChannelID != that1.ChannelID { + return false + } + return true +} +func (this *IBCPacketReceipt) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCPacketReceipt) + if !ok { + that2, ok := that.(IBCPacketReceipt) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sequence != that1.Sequence { + return false + } + return true +} +func (this *TunnelPricesPacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TunnelPricesPacketData) + if !ok { + that2, ok := that.(TunnelPricesPacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TunnelID != that1.TunnelID { + return false + } + if this.Sequence != that1.Sequence { + return false + } + if len(this.Prices) != len(that1.Prices) { + return false + } + for i := range this.Prices { + if !this.Prices[i].Equal(&that1.Prices[i]) { + return false + } + } + if this.CreatedAt != that1.CreatedAt { return false } return true @@ -272,7 +513,7 @@ func (m *TSSRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *TSSPacketContent) Marshal() (dAtA []byte, err error) { +func (m *TSSPacketReceipt) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -282,32 +523,128 @@ func (m *TSSPacketContent) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *TSSPacketContent) MarshalTo(dAtA []byte) (int, error) { +func (m *TSSPacketReceipt) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TSSPacketContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TSSPacketReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.DestinationContractAddress) > 0 { - i -= len(m.DestinationContractAddress) - copy(dAtA[i:], m.DestinationContractAddress) - i = encodeVarintRoute(dAtA, i, uint64(len(m.DestinationContractAddress))) + if m.SigningID != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.SigningID)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x8 } - if len(m.DestinationChainID) > 0 { - i -= len(m.DestinationChainID) - copy(dAtA[i:], m.DestinationChainID) - i = encodeVarintRoute(dAtA, i, uint64(len(m.DestinationChainID))) + return len(dAtA) - i, nil +} + +func (m *IBCRoute) 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 *IBCRoute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCRoute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintRoute(dAtA, i, uint64(len(m.ChannelID))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa } - if m.SigningID != 0 { - i = encodeVarintRoute(dAtA, i, uint64(m.SigningID)) + return len(dAtA) - i, nil +} + +func (m *IBCPacketReceipt) 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 *IBCPacketReceipt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCPacketReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TunnelPricesPacketData) 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 *TunnelPricesPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TunnelPricesPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CreatedAt != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x20 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRoute(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Sequence != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if m.TunnelID != 0 { + i = encodeVarintRoute(dAtA, i, uint64(m.TunnelID)) i-- dAtA[i] = 0x8 } @@ -342,7 +679,7 @@ func (m *TSSRoute) Size() (n int) { return n } -func (m *TSSPacketContent) Size() (n int) { +func (m *TSSPacketReceipt) Size() (n int) { if m == nil { return 0 } @@ -351,17 +688,58 @@ func (m *TSSPacketContent) Size() (n int) { if m.SigningID != 0 { n += 1 + sovRoute(uint64(m.SigningID)) } - l = len(m.DestinationChainID) - if l > 0 { - n += 1 + l + sovRoute(uint64(l)) + return n +} + +func (m *IBCRoute) Size() (n int) { + if m == nil { + return 0 } - l = len(m.DestinationContractAddress) + var l int + _ = l + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovRoute(uint64(l)) } return n } +func (m *IBCPacketReceipt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovRoute(uint64(m.Sequence)) + } + return n +} + +func (m *TunnelPricesPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TunnelID != 0 { + n += 1 + sovRoute(uint64(m.TunnelID)) + } + if m.Sequence != 0 { + n += 1 + sovRoute(uint64(m.Sequence)) + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovRoute(uint64(l)) + } + } + if m.CreatedAt != 0 { + n += 1 + sovRoute(uint64(m.CreatedAt)) + } + return n +} + func sovRoute(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -482,7 +860,7 @@ func (m *TSSRoute) Unmarshal(dAtA []byte) error { } return nil } -func (m *TSSPacketContent) Unmarshal(dAtA []byte) error { +func (m *TSSPacketReceipt) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -505,10 +883,10 @@ func (m *TSSPacketContent) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TSSPacketContent: wiretype end group for non-group") + return fmt.Errorf("proto: TSSPacketReceipt: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TSSPacketContent: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TSSPacketReceipt: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -530,9 +908,59 @@ func (m *TSSPacketContent) Unmarshal(dAtA []byte) error { break } } - case 2: + default: + iNdEx = preIndex + skippy, err := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IBCRoute) 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 ErrIntOverflowRoute + } + 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: IBCRoute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCRoute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationChainID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -560,13 +988,170 @@ func (m *TSSPacketContent) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DestinationChainID = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IBCPacketReceipt) 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 ErrIntOverflowRoute + } + 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: IBCPacketReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCPacketReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipRoute(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRoute + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TunnelPricesPacketData) 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 ErrIntOverflowRoute + } + 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: TunnelPricesPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TunnelPricesPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TunnelID", wireType) + } + m.TunnelID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TunnelID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationContractAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRoute @@ -576,24 +1161,45 @@ func (m *TSSPacketContent) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthRoute } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthRoute } if postIndex > l { return io.ErrUnexpectedEOF } - m.DestinationContractAddress = string(dAtA[iNdEx:postIndex]) + m.Prices = append(m.Prices, types.Price{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRoute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRoute(dAtA[iNdEx:]) diff --git a/x/tunnel/types/route_ibc.go b/x/tunnel/types/route_ibc.go new file mode 100644 index 000000000..49a5a2377 --- /dev/null +++ b/x/tunnel/types/route_ibc.go @@ -0,0 +1,57 @@ +package types + +import ( + "fmt" + + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" +) + +// IBCRoute defines the IBC route for the tunnel module +var _ RouteI = &IBCRoute{} + +// NewIBCRoute creates a new IBCRoute instance. +func NewIBCRoute(channelID string) *IBCRoute { + return &IBCRoute{ + ChannelID: channelID, + } +} + +// ValidateBasic validates the IBCRoute +func (r *IBCRoute) ValidateBasic() error { + // Validate the ChannelID format + if !channeltypes.IsChannelIDFormat(r.ChannelID) { + return fmt.Errorf("channel identifier is not in the format: `channel-{N}`") + } + return nil +} + +// NewIBCPacketReceipt creates a new IBCPacketReceipt instance. +func NewIBCPacketReceipt(sequence uint64) *IBCPacketReceipt { + return &IBCPacketReceipt{ + Sequence: sequence, + } +} + +// NewTunnelPricesPacketData creates a new TunnelPricesPacketData instance. +func NewTunnelPricesPacketData( + tunnelID uint64, + sequence uint64, + prices []feedstypes.Price, + createdAt int64, +) TunnelPricesPacketData { + return TunnelPricesPacketData{ + TunnelID: tunnelID, + Sequence: sequence, + Prices: prices, + CreatedAt: createdAt, + } +} + +// GetBytes is a helper for serialising +func (p TunnelPricesPacketData) GetBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&p)) +} diff --git a/x/tunnel/types/route_ibc_test.go b/x/tunnel/types/route_ibc_test.go new file mode 100644 index 000000000..26b91d30f --- /dev/null +++ b/x/tunnel/types/route_ibc_test.go @@ -0,0 +1,27 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestGetByteTunnelPricesPacketData(t *testing.T) { + packet := types.NewTunnelPricesPacketData( + 1, + 2, + []feedstypes.Price{{Status: feedstypes.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "BTC", Price: 50000}}, + 1633024800, + ) + + require.Equal( + t, + []byte( + `{"created_at":"1633024800","prices":[{"price":"50000","signal_id":"BTC","status":"PRICE_STATUS_NOT_IN_CURRENT_FEEDS","timestamp":"0"}],"sequence":"2","tunnel_id":"1"}`, + ), + packet.GetBytes(), + ) +} diff --git a/x/tunnel/types/route_tss.go b/x/tunnel/types/route_tss.go index 011ca9ddd..0e9d9330b 100644 --- a/x/tunnel/types/route_tss.go +++ b/x/tunnel/types/route_tss.go @@ -27,14 +27,9 @@ func (r *TSSRoute) ValidateBasic() error { return nil } -func NewTSSPacketContent( - signingID bandtsstypes.SigningID, - destinationChainID string, - destinationContractAddress string, -) TSSPacketContent { - return TSSPacketContent{ - SigningID: signingID, - DestinationChainID: destinationChainID, - DestinationContractAddress: destinationContractAddress, +// NewTSSPacketReceipt creates a new TSSPacketReceipt instance. +func NewTSSPacketReceipt(signingID bandtsstypes.SigningID) *TSSPacketReceipt { + return &TSSPacketReceipt{ + SigningID: signingID, } } diff --git a/x/tunnel/types/signal_deviation.go b/x/tunnel/types/signal_deviation.go index 48358d8ee..10e1e8220 100644 --- a/x/tunnel/types/signal_deviation.go +++ b/x/tunnel/types/signal_deviation.go @@ -14,22 +14,27 @@ func NewSignalDeviation( } // ValidateSignalDeviations validates the signal deviations with the given params. -func ValidateSignalDeviations(signalDeviations []SignalDeviation, params Params) error { +func ValidateSignalDeviations( + signalDeviations []SignalDeviation, + maxSignals uint64, + maxDeviationBPS uint64, + minDeviationBPS uint64, +) error { // validate max signals - if len(signalDeviations) > int(params.MaxSignals) { - return ErrMaxSignalsExceeded.Wrapf("max signals %d, got %d", params.MaxSignals, len(signalDeviations)) + if len(signalDeviations) > int(maxSignals) { + return ErrMaxSignalsExceeded.Wrapf("max signals %d, got %d", maxSignals, len(signalDeviations)) } // validate min and max deviation for _, signalDeviation := range signalDeviations { - if signalDeviation.HardDeviationBPS < params.MinDeviationBPS || - signalDeviation.SoftDeviationBPS < params.MinDeviationBPS || - signalDeviation.HardDeviationBPS > params.MaxDeviationBPS || - signalDeviation.SoftDeviationBPS > params.MaxDeviationBPS { + if signalDeviation.HardDeviationBPS < minDeviationBPS || + signalDeviation.SoftDeviationBPS < minDeviationBPS || + signalDeviation.HardDeviationBPS > maxDeviationBPS || + signalDeviation.SoftDeviationBPS > maxDeviationBPS { return ErrDeviationOutOfRange.Wrapf( "min %d, max %d, got %d, %d", - params.MinDeviationBPS, - params.MaxDeviationBPS, + minDeviationBPS, + maxDeviationBPS, signalDeviation.SoftDeviationBPS, signalDeviation.HardDeviationBPS, ) diff --git a/x/tunnel/types/signal_deviation_test.go b/x/tunnel/types/signal_deviation_test.go index 346170f07..30d168a7b 100644 --- a/x/tunnel/types/signal_deviation_test.go +++ b/x/tunnel/types/signal_deviation_test.go @@ -63,7 +63,12 @@ func TestValidateSignalDeviations(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := types.ValidateSignalDeviations(tc.signalDeviations, params) + err := types.ValidateSignalDeviations( + tc.signalDeviations, + params.MaxSignals, + params.MaxDeviationBPS, + params.MinDeviationBPS, + ) if tc.expErr { require.Error(t, err) require.Contains(t, err.Error(), tc.expErrMsg) diff --git a/x/tunnel/types/signature_order.go b/x/tunnel/types/signature_order.go index 74adaa367..1ffa71384 100644 --- a/x/tunnel/types/signature_order.go +++ b/x/tunnel/types/signature_order.go @@ -1,24 +1,35 @@ package types import ( + feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" ) // signature order types -const SignatureOrderTypeTunnel = "Tunnel" +const SignatureOrderTypeTunnel = "tunnel" // Implements Content Interface var _ tsstypes.Content = &TunnelSignatureOrder{} // NewTunnelSignatureOrder returns a new TunnelSignatureOrder object -func NewTunnelSignatureOrder(tunnelID uint64, sequence uint64) *TunnelSignatureOrder { - return &TunnelSignatureOrder{tunnelID, sequence} +func NewTunnelSignatureOrder( + sequence uint64, + prices []feedstypes.Price, + createdAt int64, + encoder feedstypes.Encoder, +) *TunnelSignatureOrder { + return &TunnelSignatureOrder{ + Sequence: sequence, + Prices: prices, + CreatedAt: createdAt, + Encoder: encoder, + } } // OrderRoute returns the order router key func (ts *TunnelSignatureOrder) OrderRoute() string { return RouterKey } -// OrderType returns type of signature order that should be "Tunnel" +// OrderType returns type of signature order that should be "tunnel" func (ts *TunnelSignatureOrder) OrderType() string { return SignatureOrderTypeTunnel } diff --git a/x/tunnel/types/total_fees.go b/x/tunnel/types/total_fees.go new file mode 100644 index 000000000..ef3544ca4 --- /dev/null +++ b/x/tunnel/types/total_fees.go @@ -0,0 +1,20 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Total returns the total fees +func (tf TotalFees) Total() sdk.Coins { + return tf.TotalBasePacketFee +} + +// Validate validates the total fees +func (tf TotalFees) Validate() error { + if !tf.TotalBasePacketFee.IsValid() { + return fmt.Errorf("invalid total packet fee: %s", tf.TotalBasePacketFee) + } + return nil +} diff --git a/x/tunnel/types/total_fees_test.go b/x/tunnel/types/total_fees_test.go new file mode 100644 index 000000000..5c9ef2ccf --- /dev/null +++ b/x/tunnel/types/total_fees_test.go @@ -0,0 +1,47 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v3/x/tunnel/types" +) + +func TestTotalFees_Validate(t *testing.T) { + tests := []struct { + name string + totalFees types.TotalFees + expErr bool + }{ + { + name: "invalid total packet fee", + totalFees: types.TotalFees{ + TotalBasePacketFee: sdk.Coins{(sdk.Coin{Denom: "uband", Amount: math.NewInt(-100)})}, + }, + expErr: true, + }, + { + name: "all good", + totalFees: types.TotalFees{ + TotalBasePacketFee: sdk.NewCoins(sdk.NewInt64Coin("uband", 100)), + }, + expErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.totalFees.Validate() + if tt.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/tunnel/types/tunnel.go b/x/tunnel/types/tunnel.go index 79196c1cb..b753fd03c 100644 --- a/x/tunnel/types/tunnel.go +++ b/x/tunnel/types/tunnel.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" ) @@ -63,6 +64,7 @@ func (t *Tunnel) SetRoute(route RouteI) error { if !ok { return fmt.Errorf("can't proto marshal %T", msg) } + any, err := types.NewAnyWithValue(msg) if err != nil { return err @@ -72,6 +74,20 @@ func (t *Tunnel) SetRoute(route RouteI) error { return nil } +// GetRouteValue returns the route value of the tunnel. +func (t Tunnel) GetRouteValue() (RouteI, error) { + r, ok := t.Route.GetCachedValue().(RouteI) + if !ok { + return nil, sdkerrors.ErrInvalidType.Wrapf( + "expected %T, got %T", + (RouteI)(nil), + t.Route.GetCachedValue(), + ) + } + + return r, nil +} + // GetSignalDeviationMap returns the signal deviation map of the tunnel. func (t Tunnel) GetSignalDeviationMap() map[string]SignalDeviation { signalDeviationMap := make(map[string]SignalDeviation, len(t.SignalDeviations)) @@ -90,21 +106,13 @@ func (t Tunnel) GetSignalIDs() []string { return signalIDs } -// Validate validates the total fees -func (tf TotalFees) Validate() error { - if !tf.TotalPacketFee.IsValid() { - return fmt.Errorf("invalid total packet fee: %s", tf.TotalPacketFee) - } - return nil -} - -// ValidateInterval validates the interval. -func ValidateInterval(interval uint64, params Params) error { - if interval < params.MinInterval || interval > params.MaxInterval { +// ValidateInterval validates the interval of the tunnel. +func ValidateInterval(interval, maxInterval, minInterval uint64) error { + if interval < minInterval || interval > maxInterval { return ErrIntervalOutOfRange.Wrapf( "max %d, min %d, got %d", - params.MaxInterval, - params.MinInterval, + maxInterval, + minInterval, interval, ) } diff --git a/x/tunnel/types/tunnel.pb.go b/x/tunnel/types/tunnel.pb.go index 36c2109d8..6bb39de9d 100644 --- a/x/tunnel/types/tunnel.pb.go +++ b/x/tunnel/types/tunnel.pb.go @@ -231,8 +231,8 @@ func (m *LatestPrices) GetLastInterval() int64 { // TotalFees is the type for the total fees collected by the tunnel type TotalFees struct { - // total_packet_fee is the total packet fee collected - TotalPacketFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=total_packet_fee,json=totalPacketFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_packet_fee"` + // total_base_packet_fee is the total base packet fee collected by the tunnel + TotalBasePacketFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=total_base_packet_fee,json=totalBasePacketFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_base_packet_fee"` } func (m *TotalFees) Reset() { *m = TotalFees{} } @@ -268,9 +268,9 @@ func (m *TotalFees) XXX_DiscardUnknown() { var xxx_messageInfo_TotalFees proto.InternalMessageInfo -func (m *TotalFees) GetTotalPacketFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *TotalFees) GetTotalBasePacketFee() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.TotalPacketFee + return m.TotalBasePacketFee } return nil } @@ -283,8 +283,8 @@ type Packet struct { Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` // prices is the list of prices information from feeds module. Prices []types1.Price `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices"` - // packet_content is the content of the packet that implements PacketContentI - PacketContent *types.Any `protobuf:"bytes,4,opt,name=packet_content,json=packetContent,proto3" json:"packet_content,omitempty"` + // receipt represents the confirmation of the packet delivery to the destination via the specified route. + Receipt *types.Any `protobuf:"bytes,4,opt,name=receipt,proto3" json:"receipt,omitempty"` // base_fee is the base fee of the packet BaseFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=base_fee,json=baseFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"base_fee"` // route_fee is the route fee of the packet @@ -347,9 +347,9 @@ func (m *Packet) GetPrices() []types1.Price { return nil } -func (m *Packet) GetPacketContent() *types.Any { +func (m *Packet) GetReceipt() *types.Any { if m != nil { - return m.PacketContent + return m.Receipt } return nil } @@ -505,10 +505,14 @@ func (m *SignalDeviation) GetHardDeviationBPS() uint64 { // TunnelSignatureOrder defines a general signature order for sending signature to tss group. type TunnelSignatureOrder struct { - // tunnel_id is the ID of the tunnel - TunnelID uint64 `protobuf:"varint,1,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"` // sequence is the sequence of the packet - Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` + // prices is the list of prices information from feeds module. + Prices []types1.Price `protobuf:"bytes,2,rep,name=prices,proto3" json:"prices"` + // created_at is the timestamp when the packet is created + CreatedAt int64 `protobuf:"varint,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + // encoder is the mode of encoding price data. + Encoder types1.Encoder `protobuf:"varint,4,opt,name=encoder,proto3,enum=band.feeds.v1beta1.Encoder" json:"encoder,omitempty"` } func (m *TunnelSignatureOrder) Reset() { *m = TunnelSignatureOrder{} } @@ -557,64 +561,66 @@ func init() { func init() { proto.RegisterFile("band/tunnel/v1beta1/tunnel.proto", fileDescriptor_6bb6151451ba2f25) } var fileDescriptor_6bb6151451ba2f25 = []byte{ - // 912 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6b, 0x1b, 0x47, - 0x14, 0xf7, 0x48, 0xb2, 0xb4, 0x3b, 0xfe, 0x53, 0x67, 0x2a, 0xca, 0xc6, 0xa1, 0x92, 0x70, 0x7b, - 0x50, 0x0b, 0xde, 0x6d, 0x1c, 0x9c, 0x42, 0x6e, 0x56, 0x5c, 0x53, 0x41, 0x4b, 0xcc, 0x3a, 0x50, - 0xe8, 0x65, 0x19, 0xed, 0x3e, 0x49, 0x4b, 0xe4, 0x99, 0xed, 0xce, 0xac, 0xa8, 0xbf, 0x41, 0x8e, - 0xfd, 0x02, 0x85, 0x1c, 0x43, 0x4f, 0x3d, 0xf8, 0x23, 0xf4, 0x10, 0x7c, 0x0a, 0x3d, 0xf5, 0x50, - 0xdc, 0x22, 0x1f, 0xda, 0x8f, 0x51, 0xe6, 0xcf, 0x4a, 0x91, 0x49, 0x13, 0x0c, 0xbe, 0xd8, 0x7a, - 0xef, 0xfd, 0xe6, 0xbd, 0x37, 0xbf, 0xdf, 0xbc, 0x27, 0xe1, 0xce, 0x80, 0xb2, 0x24, 0x90, 0x05, - 0x63, 0x30, 0x09, 0xa6, 0xf7, 0x07, 0x20, 0xe9, 0x7d, 0x6b, 0xfa, 0x59, 0xce, 0x25, 0x27, 0x1f, - 0x2a, 0x84, 0x6f, 0x5d, 0x16, 0xb1, 0x7d, 0x87, 0x9e, 0xa6, 0x8c, 0x07, 0xfa, 0xaf, 0xc1, 0x6d, - 0xb7, 0x62, 0x2e, 0x4e, 0xb9, 0x08, 0x06, 0x54, 0xc0, 0x3c, 0x53, 0xcc, 0x53, 0x66, 0xe3, 0x77, - 0x4d, 0x3c, 0xd2, 0x56, 0x60, 0x0c, 0x1b, 0x6a, 0x8e, 0xf8, 0x88, 0x1b, 0xbf, 0xfa, 0x54, 0x1e, - 0x18, 0x71, 0x3e, 0x9a, 0x40, 0xa0, 0xad, 0x41, 0x31, 0x0c, 0x28, 0x3b, 0x2b, 0x6b, 0xe9, 0xae, - 0x87, 0x00, 0x89, 0x98, 0x97, 0xd2, 0x96, 0x89, 0xef, 0xfc, 0x56, 0xc3, 0xf5, 0xa7, 0xba, 0x63, - 0xf2, 0x11, 0xae, 0xa4, 0x89, 0x87, 0x3a, 0xa8, 0x5b, 0xeb, 0xd5, 0x67, 0x97, 0xed, 0x4a, 0xff, - 0x30, 0xac, 0xa4, 0x09, 0xd9, 0xc6, 0x8e, 0x80, 0x1f, 0x0a, 0x60, 0x31, 0x78, 0x15, 0x15, 0x0d, - 0xe7, 0x36, 0x79, 0x88, 0x57, 0x73, 0x5e, 0x48, 0xf0, 0xaa, 0x1d, 0xd4, 0x5d, 0xdb, 0x6b, 0xfa, - 0xa6, 0x13, 0xbf, 0xec, 0xc4, 0x3f, 0x60, 0x67, 0x3d, 0x7c, 0x71, 0xbe, 0x5b, 0x0f, 0x15, 0xac, - 0x1f, 0x1a, 0x38, 0xd9, 0xc7, 0x0d, 0x60, 0x31, 0x4f, 0x20, 0xf7, 0x6a, 0x1d, 0xd4, 0xdd, 0xdc, - 0xbb, 0xe7, 0x6b, 0xf2, 0x4c, 0x6b, 0xb6, 0x51, 0xff, 0x2b, 0x03, 0x09, 0x4b, 0x2c, 0xd9, 0xc7, - 0xee, 0x10, 0x20, 0xca, 0xe8, 0x19, 0xe4, 0xde, 0x6a, 0x07, 0x75, 0xdd, 0x9e, 0xf7, 0xfb, 0xf9, - 0x6e, 0xd3, 0x72, 0x74, 0x90, 0x24, 0x39, 0x08, 0x71, 0x22, 0xf3, 0x94, 0x8d, 0x42, 0x67, 0x08, - 0x70, 0xac, 0x90, 0xe4, 0x3b, 0x7c, 0x47, 0xa4, 0x23, 0x46, 0x27, 0x51, 0x02, 0xd3, 0x94, 0xca, - 0x94, 0x33, 0xe1, 0xd5, 0x3b, 0xd5, 0xee, 0xda, 0xde, 0xa7, 0xfe, 0x5b, 0x44, 0xf3, 0x4f, 0x34, - 0xfa, 0xb0, 0x04, 0xf7, 0x6a, 0xaf, 0x2e, 0xdb, 0x2b, 0xe1, 0x96, 0x58, 0x76, 0x0b, 0x45, 0x4d, - 0xca, 0x24, 0xe4, 0x53, 0x3a, 0xf1, 0x1a, 0x86, 0x9a, 0xd2, 0x26, 0x05, 0xde, 0x90, 0x5c, 0xea, - 0x9a, 0x19, 0x17, 0xa9, 0xf4, 0x1c, 0x5d, 0xf0, 0xae, 0x6f, 0x9b, 0x55, 0xea, 0xcf, 0x0b, 0x3e, - 0xe6, 0x29, 0xeb, 0xed, 0xab, 0x2a, 0xbf, 0xfc, 0xd5, 0xee, 0x8e, 0x52, 0x39, 0x2e, 0x06, 0x7e, - 0xcc, 0x4f, 0xad, 0xfa, 0xf6, 0xdf, 0xae, 0x48, 0x9e, 0x05, 0xf2, 0x2c, 0x03, 0xa1, 0x0f, 0x88, - 0x97, 0xff, 0xfc, 0xfa, 0x39, 0x0a, 0xd7, 0x75, 0x99, 0x43, 0x53, 0x85, 0xdc, 0xc3, 0x6e, 0x2a, - 0x22, 0x1a, 0xcb, 0x74, 0x0a, 0x9e, 0xdb, 0x41, 0x5d, 0x27, 0x74, 0x52, 0x71, 0xa0, 0x6d, 0xf2, - 0x31, 0xc6, 0x71, 0x0e, 0x54, 0x42, 0x12, 0x51, 0xe9, 0xe1, 0x0e, 0xea, 0x56, 0x43, 0xd7, 0x7a, - 0x0e, 0x24, 0xd9, 0xc3, 0x0d, 0x6d, 0xf0, 0xdc, 0x5b, 0x7b, 0x0f, 0xb9, 0x25, 0xf0, 0x51, 0xed, - 0xdf, 0x17, 0x6d, 0xb4, 0xf3, 0x33, 0xc2, 0xeb, 0xdf, 0x50, 0x09, 0x42, 0x1e, 0xe7, 0x69, 0x0c, - 0x82, 0x7c, 0x86, 0x5d, 0xc3, 0x69, 0x34, 0x7f, 0x53, 0xeb, 0xb3, 0xcb, 0xb6, 0x63, 0xde, 0x5a, - 0xff, 0x30, 0x74, 0x4c, 0xb8, 0x9f, 0x90, 0x2f, 0x71, 0x3d, 0xd3, 0x87, 0xbc, 0x8a, 0x65, 0xe8, - 0x2d, 0x4f, 0x41, 0xa7, 0xb5, 0x3a, 0x58, 0x38, 0xf9, 0x04, 0x6f, 0x4c, 0xa8, 0x90, 0xd1, 0x5c, - 0x82, 0xaa, 0xbe, 0xd0, 0xba, 0x72, 0xf6, 0xad, 0xcf, 0xf6, 0xf7, 0x1c, 0x61, 0xf7, 0xa9, 0xa2, - 0xe9, 0x08, 0x40, 0x90, 0x02, 0x6f, 0x19, 0x69, 0x32, 0x1a, 0x3f, 0x03, 0x19, 0x0d, 0x01, 0x3c, - 0xf4, 0x3e, 0x75, 0xbe, 0xb8, 0xa9, 0x3a, 0xe1, 0xa6, 0x2e, 0x72, 0xac, 0x6b, 0x1c, 0x01, 0xd8, - 0x56, 0x2e, 0xaa, 0xb8, 0x6e, 0x7c, 0x37, 0x21, 0xe9, 0x5d, 0x43, 0xb8, 0x20, 0xb0, 0x7a, 0x33, - 0x02, 0x9f, 0xe0, 0x4d, 0xcb, 0x40, 0xcc, 0x99, 0x04, 0x26, 0xf5, 0x30, 0xfe, 0xdf, 0x18, 0x93, - 0x8b, 0xf3, 0xdd, 0x4d, 0xd3, 0xf9, 0x63, 0x03, 0xef, 0x87, 0x1b, 0xd9, 0x9b, 0x36, 0x19, 0x62, - 0x47, 0x11, 0xa7, 0x09, 0x5d, 0xbd, 0x7d, 0x42, 0x1b, 0x2a, 0xc9, 0x11, 0x00, 0x19, 0x63, 0x57, - 0xef, 0x11, 0x5d, 0xa8, 0x7e, 0xfb, 0x85, 0x1c, 0x9d, 0x5d, 0x55, 0x5a, 0x9e, 0x98, 0xc6, 0xb5, - 0x89, 0xd9, 0xf9, 0x13, 0xe1, 0x46, 0x39, 0x79, 0x37, 0x50, 0xf3, 0x21, 0x76, 0xed, 0x56, 0xe0, - 0xb9, 0x96, 0xf3, 0x5d, 0xa3, 0xb6, 0x80, 0x92, 0x31, 0xae, 0xd3, 0x53, 0x5e, 0x30, 0x39, 0x57, - 0xfa, 0xb6, 0x97, 0x89, 0xcd, 0x5f, 0xbe, 0x55, 0x84, 0x3f, 0xb8, 0xb6, 0x0b, 0xd5, 0x35, 0xed, - 0x32, 0xb5, 0xd7, 0x74, 0xcd, 0x35, 0x0d, 0x4e, 0x5d, 0xd3, 0x84, 0xfb, 0x09, 0xe9, 0x61, 0x22, - 0xf8, 0x50, 0x2e, 0xb6, 0x6e, 0x34, 0xc8, 0x84, 0x79, 0xbe, 0xbd, 0xe6, 0xec, 0xb2, 0xbd, 0x75, - 0xc2, 0x87, 0x72, 0xb1, 0x65, 0x8f, 0x4f, 0xc2, 0x2d, 0xb1, 0xe4, 0xc9, 0x84, 0xca, 0x31, 0xa6, - 0x79, 0x72, 0x2d, 0x47, 0x75, 0x91, 0xe3, 0x6b, 0x9a, 0x27, 0xcb, 0x39, 0xc6, 0x4b, 0x9e, 0x4c, - 0xd8, 0xcb, 0xc4, 0xb8, 0x69, 0xa4, 0xd0, 0x9d, 0xca, 0x22, 0x87, 0x27, 0xb9, 0xfa, 0x52, 0xb9, - 0x9d, 0x29, 0x7c, 0x54, 0x7b, 0xfe, 0xa2, 0xbd, 0xd2, 0xfb, 0xf6, 0xe5, 0xac, 0x85, 0x5e, 0xcd, - 0x5a, 0xe8, 0xf5, 0xac, 0x85, 0xfe, 0x9e, 0xb5, 0xd0, 0x4f, 0x57, 0xad, 0x95, 0xd7, 0x57, 0xad, - 0x95, 0x3f, 0xae, 0x5a, 0x2b, 0xdf, 0x07, 0x6f, 0x88, 0xa1, 0x66, 0x54, 0xcf, 0x57, 0xcc, 0x27, - 0x41, 0x3c, 0xa6, 0x29, 0x0b, 0xa6, 0x0f, 0x82, 0x1f, 0xcb, 0x5f, 0x18, 0x5a, 0x99, 0x41, 0x5d, - 0x23, 0x1e, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xe8, 0x5c, 0xd3, 0x7d, 0x08, 0x00, 0x00, + // 933 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xd8, 0x8e, 0xed, 0x9d, 0xa4, 0x25, 0x1d, 0x0c, 0xda, 0xa6, 0xc2, 0xb6, 0x02, 0x07, + 0x83, 0x94, 0x5d, 0x9a, 0x2a, 0x45, 0xea, 0x2d, 0x4b, 0x88, 0xb0, 0x04, 0x22, 0xda, 0x54, 0x42, + 0xe2, 0xb2, 0x1a, 0xef, 0x3e, 0xdb, 0xa3, 0x3a, 0x3b, 0xcb, 0xce, 0xd8, 0x22, 0x17, 0xce, 0x1c, + 0xe1, 0x0f, 0x40, 0xea, 0xb1, 0xe2, 0xc4, 0x21, 0x57, 0x6e, 0x48, 0x54, 0x39, 0x55, 0x9c, 0x38, + 0xa0, 0x80, 0x9c, 0x03, 0xfc, 0x19, 0x68, 0x7e, 0xac, 0x5d, 0x47, 0xfd, 0x21, 0xa3, 0x5c, 0x92, + 0xbc, 0x37, 0xdf, 0xbc, 0xf7, 0xe6, 0xfb, 0xde, 0x7b, 0x1b, 0xdc, 0xe9, 0xd3, 0x34, 0xf1, 0xe5, + 0x24, 0x4d, 0x61, 0xec, 0x4f, 0xef, 0xf6, 0x41, 0xd2, 0xbb, 0xd6, 0xf4, 0xb2, 0x9c, 0x4b, 0x4e, + 0xde, 0x54, 0x08, 0xcf, 0xba, 0x2c, 0x62, 0xeb, 0x16, 0x3d, 0x61, 0x29, 0xf7, 0xf5, 0x4f, 0x83, + 0xdb, 0x6a, 0xc5, 0x5c, 0x9c, 0x70, 0xe1, 0xf7, 0xa9, 0x80, 0x79, 0xa4, 0x98, 0xb3, 0xd4, 0x9e, + 0xdf, 0x36, 0xe7, 0x91, 0xb6, 0x7c, 0x63, 0xd8, 0xa3, 0xe6, 0x90, 0x0f, 0xb9, 0xf1, 0xab, 0xbf, + 0x8a, 0x0b, 0x43, 0xce, 0x87, 0x63, 0xf0, 0xb5, 0xd5, 0x9f, 0x0c, 0x7c, 0x9a, 0x9e, 0x16, 0xb9, + 0x74, 0xd5, 0x03, 0x80, 0x44, 0xcc, 0x53, 0x69, 0xcb, 0x9c, 0x6f, 0xff, 0x5a, 0xc5, 0xb5, 0x87, + 0xba, 0x62, 0xf2, 0x36, 0x2e, 0xb3, 0xc4, 0x45, 0x1d, 0xd4, 0xad, 0x06, 0xb5, 0xd9, 0x45, 0xbb, + 0xdc, 0x3b, 0x08, 0xcb, 0x2c, 0x21, 0x5b, 0xb8, 0x21, 0xe0, 0xeb, 0x09, 0xa4, 0x31, 0xb8, 0x65, + 0x75, 0x1a, 0xce, 0x6d, 0x72, 0x1f, 0xaf, 0xe5, 0x7c, 0x22, 0xc1, 0xad, 0x74, 0x50, 0x77, 0x7d, + 0xb7, 0xe9, 0x99, 0x4a, 0xbc, 0xa2, 0x12, 0x6f, 0x3f, 0x3d, 0x0d, 0xf0, 0xf9, 0xd9, 0x4e, 0x2d, + 0x54, 0xb0, 0x5e, 0x68, 0xe0, 0x64, 0x0f, 0xd7, 0x21, 0x8d, 0x79, 0x02, 0xb9, 0x5b, 0xed, 0xa0, + 0xee, 0xcd, 0xdd, 0x3b, 0x9e, 0x26, 0xcf, 0x94, 0x66, 0x0b, 0xf5, 0x3e, 0x31, 0x90, 0xb0, 0xc0, + 0x92, 0x3d, 0xec, 0x0c, 0x00, 0xa2, 0x8c, 0x9e, 0x42, 0xee, 0xae, 0x75, 0x50, 0xd7, 0x09, 0xdc, + 0xdf, 0xcf, 0x76, 0x9a, 0x96, 0xa3, 0xfd, 0x24, 0xc9, 0x41, 0x88, 0x63, 0x99, 0xb3, 0x74, 0x18, + 0x36, 0x06, 0x00, 0x47, 0x0a, 0x49, 0xbe, 0xc4, 0xb7, 0x04, 0x1b, 0xa6, 0x74, 0x1c, 0x25, 0x30, + 0x65, 0x54, 0x32, 0x9e, 0x0a, 0xb7, 0xd6, 0xa9, 0x74, 0xd7, 0x77, 0xdf, 0xf3, 0x5e, 0x20, 0x9a, + 0x77, 0xac, 0xd1, 0x07, 0x05, 0x38, 0xa8, 0x3e, 0xbd, 0x68, 0x97, 0xc2, 0x4d, 0xb1, 0xec, 0x16, + 0x8a, 0x1a, 0x96, 0x4a, 0xc8, 0xa7, 0x74, 0xec, 0xd6, 0x0d, 0x35, 0x85, 0x4d, 0x26, 0xf8, 0x86, + 0xe4, 0x52, 0xe7, 0xcc, 0xb8, 0x60, 0xd2, 0x6d, 0xe8, 0x84, 0xb7, 0x3d, 0x5b, 0xac, 0x52, 0x7f, + 0x9e, 0xf0, 0x63, 0xce, 0xd2, 0x60, 0x4f, 0x65, 0xf9, 0xe9, 0xaf, 0x76, 0x77, 0xc8, 0xe4, 0x68, + 0xd2, 0xf7, 0x62, 0x7e, 0x62, 0xd5, 0xb7, 0xbf, 0x76, 0x44, 0xf2, 0xc8, 0x97, 0xa7, 0x19, 0x08, + 0x7d, 0x41, 0x3c, 0xf9, 0xe7, 0xe7, 0x0f, 0x50, 0xb8, 0xa1, 0xd3, 0x1c, 0x98, 0x2c, 0xe4, 0x0e, + 0x76, 0x98, 0x88, 0x68, 0x2c, 0xd9, 0x14, 0x5c, 0xa7, 0x83, 0xba, 0x8d, 0xb0, 0xc1, 0xc4, 0xbe, + 0xb6, 0xc9, 0x3b, 0x18, 0xc7, 0x39, 0x50, 0x09, 0x49, 0x44, 0xa5, 0x8b, 0x3b, 0xa8, 0x5b, 0x09, + 0x1d, 0xeb, 0xd9, 0x97, 0x64, 0x17, 0xd7, 0xb5, 0xc1, 0x73, 0x77, 0xfd, 0x35, 0xe4, 0x16, 0xc0, + 0x07, 0xd5, 0x7f, 0x1f, 0xb7, 0xd1, 0xf6, 0x8f, 0x08, 0x6f, 0x7c, 0x46, 0x25, 0x08, 0x79, 0x94, + 0xb3, 0x18, 0x04, 0x79, 0x1f, 0x3b, 0x86, 0xd3, 0x68, 0xde, 0x53, 0x1b, 0xb3, 0x8b, 0x76, 0xc3, + 0xf4, 0x5a, 0xef, 0x20, 0x6c, 0x98, 0xe3, 0x5e, 0x42, 0x3e, 0xc2, 0xb5, 0x4c, 0x5f, 0x72, 0xcb, + 0x96, 0xa1, 0x17, 0xb4, 0x82, 0x0e, 0x6b, 0x75, 0xb0, 0x70, 0xf2, 0x2e, 0xbe, 0x31, 0xa6, 0x42, + 0x46, 0x73, 0x09, 0x2a, 0xfa, 0x41, 0x1b, 0xca, 0xd9, 0xb3, 0x3e, 0x5b, 0xdf, 0x0f, 0x08, 0x3b, + 0x0f, 0x15, 0x4d, 0x87, 0x00, 0x82, 0x7c, 0x8b, 0xdf, 0x32, 0xd2, 0x28, 0x0d, 0xa2, 0x8c, 0xc6, + 0x8f, 0x40, 0x46, 0x03, 0x00, 0x17, 0xbd, 0x4e, 0xa2, 0x0f, 0x57, 0x95, 0x28, 0x24, 0x3a, 0x53, + 0x40, 0x05, 0x1c, 0xe9, 0x3c, 0x87, 0x00, 0xb6, 0xa6, 0x5f, 0x2a, 0xb8, 0x66, 0x7c, 0xab, 0xb0, + 0xf5, 0xaa, 0x69, 0x5c, 0x30, 0x59, 0x59, 0x8d, 0xc9, 0x00, 0xd7, 0x73, 0x88, 0x81, 0x65, 0x52, + 0x8f, 0xe3, 0xcb, 0x06, 0x99, 0x9c, 0x9f, 0xed, 0xdc, 0x34, 0x25, 0x87, 0x06, 0xde, 0x0b, 0x8b, + 0x8b, 0x64, 0x80, 0x1b, 0x9a, 0x4e, 0xc5, 0xe3, 0xda, 0xf5, 0xf3, 0x58, 0x57, 0x41, 0x0e, 0x01, + 0xc8, 0x08, 0x3b, 0x7a, 0x87, 0xe8, 0x44, 0xb5, 0xeb, 0x4f, 0xd4, 0xd0, 0xd1, 0x55, 0xa6, 0xe5, + 0x69, 0xa9, 0x5f, 0x99, 0x96, 0xed, 0x3f, 0x11, 0xae, 0x17, 0x53, 0xb7, 0x82, 0x80, 0xf7, 0xb1, + 0x63, 0x37, 0x02, 0xcf, 0xb5, 0x82, 0xaf, 0x1a, 0xb3, 0x05, 0x94, 0x8c, 0x70, 0x8d, 0x9e, 0xf0, + 0x49, 0x2a, 0xe7, 0xe2, 0x5e, 0xf7, 0x22, 0xb1, 0xf1, 0x6d, 0x7b, 0x9e, 0x23, 0xfc, 0xc6, 0x95, + 0x3d, 0xa8, 0x9e, 0x69, 0x17, 0xa9, 0x7d, 0xa6, 0x63, 0x9e, 0x69, 0x70, 0xea, 0x99, 0xe6, 0xb8, + 0x97, 0x90, 0x00, 0x13, 0xc1, 0x07, 0x72, 0xb1, 0x71, 0xa3, 0x7e, 0x26, 0x4c, 0xc7, 0x06, 0xcd, + 0xd9, 0x45, 0x7b, 0xf3, 0x98, 0x0f, 0xe4, 0x62, 0xc3, 0x1e, 0x1d, 0x87, 0x9b, 0x62, 0xc9, 0x93, + 0xa9, 0xb6, 0x24, 0x23, 0x9a, 0x27, 0x57, 0x62, 0x54, 0x16, 0x31, 0x3e, 0xa5, 0x79, 0xb2, 0x1c, + 0x63, 0xb4, 0xe4, 0xc9, 0x84, 0x7d, 0xcc, 0x6f, 0x08, 0x37, 0x8d, 0x16, 0xba, 0x54, 0x39, 0xc9, + 0xe1, 0x8b, 0x5c, 0x7d, 0x51, 0x9e, 0x1f, 0x27, 0xf4, 0xd2, 0x71, 0x5a, 0x71, 0x31, 0x2d, 0x37, + 0x4e, 0xe5, 0xea, 0x9a, 0xfd, 0x7f, 0x1f, 0xbf, 0x07, 0xd5, 0xef, 0x1e, 0xb7, 0x4b, 0xc1, 0xe7, + 0x4f, 0x66, 0x2d, 0xf4, 0x74, 0xd6, 0x42, 0xcf, 0x66, 0x2d, 0xf4, 0xf7, 0xac, 0x85, 0xbe, 0xbf, + 0x6c, 0x95, 0x9e, 0x5d, 0xb6, 0x4a, 0x7f, 0x5c, 0xb6, 0x4a, 0x5f, 0xf9, 0xcf, 0x29, 0xae, 0x62, + 0xea, 0xf1, 0x8d, 0xf9, 0xd8, 0x8f, 0x47, 0x94, 0xa5, 0xfe, 0xf4, 0x9e, 0xff, 0x4d, 0xf1, 0x2f, + 0x8c, 0x96, 0xbf, 0x5f, 0xd3, 0x88, 0x7b, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xe8, 0x07, + 0xfd, 0xde, 0x08, 0x00, 0x00, } func (this *Tunnel) Equal(that interface{}) bool { @@ -735,11 +741,11 @@ func (this *TotalFees) Equal(that interface{}) bool { } else if this == nil { return false } - if len(this.TotalPacketFee) != len(that1.TotalPacketFee) { + if len(this.TotalBasePacketFee) != len(that1.TotalBasePacketFee) { return false } - for i := range this.TotalPacketFee { - if !this.TotalPacketFee[i].Equal(&that1.TotalPacketFee[i]) { + for i := range this.TotalBasePacketFee { + if !this.TotalBasePacketFee[i].Equal(&that1.TotalBasePacketFee[i]) { return false } } @@ -778,7 +784,7 @@ func (this *Packet) Equal(that interface{}) bool { return false } } - if !this.PacketContent.Equal(that1.PacketContent) { + if !this.Receipt.Equal(that1.Receipt) { return false } if len(this.BaseFee) != len(that1.BaseFee) { @@ -886,10 +892,21 @@ func (this *TunnelSignatureOrder) Equal(that interface{}) bool { } else if this == nil { return false } - if this.TunnelID != that1.TunnelID { + if this.Sequence != that1.Sequence { return false } - if this.Sequence != that1.Sequence { + if len(this.Prices) != len(that1.Prices) { + return false + } + for i := range this.Prices { + if !this.Prices[i].Equal(&that1.Prices[i]) { + return false + } + } + if this.CreatedAt != that1.CreatedAt { + return false + } + if this.Encoder != that1.Encoder { return false } return true @@ -1073,10 +1090,10 @@ func (m *TotalFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TotalPacketFee) > 0 { - for iNdEx := len(m.TotalPacketFee) - 1; iNdEx >= 0; iNdEx-- { + if len(m.TotalBasePacketFee) > 0 { + for iNdEx := len(m.TotalBasePacketFee) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.TotalPacketFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TotalBasePacketFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1143,9 +1160,9 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if m.PacketContent != nil { + if m.Receipt != nil { { - size, err := m.PacketContent.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Receipt.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1291,13 +1308,32 @@ func (m *TunnelSignatureOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Sequence != 0 { - i = encodeVarintTunnel(dAtA, i, uint64(m.Sequence)) + if m.Encoder != 0 { + i = encodeVarintTunnel(dAtA, i, uint64(m.Encoder)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } - if m.TunnelID != 0 { - i = encodeVarintTunnel(dAtA, i, uint64(m.TunnelID)) + if m.CreatedAt != 0 { + i = encodeVarintTunnel(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x18 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTunnel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Sequence != 0 { + i = encodeVarintTunnel(dAtA, i, uint64(m.Sequence)) i-- dAtA[i] = 0x8 } @@ -1393,8 +1429,8 @@ func (m *TotalFees) Size() (n int) { } var l int _ = l - if len(m.TotalPacketFee) > 0 { - for _, e := range m.TotalPacketFee { + if len(m.TotalBasePacketFee) > 0 { + for _, e := range m.TotalBasePacketFee { l = e.Size() n += 1 + l + sovTunnel(uint64(l)) } @@ -1420,8 +1456,8 @@ func (m *Packet) Size() (n int) { n += 1 + l + sovTunnel(uint64(l)) } } - if m.PacketContent != nil { - l = m.PacketContent.Size() + if m.Receipt != nil { + l = m.Receipt.Size() n += 1 + l + sovTunnel(uint64(l)) } if len(m.BaseFee) > 0 { @@ -1489,12 +1525,21 @@ func (m *TunnelSignatureOrder) Size() (n int) { } var l int _ = l - if m.TunnelID != 0 { - n += 1 + sovTunnel(uint64(m.TunnelID)) - } if m.Sequence != 0 { n += 1 + sovTunnel(uint64(m.Sequence)) } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovTunnel(uint64(l)) + } + } + if m.CreatedAt != 0 { + n += 1 + sovTunnel(uint64(m.CreatedAt)) + } + if m.Encoder != 0 { + n += 1 + sovTunnel(uint64(m.Encoder)) + } return n } @@ -1990,7 +2035,7 @@ func (m *TotalFees) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalPacketFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalBasePacketFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2017,8 +2062,8 @@ func (m *TotalFees) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TotalPacketFee = append(m.TotalPacketFee, types2.Coin{}) - if err := m.TotalPacketFee[len(m.TotalPacketFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TotalBasePacketFee = append(m.TotalBasePacketFee, types2.Coin{}) + if err := m.TotalBasePacketFee[len(m.TotalBasePacketFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2146,7 +2191,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketContent", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2173,10 +2218,10 @@ func (m *Packet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketContent == nil { - m.PacketContent = &types.Any{} + if m.Receipt == nil { + m.Receipt = &types.Any{} } - if err := m.PacketContent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Receipt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2574,9 +2619,9 @@ func (m *TunnelSignatureOrder) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TunnelID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } - m.TunnelID = 0 + m.Sequence = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTunnel @@ -2586,16 +2631,50 @@ func (m *TunnelSignatureOrder) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TunnelID |= uint64(b&0x7F) << shift + m.Sequence |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTunnel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTunnel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTunnel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, types1.Price{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) } - m.Sequence = 0 + m.CreatedAt = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTunnel @@ -2605,7 +2684,26 @@ func (m *TunnelSignatureOrder) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Sequence |= uint64(b&0x7F) << shift + m.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Encoder", wireType) + } + m.Encoder = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTunnel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Encoder |= types1.Encoder(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/tunnel/types/tunnel_test.go b/x/tunnel/types/tunnel_test.go index 4a4c631be..e009bd5ca 100644 --- a/x/tunnel/types/tunnel_test.go +++ b/x/tunnel/types/tunnel_test.go @@ -8,16 +8,19 @@ import ( "github.com/bandprotocol/chain/v3/x/tunnel/types" ) -func TestTunnel_SetRoute(t *testing.T) { +func TestGetSetRoute(t *testing.T) { tunnel := types.Tunnel{} route := &types.TSSRoute{DestinationChainID: "chain-1", DestinationContractAddress: "contract-1"} err := tunnel.SetRoute(route) require.NoError(t, err) - require.Equal(t, route, tunnel.Route.GetCachedValue()) + + routeValue, err := tunnel.GetRouteValue() + require.NoError(t, err) + require.Equal(t, route, routeValue) } -func TestTunnel_GetSignalDeviationMap(t *testing.T) { +func TestGetSignalDeviationMap(t *testing.T) { signalDeviations := []types.SignalDeviation{{SignalID: "signal1", SoftDeviationBPS: 100, HardDeviationBPS: 200}} tunnel := types.Tunnel{SignalDeviations: signalDeviations} @@ -26,7 +29,7 @@ func TestTunnel_GetSignalDeviationMap(t *testing.T) { require.Equal(t, signalDeviations[0], signalDeviationMap["signal1"]) } -func TestTunnel_GetSignalIDs(t *testing.T) { +func TestGetSignalIDs(t *testing.T) { signalDeviations := []types.SignalDeviation{ {SignalID: "signal1", SoftDeviationBPS: 100, HardDeviationBPS: 200}, {SignalID: "signal2", SoftDeviationBPS: 100, HardDeviationBPS: 200}, @@ -38,3 +41,46 @@ func TestTunnel_GetSignalIDs(t *testing.T) { require.Contains(t, signalIDs, "signal1") require.Contains(t, signalIDs, "signal2") } + +func TestValidateInterval(t *testing.T) { + tests := []struct { + name string + interval uint64 + maxInterval uint64 + minInterval uint64 + expErr bool + }{ + { + name: "interval too low", + interval: 5, + maxInterval: 100, + minInterval: 10, + expErr: true, + }, + { + name: "interval too high", + interval: 150, + maxInterval: 100, + minInterval: 10, + expErr: true, + }, + { + name: "all good", + interval: 50, + maxInterval: 100, + minInterval: 10, + expErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := types.ValidateInterval(tt.interval, tt.maxInterval, tt.minInterval) + if tt.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +}