diff --git a/api/fairyring/pep/params.pulsar.go b/api/fairyring/pep/params.pulsar.go index e5fd61a4..c35f73ae 100644 --- a/api/fairyring/pep/params.pulsar.go +++ b/api/fairyring/pep/params.pulsar.go @@ -120,6 +120,7 @@ var ( fd_Params_trusted_addresses protoreflect.FieldDescriptor fd_Params_min_gas_price protoreflect.FieldDescriptor fd_Params_private_decryption_key_price protoreflect.FieldDescriptor + fd_Params_max_contract_gas protoreflect.FieldDescriptor ) func init() { @@ -131,6 +132,7 @@ func init() { fd_Params_trusted_addresses = md_Params.Fields().ByName("trusted_addresses") fd_Params_min_gas_price = md_Params.Fields().ByName("min_gas_price") fd_Params_private_decryption_key_price = md_Params.Fields().ByName("private_decryption_key_price") + fd_Params_max_contract_gas = md_Params.Fields().ByName("max_contract_gas") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -234,6 +236,12 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.MaxContractGas != uint64(0) { + value := protoreflect.ValueOfUint64(x.MaxContractGas) + if !f(fd_Params_max_contract_gas, value) { + return + } + } } // Has reports whether a field is populated. @@ -261,6 +269,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.MinGasPrice != nil case "fairyring.pep.Params.private_decryption_key_price": return x.PrivateDecryptionKeyPrice != nil + case "fairyring.pep.Params.max_contract_gas": + return x.MaxContractGas != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -289,6 +299,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.MinGasPrice = nil case "fairyring.pep.Params.private_decryption_key_price": x.PrivateDecryptionKeyPrice = nil + case "fairyring.pep.Params.max_contract_gas": + x.MaxContractGas = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -329,6 +341,9 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "fairyring.pep.Params.private_decryption_key_price": value := x.PrivateDecryptionKeyPrice return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "fairyring.pep.Params.max_contract_gas": + value := x.MaxContractGas + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -365,6 +380,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.MinGasPrice = value.Message().Interface().(*v1beta1.Coin) case "fairyring.pep.Params.private_decryption_key_price": x.PrivateDecryptionKeyPrice = value.Message().Interface().(*v1beta1.Coin) + case "fairyring.pep.Params.max_contract_gas": + x.MaxContractGas = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -411,6 +428,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field keyshare_channel_id of message fairyring.pep.Params is not mutable")) case "fairyring.pep.Params.is_source_chain": panic(fmt.Errorf("field is_source_chain of message fairyring.pep.Params is not mutable")) + case "fairyring.pep.Params.max_contract_gas": + panic(fmt.Errorf("field max_contract_gas of message fairyring.pep.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -440,6 +459,8 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor case "fairyring.pep.Params.private_decryption_key_price": m := new(v1beta1.Coin) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "fairyring.pep.Params.max_contract_gas": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: fairyring.pep.Params")) @@ -536,6 +557,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { l = options.Size(x.PrivateDecryptionKeyPrice) n += 1 + l + runtime.Sov(uint64(l)) } + if x.MaxContractGas != 0 { + n += 1 + runtime.Sov(uint64(x.MaxContractGas)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -565,6 +589,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.MaxContractGas != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.MaxContractGas)) + i-- + dAtA[i] = 0x38 + } if x.PrivateDecryptionKeyPrice != nil { encoded, err := options.Marshal(x.PrivateDecryptionKeyPrice) if err != nil { @@ -874,6 +903,25 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 7: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MaxContractGas", wireType) + } + x.MaxContractGas = 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.MaxContractGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1483,6 +1531,7 @@ type Params struct { TrustedAddresses []string `protobuf:"bytes,4,rep,name=trusted_addresses,json=trustedAddresses,proto3" json:"trusted_addresses,omitempty"` MinGasPrice *v1beta1.Coin `protobuf:"bytes,5,opt,name=min_gas_price,json=minGasPrice,proto3" json:"min_gas_price,omitempty"` PrivateDecryptionKeyPrice *v1beta1.Coin `protobuf:"bytes,6,opt,name=private_decryption_key_price,json=privateDecryptionKeyPrice,proto3" json:"private_decryption_key_price,omitempty"` + MaxContractGas uint64 `protobuf:"varint,7,opt,name=max_contract_gas,json=maxContractGas,proto3" json:"max_contract_gas,omitempty"` } func (x *Params) Reset() { @@ -1547,6 +1596,13 @@ func (x *Params) GetPrivateDecryptionKeyPrice() *v1beta1.Coin { return nil } +func (x *Params) GetMaxContractGas() uint64 { + if x != nil { + return x.MaxContractGas + } + return 0 +} + // TrustedCounterParty defines the structure to store the ibc info // of the source chain (fairyring) to reliably fetch active keys and // general/private decryption keys @@ -1611,7 +1667,7 @@ var file_fairyring_pep_params_proto_rawDesc = []byte{ 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbf, 0x04, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x86, 0x05, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x4e, 0x0a, 0x13, 0x6b, 0x65, 0x79, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e, 0xf2, 0xde, 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6b, 0x65, 0x79, 0x73, 0x68, 0x61, 0x72, 0x65, @@ -1645,26 +1701,31 @@ var file_fairyring_pep_params_proto_rawDesc = []byte{ 0x22, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0x52, 0x19, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x3a, 0x1b, 0x8a, 0xe7, 0xb0, 0x2a, 0x16, - 0x66, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x78, 0x2f, 0x70, 0x65, 0x70, 0x2f, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x76, 0x0a, 0x13, 0x54, 0x72, 0x75, 0x73, 0x74, 0x65, - 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x79, 0x12, 0x1b, 0x0a, - 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x42, 0x95, - 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, - 0x2e, 0x70, 0x65, 0x70, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2f, - 0x70, 0x65, 0x70, 0xa2, 0x02, 0x03, 0x46, 0x50, 0x58, 0xaa, 0x02, 0x0d, 0x46, 0x61, 0x69, 0x72, - 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x50, 0x65, 0x70, 0xca, 0x02, 0x0d, 0x46, 0x61, 0x69, 0x72, - 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x50, 0x65, 0x70, 0xe2, 0x02, 0x19, 0x46, 0x61, 0x69, 0x72, - 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x50, 0x65, 0x70, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x46, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, - 0x67, 0x3a, 0x3a, 0x50, 0x65, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x6d, 0x61, 0x78, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x1b, 0xf2, 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, + 0x61, 0x78, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x67, 0x61, 0x73, 0x22, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x47, 0x61, 0x73, + 0x3a, 0x1b, 0x8a, 0xe7, 0xb0, 0x2a, 0x16, 0x66, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, + 0x2f, 0x78, 0x2f, 0x70, 0x65, 0x70, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x76, 0x0a, + 0x13, 0x54, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x50, + 0x61, 0x72, 0x74, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, + 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x42, 0x95, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x61, + 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x65, 0x70, 0x42, 0x0b, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x61, 0x69, + 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x65, 0x70, 0xa2, 0x02, 0x03, 0x46, 0x50, 0x58, + 0xaa, 0x02, 0x0d, 0x46, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x50, 0x65, 0x70, + 0xca, 0x02, 0x0d, 0x46, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x50, 0x65, 0x70, + 0xe2, 0x02, 0x19, 0x46, 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x50, 0x65, 0x70, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x46, + 0x61, 0x69, 0x72, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x3a, 0x3a, 0x50, 0x65, 0x70, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/fairyring/pep/params.proto b/proto/fairyring/pep/params.proto index 7e8bdc6e..39e17a92 100644 --- a/proto/fairyring/pep/params.proto +++ b/proto/fairyring/pep/params.proto @@ -17,6 +17,7 @@ message Params { repeated string trusted_addresses = 4 [(gogoproto.moretags) = "yaml:\"trusted_addresses\""]; cosmos.base.v1beta1.Coin min_gas_price = 5 [(gogoproto.moretags) = "yaml:\"min_gas_price\""]; cosmos.base.v1beta1.Coin private_decryption_key_price = 6 [(gogoproto.moretags) = "yaml:\"private_decryption_key_price\""]; + uint64 max_contract_gas = 7 [(gogoproto.moretags) = "yaml:\"max_contract_gas\""]; } // TrustedCounterParty defines the structure to store the ibc info diff --git a/scripts/tests/fairyring_contract/Cargo.lock b/scripts/tests/fairyring_contract/Cargo.lock index 87f3ff3d..55560890 100644 --- a/scripts/tests/fairyring_contract/Cargo.lock +++ b/scripts/tests/fairyring_contract/Cargo.lock @@ -37,9 +37,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" [[package]] name = "ark-bls12-381" @@ -170,7 +170,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -302,7 +302,7 @@ checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -326,7 +326,7 @@ checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -432,7 +432,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -526,7 +526,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", "unicode-xid", ] @@ -612,7 +612,7 @@ dependencies = [ [[package]] name = "fairblock-proto" version = "0.1.0" -source = "git+https://github.com/Fairblock/fairblock-rust/?branch=audit-2.0#be5cf6dfb949a70c2e5caef65390f804278e3f34" +source = "git+https://github.com/Fairblock/fairblock-rust/?branch=main#3ae44d8174dea2e2372b0724ab18b8b303b7c2d9" dependencies = [ "cosmos-sdk-proto", "prost", @@ -930,29 +930,29 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -1013,7 +1013,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1135,7 +1135,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1159,9 +1159,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] @@ -1186,13 +1186,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1203,7 +1203,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1273,9 +1273,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.82" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -1300,22 +1300,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1420,7 +1420,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1544,7 +1544,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] [[package]] @@ -1564,5 +1564,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.87", ] diff --git a/scripts/tests/fairyring_contract/Cargo.toml b/scripts/tests/fairyring_contract/Cargo.toml index 38d35a7c..d6712b57 100644 --- a/scripts/tests/fairyring_contract/Cargo.toml +++ b/scripts/tests/fairyring_contract/Cargo.toml @@ -25,7 +25,7 @@ library = [] optimize = """docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.15.0 + cosmwasm/optimizer:0.16.0 """ [dependencies] @@ -42,7 +42,7 @@ thiserror = "1.0" prost = "0.13.3" # Protobuf support prost-types = "0.13" # tonic = { version = "0.12.3", features = ["prost", "tls"] } -fairblock-proto = { git = "https://github.com/Fairblock/fairblock-rust/", branch = "audit-2.0", default-features = false } +fairblock-proto = { git = "https://github.com/Fairblock/fairblock-rust/", branch = "main", default-features = false } # getrandom = { version = "0.2", features = ["js"] } # mio = "1.0.2" # tokio = "1.40.0" diff --git a/scripts/tests/fairyring_contract/artifacts/checksums.txt b/scripts/tests/fairyring_contract/artifacts/checksums.txt index 0d20f445..0ae55ac9 100644 --- a/scripts/tests/fairyring_contract/artifacts/checksums.txt +++ b/scripts/tests/fairyring_contract/artifacts/checksums.txt @@ -1 +1 @@ -8d0f9a419565f07832c886b48a8ec6dc79b374ee94fcaa7291c07ab83cbb9ac6 fairyring_contract.wasm +7c4d15da244b9af07d188fea47e7907fdde3e2a9413b1ecf451bc63d47a2b85d fairyring_contract.wasm diff --git a/scripts/tests/fairyring_contract/artifacts/fairyring_contract.wasm b/scripts/tests/fairyring_contract/artifacts/fairyring_contract.wasm index ee341150..9707a105 100644 Binary files a/scripts/tests/fairyring_contract/artifacts/fairyring_contract.wasm and b/scripts/tests/fairyring_contract/artifacts/fairyring_contract.wasm differ diff --git a/scripts/tests/fairyring_contract/src/contract.rs b/scripts/tests/fairyring_contract/src/contract.rs index 381162f4..df6d1d4f 100644 --- a/scripts/tests/fairyring_contract/src/contract.rs +++ b/scripts/tests/fairyring_contract/src/contract.rs @@ -19,6 +19,13 @@ pub fn execute( return Err(StdError::generic_err("Identity cannot be empty")); } + // go into infinite loop for testing + if msg.identity == "fairy1m9l358xunhhwds0568za49mzhvuxx9uxdra8sq/loop" { + loop { + // Infinite loop + } + } + // Use the identity directly let identity = msg.identity; diff --git a/scripts/tests/loop.wasm b/scripts/tests/loop.wasm new file mode 100644 index 00000000..9dd633e5 Binary files /dev/null and b/scripts/tests/loop.wasm differ diff --git a/scripts/tests/pep.sh b/scripts/tests/pep.sh index 37c1934a..8a49d6ca 100755 --- a/scripts/tests/pep.sh +++ b/scripts/tests/pep.sh @@ -156,6 +156,27 @@ echo "Sending 1 $TARGET_BAL_DENOM to target address" $BINARY tx bank send $VALIDATOR_2 $WALLET_2 1$TARGET_BAL_DENOM --from $VALIDATOR_2 --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --keyring-backend test --generate-only -o json -y > unsigned2.json SIGNED_DATA_2=$($BINARY tx sign unsigned2.json --from $VALIDATOR_2 --offline --account-number 0 --sequence $PEP_NONCE_2ND --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --keyring-backend test -y) +echo "Creating new account for testing insufficient fund for rest of the gas in encrypted tx" +ACC_INFO=$($BINARY keys add new_temp --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test --output json) +echo $ACC_INFO +NEW_ACC_ADDR=$(echo $ACC_INFO | jq -r '.address') + +echo "Send 300k ufairy to new account for testing" +# 900,000 ufairy for submitting tx +# the underlying tx suppossingly need 200,000ufairy gas +# 1 ufairy for the up front gas cost when submitting encrypted tx +$BINARY tx bank send $VALIDATOR_2 $NEW_ACC_ADDR 1200000ufairy --from $VALIDATOR_2 --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --keyring-backend test --yes + +sleep 5 + +NEW_ACC_INFO=$($BINARY q auth account $NEW_ACC_ADDR --home $CHAIN_DIR/$CHAINID_2 --node $CHAIN2_NODE --output json) +echo $NEW_ACC_INFO + +RESULT=$($BINARY query pep show-pep-nonce $NEW_ACC_ADDR --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE -o json) + +NEW_ACC_PEP_NONCE=$(echo "$RESULT" | jq -r '.pep_nonce.nonce') +$BINARY tx bank send $NEW_ACC_ADDR $VALIDATOR_2 1ufairy --from new_temp --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --keyring-backend test --generate-only -o json -y > unsigned3.json +SIGNED_DATA_3=$($BINARY tx sign unsigned3.json --from new_temp --offline --account-number 10 --sequence $NEW_ACC_PEP_NONCE --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --keyring-backend test -y) echo "Query aggregated key share from key share module for submitting to pep module on chain fairyring_test_1" CURRENT_BLOCK=$($BINARY query consensus comet block-latest --home $CHAIN_DIR/$CHAINID_1 --node $CHAIN1_NODE -o json | jq -r '.block.header.height') @@ -163,6 +184,8 @@ RESULT=$($BINARY query keyshare list-decryption-keys --node $CHAIN1_NODE -o json AGG_KEY_HEIGHT=$(echo "$RESULT" | jq -r '.decryption_keys | last | .height') AGG_KEY=$(echo "$RESULT" | jq -r '.decryption_keys | last | .data') +sleep 5 + CURRENT_BLOCK=$($BINARY query consensus comet block-latest --home $CHAIN_DIR/$CHAINID_2 --node $CHAIN2_NODE -o json | jq -r '.block.header.height') echo "Chain 2 Current Block: $CURRENT_BLOCK" echo "Submit valid aggregated key to pep module on chain fairyring_test_2 from address: $VALIDATOR_2" @@ -195,10 +218,12 @@ CIPHER=$($BINARY encrypt $AGG_KEY_HEIGHT "" $SIGNED_DATA --node $CHAIN1_NODE) echo "Encrypting 2nd signed tx with Pub key: '$PUB_KEY'" CIPHER_2=$($BINARY encrypt $AGG_KEY_HEIGHT "" $SIGNED_DATA_2 --node $CHAIN1_NODE) +echo "Encrypting 3rd signed tx with Pub key: '$PUB_KEY'" +CIPHER_3=$($BINARY encrypt $AGG_KEY_HEIGHT "" $SIGNED_DATA_3 --node $CHAIN1_NODE) rm -r unsigned.json &> /dev/null rm -r unsigned2.json &> /dev/null - +rm -r unsigned3.json &> /dev/null RESULT=$($BINARY query bank balances $VALIDATOR_2 --node $CHAIN2_NODE -o json) BAL_DENOM=$(echo "$RESULT" | jq -r '.balances[0].denom') @@ -255,6 +280,25 @@ if [ "$VALIDATOR_PEP_NONCE" != "1" ]; then exit 1 fi +echo "Submit 3rd encrypted tx to pep module on chain fairyring_test_2" +RESULT=$($BINARY tx pep submit-encrypted-tx $CIPHER_3 $AGG_KEY_HEIGHT --from new_temp --gas-prices 1ufairy --gas 900000 --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --broadcast-mode sync --keyring-backend test -o json -y) +check_tx_code $RESULT +RESULT=$(wait_for_tx $RESULT) +TARGET_HEIGHT=$(echo "$RESULT" | jq '.events' | jq 'map(select(any(.type; contains("new-encrypted-tx-submitted"))))[]' | jq '.attributes' | jq 'map(select(any(.key; contains("height"))))[]' | jq -r '.value') +if [ "$TARGET_HEIGHT" != "$AGG_KEY_HEIGHT" ]; then + echo "ERROR: Pep module submit 3rd encrypted tx error. Expected tx to submitted without error with target height '$AGG_KEY_HEIGHT', got '$TARGET_HEIGHT' and '$EVENT_TYPE' | '$CURRENT_BLOCK'" + echo "ERROR MESSAGE: $(echo "$RESULT" | jq -r '.raw_log')" + echo "ERROR MESSAGE: $(echo "$RESULT" | jq '.')" + echo $RESULT | jq + exit 1 +fi + + +RESULT=$($BINARY query bank balances $NEW_ACC_ADDR --node $CHAIN2_NODE -o json) +BAL_DENOM=$(echo "$RESULT" | jq -r '.balances[0].denom') +BAL_AMT=$(echo "$RESULT" | jq -r '.balances[0].amount') +echo "Balance after submitting second encrypted tx: $BAL_AMT$BAL_DENOM" + CURRENT_BLOCK=$($BINARY query consensus comet block-latest --home $CHAIN_DIR/$CHAINID_2 --node $CHAIN2_NODE -o json | jq -r '.block.header.height') echo "Chain 2 Current Block: $CURRENT_BLOCK" @@ -328,6 +372,7 @@ fi FIRST_ENCRYPTED_TX_HEIGHT=$($BINARY query pep list-encrypted-tx --node $CHAIN2_NODE -o json | jq -r '.encrypted_tx_array[0].encrypted_txs[0].processed_at_chain_height') SECOND_ENCRYPTED_TX_HEIGHT=$($BINARY query pep list-encrypted-tx --node $CHAIN2_NODE -o json | jq -r '.encrypted_tx_array[0].encrypted_txs[1].processed_at_chain_height') +THIRD_ENCRYPTED_TX_HEIGHT=$($BINARY query pep list-encrypted-tx --node $CHAIN2_NODE -o json | jq -r '.encrypted_tx_array[0].encrypted_txs[2].processed_at_chain_height') echo "First Encrypted tx processed at height: $FIRST_ENCRYPTED_TX_HEIGHT, 2nd one processed at: $SECOND_ENCRYPTED_TX_HEIGHT" @@ -343,7 +388,87 @@ if [[ "$SECOND_EVENT" != *"coin_received"* ]]; then echo "ERROR: Pep module expected second encrypted tx succeeded with events, got: $SECOND_EVENT instead" exit 1 fi -echo "Second Encrypted TX succeeded with Events: $(echo $SECOND_EVENT | jq) as expected." +echo "Second Encrypted TX succeeded as expected." + +echo "Third Encrypted TX: " +THIRD_EVENT=$($BINARY q block-results $THIRD_ENCRYPTED_TX_HEIGHT -o json | jq '.finalize_block_events[] | select(.type == "reverted-encrypted-tx") | .attributes[] | select(.key == "reason") | .value') +if [[ "$THIRD_EVENT" != *"insufficient fees"* ]]; then + echo "ERROR: Pep module expected third encrypted tx failed with reason insufficient fee, got: $THIRD_EVENT instead" + exit 1 +fi +echo "Third Encrypted TX Failed with Reason: $THIRD_EVENT as expected." + + +RESULT=$($BINARY query pep show-pep-nonce $VALIDATOR_2 --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE -o json) +LOOP_PEP_NONCE=$(echo "$RESULT" | jq -r '.pep_nonce.nonce') +echo "PEP Nonce for the wasm contract loop test: $LOOP_PEP_NONCE" +RESULT=$($BINARY tx wasm store ./scripts/tests/loop.wasm -y --output json --home $CHAIN_DIR/$CHAINID_2 --gas-prices 1ufairy --chain-id $CHAINID_2 --node $CHAIN2_NODE --from $VALIDATOR_2 --keyring-backend test --gas 2000000) +check_tx_code $RESULT +RESULT=$(wait_for_tx $RESULT) + +RESULT=$($BINARY tx wasm instantiate 1 '{}' -y --output json --home $CHAIN_DIR/$CHAINID_2 --gas-prices 1ufairy --chain-id $CHAINID_2 --node $CHAIN2_NODE --from $VALIDATOR_2 --keyring-backend test --admin $VALIDATOR_2 --label foo) +check_tx_code $RESULT +RESULT=$(wait_for_tx $RESULT) + +CONTRACT_ADDR=$($BINARY q wasm list-contracts-by-code 1 --output=json | jq -r '.contracts[0]') + +echo "" +echo "" +echo "Contract Addr: $CONTRACT_ADDR" +echo "" +echo "" + +$BINARY tx wasm execute $CONTRACT_ADDR '{"identity": "", "pubkey": "", "decryption_key": ""}' -y --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --from $VALIDATOR_2 --keyring-backend test --chain-id $CHAINID_2 --generate-only > execute_loop_unsigned.json + +$BINARY tx sign execute_loop_unsigned.json --home $CHAIN_DIR/$CHAINID_2 --gas-prices 1ufairy --account-number 0 --sequence $LOOP_PEP_NONCE --from $VALIDATOR_2 --keyring-backend test --chain-id $CHAINID_2 > execute_loop.json +TARGET_HEIGHT=$(($($BINARY q pep latest-height --node $CHAIN1_NODE -o json | jq -r '.height') + 15)) + +$BINARY encrypt $TARGET_HEIGHT '' "$(cat execute_loop.json)" --node $CHAIN2_NODE --home $CHAIN_DIR/$CHAINID_2 > execute_loop.hex +RESULT=$($BINARY tx pep submit-encrypted-tx $(cat execute_loop.hex) $TARGET_HEIGHT -y --output json --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --from $VALIDATOR_2 --keyring-backend test --chain-id $CHAINID_2) +check_tx_code $RESULT +RESULT=$(wait_for_tx $RESULT) + +while true; do + CURRENT_BLOCK=$($BINARY query consensus comet block-latest --home $CHAIN_DIR/$CHAINID_1 --node $CHAIN1_NODE -o json | jq -r '.block.header.height') + RESULT=$($BINARY query keyshare list-decryption-keys --node $CHAIN1_NODE -o json) + AGG_KEY_HEIGHT=$(echo "$RESULT" | jq -r '.decryption_keys | last | .height') + echo "Getting decryption key on chain 1: aggr key height: $AGG_KEY_HEIGHT & Encrypted TX Target Height: $TARGET_HEIGHT" + AGG_KEY=$(echo "$RESULT" | jq -r '.decryption_keys | last | .data') + if [[ "$AGG_KEY_HEIGHT" -eq "$TARGET_HEIGHT" ]]; then + break + fi + sleep 1 +done + +RESULT=$($BINARY query bank balances $VALIDATOR_2 --node $CHAIN2_NODE -o json) +echo "Bank balance before executing wasm loop contract tx: $(echo $RESULT | jq)" + +echo "Submit valid aggregated key to pep module on chain fairyring_test_2 from address: $VALIDATOR_2" +RESULT=$($BINARY tx pep submit-decryption-key $AGG_KEY_HEIGHT $AGG_KEY --from $VALIDATOR_2 --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --node $CHAIN2_NODE --broadcast-mode sync --keyring-backend test -o json -y) +check_tx_code $RESULT +RESULT=$(wait_for_tx $RESULT) +ACTION=$(echo "$RESULT" | jq -r | jq '.events' | jq 'map(select(any(.type; contains("message"))))[]' | jq '.attributes' | jq 'map(select(any(.key; contains("action"))))[]' | jq -r '.value') +if [ "$ACTION" != "/fairyring.pep.MsgSubmitDecryptionKey" ]; then + echo "ERROR: Pep module submit decryption key error. Expected tx action to be MsgSubmitDecryptionKey, got '$ACTION'" + echo "ERROR MESSAGE: $(echo "$RESULT" | jq -r '.raw_log')" + exit 1 +fi + +rm execute_loop.hex &> /dev/null +rm execute_loop.json &> /dev/null +rm execute_loop_unsigned.json &> /dev/null + +echo "If the loop contract bug works, test script will be stucked right here." + +LOOP_TX_HEIGHT=$($BINARY query pep list-encrypted-tx --node $CHAIN2_NODE -o json | jq -r '.encrypted_tx_array[1].encrypted_txs[0].processed_at_chain_height') +LOOP_TC_EVENT=$($BINARY q block-results $LOOP_TX_HEIGHT -o json | jq '.finalize_block_events[] | select(.type == "reverted-encrypted-tx") | .attributes[] | select(.key == "reason") | .value') +LOOP_TC_EVENT_2=$($BINARY q block-results $LOOP_TX_HEIGHT -o json | jq '.finalize_block_events[] | select(.type == "executed-encrypted-tx") | .attributes[] | select(.key == "events") | .value') + +echo $LOOP_TC_EVENT | jq +echo $LOOP_TC_EVENT_2 | jq + +RESULT=$($BINARY query bank balances $VALIDATOR_2 --node $CHAIN2_NODE -o json) +echo "Bank balance AFTER executing wasm loop contract tx: $(echo $RESULT | jq)" echo "#############################################" echo "Testing general keyshare on source chain" @@ -918,6 +1043,49 @@ echo "Query Contract state" RSP=$($BINARY q wasm contract-state smart $CONTRACT_ADDR '{"get_stored_data":{"identity": "'"$TARGET_HEIGHT"'"}}' --node $CHAIN1_NODE -o json) echo $RSP +echo "Testing gas capping mechanism in contract callback" +echo "Creating new General keyshare Request on chain fairyring_test_1" +RESULT=$($BINARY tx pep request-general-identity 30s loop --from $WALLET_1 --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node $CHAIN1_NODE --broadcast-mode sync --keyring-backend test -o json -y) +check_tx_code $RESULT + +sleep 5 + +IDENTITY="fairy1m9l358xunhhwds0568za49mzhvuxx9uxdra8sq/loop" + +echo "Registering contract with identity" +RESULT=$($BINARY tx pep register-contract $CONTRACT_ADDR $IDENTITY --from $WALLET_1 --gas-prices 1ufairy --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node $CHAIN1_NODE --broadcast-mode sync --keyring-backend test -o json -y) +check_tx_code $RESULT +RESULT=$(wait_for_tx_source $RESULT) + +sleep 5 + +echo "Request Generation of Aggr keyshare" +RESULT=$($BINARY tx pep request-general-decryption-key $IDENTITY --from $WALLET_1 --gas-prices 1ufairy --gas 900000 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node $CHAIN1_NODE --broadcast-mode sync --keyring-backend test -o json -y) +echo "$RESULT" +check_tx_code $RESULT + +sleep 5 + +EXTRACTED_RESULT=$($BINARY share-generation derive $GENERATED_SHARE 1 $IDENTITY) +EXTRACTED_SHARE=$(echo "$EXTRACTED_RESULT" | jq -r '.Keyshare') + +while true; do + echo "Submitting General Key Share" + + RESULT=$($BINARY tx keyshare submit-general-keyshare "private-gov-identity" $IDENTITY $EXTRACTED_SHARE 1 --from $VALIDATOR_1 --gas-prices 1ufairy --gas 900000 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode sync --keyring-backend test -o json -y) + echo "$RESULT" + check_tx_err $RESULT + if [ $? -eq 0 ]; then + break + fi +done + +sleep 8 + +echo "Query Contract state [should fail]" +RSP=$($BINARY q wasm contract-state smart $CONTRACT_ADDR '{"get_stored_data":{"identity": "fairy1m9l358xunhhwds0568za49mzhvuxx9uxdra8sq/loop"}}' --node $CHAIN1_NODE -o json) +echo $RSP + echo "#########################################################" echo "# Testing decryption from contract request source chain #" echo "#########################################################" diff --git a/scripts/tests/start.sh b/scripts/tests/start.sh index 7e60d616..eec0500e 100755 --- a/scripts/tests/start.sh +++ b/scripts/tests/start.sh @@ -155,6 +155,10 @@ sed -i -e 's/"avg_block_time": 5.6/"avg_block_time": 1.12/g' $CHAIN_DIR/$CHAINID sed -i -e 's/"is_source_chain": false/"is_source_chain": true/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json +#sed -i -e 's/"amount": "300000"/"amount": "1"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json +#sed -i -e 's/"amount": "300000"/"amount": "1"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json + + jsonData2=$(cat "$CHAIN_DIR/$CHAINID_2/config/genesis.json") modifiedJson2=$(echo "$jsonData2" | jq '.app_state.gov.params.channel_id = "channel-0" | diff --git a/x/keyshare/keeper/msg_send_keyshare.go b/x/keyshare/keeper/msg_send_keyshare.go index 9a9aa903..ef912bdf 100644 --- a/x/keyshare/keeper/msg_send_keyshare.go +++ b/x/keyshare/keeper/msg_send_keyshare.go @@ -62,6 +62,20 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar return nil, types.ErrCommitmentsNotFound } + pubKey, found := k.GetActivePubkey(ctx) + if !found { + return nil, types.ErrPubkeyNotFound + } + + if ctx.IsCheckTx() && msg.BlockHeight >= pubKey.Expiry { + queuedCommits, found := k.GetQueuedCommitments(ctx) + if !found { + return nil, types.ErrCommitmentsNotFound + } + k.Logger().Info("IsCheckTX && keyshare height is next epoch, using queued commitments for verification") + commitments = queuedCommits + } + commitmentsLen := uint64(len(commitments.Commitments)) if msg.KeyshareIndex > commitmentsLen { return nil, types.ErrInvalidKeyshareIndex.Wrap(fmt.Sprintf("Expect Index within: %d, got: %d", commitmentsLen, msg.KeyshareIndex)) diff --git a/x/keyshare/module/module.go b/x/keyshare/module/module.go index 0e45d07f..9576e072 100644 --- a/x/keyshare/module/module.go +++ b/x/keyshare/module/module.go @@ -182,12 +182,15 @@ func (am AppModule) BeginBlock(cctx context.Context) error { continue } bondedVal, err := am.stakingKeeper.GetValidator(ctx, sdk.ValAddress(accAddr)) - if err != nil { - am.keeper.RemoveValidatorSet(ctx, eachValidator.Validator) - continue - } - if !bondedVal.IsBonded() { + if err != nil || !bondedVal.IsBonded() { am.keeper.RemoveValidatorSet(ctx, eachValidator.Validator) + for _, v := range am.keeper.GetAllAuthorizedAddress(ctx) { + if v.AuthorizedBy == eachValidator.Validator { + am.keeper.RemoveAuthorizedAddress(ctx, v.Target) + am.keeper.DecreaseAuthorizedCount(ctx, eachValidator.Validator) + break + } + } } } diff --git a/x/pep/keeper/contract.go b/x/pep/keeper/contract.go index 0d585f25..2f81842a 100644 --- a/x/pep/keeper/contract.go +++ b/x/pep/keeper/contract.go @@ -97,6 +97,12 @@ func (k Keeper) GetAllContractEntries(ctx context.Context) (list []types.Registe } func (k Keeper) ExecuteContract(ctx sdk.Context, contractAddr string, msg types.ExecuteContractMsg) { + defer func() { + if r := recover(); r != nil { + k.logger.Error("recovered from panic in contract execution", "contractAddr", contractAddr, "error", r) + } + }() + addr := sdk.MustAccAddressFromBech32(contractAddr) msgBytes, err := json.Marshal(msg) if err != nil { @@ -105,8 +111,19 @@ func (k Keeper) ExecuteContract(ctx sdk.Context, contractAddr string, msg types. } wasmAddr := authtypes.NewModuleAddress(wasmtypes.ModuleName) - _, err = k.contractKeeper.Execute(ctx, addr, wasmAddr, msgBytes, sdk.Coins{}) + gasLimit := k.MaxContractGas(ctx) + + // Create a new context with a gas meter + gasCtx := ctx + gasCtx = gasCtx.WithGasMeter(storetypes.NewGasMeter(gasLimit)) + + // Execute the contract within the gas-limited context + _, err = k.contractKeeper.Execute(gasCtx, addr, wasmAddr, msgBytes, sdk.Coins{}) if err != nil { - k.logger.Error("error executing contract: %s; error: %v", contractAddr, err) + if gasCtx.GasMeter().IsOutOfGas() { + k.logger.Error("contract execution failed due to gas limit: %s", contractAddr) + } else { + k.logger.Error("error executing contract: %s; error: %v", contractAddr, err) + } } } diff --git a/x/pep/keeper/params.go b/x/pep/keeper/params.go index 0a1aaee1..9337cad8 100644 --- a/x/pep/keeper/params.go +++ b/x/pep/keeper/params.go @@ -56,3 +56,7 @@ func (k Keeper) MinGasPrice(ctx context.Context) (res sdk.Coin) { func (k Keeper) IsSourceChain(ctx context.Context) (res bool) { return k.GetParams(ctx).IsSourceChain } + +func (k Keeper) MaxContractGas(ctx context.Context) (res uint64) { + return k.GetParams(ctx).MaxContractGas +} diff --git a/x/pep/migrations/v2/store.go b/x/pep/migrations/v2/store.go index b2c3bd75..8f6bab94 100644 --- a/x/pep/migrations/v2/store.go +++ b/x/pep/migrations/v2/store.go @@ -22,6 +22,7 @@ func MigrateStore(ctx sdk.Context, storeService store.KVStoreService, cdc codec. &types.DefaultMinGasPrice, true, &types.DefaultKeysharePrice, + types.DefaultContractGas, ) bz, err := cdc.Marshal(&currParams) diff --git a/x/pep/migrations/v3/store.go b/x/pep/migrations/v3/store.go index d4b51a5b..9ad5c484 100644 --- a/x/pep/migrations/v3/store.go +++ b/x/pep/migrations/v3/store.go @@ -26,6 +26,7 @@ func MigrateStore(ctx sdk.Context, storeService store.KVStoreService, cdc codec. currentParams.MinGasPrice, currentParams.IsSourceChain, &types.DefaultKeysharePrice, + types.DefaultContractGas, ) bz, err := cdc.Marshal(&currParams) diff --git a/x/pep/module/module.go b/x/pep/module/module.go index f65aa58f..f4c0048c 100644 --- a/x/pep/module/module.go +++ b/x/pep/module/module.go @@ -3,6 +3,7 @@ package pep import ( "bytes" "context" + storetypes "cosmossdk.io/store/types" "encoding/hex" "encoding/json" "errors" @@ -238,7 +239,7 @@ func (am AppModule) BeginBlock(cctx context.Context) error { if len(encryptedTxs.EncryptedTxs) > 0 { am.keeper.SetAllEncryptedTxExpired(ctx, h) am.keeper.Logger().Info(fmt.Sprintf("Updated total %d encrypted txs at block %d to expired", len(encryptedTxs.EncryptedTxs), h)) - indexes := make([]string, len(encryptedTxs.EncryptedTxs)) + indexes := make([]string, 0) for _, v := range encryptedTxs.EncryptedTxs { indexes = append(indexes, strconv.FormatUint(v.Index, 10)) } @@ -504,6 +505,11 @@ func (am AppModule) handleGasConsumption(ctx sdk.Context, recipient sdk.AccAddre } if gasUsed.GT(gasCharged.Amount) { + creatorBal := am.bankKeeper.SpendableCoins(ctx, creatorAccount.GetAddress()) + remainingAmount := gasUsed.Sub(gasCharged.Amount) + denomBal := creatorBal.AmountOf(gasCharged.Denom) + finalChargeAmount := cosmosmath.MinInt(denomBal, remainingAmount) + deductFeeErr := ante.DeductFees( am.bankKeeper, ctx, @@ -511,14 +517,23 @@ func (am AppModule) handleGasConsumption(ctx sdk.Context, recipient sdk.AccAddre sdk.NewCoins( sdk.NewCoin( gasCharged.Denom, - gasUsed.Sub(gasCharged.Amount)), + finalChargeAmount, + ), ), ) if deductFeeErr != nil { - am.keeper.Logger().Error("deduct failed tx fee error") + am.keeper.Logger().Error( + fmt.Sprintf("deduct failed tx fee error, remaining amount: %s, denomBal: %s, charged: %s", + remainingAmount.String(), + denomBal.String(), + finalChargeAmount.String()), + ) am.keeper.Logger().Error(deductFeeErr.Error()) } else { - am.keeper.Logger().Info("failed tx fee deducted without error") + am.keeper.Logger().Info(fmt.Sprintf( + "failed tx fee deducted without error, deducted: %s %s", + finalChargeAmount.String(), + gasCharged.Denom)) } } else { amount := gasCharged.Amount.Sub(gasUsed) @@ -774,7 +789,7 @@ func (am AppModule) decryptAndExecuteTx( txFee[0].Denom, // Tx Fee Amount Divide Provide Gas => provided gas price // Provided Gas Price * Gas Used => Amount to deduct as gas fee - txFee[0].Amount.Quo(gasProvided).Mul(gasUsedInBig), + txFee[0].Amount.Mul(gasUsedInBig).Quo(gasProvided), ) if eachTx.ChargedGas == nil { @@ -798,8 +813,8 @@ func (am AppModule) decryptAndExecuteTx( if refundAmount.IsZero() { deductFeeErr := ante.DeductFees(am.bankKeeper, ctx, creatorAccount, sdk.NewCoins(usedGasFee)) if deductFeeErr != nil { - am.keeper.Logger().Error("Deduct fee Err") - am.keeper.Logger().Error(deductFeeErr.Error()) + am.processFailedEncryptedTx(ctx, eachTx, fmt.Sprintf("error while deducting rest of the fee: %s", err.Error()), startConsumedGas) + return deductFeeErr } else { am.keeper.Logger().Info("Fee deducted without error") } @@ -819,8 +834,21 @@ func (am AppModule) decryptAndExecuteTx( } } + defer func(sdkCtx sdk.Context, tx DecryptionTx, startGas uint64) { + if r := recover(); r != nil { + am.keeper.Logger().Error("recovered from panic in contract execution", "error", r) + am.processFailedEncryptedTx(sdkCtx, tx, fmt.Sprintf("panic when handling tx message: %v", r), startGas) + } + }(ctx, eachTx, startConsumedGas) + handler := am.msgServiceRouter.Handler(txMsgs[0]) - handlerResult, err := handler(ctx, txMsgs[0]) + gasMax := am.keeper.GetParams(ctx).MinGasPrice.Amount.Uint64() + if eachTx.ChargedGas != nil { + gasMax = eachTx.ChargedGas.Amount.Uint64() + } + + gasCtx := ctx.WithGasMeter(storetypes.NewGasMeter(gasMax)) + handlerResult, err := handler(gasCtx, txMsgs[0]) if err != nil { am.processFailedEncryptedTx(ctx, eachTx, fmt.Sprintf("error when handling tx message: %s", err.Error()), startConsumedGas) return err diff --git a/x/pep/types/params.go b/x/pep/types/params.go index 90cdf819..7f1df13c 100644 --- a/x/pep/types/params.go +++ b/x/pep/types/params.go @@ -21,10 +21,12 @@ var ( ) var ( - KeyMinGasPrice = []byte("MinGasPrice") - DefaultMinGasPrice = sdk.NewCoin("ufairy", cosmosmath.NewInt(300000)) - DecryptionKeyPrice = []byte("PrivateKeysPrice") - DefaultKeysharePrice = sdk.NewCoin("ufairy", cosmosmath.NewInt(300000)) + KeyMinGasPrice = []byte("MinGasPrice") + DefaultMinGasPrice = sdk.NewCoin("ufairy", cosmosmath.NewInt(300000)) + DecryptionKeyPrice = []byte("PrivateKeysPrice") + DefaultKeysharePrice = sdk.NewCoin("ufairy", cosmosmath.NewInt(300000)) + KeyMaxContractGas = []byte("MaxContractGas") + DefaultContractGas uint64 = 500000 ) var ( @@ -50,6 +52,7 @@ func NewParams( minGasPrice *sdk.Coin, isSourceChain bool, decryptionKeyPrice *sdk.Coin, + maxContractGas uint64, ) Params { return Params{ TrustedAddresses: trAddrs, @@ -58,6 +61,7 @@ func NewParams( MinGasPrice: minGasPrice, IsSourceChain: isSourceChain, PrivateDecryptionKeyPrice: decryptionKeyPrice, + MaxContractGas: maxContractGas, } } @@ -70,6 +74,7 @@ func DefaultParams() Params { &DefaultMinGasPrice, DefaultIsSourceChain, &DefaultKeysharePrice, + DefaultContractGas, ) } @@ -82,6 +87,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyMinGasPrice, &p.MinGasPrice, validateMinGasPrice), paramtypes.NewParamSetPair(KeyIsSourceChain, &p.IsSourceChain, validateIsSourceChain), paramtypes.NewParamSetPair(DecryptionKeyPrice, &p.PrivateDecryptionKeyPrice, validateMinGasPrice), + paramtypes.NewParamSetPair(KeyMaxContractGas, &p.MaxContractGas, validateMaxContractGas), } } @@ -111,6 +117,10 @@ func (p Params) Validate() error { return err } + if err := validateMaxContractGas(p.MaxContractGas); err != nil { + return err + } + return nil } @@ -197,3 +207,13 @@ func validateTrustedCounterParties(v interface{}) error { return nil } + +// validateMaxContractGas validates the MaxContractGas param +func validateMaxContractGas(v interface{}) error { + _, ok := v.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + return nil +} diff --git a/x/pep/types/params.pb.go b/x/pep/types/params.pb.go index 5f56131f..31773eac 100644 --- a/x/pep/types/params.pb.go +++ b/x/pep/types/params.pb.go @@ -34,6 +34,7 @@ type Params struct { TrustedAddresses []string `protobuf:"bytes,4,rep,name=trusted_addresses,json=trustedAddresses,proto3" json:"trusted_addresses,omitempty" yaml:"trusted_addresses"` MinGasPrice *types.Coin `protobuf:"bytes,5,opt,name=min_gas_price,json=minGasPrice,proto3" json:"min_gas_price,omitempty" yaml:"min_gas_price"` PrivateDecryptionKeyPrice *types.Coin `protobuf:"bytes,6,opt,name=private_decryption_key_price,json=privateDecryptionKeyPrice,proto3" json:"private_decryption_key_price,omitempty" yaml:"private_decryption_key_price"` + MaxContractGas uint64 `protobuf:"varint,7,opt,name=max_contract_gas,json=maxContractGas,proto3" json:"max_contract_gas,omitempty" yaml:"max_contract_gas"` } func (m *Params) Reset() { *m = Params{} } @@ -111,6 +112,13 @@ func (m *Params) GetPrivateDecryptionKeyPrice() *types.Coin { return nil } +func (m *Params) GetMaxContractGas() uint64 { + if m != nil { + return m.MaxContractGas + } + return 0 +} + // TrustedCounterParty defines the structure to store the ibc info // of the source chain (fairyring) to reliably fetch active keys and // general/private decryption keys @@ -182,41 +190,44 @@ func init() { func init() { proto.RegisterFile("fairyring/pep/params.proto", fileDescriptor_9a32cf7d58c7a431) } var fileDescriptor_9a32cf7d58c7a431 = []byte{ - // 537 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x63, 0x52, 0xa2, 0xe6, 0x42, 0x04, 0x71, 0x4b, 0x71, 0xd3, 0xe2, 0x44, 0xee, 0x40, - 0xd4, 0xc1, 0x56, 0xcb, 0xd6, 0x0d, 0xa7, 0x02, 0x45, 0x48, 0x28, 0x32, 0x48, 0x48, 0x5d, 0xac, - 0xcb, 0xf9, 0x25, 0x39, 0x25, 0xbe, 0xb3, 0xee, 0x2e, 0x11, 0x9e, 0xd9, 0x98, 0xf8, 0x28, 0x7c, - 0x03, 0x56, 0xc6, 0x8e, 0x4c, 0x11, 0x4a, 0x06, 0xf6, 0x7c, 0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, 0x45, 0xdb, 0x06, 0x74, 0x12, 0xfb, 0x08, 0x55, 0x09, 0x67, 0x0c, - 0x88, 0x5e, 0x82, 0x26, 0x3a, 0x18, 0xe5, 0xe8, 0xd1, 0x15, 0xec, 0x24, 0xf6, 0x73, 0x84, 0xfe, - 0x89, 0x61, 0x51, 0x2b, 0xca, 0x64, 0x1d, 0xaf, 0xf0, 0xfc, 0xe7, 0xcc, 0xb5, 0x2e, 0x67, 0xae, - 0xf5, 0x7b, 0xe6, 0x5a, 0xdf, 0xe6, 0x6e, 0xe1, 0x72, 0xee, 0x16, 0x7e, 0xcd, 0xdd, 0xc2, 0xc5, - 0x71, 0x9f, 0xaa, 0xc1, 0xb8, 0xe7, 0x13, 0x9e, 0x06, 0xaf, 0x31, 0x15, 0xbd, 0x11, 0x27, 0xc3, - 0xe0, 0xe6, 0xfa, 0x2a, 0xcf, 0x40, 0xf6, 0x4a, 0xfa, 0x19, 0xbc, 0xfc, 0x1b, 0x00, 0x00, 0xff, - 0xff, 0xc4, 0xcb, 0xd3, 0xb6, 0x7c, 0x03, 0x00, 0x00, + // 577 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x41, 0x6f, 0xd3, 0x3e, + 0x18, 0xc6, 0x97, 0x7f, 0xb7, 0xfd, 0x57, 0x8f, 0xc2, 0x96, 0x8d, 0x2d, 0xeb, 0x46, 0x12, 0x65, + 0x07, 0xa2, 0x1d, 0x12, 0x6d, 0xdc, 0x76, 0x23, 0x1d, 0x4c, 0x15, 0x12, 0x9a, 0x02, 0x12, 0xd2, + 0x2e, 0x91, 0xeb, 0x98, 0xd6, 0x6a, 0x63, 0x47, 0xb6, 0x5b, 0x35, 0x67, 0x24, 0x0e, 0x9c, 0xf8, + 0x28, 0x7c, 0x0c, 0x8e, 0x3b, 0x72, 0x8a, 0x50, 0x7b, 0xe0, 0x9e, 0x4f, 0x80, 0x1a, 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x09, 0xc5, 0xf9, 0xe1, 0x97, + 0x5f, 0xdf, 0x4e, 0xf6, 0x6e, 0x43, 0x3e, 0x2e, 0x63, 0xae, 0xd2, 0xe7, 0x8c, 0xc0, 0xce, 0x03, + 0xdf, 0x4e, 0x3f, 0x04, 0x75, 0x34, 0x20, 0x98, 0xca, 0x45, 0x14, 0xc3, 0x0d, 0x05, 0xda, 0xb1, + 0x7e, 0x0c, 0x1a, 0x88, 0x51, 0x8a, 0x51, 0x79, 0x17, 0x12, 0x97, 0xf9, 0xaa, 0x87, 0x8f, 0x6e, + 0x61, 0x3b, 0xd6, 0x9f, 0x01, 0xf0, 0x47, 0x9a, 0x6b, 0xa5, 0xa2, 0x8e, 0xe6, 0x29, 0x0d, 0x2e, + 0xbe, 0x4f, 0x4c, 0xed, 0x66, 0x62, 0x6a, 0x3f, 0x27, 0xa6, 0xf6, 0x75, 0x6a, 0xae, 0xdc, 0x4c, + 0xcd, 0x95, 0x1f, 0x53, 0x73, 0xe5, 0xfa, 0xa4, 0x4b, 0x64, 0x6f, 0xd8, 0xf1, 0x10, 0x4b, 0xfc, + 0xd7, 0x90, 0xf0, 0xce, 0x80, 0xa1, 0xbe, 0xbf, 0xdc, 0xbe, 0xcc, 0x52, 0x2c, 0x3a, 0xeb, 0xe5, + 0xdf, 0xf4, 0xe2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x52, 0x3a, 0x4e, 0xc3, 0x03, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -239,6 +250,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MaxContractGas != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxContractGas)) + i-- + dAtA[i] = 0x38 + } if m.PrivateDecryptionKeyPrice != nil { { size, err := m.PrivateDecryptionKeyPrice.MarshalToSizedBuffer(dAtA[:i]) @@ -394,6 +410,9 @@ func (m *Params) Size() (n int) { l = m.PrivateDecryptionKeyPrice.Size() n += 1 + l + sovParams(uint64(l)) } + if m.MaxContractGas != 0 { + n += 1 + sovParams(uint64(m.MaxContractGas)) + } return n } @@ -643,6 +662,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxContractGas", wireType) + } + m.MaxContractGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxContractGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])