diff --git a/integration/contracts/contract-revert/.gitignore b/integration/contracts/contract-revert/.gitignore new file mode 100755 index 000000000..6e1158bed --- /dev/null +++ b/integration/contracts/contract-revert/.gitignore @@ -0,0 +1,5 @@ +# Ignore build artifacts from the local tests sub-crate. +/target/ + +# Ignore backup files creates by cargo fmt. +**/*.rs.bk diff --git a/integration/contracts/contract-revert/Cargo.lock b/integration/contracts/contract-revert/Cargo.lock new file mode 100644 index 000000000..e1b9e1617 --- /dev/null +++ b/integration/contracts/contract-revert/Cargo.lock @@ -0,0 +1,1035 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "cc" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "contract-revert" +version = "3.0.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ink" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9fd4f77d66c94aa7f27a7cf41cd2edbc2229afe34ec475c3f32b6e8fdf561a0" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "870914970470fd77a3f42d3c5d1918b562817af127fd063ee8b1d9fbf59aa1fe" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22d79057b2565df31a10af6510a44b161093f110c5f9c22ad02c20af9cea4c29" +dependencies = [ + "blake2", + "derive_more", + "either", + "env_logger", + "heck", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 2.0.61", +] + +[[package]] +name = "ink_engine" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "722ec3a5eb557124b001c60ff8f961079f6d566af643edea579f152b15822fe5" +dependencies = [ + "blake2", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "584e73bc0982f6f1a067bb63ebc75262f6dc54ed2a17060efa73eaba84dc9308" +dependencies = [ + "arrayref", + "blake2", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-decode", + "scale-encode", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b529c941518e8f450395fab9fe8ebba0a7acbb18778fc7e0a87f6248286ec72" +dependencies = [ + "blake2", + "either", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "ink_macro" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8579576c995ca9baa032584beca19155cbd63b6739570aa9da4d35a0415f4be8" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.61", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fddff95ce3e01f42002fdaf96edda691dbccb08c9ae76d7101daa1fa634e601" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8cfdf91d2b442f08efb34dd3780fd6fbd3d033f63b42f62684fe47534948ef6" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6414bcad12ebf0c3abbbb192a09e4d06e22f662cf3e19545204e1b0684be12a1" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-decode", + "scale-encode", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd728409de235de0489f71ee2d1beb320613fdb50dda9fa1c564825f4ad06daa" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8dcb50f70377ac35c28d63b06383a0a3cbb79542ea4cdc5b00e3e2b3de4a549" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "parity-scale-codec" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +dependencies = [ + "proc-macro-crate 2.0.2", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scale-bits" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "scale-decode" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7789f5728e4e954aaa20cadcc370b99096fb8645fca3c9333ace44bb18f30095" +dependencies = [ + "derive_more", + "parity-scale-codec", + "scale-bits", + "scale-decode-derive", + "scale-info", + "smallvec", +] + +[[package]] +name = "scale-decode-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27873eb6005868f8cc72dcfe109fae664cf51223d35387bc2f28be4c28d94c47" +dependencies = [ + "darling", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scale-encode" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" +dependencies = [ + "derive_more", + "parity-scale-codec", + "scale-encode-derive", + "scale-info", + "smallvec", +] + +[[package]] +name = "scale-encode-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" +dependencies = [ + "darling", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scale-info" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + +[[package]] +name = "serde" +version = "1.0.200" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.200" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" diff --git a/integration/contracts/contract-revert/Cargo.toml b/integration/contracts/contract-revert/Cargo.toml new file mode 100755 index 000000000..28b013930 --- /dev/null +++ b/integration/contracts/contract-revert/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "contract-revert" +version = "3.0.0" +authors = ["Polymesh Association"] +edition = "2021" +publish = false + +[dependencies] +ink = { version = "4.3", default-features = false } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", + "scale/std", + "scale-info/std", +] +ink-as-dependency = [] diff --git a/integration/contracts/contract-revert/lib.rs b/integration/contracts/contract-revert/lib.rs new file mode 100755 index 000000000..7691bb68a --- /dev/null +++ b/integration/contracts/contract-revert/lib.rs @@ -0,0 +1,44 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] + +extern crate alloc; + +#[ink::contract] +mod revert_tester { + use crate::*; + + /// A simple contract. + #[ink(storage)] + pub struct RevertTester {} + + /// The contract error types. + #[derive(Debug, scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum Error { + /// Revert contract. + Revert, + } + + /// The contract result type. + pub type Result = core::result::Result; + + impl RevertTester { + /// Creates a new contract. + #[ink(constructor)] + pub fn new(return_error: bool) -> Result { + if return_error { + Err(Error::Revert) + } else { + Ok(Self {}) + } + } + + #[ink(message)] + pub fn test(&mut self, return_error: bool) -> Result<()> { + if return_error { + Err(Error::Revert) + } else { + Ok(()) + } + } + } +} diff --git a/integration/src/lib.rs b/integration/src/lib.rs index ee685fab9..981b9188e 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -271,6 +271,20 @@ pub async fn get_auth_id(res: &mut TransactionResults) -> Result> { Ok(None) } +pub async fn get_contract_address(res: &mut TransactionResults) -> Result> { + if let Some(events) = res.events().await? { + for rec in &events.0 { + match &rec.event { + RuntimeEvent::Contracts(ContractsEvent::Instantiated { contract, .. }) => { + return Ok(Some(*contract)); + } + _ => (), + } + } + } + Ok(None) +} + /// Helper trait to add methods to `User` #[async_trait::async_trait] pub trait IntegrationUser: Signer { diff --git a/integration/tests/contract_permissions.rs b/integration/tests/contract_permissions.rs index 7fc59c815..c1b5cd7e1 100644 --- a/integration/tests/contract_permissions.rs +++ b/integration/tests/contract_permissions.rs @@ -7,27 +7,12 @@ use polymesh_api::{ secondary_key::Signatory, settlement::{VenueDetails, VenueType}, }, - TransactionResults, }; use sp_core::Encode; use sp_weights::Weight; use integration::*; -async fn get_contract_address(res: &mut TransactionResults) -> Result> { - if let Some(events) = res.events().await? { - for rec in &events.0 { - match &rec.event { - RuntimeEvent::Contracts(ContractsEvent::Instantiated { contract, .. }) => { - return Ok(Some(*contract)); - } - _ => (), - } - } - } - Ok(None) -} - #[tokio::test] async fn contract_as_secondary_key_change_identity() -> Result<()> { let mut tester = PolymeshTester::new().await?; diff --git a/integration/tests/contract_revert.contract b/integration/tests/contract_revert.contract new file mode 100644 index 000000000..1d2d8fb98 --- /dev/null +++ b/integration/tests/contract_revert.contract @@ -0,0 +1 @@ +{"source":{"hash":"0x35cedaa8f8d3cf9271a8f9584ac70f26e24d957d29e709673d0aada120321326","language":"ink! 4.3.0","compiler":"rustc 1.80.0-nightly","wasm":"0x0061736d0100000001240760000060027f7f0060047f7f7f7f017f60037f7f7f0060017f006000017f60017f017f027406057365616c310b6765745f73746f726167650002057365616c301176616c75655f7472616e736665727265640001057365616c3005696e7075740001057365616c320b7365745f73746f726167650002057365616c300b7365616c5f72657475726e000303656e76066d656d6f72790201021003090804050600000100000608017f01418080040b0711020463616c6c000b066465706c6f79000c0ad306084601027f024002402000280208220141046a22022001490d00200220002802044b0d00200220016b4104470d0120002002360208200028020020016a41003600000f0b000b000b5502027f027e230041206b22002400200041106a22014200370300200042003703082000411036021c200041086a2000411c6a10012001290300210220002903082103200041206a2400410541042002200384501b0b3f01017f2000280204220145044041020f0b2000200141016b36020420002000280200220041016a3602004101410220002d000022004101461b410020001b0b1300418080044181023b010041014102100a000b5101037f230041106b22002400200042808001370208200041808004360204200041046a1005200028020c220120002802084b0440000b200028020422022001200120026a410010031a200041106a24000b0d0020004180800420011004000ba60201057f230041106b220024000240100641ff01714105470d0020004180800136020441808004200041046a100220002802042201418180014f0d00024020014104490d002000418480043602042000200141046b3602084180800428020041929782b103470d00200041046a1007220341ff01714102460d00200042808001370208200041808004360204200041046a100520002802082202200028020c2201490d01200028020421042000200220016b220236020420042001200120046a200041046a1000200028020420024b720d01200341ff0171220045044010090b200041004721014180800441003a000041012100200341ff017104404181800441013a0000410221000b2000418080046a41003a00002001200041016a100a000b1008000b000bd70101037f230041106b220024000240100641ff01714105470d0020004180800136020841808004200041086a100220002802082201418180014f0d00024020014104490d002000418480043602002000200141046b36020441808004280200419bddf6f405470d0020001007220141ff017122024102460d00200020013a000f200141ff017141004721012002047f200041106a05100941000b21024180800441003a000041012100200204404181800441013a0000410221000b2000418080046a41003a00002001200041016a100a000b1008000b000b","build_info":{"build_mode":"Release","cargo_contract_version":"3.2.0","rust_toolchain":"nightly-x86_64-unknown-linux-gnu","wasm_opt_settings":{"keep_debug_symbols":false,"optimization_passes":"Z"}}},"contract":{"name":"contract-revert","version":"3.0.0","authors":["Polymesh Association"]},"spec":{"constructors":[{"args":[{"label":"return_error","type":{"displayName":["bool"],"type":0}}],"default":false,"docs":["Creates a new contract."],"label":"new","payable":false,"returnType":{"displayName":["ink_primitives","ConstructorResult"],"type":1},"selector":"0x9bae9d5e"}],"docs":[],"environment":{"accountId":{"displayName":["AccountId"],"type":6},"balance":{"displayName":["Balance"],"type":9},"blockNumber":{"displayName":["BlockNumber"],"type":12},"chainExtension":{"displayName":["ChainExtension"],"type":13},"hash":{"displayName":["Hash"],"type":10},"maxEventTopics":4,"timestamp":{"displayName":["Timestamp"],"type":11}},"events":[],"lang_error":{"displayName":["ink","LangError"],"type":5},"messages":[{"args":[{"label":"return_error","type":{"displayName":["bool"],"type":0}}],"default":false,"docs":[],"label":"test","mutates":true,"payable":false,"returnType":{"displayName":["ink","MessageResult"],"type":1},"selector":"0x928b2036"}]},"storage":{"root":{"layout":{"struct":{"fields":[],"name":"RevertTester"}},"root_key":"0x00000000"}},"types":[{"id":0,"type":{"def":{"primitive":"bool"}}},{"id":1,"type":{"def":{"variant":{"variants":[{"fields":[{"type":2}],"index":0,"name":"Ok"},{"fields":[{"type":5}],"index":1,"name":"Err"}]}},"params":[{"name":"T","type":2},{"name":"E","type":5}],"path":["Result"]}},{"id":2,"type":{"def":{"variant":{"variants":[{"fields":[{"type":3}],"index":0,"name":"Ok"},{"fields":[{"type":4}],"index":1,"name":"Err"}]}},"params":[{"name":"T","type":3},{"name":"E","type":4}],"path":["Result"]}},{"id":3,"type":{"def":{"tuple":[]}}},{"id":4,"type":{"def":{"variant":{"variants":[{"index":0,"name":"Revert"}]}},"path":["contract_revert","revert_tester","Error"]}},{"id":5,"type":{"def":{"variant":{"variants":[{"index":1,"name":"CouldNotReadInput"}]}},"path":["ink_primitives","LangError"]}},{"id":6,"type":{"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}},"path":["ink_primitives","types","AccountId"]}},{"id":7,"type":{"def":{"array":{"len":32,"type":8}}}},{"id":8,"type":{"def":{"primitive":"u8"}}},{"id":9,"type":{"def":{"primitive":"u128"}}},{"id":10,"type":{"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}},"path":["ink_primitives","types","Hash"]}},{"id":11,"type":{"def":{"primitive":"u64"}}},{"id":12,"type":{"def":{"primitive":"u32"}}},{"id":13,"type":{"def":{"variant":{}},"path":["ink_env","types","NoChainExtension"]}}],"version":"4"} \ No newline at end of file diff --git a/integration/tests/contract_revert.json b/integration/tests/contract_revert.json new file mode 100644 index 000000000..3b7dcff06 --- /dev/null +++ b/integration/tests/contract_revert.json @@ -0,0 +1,379 @@ +{ + "source": { + "hash": "0x35cedaa8f8d3cf9271a8f9584ac70f26e24d957d29e709673d0aada120321326", + "language": "ink! 4.3.0", + "compiler": "rustc 1.80.0-nightly", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "3.2.0", + "rust_toolchain": "nightly-x86_64-unknown-linux-gnu", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "contract-revert", + "version": "3.0.0", + "authors": [ + "Polymesh Association" + ] + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "return_error", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + "Creates a new contract." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 6 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 9 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 12 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 13 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 10 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 11 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 5 + }, + "messages": [ + { + "args": [ + { + "label": "return_error", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [], + "label": "test", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 1 + }, + "selector": "0x928b2036" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [], + "name": "RevertTester" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 5 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 5 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 3 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 4 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 3 + }, + { + "name": "E", + "type": 4 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 3, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "Revert" + } + ] + } + }, + "path": [ + "contract_revert", + "revert_tester", + "Error" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 7, + "type": { + "def": { + "array": { + "len": 32, + "type": 8 + } + } + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 9, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 10, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 12, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 13, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/integration/tests/contract_revert.rs b/integration/tests/contract_revert.rs new file mode 100644 index 000000000..0c3416830 --- /dev/null +++ b/integration/tests/contract_revert.rs @@ -0,0 +1,34 @@ +use anyhow::Result; + +use sp_weights::Weight; + +use integration::*; + +#[tokio::test] +async fn contract_constructor_reverted() -> Result<()> { + let mut tester = PolymeshTester::new().await?; + let mut users = tester.users(&["ContractRevertedDID"]).await?; + + // Upload and deploy `contract_revert` contract as a secondary key of DID1. + let contract_revert_bytes = include_bytes!("contract_revert.wasm"); + let perms = PermissionsBuilder::whole(); + let mut res = tester + .api + .call() + .polymesh_contracts() + .instantiate_with_code_perms( + 0, + Weight::from_parts(10_000_000_000, 0), + None, + contract_revert_bytes.to_vec(), + vec![0x9b, 0xae, 0x9d, 0x5e, 0x01], // Selector for `new(true)` constructor. + vec![0x42], // salt. + perms.build(), + )? + .submit_and_watch(&mut users[0]) + .await?; + + let tx_res = res.extrinsic_result().await?.expect("should have results"); + assert!(tx_res.is_failed(), "The transaction should have failed."); + Ok(()) +} diff --git a/integration/tests/contract_revert.wasm b/integration/tests/contract_revert.wasm new file mode 100644 index 000000000..83a29adc0 Binary files /dev/null and b/integration/tests/contract_revert.wasm differ diff --git a/pallets/contracts/src/benchmarking.rs b/pallets/contracts/src/benchmarking.rs index 9b5c9da51..11aead3c8 100644 --- a/pallets/contracts/src/benchmarking.rs +++ b/pallets/contracts/src/benchmarking.rs @@ -121,11 +121,6 @@ fn funded_user>>(seed: u32) -> User { user } -/// Returns the free balance of `acc`. -fn free_balance(acc: &T::AccountId) -> Balance { - T::Currency::free_balance(&acc) -} - /// The `user` instantiates `wasm.code` as the contract with `salt`. /// Returns the address of the new contract. fn instantiate(user: &User, wasm: WasmModule, salt: Vec) -> T::AccountId @@ -471,57 +466,40 @@ benchmarks! { System::::remark(origin, remark).unwrap(); } - // Use a dummy contract constructor to measure the overhead. - // `s`: Size of the salt in kilobytes. - instantiate_with_hash_perms { - let s in 0 .. max_pages::() * 64 * 1024; - let other_salt = vec![42u8; s as usize]; + base_weight_with_hash { + let i in 0 .. max_pages::() * 64 * 1024; + let s in 0 .. max_pages::() * 64 * 1024; + let input = vec![42u8; i as usize]; + let salt = vec![42u8; s as usize]; // Have the user instantiate a dummy contract. let wasm = WasmModule::::dummy(); - let hash = wasm.hash.clone(); - - // Pre-instantiate a contract so that one with the hash exists. - let contract = Contract::::new(wasm); - let user = contract.caller; + let code = Code::Existing(wasm.hash.clone()); - // Calculate new contract's address. - let addr = FrameContracts::::contract_address(&user.account(), &hash, &[], &other_salt); - }: _(user.origin(), ENDOWMENT, Weight::MAX, None, hash, vec![], other_salt, Permissions::default()) - verify { - // Ensure contract has the full value. - assert_eq!(free_balance::(&addr), ENDOWMENT + 1 as Balance); + let user = funded_user::(SEED); + let caller = user.account(); + let perms = Some(Permissions::default()); + }: { + Module::::base_weight_and_contract_address(&caller, &code, &input, &salt, perms.as_ref()) } - // This constructs a contract that is maximal expensive to instrument. - // It creates a maximum number of metering blocks per byte. - // The size of the salt influences the runtime because is is hashed in order to - // determine the contract address. All code is generated to the `call` function so that - // we don't benchmark the actual execution of this code but merely what it takes to load - // a code of that size into the sandbox. - // - // `c`: Size of the code in kilobytes. - // `s`: Size of the salt in kilobytes. - // - // # Note - // - // We cannot let `c` grow to the maximum code size because the code is not allowed - // to be larger than the maximum size **after instrumentation**. - instantiate_with_code_perms { - let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); - let s in 0 .. max_pages::() * 64 * 1024; - let salt = vec![42u8; s as usize]; - - // Construct a user doing everything. - let user = funded_user::(SEED); + base_weight_with_code { + let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); + let i in 0 .. max_pages::() * 64 * 1024; + let s in 0 .. max_pages::() * 64 * 1024; + + let input = vec![42u8; i as usize]; + let salt = vec![42u8; s as usize]; - // Construct the contract code + get addr. + // Create a dummy contract. let wasm = WasmModule::::sized(c, Location::Deploy); - let addr = FrameContracts::::contract_address(&user.account(), &wasm.hash, &[], &salt); - }: _(user.origin(), ENDOWMENT, Weight::MAX, None, wasm.code, vec![], salt, Permissions::default()) - verify { - // Ensure contract has the full value. - assert_eq!(free_balance::(&addr), ENDOWMENT + 1 as Balance); + let code = Code::Upload(wasm.code.clone()); + + let user = funded_user::(SEED); + let caller = user.account(); + let perms = Some(Permissions::default()); + }: { + Module::::base_weight_and_contract_address(&caller, &code, &input, &salt, perms.as_ref()) } update_call_runtime_whitelist { @@ -532,40 +510,33 @@ benchmarks! { .collect(); }: _(RawOrigin::Root, updates) - instantiate_with_code_as_primary_key { - let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); - let s in 0 .. max_pages::() * 64 * 1024; - + link_contract_as_secondary_key { let alice = UserBuilder::::default() .generate_did() .become_cdd_provider() .build("Alice"); T::Currency::make_free_balance_be(&alice.account(), 1_000_000 * POLY); + let caller = alice.account(); - let salt = vec![42u8; s as usize]; - let wasm = WasmModule::::sized(c, Location::Deploy); - let addr = FrameContracts::::contract_address(&alice.account(), &wasm.hash, &[], &salt); - }: _(alice.origin(), ENDOWMENT, Weight::MAX, None, wasm.code, vec![], salt) - verify { - assert_eq!(free_balance::(&addr), ENDOWMENT + 1 as Balance); + let wasm = WasmModule::::dummy(); + let addr = FrameContracts::::contract_address(&caller, &wasm.hash, &[], &[]); + let perms = Some(Permissions::default()); + }: { + Module::::link_contract_to_did(&caller, addr, perms, false)?; } - instantiate_with_hash_as_primary_key { - let s in 0 .. max_pages::() * 64 * 1024; - let salt = vec![42u8; s as usize]; + link_contract_as_primary_key { + let alice = UserBuilder::::default() + .generate_did() + .become_cdd_provider() + .build("Alice"); + T::Currency::make_free_balance_be(&alice.account(), 1_000_000 * POLY); + let caller = alice.account(); let wasm = WasmModule::::dummy(); - let hash = wasm.hash.clone(); - - // Pre-instantiate a contract so that one with the hash exists. - let contract = Contract::::new(wasm); - let user = contract.caller; - - // Calculate new contract's address. - let addr = FrameContracts::::contract_address(&user.account(), &hash, &[], &salt); - }: _(user.origin(), ENDOWMENT, Weight::MAX, None, hash, vec![], salt) - verify { - assert_eq!(free_balance::(&addr), ENDOWMENT + 1 as Balance); + let addr = FrameContracts::::contract_address(&caller, &wasm.hash, &[], &[]); + }: { + Module::::link_contract_to_did(&caller, addr, None, true)?; } upgrade_api { diff --git a/pallets/contracts/src/lib.rs b/pallets/contracts/src/lib.rs index 55dfd20c3..5a6326f12 100644 --- a/pallets/contracts/src/lib.rs +++ b/pallets/contracts/src/lib.rs @@ -55,25 +55,27 @@ pub mod benchmarking; pub mod chain_extension; -use codec::{Decode, Encode}; +use codec::{Compact, Decode, Encode}; use frame_support::dispatch::{ - DispatchError, DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, + DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, }; use frame_support::pallet_prelude::MaxEncodedLen; use frame_support::traits::Get; use frame_support::weights::Weight; use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure}; use frame_system::ensure_root; +use frame_system::ensure_signed; +#[cfg(feature = "std")] use pallet_contracts::Determinism; use scale_info::TypeInfo; use sp_core::crypto::UncheckedFrom; use sp_runtime::traits::Hash; -use sp_std::borrow::Cow; use sp_std::{vec, vec::Vec}; pub use chain_extension::{ExtrinsicId, PolymeshExtension}; +use pallet_contracts::weights::WeightInfo as FrameWeightInfo; use pallet_contracts::Config as BConfig; -use pallet_contracts_primitives::{Code, ContractResult}; +use pallet_contracts_primitives::Code; use pallet_identity::ParentDid; use polymesh_common_utilities::traits::identity::{ Config as IdentityConfig, WeightInfo as IdentityWeightInfo, @@ -237,34 +239,16 @@ pub trait WeightInfo { fn chain_extension_call_runtime(n: u32) -> Weight; fn dummy_contract() -> Weight; fn basic_runtime_call(n: u32) -> Weight; - fn instantiate_with_code_as_primary_key(code_len: u32, salt_len: u32) -> Weight; - fn instantiate_with_hash_as_primary_key(salt_len: u32) -> Weight; fn chain_extension_get_latest_api_upgrade(r: u32) -> Weight; fn upgrade_api() -> Weight; - /// Computes the cost of instantiating where `code_len` - /// and `salt_len` are specified in kilobytes. - fn instantiate_with_code_perms(code_len: u32, salt_len: u32) -> Weight; - - /// Computes the cost of instantiating for `code` and `salt`. - /// - /// Permissions are not accounted for here. - fn instantiate_with_code_bytes(code: &[u8], salt: &[u8]) -> Weight { - Self::instantiate_with_code_perms(code.len() as u32, salt.len() as u32) - } - - /// Computes the cost of instantiating where `salt_len` is specified in kilobytes. - fn instantiate_with_hash_perms(salt_len: u32) -> Weight; + fn base_weight_with_code(code_len: u32, data_len: u32, salt_len: u32) -> Weight; + fn base_weight_with_hash(data_len: u32, salt_len: u32) -> Weight; + fn link_contract_as_primary_key() -> Weight; + fn link_contract_as_secondary_key() -> Weight; fn update_call_runtime_whitelist(u: u32) -> Weight; - /// Computes the cost of instantiating for `salt`. - /// - /// Permissions are not accounted for here. - fn instantiate_with_hash_bytes(salt: &[u8]) -> Weight { - Self::instantiate_with_hash_perms((salt.len()) as u32) - } - // TODO: Needs improvement. fn read_storage(k: u32, v: u32) -> Weight { Self::chain_extension_read_storage(k, v).saturating_sub(Self::dummy_contract()) @@ -460,7 +444,7 @@ decl_module! { /// - All the errors in `pallet_contracts::Call::instantiate_with_code` can also happen here. /// - CDD/Permissions are checked, unlike in `pallet_contracts`. /// - Errors that arise when adding a new secondary key can also occur here. - #[weight = Module::::weight_instantiate_with_code(&code, &salt, Some(perms)).saturating_add(*gas_limit)] + #[weight = Module::::weight_instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32, Some(perms)).saturating_add(*gas_limit)] pub fn instantiate_with_code_perms( origin, endowment: Balance, @@ -471,12 +455,12 @@ decl_module! { salt: Vec, perms: Permissions ) -> DispatchResultWithPostInfo { - Self::base_instantiate_with_code( + Self::general_instantiate( origin, endowment, gas_limit, storage_deposit_limit, - code, + Code::Upload(code), data, salt, Some(perms), @@ -511,7 +495,7 @@ decl_module! { /// - All the errors in `pallet_contracts::Call::instantiate` can also happen here. /// - CDD/Permissions are checked, unlike in `pallet_contracts`. /// - Errors that arise when adding a new secondary key can also occur here. - #[weight = Module::::weight_instantiate_with_hash(&salt, Some(perms)).saturating_add(*gas_limit)] + #[weight = Module::::weight_instantiate_with_hash(data.len() as u32, salt.len() as u32, Some(perms)).saturating_add(*gas_limit)] pub fn instantiate_with_hash_perms( origin, endowment: Balance, @@ -522,12 +506,12 @@ decl_module! { salt: Vec, perms: Permissions ) -> DispatchResultWithPostInfo { - Self::base_instantiate_with_hash( + Self::general_instantiate( origin, endowment, gas_limit, storage_deposit_limit, - code_hash, + Code::Existing(code_hash), data, salt, Some(perms), @@ -557,7 +541,7 @@ decl_module! { /// - `data`: The input data to pass to the contract constructor. /// - `salt`: Used for contract address derivation. By varying this, the same `code` can be used under the same identity. /// - #[weight = Module::::weight_instantiate_with_code(&code, &salt, None).saturating_add(*gas_limit)] + #[weight = Module::::weight_instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32, None).saturating_add(*gas_limit)] pub fn instantiate_with_code_as_primary_key( origin, endowment: Balance, @@ -567,12 +551,12 @@ decl_module! { data: Vec, salt: Vec ) -> DispatchResultWithPostInfo { - Self::base_instantiate_with_code( + Self::general_instantiate( origin, endowment, gas_limit, storage_deposit_limit, - code, + Code::Upload(code), data, salt, None, @@ -594,7 +578,7 @@ decl_module! { /// - `data`: The input data to pass to the contract constructor. /// - `salt`: used for contract address derivation. By varying this, the same `code` can be used under the same identity. /// - #[weight = Module::::weight_instantiate_with_hash(&salt, None).saturating_add(*gas_limit)] + #[weight = Module::::weight_instantiate_with_hash(data.len() as u32, salt.len() as u32, None).saturating_add(*gas_limit)] pub fn instantiate_with_hash_as_primary_key( origin, endowment: Balance, @@ -604,12 +588,12 @@ decl_module! { data: Vec, salt: Vec, ) -> DispatchResultWithPostInfo { - Self::base_instantiate_with_hash( + Self::general_instantiate( origin, endowment, gas_limit, storage_deposit_limit, - code_hash, + Code::Existing(code_hash), data, salt, None, @@ -657,173 +641,158 @@ where Ok(()) } - /// Instantiates a contract using `code` as the WASM code blob. - fn base_instantiate_with_code( - origin: T::RuntimeOrigin, - endowment: Balance, - gas_limit: Weight, - storage_deposit_limit: Option, - code: Vec, - inst_data: Vec, - salt: Vec, - perms: Option, - deploy_as_child_identity: bool, - ) -> DispatchResultWithPostInfo { - Self::general_instantiate( - origin, - endowment, - Self::weight_instantiate_with_code(&code, &salt, perms.as_ref()), - gas_limit, - storage_deposit_limit, - Code::Upload(code), - inst_data, - salt, - perms, - deploy_as_child_identity, - ) + /// Computes the weight of `instantiate_with_code(code, salt, perms)`. + fn weight_link_contract_to_did(perms: Option<&Permissions>) -> Weight { + match perms { + Some(permissions) => ::WeightInfo::link_contract_as_secondary_key() + .saturating_add(::WeightInfo::permissions_cost_perms( + permissions, + )), + None => ::WeightInfo::link_contract_as_primary_key(), + } } /// Computes the weight of `instantiate_with_code(code, salt, perms)`. fn weight_instantiate_with_code( - code: &[u8], - salt: &[u8], + code_len: u32, + data_len: u32, + salt_len: u32, perms: Option<&Permissions>, ) -> Weight { - match perms { - Some(permissions) => { - ::WeightInfo::instantiate_with_code_bytes(&code, &salt).saturating_add( - ::WeightInfo::permissions_cost_perms(permissions), + let instantiate_weight = + ::WeightInfo::instantiate_with_code(code_len, data_len, salt_len) + .saturating_add(::WeightInfo::base_weight_with_code( + code_len, data_len, salt_len, + )); + instantiate_weight.saturating_add(Self::weight_link_contract_to_did(perms)) + } + + /// Computes weight of `instantiate_with_hash(salt, perms)`. + fn weight_instantiate_with_hash( + data_len: u32, + salt_len: u32, + perms: Option<&Permissions>, + ) -> Weight { + let instantiate_weight = ::WeightInfo::instantiate(data_len, salt_len) + .saturating_add(::WeightInfo::base_weight_with_hash( + data_len, salt_len, + )); + instantiate_weight.saturating_add(Self::weight_link_contract_to_did(perms)) + } + + /// Get base weight and contract address. + pub fn base_weight_and_contract_address( + caller: &T::AccountId, + code: &Code>, + data: &[u8], + salt: &[u8], + perms: Option<&Permissions>, + ) -> (Weight, T::AccountId) { + let data_len = data.len() as u32; + let salt_len = salt.len() as u32; + // The base weight of the Substrate call `instantiate*`. + let (base_weight, code_hash) = match &code { + Code::Existing(h) => ( + Self::weight_instantiate_with_hash(data_len, salt_len, perms), + *h, + ), + Code::Upload(c) => { + let code_len = c.len() as u32; + ( + Self::weight_instantiate_with_code(code_len, data_len, salt_len, perms), + T::Hashing::hash(c), ) } - None => ::WeightInfo::instantiate_with_code_as_primary_key( - code.len() as u32, - salt.len() as u32, - ), - } + }; + + // Pre-compute what contract's address will be + let contract = FrameContracts::::contract_address(caller, &code_hash, &data, &salt); + (base_weight, contract) } - /// Instantiates a contract using an existing WASM code blob with `code_hash` as its code. - fn base_instantiate_with_hash( - origin: T::RuntimeOrigin, - endowment: Balance, - gas_limit: Weight, - storage_deposit_limit: Option, - code_hash: CodeHash, - inst_data: Vec, - salt: Vec, + /// Link the contract to the caller's identity. + pub fn link_contract_to_did( + caller: &T::AccountId, + contract: T::AccountId, perms: Option, deploy_as_child_identity: bool, - ) -> DispatchResultWithPostInfo { - Self::general_instantiate( - origin, - endowment, - // Compute the base weight of roughly `base_instantiate`. - Self::weight_instantiate_with_hash(&salt, perms.as_ref()), - gas_limit, - storage_deposit_limit, - Code::Existing(code_hash), - inst_data, - salt, - perms, - deploy_as_child_identity, - ) - } + ) -> Result<(), DispatchErrorWithPostInfo> { + // Ensure we have perms + we'll need sender & DID. + let caller = pallet_permissions::Module::::ensure_call_permissions(caller)?; - /// Computes weight of `instantiate_with_hash(salt, perms)`. - fn weight_instantiate_with_hash(salt: &[u8], perms: Option<&Permissions>) -> Weight { - match perms { - Some(permissions) => ::WeightInfo::instantiate_with_hash_bytes(&salt) - .saturating_add(::WeightInfo::permissions_cost_perms( - permissions, - )), - None => { - ::WeightInfo::instantiate_with_hash_as_primary_key(salt.len() as u32) - } + // Ensure contract is not linked to a DID + Identity::::ensure_key_did_unlinked(&contract)?; + if deploy_as_child_identity { + ensure!( + caller.secondary_key.is_none(), + Error::::CallerNotAPrimaryKey + ); + Identity::::ensure_no_parent(caller.primary_did)?; + Identity::::unverified_create_child_identity(contract, caller.primary_did)?; + } else { + let perms = perms.ok_or(Error::::MissingKeyPermissions)?; + // Ensure that the key can be a secondary-key + Identity::::ensure_perms_length_limited(&perms)?; + // Link contract's address to caller's identity as a secondary key with `perms`. + Identity::::unsafe_join_identity(caller.primary_did, perms, contract); } + Ok(()) } /// General logic for contract instantiation both when the code or code hash is given. - /// - /// The interesting parameters here are: - /// - `base_weight` assigns a base non-variable weight to the full extrinsic. - /// - `code_hash` specifies the hash to use to derive the contract's key. - /// - `code` specifies the code for the contract, either as a code blob or an existing hash. - /// The hash of `code` in either case is assumed to correspond to `code_hash`. fn general_instantiate( origin: T::RuntimeOrigin, endowment: Balance, - base_weight: Weight, gas_limit: Weight, storage_deposit_limit: Option, code: Code>, - inst_data: Vec, + data: Vec, salt: Vec, perms: Option, deploy_as_child_identity: bool, ) -> DispatchResultWithPostInfo { - // Ensure we have perms + we'll need sender & DID. - let origin_data = Identity::::ensure_origin_call_permissions(origin)?; - - // Pre-compute what contract's key will be - let contract_key = FrameContracts::::contract_address( - &origin_data.sender, - &Self::code_hash(&code), - &inst_data, - &salt, - ); - - // Ensure contract_key is not linked to a DID - Identity::::ensure_key_did_unlinked(&contract_key)?; - if !deploy_as_child_identity { - let perms = perms.ok_or(Error::::MissingKeyPermissions)?; - // Ensure that the key can be a secondary-key - Identity::::ensure_perms_length_limited(&perms)?; - // Link contract's address to caller's identity as a secondary key with `perms`. - Identity::::unsafe_join_identity(origin_data.primary_did, perms, contract_key); - } else { - ensure!( - origin_data.secondary_key.is_none(), - Error::::CallerNotAPrimaryKey - ); - Identity::::ensure_no_parent(origin_data.primary_did)?; - Identity::::unverified_create_child_identity(contract_key, origin_data.primary_did)?; - } + let caller = ensure_signed(origin.clone())?; + let (base_weight, contract) = + Self::base_weight_and_contract_address(&caller, &code, &data, &salt, perms.as_ref()); + Self::link_contract_to_did(&caller, contract, perms, deploy_as_child_identity)?; // Instantiate the contract. - Self::handle_error( - base_weight, - FrameContracts::::bare_instantiate( - origin_data.sender, + let storage_deposit_limit = storage_deposit_limit.map(Compact); + let mut result = match code { + Code::Existing(code_hash) => FrameContracts::::instantiate( + origin, + endowment, + gas_limit, + storage_deposit_limit, + code_hash, + data, + salt, + ), + Code::Upload(code) => FrameContracts::::instantiate_with_code( + origin, endowment, gas_limit, storage_deposit_limit, code, - inst_data, + data, salt, - false, ), - ) - } - - /// Computes the code hash of `code`. - fn code_hash(code: &Code>) -> Cow<'_, CodeHash> { - match &code { - Code::Existing(h) => Cow::Borrowed(h), - Code::Upload(c) => Cow::Owned(T::Hashing::hash(c)), - } - } - - /// Enriches `result` of executing a smart contract with actual weight, - /// accounting for the consumed gas. - fn handle_error( - base_weight: Weight, - result: ContractResult, Balance>, - ) -> DispatchResultWithPostInfo { - let post_info = Some(result.gas_consumed.saturating_add(base_weight)).into(); - match result.result { - Ok(_) => Ok(post_info), - Err(error) => Err(DispatchErrorWithPostInfo { post_info, error }), + }; + // Add `base_weight` in returned actual weight. + { + // Get `post_info` from either the Ok/Err variant. + let post_info = match &mut result { + Ok(post_info) => post_info, + Err(err) => &mut err.post_info, + }; + // add the base weight to the actual weight. + if let Some(actual_weight) = &mut post_info.actual_weight { + *actual_weight = actual_weight.saturating_add(base_weight); + } + // Note: `actual_weight=None` is the worse case weight with already include the base weight. } + // Return the result with the updated actual_weight. + result } fn base_upgrade_api( diff --git a/pallets/weights/src/polymesh_contracts.rs b/pallets/weights/src/polymesh_contracts.rs index 74bf00b43..73987f165 100644 --- a/pallets/weights/src/polymesh_contracts.rs +++ b/pallets/weights/src/polymesh_contracts.rs @@ -368,65 +368,31 @@ impl polymesh_contracts::WeightInfo for SubstrateWeight { // Minimum execution time: 2_093 nanoseconds. Weight::from_ref_time(2_909_155) } - // Storage: Identity KeyRecords (r:3 w:1) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts CodeStorage (r:1 w:0) - // Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: MaxEncodedLen) - // Storage: System Account (r:3 w:3) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Contracts Nonce (r:1 w:1) - // Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Identity IsDidFrozen (r:1 w:0) - // Proof Skipped: Identity IsDidFrozen (max_values: None, max_size: None, mode: Measured) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:2 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - // Storage: System EventTopics (r:2 w:2) - // Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - // Storage: Identity DidKeys (r:0 w:1) - // Proof Skipped: Identity DidKeys (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyPortfolioPermissions (r:0 w:1) - // Proof Skipped: Identity KeyPortfolioPermissions (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyExtrinsicPermissions (r:0 w:1) - // Proof Skipped: Identity KeyExtrinsicPermissions (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyAssetPermissions (r:0 w:1) - // Proof Skipped: Identity KeyAssetPermissions (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[0, 1048576]`. + /// The range of component `s` is `[0, 1048576]`. + fn base_weight_with_hash(i: u32, s: u32) -> Weight { + // Minimum execution time: 960_746 nanoseconds. + Weight::from_ref_time(40_570_806) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(867).saturating_mul(i.into())) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(955).saturating_mul(s.into())) + } + /// The range of component `c` is `[0, 61717]`. + /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. - fn instantiate_with_hash_perms(s: u32) -> Weight { - // Minimum execution time: 403_410 nanoseconds. - Weight::from_ref_time(426_230_660) - // Standard Error: 4 - .saturating_add(Weight::from_ref_time(2_726).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(17)) - .saturating_add(DbWeight::get().writes(13)) + fn base_weight_with_code(c: u32, i: u32, s: u32) -> Weight { + // Minimum execution time: 1_007_560 nanoseconds. + Weight::from_ref_time(17_914_552) + // Standard Error: 45 + .saturating_add(Weight::from_ref_time(1_330).saturating_mul(c.into())) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(864).saturating_mul(i.into())) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(951).saturating_mul(s.into())) } - // Storage: Identity KeyRecords (r:3 w:1) + // Storage: Identity KeyRecords (r:2 w:1) // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - // Storage: System Account (r:3 w:3) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Contracts Nonce (r:1 w:1) - // Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Identity IsDidFrozen (r:1 w:0) - // Proof Skipped: Identity IsDidFrozen (max_values: None, max_size: None, mode: Measured) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:2 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: System EventTopics (r:3 w:3) - // Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) // Storage: Identity DidKeys (r:0 w:1) // Proof Skipped: Identity DidKeys (max_values: None, max_size: None, mode: Measured) // Storage: Identity KeyPortfolioPermissions (r:0 w:1) @@ -435,33 +401,13 @@ impl polymesh_contracts::WeightInfo for SubstrateWeight { // Proof Skipped: Identity KeyExtrinsicPermissions (max_values: None, max_size: None, mode: Measured) // Storage: Identity KeyAssetPermissions (r:0 w:1) // Proof Skipped: Identity KeyAssetPermissions (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts CodeStorage (r:0 w:1) - // Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: MaxEncodedLen) - // Storage: Contracts PristineCode (r:0 w:1) - // Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: MaxEncodedLen) - /// The range of component `c` is `[0, 61717]`. - /// The range of component `s` is `[0, 1048576]`. - fn instantiate_with_code_perms(c: u32, s: u32) -> Weight { - // Minimum execution time: 3_335_726 nanoseconds. - Weight::from_ref_time(626_137_371) - // Standard Error: 302 - .saturating_add(Weight::from_ref_time(107_506).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_ref_time(2_679).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(17)) - .saturating_add(DbWeight::get().writes(16)) - } - // Storage: PolymeshContracts CallRuntimeWhitelist (r:0 w:2000) - // Proof Skipped: PolymeshContracts CallRuntimeWhitelist (max_values: None, max_size: None, mode: Measured) - /// The range of component `u` is `[0, 2000]`. - fn update_call_runtime_whitelist(u: u32) -> Weight { - // Minimum execution time: 3_826 nanoseconds. - Weight::from_ref_time(4_076_000) - // Standard Error: 2_097 - .saturating_add(Weight::from_ref_time(1_640_807).saturating_mul(u.into())) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + fn link_contract_as_secondary_key() -> Weight { + // Minimum execution time: 18_033 nanoseconds. + Weight::from_ref_time(18_404_000) + .saturating_add(DbWeight::get().reads(2)) + .saturating_add(DbWeight::get().writes(5)) } - // Storage: Identity KeyRecords (r:3 w:1) + // Storage: Identity KeyRecords (r:2 w:1) // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) // Storage: Identity ParentDid (r:1 w:1) // Proof Skipped: Identity ParentDid (max_values: None, max_size: None, mode: Measured) @@ -475,86 +421,25 @@ impl polymesh_contracts::WeightInfo for SubstrateWeight { // Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) // Storage: Identity DidRecords (r:1 w:1) // Proof Skipped: Identity DidRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - // Storage: System Account (r:3 w:3) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Contracts Nonce (r:1 w:1) - // Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:3 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: System EventTopics (r:3 w:3) - // Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) // Storage: Identity DidKeys (r:0 w:1) // Proof Skipped: Identity DidKeys (max_values: None, max_size: None, mode: Measured) // Storage: Identity ChildDid (r:0 w:1) // Proof Skipped: Identity ChildDid (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts CodeStorage (r:0 w:1) - // Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: MaxEncodedLen) - // Storage: Contracts PristineCode (r:0 w:1) - // Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: MaxEncodedLen) - /// The range of component `c` is `[0, 61717]`. - /// The range of component `s` is `[0, 1048576]`. - fn instantiate_with_code_as_primary_key(c: u32, s: u32) -> Weight { - // Minimum execution time: 3_367_714 nanoseconds. - Weight::from_ref_time(601_623_986) - // Standard Error: 368 - .saturating_add(Weight::from_ref_time(107_633).saturating_mul(c.into())) - // Standard Error: 21 - .saturating_add(Weight::from_ref_time(2_738).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(23)) - .saturating_add(DbWeight::get().writes(17)) + fn link_contract_as_primary_key() -> Weight { + // Minimum execution time: 32_310 nanoseconds. + Weight::from_ref_time(32_881_000) + .saturating_add(DbWeight::get().reads(8)) + .saturating_add(DbWeight::get().writes(6)) } - // Storage: Identity KeyRecords (r:3 w:1) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Identity ParentDid (r:1 w:1) - // Proof Skipped: Identity ParentDid (max_values: None, max_size: None, mode: Measured) - // Storage: ProtocolFee Coefficient (r:1 w:0) - // Proof Skipped: ProtocolFee Coefficient (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ProtocolFee BaseFees (r:1 w:0) - // Proof Skipped: ProtocolFee BaseFees (max_values: None, max_size: None, mode: Measured) - // Storage: Identity MultiPurposeNonce (r:1 w:1) - // Proof Skipped: Identity MultiPurposeNonce (max_values: Some(1), max_size: None, mode: Measured) - // Storage: System ParentHash (r:1 w:0) - // Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - // Storage: Identity DidRecords (r:1 w:1) - // Proof Skipped: Identity DidRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts CodeStorage (r:1 w:0) - // Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: MaxEncodedLen) - // Storage: System Account (r:3 w:3) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Contracts Nonce (r:1 w:1) - // Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:3 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) - // Storage: System EventTopics (r:2 w:2) - // Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - // Storage: Identity DidKeys (r:0 w:1) - // Proof Skipped: Identity DidKeys (max_values: None, max_size: None, mode: Measured) - // Storage: Identity ChildDid (r:0 w:1) - // Proof Skipped: Identity ChildDid (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[0, 1048576]`. - fn instantiate_with_hash_as_primary_key(s: u32) -> Weight { - // Minimum execution time: 426_324 nanoseconds. - Weight::from_ref_time(466_149_541) - // Standard Error: 4 - .saturating_add(Weight::from_ref_time(2_715).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(23)) - .saturating_add(DbWeight::get().writes(14)) + // Storage: PolymeshContracts CallRuntimeWhitelist (r:0 w:2000) + // Proof Skipped: PolymeshContracts CallRuntimeWhitelist (max_values: None, max_size: None, mode: Measured) + /// The range of component `u` is `[0, 2000]`. + fn update_call_runtime_whitelist(u: u32) -> Weight { + // Minimum execution time: 3_826 nanoseconds. + Weight::from_ref_time(4_076_000) + // Standard Error: 2_097 + .saturating_add(Weight::from_ref_time(1_640_807).saturating_mul(u.into())) + .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(u.into()))) } // Storage: PolymeshContracts ApiNextUpgrade (r:0 w:1) // Proof Skipped: PolymeshContracts ApiNextUpgrade (max_values: None, max_size: None, mode: Measured)