From 0cd7393dbddd7bd5c593cd5a92363de0197637f2 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Mon, 27 Jun 2022 12:58:02 +0300 Subject: [PATCH 01/25] Added sold invocation --- Cargo.lock | 793 +++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 + src/compile.rs | 135 +++++++++ src/main.rs | 8 +- 4 files changed, 905 insertions(+), 33 deletions(-) create mode 100644 src/compile.rs diff --git a/Cargo.lock b/Cargo.lock index c55f78fe..8416d184 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,6 +85,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "assert_cmd" version = "1.0.8" @@ -178,12 +184,46 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "clap 2.34.0", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -239,6 +279,7 @@ dependencies = [ "lazy_static", "memchr", "regex-automata", + "serde", ] [[package]] @@ -277,6 +318,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "cast" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" +dependencies = [ + "rustc_version", +] + [[package]] name = "cc" version = "1.0.73" @@ -286,6 +336,15 @@ dependencies = [ "jobserver", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -344,6 +403,17 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "clang-sys" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "2.34.0" @@ -353,12 +423,60 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", - "textwrap", + "strsim 0.8.0", + "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1fe12880bae935d142c8702d500c63a4e8634b6c3c57ad72bf978fc7b6249a" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "strsim 0.10.0", + "termcolor", + "textwrap 0.15.0", +] + +[[package]] +name = "clap_derive" +version = "3.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6db9e867166a43a53f7199b5e4d1f522a1e5bd626654be263c999ce59df39a" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87eba3c8c7f42ef17f6c659fc7416d0f4758cd3e58861ee63c5fa4a4dde649e4" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cmake" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +dependencies = [ + "cc", +] + [[package]] name = "console" version = "0.15.0" @@ -372,6 +490,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "core-foundation" version = "0.9.3" @@ -421,6 +545,87 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" +[[package]] +name = "criterion" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +dependencies = [ + "atty", + "cast", + "clap 2.34.0", + "criterion-plot", + "csv", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils", + "memoffset", + "once_cell", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", +] + [[package]] name = "crossterm" version = "0.23.2" @@ -482,6 +687,28 @@ dependencies = [ "subtle 2.4.1", ] +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -531,6 +758,17 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -581,6 +819,19 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "env_logger" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "extfmt" version = "0.1.1" @@ -816,6 +1067,12 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "h2" version = "0.2.7" @@ -836,6 +1093,12 @@ dependencies = [ "tracing-futures", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.9.1" @@ -851,6 +1114,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -955,6 +1224,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.13.10" @@ -1119,12 +1394,28 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if 1.0.0", + "winapi 0.3.9", +] + [[package]] name = "libsecp256k1" version = "0.6.0" @@ -1221,6 +1512,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.16" @@ -1237,6 +1537,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.5.3" @@ -1350,6 +1656,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1477,6 +1793,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -1543,6 +1865,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + [[package]] name = "owned-alloc" version = "0.2.0" @@ -1567,7 +1895,7 @@ checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", + "redox_syscall 0.2.13", "smallvec", "windows-sys", ] @@ -1591,6 +1919,12 @@ dependencies = [ "crypto-mac 0.11.1", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.1.0" @@ -1661,6 +1995,34 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +[[package]] +name = "plotters" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" + +[[package]] +name = "plotters-svg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +dependencies = [ + "plotters-backend", +] + [[package]] name = "pom" version = "1.1.0" @@ -1713,6 +2075,30 @@ dependencies = [ "termtree", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.40" @@ -1821,6 +2207,36 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rayon" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + [[package]] name = "redox_syscall" version = "0.2.13" @@ -1830,6 +2246,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom 0.1.16", + "redox_syscall 0.1.57", + "rust-argon2", +] + [[package]] name = "regex" version = "1.5.6" @@ -1897,6 +2324,18 @@ dependencies = [ "winreg", ] +[[package]] +name = "rust-argon2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +dependencies = [ + "base64 0.13.0", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1909,6 +2348,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.10" @@ -1924,6 +2372,15 @@ dependencies = [ "cipher 0.3.0", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.20" @@ -1984,6 +2441,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" + [[package]] name = "serde" version = "1.0.137" @@ -1993,6 +2456,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.137" @@ -2077,6 +2550,12 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + [[package]] name = "signal-hook" version = "0.3.14" @@ -2113,6 +2592,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" +[[package]] +name = "simplelog" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e95345f185d5adeb8ec93459d2dc99654e294cc6ccf5b75414d8ea262de9a13" +dependencies = [ + "chrono", + "log", + "term", +] + [[package]] name = "simplelog" version = "0.8.0" @@ -2156,6 +2646,26 @@ dependencies = [ "rand 0.7.3", ] +[[package]] +name = "sold" +version = "0.1.0" +dependencies = [ + "ansi_term", + "atty", + "bindgen", + "clap 3.2.6", + "cmake", + "failure", + "lazy_static", + "once_cell", + "serde", + "serde_json", + "ton_abi 2.2.5", + "ton_block 1.7.48", + "ton_types 1.11.1", + "tvm_linker", +] + [[package]] name = "string-error" version = "0.1.0" @@ -2168,6 +2678,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subtle" version = "1.0.0" @@ -2212,11 +2728,22 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "libc", - "redox_syscall", + "redox_syscall 0.2.13", "remove_dir_all", "winapi 0.3.9", ] +[[package]] +name = "term" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +dependencies = [ + "byteorder", + "dirs", + "winapi 0.3.9", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -2251,6 +2778,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + [[package]] name = "time" version = "0.1.44" @@ -2278,6 +2811,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2397,6 +2940,28 @@ dependencies = [ "tokio 0.2.25", ] +[[package]] +name = "ton_abi" +version = "2.2.5" +source = "git+https://github.com/tonlabs/ton-labs-abi.git?tag=2.2.5#58a385a19e99b7d2c160ffd98e5bee4c2c8e4497" +dependencies = [ + "base64 0.10.1", + "byteorder", + "chrono", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.3.2", + "num-bigint", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "sha2 0.8.2", + "ton_block 1.7.48", + "ton_types 1.11.1", +] + [[package]] name = "ton_abi" version = "2.2.8" @@ -2415,8 +2980,8 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_block", - "ton_types", + "ton_block 1.7.51", + "ton_types 1.11.2", ] [[package]] @@ -2434,9 +2999,47 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "ton_block", + "ton_block 1.7.51", "ton_tl_codegen", - "ton_types", + "ton_types 1.11.2", +] + +[[package]] +name = "ton_block" +version = "1.7.48" +source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.7.48#1c3648dedb9e98f1e30f84fa9beadabfe252582b" +dependencies = [ + "base64 0.13.0", + "crc", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "rand 0.7.3", + "sha2 0.8.2", + "ton_types 1.11.1", +] + +[[package]] +name = "ton_block" +version = "1.7.49" +source = "git+https://github.com/tonlabs/ton-labs-block?tag=1.7.49#71f9aeb2a0c25cbbe191776e1c84acb3eefadca5" +dependencies = [ + "base64 0.13.0", + "crc", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "rand 0.7.3", + "sha2 0.8.2", + "ton_types 1.11.1", ] [[package]] @@ -2455,7 +3058,7 @@ dependencies = [ "num-traits", "rand 0.7.3", "sha2 0.8.2", - "ton_types", + "ton_types 1.11.2", ] [[package]] @@ -2472,8 +3075,8 @@ dependencies = [ "serde_derive", "serde_json", "ton_api", - "ton_block", - "ton_types", + "ton_block 1.7.51", + "ton_types 1.11.2", ] [[package]] @@ -2522,13 +3125,13 @@ dependencies = [ "tiny-bip39", "tokio 0.2.25", "tokio-tungstenite", - "ton_abi", - "ton_block", + "ton_abi 2.2.8", + "ton_block 1.7.51", "ton_block_json", "ton_executor", "ton_sdk", - "ton_types", - "ton_vm", + "ton_types 1.11.2", + "ton_vm 1.8.38", "zeroize", "zstd", ] @@ -2541,9 +3144,39 @@ dependencies = [ "failure", "lazy_static", "log", - "ton_block", - "ton_types", - "ton_vm", + "ton_block 1.7.51", + "ton_types 1.11.2", + "ton_vm 1.8.38", +] + +[[package]] +name = "ton_labs_assembler" +version = "1.2.38" +source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.38#4274d926cc77e07488cf371b3ac24c344c70da8d" +dependencies = [ + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "serde", + "serde_json", + "ton_types 1.11.1", +] + +[[package]] +name = "ton_labs_assembler" +version = "1.2.39" +source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.39#a0a41dc8859784a2683f097f1d7adf7802d953cd" +dependencies = [ + "failure", + "hex 0.4.3", + "log", + "num", + "num-traits", + "serde", + "serde_json", + "ton_types 1.11.1", ] [[package]] @@ -2558,7 +3191,7 @@ dependencies = [ "num-traits", "serde", "serde_json", - "ton_types", + "ton_types 1.11.2", ] [[package]] @@ -2582,10 +3215,10 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_abi", - "ton_block", - "ton_types", - "ton_vm", + "ton_abi 2.2.8", + "ton_block 1.7.51", + "ton_types 1.11.2", + "ton_vm 1.8.38", ] [[package]] @@ -2603,6 +3236,26 @@ dependencies = [ "syn", ] +[[package]] +name = "ton_types" +version = "1.11.1" +source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.1#27836abc9febac9e593cf7b1c5696e53454391db" +dependencies = [ + "base64 0.13.0", + "crc", + "failure", + "hex 0.4.3", + "lazy_static", + "lockfree", + "log", + "num", + "num-derive", + "num-traits", + "rand 0.8.5", + "sha2 0.9.9", + "smallvec", +] + [[package]] name = "ton_types" version = "1.11.2" @@ -2623,6 +3276,27 @@ dependencies = [ "smallvec", ] +[[package]] +name = "ton_vm" +version = "1.8.35" +source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.35#b3578f3d6df1ce7c1e5798875cad7406fa825ac5" +dependencies = [ + "criterion", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.4.3", + "lazy_static", + "log", + "num", + "num-traits", + "rand 0.7.3", + "sha2 0.9.9", + "ton_block 1.7.49", + "ton_labs_assembler 1.2.39", + "ton_types 1.11.1", +] + [[package]] name = "ton_vm" version = "1.8.38" @@ -2638,19 +3312,23 @@ dependencies = [ "num-traits", "rand 0.7.3", "sha2 0.9.9", - "ton_block", - "ton_types", + "ton_block 1.7.51", + "ton_types 1.11.2", ] [[package]] name = "tonos-cli" +<<<<<<< master version = "0.26.44" +======= +version = "0.26.43" +>>>>>>> Added sold invocation dependencies = [ "assert_cmd", "async-trait", "base64 0.10.1", "chrono", - "clap", + "clap 2.34.0", "crc16", "ed25519-dalek", "failure", @@ -2669,19 +3347,20 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "simplelog", + "simplelog 0.8.0", + "sold", "string-error", "tokio 0.2.25", "tokio-retry", - "ton_abi", - "ton_block", + "ton_abi 2.2.8", + "ton_block 1.7.51", "ton_block_json", "ton_client", "ton_executor", - "ton_labs_assembler", + "ton_labs_assembler 1.2.42", "ton_sdk", - "ton_types", - "ton_vm", + "ton_types 1.11.2", + "ton_vm 1.8.38", ] [[package]] @@ -2747,6 +3426,34 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tvm_linker" +version = "0.15.39" +dependencies = [ + "base64 0.10.1", + "clap 2.34.0", + "crc16", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.3.2", + "lazy_static", + "log", + "num", + "num-traits", + "rand 0.7.3", + "regex", + "serde", + "serde_json", + "sha2 0.8.2", + "simplelog 0.5.3", + "ton_abi 2.2.5", + "ton_block 1.7.48", + "ton_labs_assembler 1.2.38", + "ton_types 1.11.1", + "ton_vm 1.8.35", +] + [[package]] name = "typenum" version = "1.15.0" @@ -2840,6 +3547,17 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi 0.3.9", + "winapi-util", +] + [[package]] name = "want" version = "0.3.0" @@ -2946,6 +3664,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +dependencies = [ + "either", + "lazy_static", + "libc", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index 822b888f..49dd3e7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,8 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.34.3' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.2' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.38' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.18' } +#sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git' } +sold = { path = "../sol2tvm/pub/sold" } [dev-dependencies] assert_cmd = '1.0.3' diff --git a/src/compile.rs b/src/compile.rs new file mode 100644 index 00000000..1f170327 --- /dev/null +++ b/src/compile.rs @@ -0,0 +1,135 @@ +/* + * Copyright 2018-2021 TON DEV SOLUTIONS LTD. + * + * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use + * this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific TON DEV software governing permissions and + * limitations under the License. + */ + +use std::path::Path; +use clap::{ArgMatches, SubCommand, Arg, App}; +use crate::config::Config; +use sold_lib::{Args, build, solidity_version}; +use crate::generate_address; + +pub fn create_compile_command<'a, 'b>() -> App<'a, 'b> { + SubCommand::with_name("compile") + .about("Compile commands.") + .subcommand(SubCommand::with_name("sol") + .about("Compile TVM Solidity code to the ready to deploy tvc.") + .arg(Arg::with_name("INPUT") + .required_unless("VERSION") + .help("Path to the Solidity source file.")) + .arg(Arg::with_name("GENKEY") + .takes_value(true) + .long("--genkey") + .conflicts_with("SETKEY") + .help("Path to the file, where a new generated keypair for the contract will be saved.")) + .arg(Arg::with_name("SETKEY") + .takes_value(true) + .long("--setkey") + .conflicts_with("GENKEY") + .help("Seed phrase or path to the file with keypair.")) + .arg(Arg::with_name("VERSION") + .long("--version") + .short("-v") + .help("Print version of the Solidity compiler.")) + .arg(Arg::with_name("WC") + .takes_value(true) + .long("--wc") + .help("Workchain id of the smart contract (default value is taken from the config).")) + .arg(Arg::with_name("CONTRACT") + .takes_value(true) + .long("--contract") + .help("Contract to build if sources define more than one contract.")) + .arg(Arg::with_name("OUTPUT_DIR") + .takes_value(true) + .long("--output_dir") + .short("-o") + .help("Output directory (by default, current directory is used).")) + .arg(Arg::with_name("OUTPUT_PREFIX") + .takes_value(true) + .long("--output_prefix") + .short("-p") + .help("Output prefix (by default, input file stem is used as prefix).")) + .arg(Arg::with_name("INCLUDE_PATH") + .takes_value(true) + .long("--include_path") + .short("-i") + .help("Include additional path to search for imports.")) + .arg(Arg::with_name("LIB") + .takes_value(true) + .long("--lib") + .short("-l") + .help("Library to use instead of default.")) + .arg(Arg::with_name("INIT") + .takes_value(true) + .long("--init") + .help("Initialize static fields.")) + .arg(Arg::with_name("REFRESH_REMOTE") + .long("--refresh_remote") + .help("Force download and rewrite remote import files.")) + ) +} + +pub async fn compile_command(matches: &ArgMatches<'_>, config: &Config) -> Result<(), String> { + if let Some(matches) = matches.subcommand_matches("sol") { + return compile_solidity(matches, config).await; + } + Err("unknown command".to_owned()) +} + +async fn compile_solidity(matches: &ArgMatches<'_>, config: &Config) -> Result<(), String> { + if matches.is_present("VERSION") { + println!("Solidity compiler version: {}", solidity_version()); + return Ok(()); + } + let input= matches.value_of("INPUT").unwrap().to_owned(); + let include_path = matches.value_of("INCLUDE_PATH") + .map(|input| { + input + .trim_end_matches('[') + .trim_start_matches('[') + .split(',') + .map(|s| s.to_string()) + .collect::>() + }) + .unwrap_or(vec![]); + + let args = Args { + input: input.clone(), + contract: matches.value_of("CONTRACT").map(|s| s.to_owned()), + output_dir: matches.value_of("OUTPUT_DIR").map(|s| s.to_owned()), + output_prefix: matches.value_of("OUTPUT_PREFIX").map(|s| s.to_owned()), + include_path, + lib: matches.value_of("LIB").map(|s| s.to_owned()), + ctor_params: None, + gen_key: None, + set_key: None, + init: matches.value_of("INIT").map(|s| s.to_owned()), + function_ids: false, + ast_json: false, + ast_compact_json: false, + abi_json: false, + tvm_refresh_remote: matches.is_present("REFRESH_REMOTE"), + }; + build(args, config.is_json).map_err(|e| format!("Failed to compile the contract: {}", e))?; + let input_canonical = Path::new(&input).canonicalize() + .map_err(|e| format!("Failed to format input path: {}", e))?; + let stem = input_canonical.file_stem().ok_or("Failed to format input path".to_owned())? + .to_str().unwrap().to_owned(); + let tvc_path = format!("{}.tvc", stem); + let abi_path = format!("{}.abi.json", stem); + if !config.is_json { + println!("Path to the TVC file: {}", tvc_path); + } + let keys = matches.value_of("GENKEY").or(matches.value_of("SETKEY")); + let new_keys = matches.is_present("GENKEY"); + let wc = matches.value_of("WC"); + generate_address(config, &tvc_path, &abi_path, wc, keys, new_keys, None, true).await +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5b079b75..f8da2ab4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ mod replay; mod debug; mod run; mod message; +mod compile; use account::{get_account, calc_storage, wait_for_change}; use call::{call_contract, call_contract_with_msg, parse_params}; @@ -61,6 +62,7 @@ use voting::{create_proposal, decode_proposal, vote}; use replay::{fetch_block_command, fetch_command, replay_command}; use ton_client::abi::{ParamsOfEncodeMessageBody, CallSet}; use crate::account::dump_accounts; +use crate::compile::{compile_command, create_compile_command}; use crate::config::FullConfig; use crate::getconfig::gen_update_config_message; @@ -913,6 +915,7 @@ async fn main_internal() -> Result <(), String> { .subcommand(create_decode_command()) .subcommand(create_debot_command()) .subcommand(create_debug_command()) + .subcommand(create_compile_command()) .subcommand(getconfig_cmd) .subcommand(bcconfig_cmd) .subcommand(nodeid_cmd) @@ -1109,6 +1112,9 @@ async fn command_parser(matches: &ArgMatches<'_>, is_json: bool) -> Result <(), if let Some(m) = matches.subcommand_matches("replay") { return replay_command(m, &config).await; } + if let Some(m) = matches.subcommand_matches("compile") { + return compile_command(m, &config).await; + } if matches.subcommand_matches("version").is_some() { if config.is_json { println!("{{"); @@ -1537,7 +1543,7 @@ async fn genaddr_command(matches: &ArgMatches<'_>, config: &Config) -> Result<() let tvc = matches.value_of("TVC"); let wc = matches.value_of("WC"); let keys = matches.value_of("GENKEY").or(matches.value_of("SETKEY")); - let new_keys = matches.is_present("GENKEY") ; + let new_keys = matches.is_present("GENKEY"); let init_data = matches.value_of("DATA"); let update_tvc = matches.is_present("SAVE"); let abi = match abi_from_matches_or_config(matches, config) { From c7e5455fb4be95b9d6c1da05b6d1ccf05d854e93 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Thu, 30 Jun 2022 12:14:11 +0300 Subject: [PATCH 02/25] 1 2 3 4 5 6 Revert "6" This reverts commit 9283b9cbf745144119ce67863f2fda9b3ab478f0. Revert "5" This reverts commit 94339a49c64abb683cb535af99bd5c8b1735383e. Revert "4" This reverts commit 0617ff931bedb353b92f3c505638201db1dfb9d9. 4 --- Cargo.lock | 441 ++++++----------------------------------------------- Cargo.toml | 5 +- 2 files changed, 51 insertions(+), 395 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8416d184..740173e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,6 @@ dependencies = [ "lazy_static", "memchr", "regex-automata", - "serde", ] [[package]] @@ -318,15 +317,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" -[[package]] -name = "cast" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" -dependencies = [ - "rustc_version", -] - [[package]] name = "cc" version = "1.0.73" @@ -431,9 +421,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.6" +version = "3.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f1fe12880bae935d142c8702d500c63a4e8634b6c3c57ad72bf978fc7b6249a" +checksum = "5b7b16274bb247b45177db843202209b12191b631a14a9d06e41b3777d6ecf14" dependencies = [ "atty", "bitflags", @@ -448,9 +438,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.2.6" +version = "3.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6db9e867166a43a53f7199b5e4d1f522a1e5bd626654be263c999ce59df39a" +checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" dependencies = [ "heck", "proc-macro-error", @@ -461,9 +451,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87eba3c8c7f42ef17f6c659fc7416d0f4758cd3e58861ee63c5fa4a4dde649e4" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] @@ -545,77 +535,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" -[[package]] -name = "criterion" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" -dependencies = [ - "atty", - "cast", - "clap 2.34.0", - "criterion-plot", - "csv", - "itertools", - "lazy_static", - "num-traits", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_cbor", - "serde_derive", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" -dependencies = [ - "cast", - "itertools", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" -dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset", - "once_cell", - "scopeguard", -] - [[package]] name = "crossbeam-utils" version = "0.8.10" @@ -687,28 +606,6 @@ dependencies = [ "subtle 2.4.1", ] -[[package]] -name = "csv" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" -dependencies = [ - "bstr", - "csv-core", - "itoa 0.4.8", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -dependencies = [ - "memchr", -] - [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -1093,12 +990,6 @@ dependencies = [ "tracing-futures", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "hashbrown" version = "0.9.1" @@ -1512,15 +1403,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "mime" version = "0.3.16" @@ -1793,12 +1675,6 @@ dependencies = [ "parking_lot_core", ] -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "opaque-debug" version = "0.2.3" @@ -1995,34 +1871,6 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" -[[package]] -name = "plotters" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" - -[[package]] -name = "plotters-svg" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" -dependencies = [ - "plotters-backend", -] - [[package]] name = "pom" version = "1.1.0" @@ -2207,30 +2055,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" version = "0.1.57" @@ -2348,15 +2172,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "ryu" version = "1.0.10" @@ -2372,15 +2187,6 @@ dependencies = [ "cipher 0.3.0", ] -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "schannel" version = "0.1.20" @@ -2441,12 +2247,6 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" - [[package]] name = "serde" version = "1.0.137" @@ -2456,16 +2256,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.137" @@ -2649,20 +2439,21 @@ dependencies = [ [[package]] name = "sold" version = "0.1.0" +source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?branch=test_sold_for_tonos#c20c7b587f513cebae065043ef34a59ec81f4bc6" dependencies = [ "ansi_term", "atty", "bindgen", - "clap 3.2.6", + "clap 3.2.7", "cmake", "failure", "lazy_static", "once_cell", "serde", "serde_json", - "ton_abi 2.2.5", - "ton_block 1.7.48", - "ton_types 1.11.1", + "ton_abi", + "ton_block", + "ton_types", "tvm_linker", ] @@ -2811,16 +2602,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -2940,28 +2721,6 @@ dependencies = [ "tokio 0.2.25", ] -[[package]] -name = "ton_abi" -version = "2.2.5" -source = "git+https://github.com/tonlabs/ton-labs-abi.git?tag=2.2.5#58a385a19e99b7d2c160ffd98e5bee4c2c8e4497" -dependencies = [ - "base64 0.10.1", - "byteorder", - "chrono", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.3.2", - "num-bigint", - "num-traits", - "serde", - "serde_derive", - "serde_json", - "sha2 0.8.2", - "ton_block 1.7.48", - "ton_types 1.11.1", -] - [[package]] name = "ton_abi" version = "2.2.8" @@ -2980,14 +2739,14 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_block 1.7.51", - "ton_types 1.11.2", + "ton_block", + "ton_types", ] [[package]] name = "ton_api" version = "0.2.128" -source = "git+https://github.com/tonlabs/ton-labs-tl?tag=0.2.128#fa91f87c1372048320e91d49ebba7dde52605a87" +source = "git+https://github.com/tonlabs/ton-labs-tl?tag=0.2.128#f16ff19f5dd4ccf73f65d830ab6dc782ea2127dd" dependencies = [ "byteorder", "extfmt", @@ -2999,47 +2758,9 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "ton_block 1.7.51", + "ton_block", "ton_tl_codegen", - "ton_types 1.11.2", -] - -[[package]] -name = "ton_block" -version = "1.7.48" -source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.7.48#1c3648dedb9e98f1e30f84fa9beadabfe252582b" -dependencies = [ - "base64 0.13.0", - "crc", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.4.3", - "log", - "num", - "num-traits", - "rand 0.7.3", - "sha2 0.8.2", - "ton_types 1.11.1", -] - -[[package]] -name = "ton_block" -version = "1.7.49" -source = "git+https://github.com/tonlabs/ton-labs-block?tag=1.7.49#71f9aeb2a0c25cbbe191776e1c84acb3eefadca5" -dependencies = [ - "base64 0.13.0", - "crc", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.4.3", - "log", - "num", - "num-traits", - "rand 0.7.3", - "sha2 0.8.2", - "ton_types 1.11.1", + "ton_types", ] [[package]] @@ -3058,7 +2779,7 @@ dependencies = [ "num-traits", "rand 0.7.3", "sha2 0.8.2", - "ton_types 1.11.2", + "ton_types", ] [[package]] @@ -3075,8 +2796,8 @@ dependencies = [ "serde_derive", "serde_json", "ton_api", - "ton_block 1.7.51", - "ton_types 1.11.2", + "ton_block", + "ton_types", ] [[package]] @@ -3125,12 +2846,12 @@ dependencies = [ "tiny-bip39", "tokio 0.2.25", "tokio-tungstenite", - "ton_abi 2.2.8", - "ton_block 1.7.51", + "ton_abi", + "ton_block", "ton_block_json", "ton_executor", "ton_sdk", - "ton_types 1.11.2", + "ton_types", "ton_vm 1.8.38", "zeroize", "zstd", @@ -3144,41 +2865,11 @@ dependencies = [ "failure", "lazy_static", "log", - "ton_block 1.7.51", - "ton_types 1.11.2", + "ton_block", + "ton_types", "ton_vm 1.8.38", ] -[[package]] -name = "ton_labs_assembler" -version = "1.2.38" -source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.38#4274d926cc77e07488cf371b3ac24c344c70da8d" -dependencies = [ - "failure", - "hex 0.4.3", - "log", - "num", - "num-traits", - "serde", - "serde_json", - "ton_types 1.11.1", -] - -[[package]] -name = "ton_labs_assembler" -version = "1.2.39" -source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.39#a0a41dc8859784a2683f097f1d7adf7802d953cd" -dependencies = [ - "failure", - "hex 0.4.3", - "log", - "num", - "num-traits", - "serde", - "serde_json", - "ton_types 1.11.1", -] - [[package]] name = "ton_labs_assembler" version = "1.2.42" @@ -3191,7 +2882,7 @@ dependencies = [ "num-traits", "serde", "serde_json", - "ton_types 1.11.2", + "ton_types", ] [[package]] @@ -3215,16 +2906,16 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_abi 2.2.8", - "ton_block 1.7.51", - "ton_types 1.11.2", + "ton_abi", + "ton_block", + "ton_types", "ton_vm 1.8.38", ] [[package]] name = "ton_tl_codegen" version = "0.0.2" -source = "git+https://github.com/tonlabs/ton-labs-tl?tag=0.2.128#fa91f87c1372048320e91d49ebba7dde52605a87" +source = "git+https://github.com/tonlabs/ton-labs-tl?tag=0.2.128#f16ff19f5dd4ccf73f65d830ab6dc782ea2127dd" dependencies = [ "crc", "failure", @@ -3236,26 +2927,6 @@ dependencies = [ "syn", ] -[[package]] -name = "ton_types" -version = "1.11.1" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.1#27836abc9febac9e593cf7b1c5696e53454391db" -dependencies = [ - "base64 0.13.0", - "crc", - "failure", - "hex 0.4.3", - "lazy_static", - "lockfree", - "log", - "num", - "num-derive", - "num-traits", - "rand 0.8.5", - "sha2 0.9.9", - "smallvec", -] - [[package]] name = "ton_types" version = "1.11.2" @@ -3278,10 +2949,9 @@ dependencies = [ [[package]] name = "ton_vm" -version = "1.8.35" -source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.35#b3578f3d6df1ce7c1e5798875cad7406fa825ac5" +version = "1.8.38" +source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.38#802aec2047e07c518136b10d091a13784ad6d696" dependencies = [ - "criterion", "ed25519", "ed25519-dalek", "failure", @@ -3292,15 +2962,14 @@ dependencies = [ "num-traits", "rand 0.7.3", "sha2 0.9.9", - "ton_block 1.7.49", - "ton_labs_assembler 1.2.39", - "ton_types 1.11.1", + "ton_block", + "ton_types", ] [[package]] name = "ton_vm" -version = "1.8.38" -source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.38#802aec2047e07c518136b10d091a13784ad6d696" +version = "1.8.39" +source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.39#b75d857c8d6c4f94be44abb3d3ae97cf7c027059" dependencies = [ "ed25519", "ed25519-dalek", @@ -3312,17 +2981,13 @@ dependencies = [ "num-traits", "rand 0.7.3", "sha2 0.9.9", - "ton_block 1.7.51", - "ton_types 1.11.2", + "ton_block", + "ton_types", ] [[package]] name = "tonos-cli" -<<<<<<< master version = "0.26.44" -======= -version = "0.26.43" ->>>>>>> Added sold invocation dependencies = [ "assert_cmd", "async-trait", @@ -3352,14 +3017,14 @@ dependencies = [ "string-error", "tokio 0.2.25", "tokio-retry", - "ton_abi 2.2.8", - "ton_block 1.7.51", + "ton_abi", + "ton_block", "ton_block_json", "ton_client", "ton_executor", - "ton_labs_assembler 1.2.42", + "ton_labs_assembler", "ton_sdk", - "ton_types 1.11.2", + "ton_types", "ton_vm 1.8.38", ] @@ -3428,7 +3093,8 @@ dependencies = [ [[package]] name = "tvm_linker" -version = "0.15.39" +version = "0.15.44" +source = "git+https://github.com/tonlabs/TVM-linker.git?branch=SilkovAlexander/sold_to_tonos#4894d2a4f30693b4929914b56661a54d53a303c8" dependencies = [ "base64 0.10.1", "clap 2.34.0", @@ -3447,11 +3113,11 @@ dependencies = [ "serde_json", "sha2 0.8.2", "simplelog 0.5.3", - "ton_abi 2.2.5", - "ton_block 1.7.48", - "ton_labs_assembler 1.2.38", - "ton_types 1.11.1", - "ton_vm 1.8.35", + "ton_abi", + "ton_block", + "ton_labs_assembler", + "ton_types", + "ton_vm 1.8.39", ] [[package]] @@ -3547,17 +3213,6 @@ dependencies = [ "libc", ] -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi 0.3.9", - "winapi-util", -] - [[package]] name = "want" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index 49dd3e7d..0703aa94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,8 +52,9 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.34.3' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.2' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.38' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.18' } -#sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git' } -sold = { path = "../sol2tvm/pub/sold" } +sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', branch = 'test_sold_for_tonos' } +#sold = { path = "../sol2tvm/pub/sold" } +#sold = { path = "../TON-Solidity-Compiler/sold" } [dev-dependencies] assert_cmd = '1.0.3' From d5a4acb2e964e60b653fd873ce2be7dbeadace55 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Thu, 30 Jun 2022 13:05:59 +0300 Subject: [PATCH 03/25] Fixed for the latest sold --- Cargo.lock | 55 ++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 4 +--- src/compile.rs | 8 -------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 740173e0..866f3e0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,9 +697,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "encode_unicode" @@ -2269,9 +2269,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" dependencies = [ "indexmap", "itoa 1.0.2", @@ -2412,9 +2412,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "socket2" @@ -2439,7 +2439,6 @@ dependencies = [ [[package]] name = "sold" version = "0.1.0" -source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?branch=test_sold_for_tonos#c20c7b587f513cebae065043ef34a59ec81f4bc6" dependencies = [ "ansi_term", "atty", @@ -2451,7 +2450,7 @@ dependencies = [ "once_cell", "serde", "serde_json", - "ton_abi", + "ton_abi 2.2.9", "ton_block", "ton_types", "tvm_linker", @@ -2743,6 +2742,28 @@ dependencies = [ "ton_types", ] +[[package]] +name = "ton_abi" +version = "2.2.9" +source = "git+https://github.com/tonlabs/ton-labs-abi.git?tag=2.2.9#c9d7823e74a1ac51359f48bd34ec74b566e3e972" +dependencies = [ + "base64 0.10.1", + "byteorder", + "chrono", + "ed25519", + "ed25519-dalek", + "failure", + "hex 0.3.2", + "num-bigint", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "sha2 0.8.2", + "ton_block", + "ton_types", +] + [[package]] name = "ton_api" version = "0.2.128" @@ -2846,7 +2867,7 @@ dependencies = [ "tiny-bip39", "tokio 0.2.25", "tokio-tungstenite", - "ton_abi", + "ton_abi 2.2.8", "ton_block", "ton_block_json", "ton_executor", @@ -2906,7 +2927,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_abi", + "ton_abi 2.2.8", "ton_block", "ton_types", "ton_vm 1.8.38", @@ -2930,7 +2951,7 @@ dependencies = [ [[package]] name = "ton_types" version = "1.11.2" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.2#1e8fab540649d4b0fe3713be64fa01ca73d2b9fe" +source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.2#0fb6b9cfacc84a3974dcb0aa674335fcf74de7ee" dependencies = [ "base64 0.13.0", "crc", @@ -3017,7 +3038,7 @@ dependencies = [ "string-error", "tokio 0.2.25", "tokio-retry", - "ton_abi", + "ton_abi 2.2.8", "ton_block", "ton_block_json", "ton_client", @@ -3093,8 +3114,8 @@ dependencies = [ [[package]] name = "tvm_linker" -version = "0.15.44" -source = "git+https://github.com/tonlabs/TVM-linker.git?branch=SilkovAlexander/sold_to_tonos#4894d2a4f30693b4929914b56661a54d53a303c8" +version = "0.15.45" +source = "git+https://github.com/tonlabs/TVM-linker.git?branch=SilkovAlexander/sold_to_tonos#ffe82f8e9dd63cefeba53c36d7e19d0a06ec5c35" dependencies = [ "base64 0.10.1", "clap 2.34.0", @@ -3113,7 +3134,7 @@ dependencies = [ "serde_json", "sha2 0.8.2", "simplelog 0.5.3", - "ton_abi", + "ton_abi 2.2.9", "ton_block", "ton_labs_assembler", "ton_types", @@ -3437,9 +3458,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.5" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +checksum = "20b578acffd8516a6c3f2a1bdefc1ec37e547bb4e0fb8b6b01a4cafc886b4442" dependencies = [ "zeroize_derive", ] diff --git a/Cargo.toml b/Cargo.toml index 0703aa94..fe6380db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,9 +52,7 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.34.3' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.2' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.38' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.18' } -sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', branch = 'test_sold_for_tonos' } -#sold = { path = "../sol2tvm/pub/sold" } -#sold = { path = "../TON-Solidity-Compiler/sold" } +sold = { path = "../sol2tvm/pub/sold" } [dev-dependencies] assert_cmd = '1.0.3' diff --git a/src/compile.rs b/src/compile.rs index 1f170327..f5515c6b 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -67,10 +67,6 @@ pub fn create_compile_command<'a, 'b>() -> App<'a, 'b> { .long("--lib") .short("-l") .help("Library to use instead of default.")) - .arg(Arg::with_name("INIT") - .takes_value(true) - .long("--init") - .help("Initialize static fields.")) .arg(Arg::with_name("REFRESH_REMOTE") .long("--refresh_remote") .help("Force download and rewrite remote import files.")) @@ -108,10 +104,6 @@ async fn compile_solidity(matches: &ArgMatches<'_>, config: &Config) -> Result<( output_prefix: matches.value_of("OUTPUT_PREFIX").map(|s| s.to_owned()), include_path, lib: matches.value_of("LIB").map(|s| s.to_owned()), - ctor_params: None, - gen_key: None, - set_key: None, - init: matches.value_of("INIT").map(|s| s.to_owned()), function_ids: false, ast_json: false, ast_compact_json: false, From f539d1a3222d9705e9386809d487d2b72de25b28 Mon Sep 17 00:00:00 2001 From: Tonjen Date: Thu, 30 Jun 2022 10:58:31 +0000 Subject: [PATCH 04/25] Auto update patch version --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 737412dd..5a7757b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.26.48' +version = '0.26.49' [dependencies] async-trait = '0.1.42' @@ -52,7 +52,7 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.35.0' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.2' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.38' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.18' } -sold = { path = "../sol2tvm/pub/sold" } +sold = { path = '../sol2tvm/pub/sold' } [dev-dependencies] assert_cmd = '1.0.3' From ec8c416bb74f11e581ce100b2046eca36345a18d Mon Sep 17 00:00:00 2001 From: Tonjen Date: Thu, 30 Jun 2022 10:58:37 +0000 Subject: [PATCH 05/25] Update CHANGELOG.md --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0df02547..1b455d1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to this project will be documented in this file. +## Version: 0.26.49 + +### New + - 2 + - 3 + - 4 + - 5 + - 6 + - Revert "6" + - This reverts commit 9283b9cbf745144119ce67863f2fda9b3ab478f0. + - Revert "5" + - This reverts commit 94339a49c64abb683cb535af99bd5c8b1735383e. + - Revert "4" + - This reverts commit 0617ff931bedb353b92f3c505638201db1dfb9d9. + - 4 + + ## Version: 0.26.45 ### New From 0e83b7123af6cc26881da4799ff43b30de914850 Mon Sep 17 00:00:00 2001 From: Tonjen Date: Tue, 5 Jul 2022 08:58:30 +0000 Subject: [PATCH 06/25] Auto update patch version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5a7757b5..4aba0013 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.26.49' +version = '0.26.50' [dependencies] async-trait = '0.1.42' From 64845bb5e294b1e1368497434a867e7f37115f2b Mon Sep 17 00:00:00 2001 From: Tonjen Date: Tue, 5 Jul 2022 14:58:39 +0000 Subject: [PATCH 07/25] Auto update patch version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4aba0013..68181045 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.26.50' +version = '0.26.51' [dependencies] async-trait = '0.1.42' From dca2571c8322350c62a109cd7bc5d5a06413e0bc Mon Sep 17 00:00:00 2001 From: Tonjen Date: Wed, 6 Jul 2022 06:53:30 +0000 Subject: [PATCH 08/25] Auto update patch version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 68181045..b24b472b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.26.51' +version = '0.26.52' [dependencies] async-trait = '0.1.42' From 333dfdc0efeaa07732fb3a8c8a1abbe939b2e0c0 Mon Sep 17 00:00:00 2001 From: Tonjen Date: Wed, 6 Jul 2022 09:08:29 +0000 Subject: [PATCH 09/25] Auto update patch version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b24b472b..d6646c0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.26.52' +version = '0.26.53' [dependencies] async-trait = '0.1.42' From 6f44aa5f856cbcd664f4e6e65a18173a6fa70fe2 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Thu, 20 Oct 2022 15:04:09 +0300 Subject: [PATCH 10/25] Added tests --- Cargo.lock | 294 +++++++++++++++++--------------- Cargo.toml | 2 +- src/compile.rs | 108 ++++++++---- tests/samples/1_Accumulator.sol | 29 ++++ tests/test_cli.rs | 60 +++++++ 5 files changed, 319 insertions(+), 174 deletions(-) create mode 100644 tests/samples/1_Accumulator.sol diff --git a/Cargo.lock b/Cargo.lock index 0f4b7887..d929373e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,7 +208,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap 3.2.17", + "clap 3.2.22", "env_logger", "lazy_static", "lazycell", @@ -409,9 +409,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" dependencies = [ "glob", "libc", @@ -433,6 +433,76 @@ dependencies = [ "vec_map", ] +[[package]] +name = "clap" +version = "3.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +dependencies = [ + "atty", + "bitflags", + "clap_lex 0.2.4", + "indexmap", + "strsim 0.10.0", + "termcolor", + "textwrap 0.15.1", +] + +[[package]] +name = "clap" +version = "4.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex 0.3.0", + "once_cell", + "strsim 0.10.0", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cmake" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -456,6 +526,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "cookie" version = "0.16.1" @@ -540,12 +616,11 @@ checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" [[package]] name = "crossbeam-utils" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" dependencies = [ "cfg-if", - "once_cell", ] [[package]] @@ -735,9 +810,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dunce" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" +checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c" [[package]] name = "ed25519" @@ -785,9 +860,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" dependencies = [ "atty", "humantime", @@ -1870,6 +1945,30 @@ dependencies = [ "termtree", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -2414,11 +2513,12 @@ dependencies = [ [[package]] name = "sold" -version = "0.64.0" +version = "0.65.0" +source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?tag=0.65.0#b7da7b3a7fbbfa030c08e10e2d3cf7bb22438411" dependencies = [ "atty", "bindgen", - "clap 3.2.17", + "clap 4.0.17", "cmake", "dunce", "failure", @@ -2426,9 +2526,9 @@ dependencies = [ "serde", "serde_json", "strip-ansi-escapes", - "ton_abi 2.3.7", - "ton_block 1.8.3", - "ton_types 1.11.4", + "ton_abi", + "ton_block", + "ton_types", "tvm_linker", ] @@ -2549,9 +2649,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" [[package]] name = "thiserror" @@ -2745,30 +2845,8 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.8.2", - "ton_block 1.8.0", - "ton_types 1.11.3", -] - -[[package]] -name = "ton_abi" -version = "2.3.7" -source = "git+https://github.com/tonlabs/ton-labs-abi.git?tag=2.3.7#958fba895b3a7c4f255d89a0f292e2136350022c" -dependencies = [ - "base64 0.10.1", - "byteorder", - "chrono", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.3.2", - "num-bigint", - "num-traits", - "serde", - "serde_derive", - "serde_json", - "sha2 0.8.2", - "ton_block 1.8.3", - "ton_types 1.11.4", + "ton_block", + "ton_types", ] [[package]] @@ -2786,9 +2864,9 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "ton_block 1.8.0", + "ton_block", "ton_tl_codegen", - "ton_types 1.11.3", + "ton_types", ] [[package]] @@ -2809,24 +2887,6 @@ dependencies = [ "ton_types", ] -[[package]] -name = "ton_block" -version = "1.8.3" -source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#8f39a1b467919d5fb3129800f07357883be82d77" -dependencies = [ - "base64 0.13.0", - "crc 3.0.0", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.4.3", - "log", - "num", - "num-traits", - "sha2 0.10.2", - "ton_types 1.11.4", -] - [[package]] name = "ton_block_json" version = "0.7.33" @@ -2841,8 +2901,8 @@ dependencies = [ "serde_derive", "serde_json", "ton_api", - "ton_block 1.8.0", - "ton_types 1.11.3", + "ton_block", + "ton_types", ] [[package]] @@ -2891,13 +2951,13 @@ dependencies = [ "tokio", "tokio-stream", "tokio-tungstenite", - "ton_abi 2.3.1", - "ton_block 1.8.0", + "ton_abi", + "ton_block", "ton_block_json", "ton_executor", "ton_sdk", - "ton_types 1.11.3", - "ton_vm 1.8.40", + "ton_types", + "ton_vm", "zeroize", "zstd", ] @@ -2910,9 +2970,9 @@ dependencies = [ "failure", "lazy_static", "log", - "ton_block 1.8.0", - "ton_types 1.11.3", - "ton_vm 1.8.40", + "ton_block", + "ton_types", + "ton_vm", ] [[package]] @@ -2927,13 +2987,13 @@ dependencies = [ "num-traits", "serde", "serde_json", - "ton_types 1.11.3", + "ton_types", ] [[package]] name = "ton_labs_assembler" -version = "1.2.47" -source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.47#4f0e7e2bf848fc74604f895fca3e7b9400b9494a" +version = "1.2.49" +source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.49#3402cd94fe15dfc249acbf891d40a41fface87c3" dependencies = [ "failure", "hex 0.4.3", @@ -2942,7 +3002,7 @@ dependencies = [ "num-traits", "serde", "serde_json", - "ton_types 1.11.4", + "ton_types", ] [[package]] @@ -2965,10 +3025,10 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.9.9", - "ton_abi 2.3.1", - "ton_block 1.8.0", - "ton_types 1.11.3", - "ton_vm 1.8.40", + "ton_abi", + "ton_block", + "ton_types", + "ton_vm", ] [[package]] @@ -3006,26 +3066,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "ton_types" -version = "1.11.4" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#fd69a6b848ddfacee86cc6b76c3ff36d61f3e1f7" -dependencies = [ - "base64 0.13.0", - "crc 1.8.1", - "failure", - "hex 0.4.3", - "lazy_static", - "lockfree", - "log", - "num", - "num-derive", - "num-traits", - "rand 0.8.5", - "sha2 0.9.9", - "smallvec", -] - [[package]] name = "ton_vm" version = "1.8.44" @@ -3048,31 +3088,9 @@ dependencies = [ "zstd", ] -[[package]] -name = "ton_vm" -version = "1.8.43" -source = "git+https://github.com/tonlabs/ton-labs-vm.git?tag=1.8.43#7aa03d20e32af14baeb0aae0babf4b9281453561" -dependencies = [ - "diffy", - "ed25519", - "ed25519-dalek", - "failure", - "hex 0.4.3", - "lazy_static", - "log", - "num", - "num-traits", - "rand 0.7.3", - "sha2 0.9.9", - "similar", - "ton_block 1.8.3", - "ton_types 1.11.4", - "zstd", -] - [[package]] name = "tonos-cli" -version = "0.28.20" +version = "0.28.21" dependencies = [ "assert_cmd", "async-trait", @@ -3102,12 +3120,12 @@ dependencies = [ "string-error", "tokio", "tokio-retry", - "ton_abi 2.3.1", - "ton_block 1.8.0", + "ton_abi", + "ton_block", "ton_block_json", "ton_client", "ton_executor", - "ton_labs_assembler 1.2.44", + "ton_labs_assembler 1.2.48", "ton_sdk", "ton_types", "ton_vm", @@ -3168,16 +3186,16 @@ dependencies = [ [[package]] name = "tvm_linker" -version = "0.15.70" -source = "git+https://github.com/tonlabs/TVM-linker.git?tag=0.15.70#ca1548e8570ec642a920e1558e930a638435009f" +version = "0.18.3" +source = "git+https://github.com/tonlabs/TVM-linker.git?tag=0.18.3#afb91fa5bac8d4343fa38bd510d0f5a47cf86278" dependencies = [ - "base64 0.10.1", + "base64 0.13.0", "clap 2.34.0", - "crc16", + "crc 3.0.0", "ed25519", "ed25519-dalek", "failure", - "hex 0.3.2", + "hex 0.4.3", "lazy_static", "log", "num", @@ -3186,13 +3204,13 @@ dependencies = [ "regex", "serde", "serde_json", - "sha2 0.8.2", + "sha2 0.10.6", "simplelog 0.5.3", - "ton_abi 2.3.7", - "ton_block 1.8.3", - "ton_labs_assembler 1.2.47", - "ton_types 1.11.4", - "ton_vm 1.8.43", + "ton_abi", + "ton_block", + "ton_labs_assembler 1.2.49", + "ton_types", + "ton_vm", ] [[package]] @@ -3411,13 +3429,13 @@ dependencies = [ [[package]] name = "which" -version = "4.2.5" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f9444f8c..9f44e65b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.38.0' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.4' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.44' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.33' } -sold = { path = '../sol2tvm/pub/sold' } +sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', tag = '0.65.0' } [dev-dependencies] assert_cmd = '1.0.3' diff --git a/src/compile.rs b/src/compile.rs index 64c43de3..40ac4a50 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -25,51 +25,72 @@ pub fn create_compile_command<'a, 'b>() -> App<'a, 'b> { .arg(Arg::with_name("INPUT") .required_unless("VERSION") .help("Path to the Solidity source file.")) - .arg(Arg::with_name("GENKEY") - .takes_value(true) - .long("--genkey") - .conflicts_with("SETKEY") - .help("Path to the file, where a new generated keypair for the contract will be saved.")) - .arg(Arg::with_name("SETKEY") - .takes_value(true) - .long("--setkey") - .conflicts_with("GENKEY") - .help("Seed phrase or path to the file with keypair.")) - .arg(Arg::with_name("VERSION") - .long("--version") - .short("-v") - .help("Print version of the Solidity compiler.")) - .arg(Arg::with_name("WC") - .takes_value(true) - .long("--wc") - .help("Workchain id of the smart contract (default value is taken from the config).")) .arg(Arg::with_name("CONTRACT") .takes_value(true) .long("--contract") + .short("-c") .help("Contract to build if sources define more than one contract.")) .arg(Arg::with_name("OUTPUT_DIR") .takes_value(true) - .long("--output_dir") - .short("-o") + .long("--output-dir") + .short("-O") .help("Output directory (by default, current directory is used).")) .arg(Arg::with_name("OUTPUT_PREFIX") .takes_value(true) - .long("--output_prefix") - .short("-p") + .long("--output-prefix") + .short("-P") .help("Output prefix (by default, input file stem is used as prefix).")) .arg(Arg::with_name("INCLUDE_PATH") .takes_value(true) - .long("--include_path") - .short("-i") + .long("--include-path") + .short("-I") .help("Include additional path to search for imports.")) .arg(Arg::with_name("LIB") .takes_value(true) .long("--lib") - .short("-l") + .short("-L") .help("Library to use instead of default.")) - .arg(Arg::with_name("REFRESH_REMOTE") - .long("--refresh_remote") + .arg(Arg::with_name("FUNCTION_IDS") + .long("--function-ids") + .help("Print name and id for each public function.")) + .arg(Arg::with_name("PRIVATE_FUNCTION_IDS") + .long("--private-function-ids") + .help("Print name and id for each private function.")) + .arg(Arg::with_name("AST_JSON") + .long("--ast-json") + .help("Get AST of all source files in JSON format.") + .conflicts_with("AST_COMPACT_JSON")) + .arg(Arg::with_name("AST_COMPACT_JSON") + .long("--ast-compact-json") + .help("Get AST of all source files in compact JSON format.") + .conflicts_with("AST_JSON")) + .arg(Arg::with_name("ABI_JSON") + .long("--abi-json") + .help("Get ABI without actual compilation.")) + .arg(Arg::with_name("GENKEY") + .takes_value(true) + .long("--genkey") + .conflicts_with("SETKEY") + .help("Path to the file, where a new generated keypair for the contract will be saved.")) + .arg(Arg::with_name("SETKEY") + .takes_value(true) + .long("--setkey") + .conflicts_with("GENKEY") + .help("Seed phrase or path to the file with keypair.")) + .arg(Arg::with_name("TVM_REFRESH_REMOTE") + .long("--tvm-refresh-remote") .help("Force download and rewrite remote import files.")) + .arg(Arg::with_name("PRINT_CODE") + .long("--print_code") + .help("After ASM compilation do not generate TVC but print the code cell only.")) + .arg(Arg::with_name("VERSION") + .long("--version") + .short("-v") + .help("Print version of the Solidity compiler.")) + .arg(Arg::with_name("WC") + .takes_value(true) + .long("--wc") + .help("Workchain id of the smart contract (default value is taken from the config).")) ) } @@ -97,6 +118,13 @@ async fn compile_solidity(matches: &ArgMatches<'_>, config: &Config) -> Result<( }) .unwrap_or(vec![]); + let function_ids = matches.is_present("FUNCTION_IDS"); + let private_function_ids = matches.is_present("PRIVATE_FUNCTION_IDS"); + let ast_json = matches.is_present("AST_JSON"); + let ast_compact_json = matches.is_present("AST_COMPACT_JSON"); + let abi_json = matches.is_present("ABI_JSON"); + let print_code = matches.is_present("PRINT_CODE"); + let args = Args { input: input.clone(), contract: matches.value_of("CONTRACT").map(|s| s.to_owned()), @@ -104,19 +132,29 @@ async fn compile_solidity(matches: &ArgMatches<'_>, config: &Config) -> Result<( output_prefix: matches.value_of("OUTPUT_PREFIX").map(|s| s.to_owned()), include_path, lib: matches.value_of("LIB").map(|s| s.to_owned()), - function_ids: false, - ast_json: false, - ast_compact_json: false, - abi_json: false, - tvm_refresh_remote: matches.is_present("REFRESH_REMOTE"), - silent: config.is_json, init: None, + function_ids, + private_function_ids, + ast_json, + ast_compact_json, + abi_json, + tvm_refresh_remote: matches.is_present("TVM_REFRESH_REMOTE"), + silent: config.is_json, + print_code, }; build(args).map_err(|e| format!("Failed to compile the contract: {}", e))?; + if function_ids || private_function_ids || ast_compact_json || ast_json || abi_json || + print_code { + return Ok(()); + } let input_canonical = Path::new(&input).canonicalize() .map_err(|e| format!("Failed to format input path: {}", e))?; - let stem = input_canonical.file_stem().ok_or("Failed to format input path".to_owned())? - .to_str().unwrap().to_owned(); + let stem = matches.value_of("OUTPUT_PREFIX").map(|s| s.to_owned()) + .unwrap_or(input_canonical.file_stem() + .ok_or("Failed to format input path".to_owned())? + .to_str().unwrap_or("").to_owned()); + let stem = format!("{}/{}", matches.value_of("OUTPUT_DIR").unwrap_or(".") + .trim_end_matches("/"), stem); let tvc_path = format!("{}.tvc", stem); let abi_path = format!("{}.abi.json", stem); if !config.is_json { diff --git a/tests/samples/1_Accumulator.sol b/tests/samples/1_Accumulator.sol new file mode 100644 index 00000000..4732abfe --- /dev/null +++ b/tests/samples/1_Accumulator.sol @@ -0,0 +1,29 @@ +pragma ever-solidity >= 0.35.0; +pragma AbiHeader expire; + +contract Accumulator { + + // State variable storing the sum of arguments that were passed to function 'add', + uint public sum = 0; + + constructor() public { + // check that contract's public key is set + require(tvm.pubkey() != 0, 101); + // Check that message has signature (msg.pubkey() is not zero) and message is signed with the owner's private key + require(msg.pubkey() == tvm.pubkey(), 102); + tvm.accept(); + } + + // Modifier that allows to accept some external messages + modifier checkOwnerAndAccept { + // Check that message was signed with contracts key. + require(msg.pubkey() == tvm.pubkey(), 102); + tvm.accept(); + _; + } + + // Function that adds its argument to the state variable. + function add(uint value) public checkOwnerAndAccept { + sum += value; + } +} diff --git a/tests/test_cli.rs b/tests/test_cli.rs index 52f350b3..66047f7d 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -3245,3 +3245,63 @@ fn test_alternative_paths() -> Result<(), Box> { } +fn check_compiled_files_and_delete(path: &str) -> Result<(), Box> { + assert!(std::path::Path::new(&format!("{path}.code")).exists()); + fs::remove_file(&format!("{path}.code"))?; + assert!(std::path::Path::new(&format!("{path}.abi.json")).exists()); + fs::remove_file(&format!("{path}.abi.json"))?; + assert!(std::path::Path::new(&format!("{path}.debug.json")).exists()); + fs::remove_file(&format!("{path}.debug.json"))?; + assert!(std::path::Path::new(&format!("{path}.tvc")).exists()); + fs::remove_file(&format!("{path}.tvc"))?; + Ok(()) +} + +#[test] +fn test_solidity_compile() -> Result<(), Box> { + let contract_path = "tests/samples/1_Accumulator"; + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("compile") + .arg("solidity") + .arg(format!("{contract_path}.sol")); + cmd.assert() + .success() + .stdout(predicate::str::contains("Raw address: 0:f45b9b2538dcc4aef9d2b6e43228e73157a63ea27c78589135fbf29a16e6354a")); + + check_compiled_files_and_delete("1_Accumulator")?; + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("compile") + .arg("solidity") + .arg(format!("{contract_path}.sol")) + .arg("-O") + .arg("tests/samples/") + .arg("-P") + .arg("contract"); + cmd.assert() + .success() + .stdout(predicate::str::contains("Raw address: 0:f45b9b2538dcc4aef9d2b6e43228e73157a63ea27c78589135fbf29a16e6354a")); + + check_compiled_files_and_delete("tests/samples/contract")?; + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("compile") + .arg("solidity") + .arg(format!("{contract_path}.sol")) + .arg("--function-ids"); + cmd.assert() + .success() + .stdout(predicate::str::contains(r#""add": "0x25efb208","#)); + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("compile") + .arg("solidity") + .arg(format!("{contract_path}.sol")) + .arg("--private-function-ids"); + cmd.assert() + .success() + .stdout(predicate::str::contains(r#""id": 3297096926,"#)); + + Ok(()) +} From 0ed48370c013bee077b945b8894aba5fe3b1691c Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Thu, 20 Oct 2022 15:26:39 +0300 Subject: [PATCH 11/25] Increased version --- Cargo.lock | 42 +++++++++++++++++++++--------------------- Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d929373e..68ca3a7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -955,9 +955,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -970,9 +970,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -980,15 +980,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -997,15 +997,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -1014,21 +1014,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -2324,9 +2324,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "indexmap", "itoa", @@ -3090,7 +3090,7 @@ dependencies = [ [[package]] name = "tonos-cli" -version = "0.28.21" +version = "0.28.22" dependencies = [ "assert_cmd", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 9f44e65b..d02ed347 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.28.21' +version = '0.28.22' [dependencies] async-trait = '0.1.42' From 8ea5b5e5938458e5401db11ad4ee7555c058a9a2 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Tue, 11 Oct 2022 16:08:25 +0400 Subject: [PATCH 12/25] Fixed config change for file which path is not equal to actual path --- src/config.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index eb77b04b..54a8cabc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -290,7 +290,7 @@ impl FullConfig { return FullConfig::new(config.unwrap(), path.to_string()); } let full_config: serde_json::error::Result = serde_json::from_str(&conf_str); - if full_config.is_err() { + let mut full_config = if full_config.is_err() { let conf_str = std::fs::read_to_string(&global_config_path()).ok() .unwrap_or_default(); let mut global_config = serde_json::from_str::(&conf_str) @@ -299,7 +299,9 @@ impl FullConfig { global_config } else { full_config.unwrap() - } + }; + full_config.path = path.to_string(); + full_config } pub fn to_file(&self, path: &str) -> Result<(), String>{ From 89072ff06dbe7d3ad5f34091c8980ac4a5648b2b Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Tue, 11 Oct 2022 20:15:16 +0400 Subject: [PATCH 13/25] Start of replay fixing --- src/debug.rs | 28 ++++++++++++++----------- src/replay.rs | 57 +++++++++++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/debug.rs b/src/debug.rs index 8dc71966..8b7f18ce 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -404,17 +404,21 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is (tr_id, address) }; - let config_path = match config_path { - Some(config_path) => { - config_path - }, - _ => { - if !config.is_json { - println!("Fetching config contract transactions..."); + let config_path = if is_empty_config { + None + } else { + Some(match config_path { + Some(config_path) => { + config_path + }, + _ => { + if !config.is_json { + println!("Fetching config contract transactions..."); + } + fetch(config, CONFIG_ADDR, DEFAULT_CONFIG_PATH, None, true).await?; + DEFAULT_CONFIG_PATH } - fetch(config, CONFIG_ADDR, DEFAULT_CONFIG_PATH, is_empty_config, None, true).await?; - DEFAULT_CONFIG_PATH - } + }) }; let contract_path = match contract_path { Some(contract_path) => { @@ -424,7 +428,7 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is if !config.is_json { println!("Fetching contract transactions..."); } - fetch(config, &address, DEFAULT_CONTRACT_PATH, false, None, true).await?; + fetch(config, &address, DEFAULT_CONTRACT_PATH, None, true).await?; DEFAULT_CONTRACT_PATH } }; @@ -456,7 +460,7 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is init_logger, dump_mask, config, - is_empty_config, + false, !matches.is_present("IGNORE_HASHES"), ).await?; diff --git a/src/replay.rs b/src/replay.rs index b6a97af4..20e70bad 100644 --- a/src/replay.rs +++ b/src/replay.rs @@ -57,7 +57,7 @@ fn construct_blockchain_config_err(config_account: &Account) -> Result, rewrite_file: bool) -> Result<(), String> { +pub async fn fetch(config: &Config, account_address: &str, filename: &str, lt_bound: Option, rewrite_file: bool) -> Result<(), String> { if !rewrite_file && std::path::Path::new(filename).exists() { if !config.is_json { println!("File exists"); @@ -144,9 +144,6 @@ pub async fn fetch(config: &Config, account_address: &str, filename: &str, fast_ .map_err(|e| format!("failed to serialize account: {}", e))?)); writer.write_all(data.as_bytes()).map_err(|e| format!("Failed to write to file: {}", e))?; } - if fast_stop { - return Ok(()); - } let retry_strategy = tokio_retry::strategy::ExponentialBackoff::from_millis(10).take(5); @@ -220,6 +217,17 @@ struct State { lines: Option>>, } +impl Default for State { + fn default() -> Self { + Self { + account: Account::default(), + account_addr: "".to_string(), + tr: None, + lines: None + } + } +} + impl State { fn new(filename: &str) -> Result { let file = File::open(filename) @@ -240,15 +248,6 @@ impl State { Ok(Self { account, account_addr, tr: None, lines: Some(lines) }) } - fn default() -> Result { - Ok(Self { - account: Account::default(), - account_addr: "".to_string(), - tr: None, - lines: None - }) - } - pub fn set_account(&mut self, account: Account) { self.account = account; } @@ -285,7 +284,7 @@ fn choose<'a>(st1: &'a mut State, st2: &'a mut State) -> &'a mut State { pub async fn replay( input_filename: &str, - config_filename: &str, + config_filename: Option<&str>, txnid: &str, trace_callback: Option>, init_trace_last_logger: impl Fn() -> Result<(), String>, @@ -296,7 +295,7 @@ pub async fn replay( ) -> Result { let mut account_state = State::new(input_filename)?; let account_address = account_state.account_addr.clone(); - + let mut empty_config = false; let (mut config, mut config_state) = if load_current_net_config { let ton_client = create_client(cli_config)?; let config = query_account_field( @@ -305,11 +304,22 @@ pub async fn replay( "boc", ).await?; let config = Account::construct_from_base64(&config).map_err(|_| "".to_string())?; - let mut state = State::default()?; + let mut state = State::default(); state.set_account(config.clone()); (construct_blockchain_config(&config)?, state) } else { - let config_state = State::new(config_filename)?; + let config_state = match config_filename { + Some(config_filename) => { + State::new(config_filename)? + } + None => { + empty_config = true; + State { + account_addr: CONFIG_ADDR.to_string(), + ..Default::default() + } + } + }; assert_eq!(config_state.account_addr, CONFIG_ADDR); (BlockchainConfig::default(), config_state) }; @@ -330,7 +340,7 @@ pub async fn replay( let state = choose(&mut account_state, &mut config_state); let tr = state.tr.as_ref().ok_or("failed to obtain state transaction")?; - if !load_current_net_config { + if !(load_current_net_config || empty_config) { if cur_block_lt == 0 || cur_block_lt != tr.block_lt { assert!(tr.block_lt > cur_block_lt); cur_block_lt = tr.block_lt; @@ -530,7 +540,7 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res fetch(config, account.as_str(), format!("{}.txns", account).as_str(), - false, Some(end_lt), false).await.map_err(err_msg)?; + Some(end_lt), false).await.map_err(err_msg)?; } let config_txns_path = format!("{}.txns", CONFIG_ADDR); @@ -539,7 +549,7 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res fetch(config, CONFIG_ADDR, config_txns_path.as_str(), - false, Some(end_lt), false).await.map_err(err_msg)?; + Some(end_lt), false).await.map_err(err_msg)?; } let acc = accounts[0].0.as_str(); @@ -548,7 +558,7 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res let config_path = format!("config-{}.boc", txnid); if !std::path::Path::new(config_path.as_str()).exists() { println!("Computing config: replaying {} up to {}", acc, txnid); - replay(format!("{}.txns", acc).as_str(),config_txns_path.as_str(), + replay(format!("{}.txns", acc).as_str(),Some(config_txns_path.as_str()), txnid, None, || Ok(()), DUMP_CONFIG, config, false, true ).await.map_err(err_msg)?; @@ -565,7 +575,7 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res if !std::path::Path::new(format!("{}-{}.boc", account_filename, txnid).as_str()).exists() { replay( format!("{}.txns", account_filename).as_str(), - format!("{}.txns", CONFIG_ADDR).as_str(), + Some(format!("{}.txns", CONFIG_ADDR).as_str()), &txnid, None, || Ok(()), @@ -636,7 +646,6 @@ pub async fn fetch_command(m: &ArgMatches<'_>, config: &Config) -> Result<(), St fetch(config, m.value_of("ADDRESS").ok_or("Missing account address")?, m.value_of("OUTPUT").ok_or("Missing output filename")?, - false, None, true ).await?; @@ -655,7 +664,7 @@ pub async fn replay_command(m: &ArgMatches<'_>, cli_config: &Config) -> Result<( (m.value_of("CONFIG_TXNS").ok_or("Missing config txns filename")?, false) }; let _ = replay(m.value_of("INPUT_TXNS").ok_or("Missing input txns filename")?, - config_txns, m.value_of("TXNID").ok_or("Missing final txn id")?, + Some(config_txns), m.value_of("TXNID").ok_or("Missing final txn id")?, None, ||{Ok(())}, DUMP_ALL, cli_config, load_config, !m.is_present("IGNORE_HASHES") ).await?; From df50a31bcd1b4fffb4e937398927800ed5bd6be4 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Sun, 23 Oct 2022 18:51:09 +0300 Subject: [PATCH 14/25] Put solidity compile functionality under feature --- Cargo.lock | 74 +++++++++++++++++++++++------------------------ Cargo.toml | 5 +++- src/main.rs | 25 +++++++++------- tests/test_cli.rs | 3 +- 4 files changed, 58 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68ca3a7d..a3e23358 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "api_derive" @@ -186,9 +186,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bincode" @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.17" +version = "4.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267" +checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" dependencies = [ "atty", "bitflags", @@ -465,9 +465,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.0.13" +version = "4.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" +checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" dependencies = [ "heck", "proc-macro-error", @@ -699,9 +699,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" dependencies = [ "cc", "cxxbridge-flags", @@ -711,9 +711,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" dependencies = [ "cc", "codespan-reporting", @@ -726,15 +726,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" [[package]] name = "cxxbridge-macro" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", @@ -1074,9 +1074,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -1770,9 +1770,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.76" +version = "0.9.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" dependencies = [ "autocfg", "cc", @@ -2087,7 +2087,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", ] [[package]] @@ -2163,7 +2163,7 @@ version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "bytes", "cookie", "cookie_store", @@ -2203,7 +2203,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "blake2b_simd", "constant_time_eq", "crossbeam-utils", @@ -2304,18 +2304,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -2514,11 +2514,11 @@ dependencies = [ [[package]] name = "sold" version = "0.65.0" -source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?tag=0.65.0#b7da7b3a7fbbfa030c08e10e2d3cf7bb22438411" +source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?branch=test#45543cf0cb2ae889fd31eaa4a35763a8e16a29e1" dependencies = [ "atty", "bindgen", - "clap 4.0.17", + "clap 4.0.18", "cmake", "dunce", "failure", @@ -2567,9 +2567,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", @@ -2874,7 +2874,7 @@ name = "ton_block" version = "1.8.3" source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 3.0.0", "ed25519", "ed25519-dalek", @@ -2892,7 +2892,7 @@ name = "ton_block_json" version = "0.7.33" source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "failure", "hex 0.4.3", "num", @@ -3051,7 +3051,7 @@ name = "ton_types" version = "1.11.4" source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 1.8.1", "failure", "hex 0.4.3", @@ -3170,7 +3170,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "byteorder", "bytes", "http", @@ -3189,7 +3189,7 @@ name = "tvm_linker" version = "0.18.3" source = "git+https://github.com/tonlabs/TVM-linker.git?tag=0.18.3#afb91fa5bac8d4343fa38bd510d0f5a47cf86278" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "clap 2.34.0", "crc 3.0.0", "ed25519", diff --git a/Cargo.toml b/Cargo.toml index d02ed347..3bb18094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,9 @@ readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' version = '0.28.22' +[features] +sold = ["dep:sold"] + [dependencies] async-trait = '0.1.42' base64 = '0.10.1' @@ -53,7 +56,7 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.38.0' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.4' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.44' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.33' } -sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', tag = '0.65.0' } +sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', branch = 'test', optional = true } [dev-dependencies] assert_cmd = '1.0.3' diff --git a/src/main.rs b/src/main.rs index aa64a6b3..db2fdc06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ mod replay; mod debug; mod run; mod message; +#[cfg(feature = "sold")] mod compile; use account::{get_account, calc_storage, wait_for_change}; @@ -64,6 +65,7 @@ use voting::{create_proposal, decode_proposal, vote}; use replay::{fetch_block_command, fetch_command, replay_command}; use ton_client::abi::{ParamsOfEncodeMessageBody, CallSet}; use crate::account::dump_accounts; +#[cfg(feature = "sold")] use crate::compile::{compile_command, create_compile_command}; use crate::config::{FullConfig, resolve_net_name}; @@ -874,14 +876,14 @@ async fn main_internal() -> Result <(), String> { .long("--ignore_hashes") .short("-i")); + let version = format!("{}\nCOMMIT_ID: {}\nBUILD_DATE: {}\nCOMMIT_DATE: {}\nGIT_BRANCH: {}", + env!("CARGO_PKG_VERSION"), + env!("BUILD_GIT_COMMIT"), + env!("BUILD_TIME"), + env!("BUILD_GIT_DATE"), + env!("BUILD_GIT_BRANCH")); let matches = App::new("tonos_cli") - .version(&*format!("{}\nCOMMIT_ID: {}\nBUILD_DATE: {}\nCOMMIT_DATE: {}\nGIT_BRANCH: {}", - env!("CARGO_PKG_VERSION"), - env!("BUILD_GIT_COMMIT"), - env!("BUILD_TIME"), - env!("BUILD_GIT_DATE"), - env!("BUILD_GIT_BRANCH")) - ) + .version(&*version) .author("TONLabs") .about("TONLabs console tool for TON") .arg(Arg::with_name("NETWORK") @@ -923,7 +925,6 @@ async fn main_internal() -> Result <(), String> { .subcommand(create_decode_command()) .subcommand(create_debot_command()) .subcommand(create_debug_command()) - .subcommand(create_compile_command()) .subcommand(getconfig_cmd) .subcommand(bcconfig_cmd) .subcommand(nodeid_cmd) @@ -935,8 +936,11 @@ async fn main_internal() -> Result <(), String> { .subcommand(deployx_cmd) .subcommand(runx_cmd) .subcommand(update_config_param_cmd) - .setting(AppSettings::SubcommandRequired) - .get_matches_safe() + .setting(AppSettings::SubcommandRequired); +#[cfg(feature = "sold")] + let matches = matches.subcommand(create_compile_command()); + + let matches = matches.get_matches_safe() .map_err(|e| match e.kind { clap::ErrorKind::VersionDisplayed => { println!(); exit(0); }, clap::ErrorKind::HelpDisplayed => { println!("{}", e); exit(0); }, @@ -1107,6 +1111,7 @@ async fn command_parser(matches: &ArgMatches<'_>, is_json: bool) -> Result <(), if let Some(m) = matches.subcommand_matches("replay") { return replay_command(m, config).await; } +#[cfg(feature = "sold")] if let Some(m) = matches.subcommand_matches("compile") { return compile_command(m, &config).await; } diff --git a/tests/test_cli.rs b/tests/test_cli.rs index 66047f7d..f1f06cb3 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -3244,7 +3244,7 @@ fn test_alternative_paths() -> Result<(), Box> { Ok(()) } - +#[cfg(feature = "sold")] fn check_compiled_files_and_delete(path: &str) -> Result<(), Box> { assert!(std::path::Path::new(&format!("{path}.code")).exists()); fs::remove_file(&format!("{path}.code"))?; @@ -3258,6 +3258,7 @@ fn check_compiled_files_and_delete(path: &str) -> Result<(), Box Result<(), Box> { let contract_path = "tests/samples/1_Accumulator"; From 07ba15dc62695ef7c7a4cd1d46aaf57d8801fcbf Mon Sep 17 00:00:00 2001 From: tonjen Date: Mon, 24 Oct 2022 11:54:22 +0000 Subject: [PATCH 15/25] Preparing to merge with the master --- Cargo.lock | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3e23358..baea3361 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,7 +208,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap 3.2.22", + "clap 3.2.21", "env_logger", "lazy_static", "lazycell", @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.22" +version = "3.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7" dependencies = [ "atty", "bitflags", @@ -445,7 +445,7 @@ dependencies = [ "indexmap", "strsim 0.10.0", "termcolor", - "textwrap 0.15.1", + "textwrap 0.15.0", ] [[package]] @@ -539,7 +539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "344adc371239ef32293cb1c4fe519592fcf21206c79c02854320afcdf3ab4917" dependencies = [ "percent-encoding", - "time 0.3.15", + "time 0.3.16", "version_check", ] @@ -555,7 +555,7 @@ dependencies = [ "publicsuffix", "serde", "serde_json", - "time 0.3.15", + "time 0.3.16", "url", ] @@ -1411,9 +1411,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" [[package]] name = "libloading" @@ -2649,9 +2649,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" @@ -2686,21 +2686,32 @@ dependencies = [ [[package]] name = "time" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c" +checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" dependencies = [ "itoa", "libc", "num_threads", + "serde", + "time-core", "time-macros", ] +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + [[package]] name = "time-macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +dependencies = [ + "time-core", +] [[package]] name = "tiny-bip39" From 033d99332e7a1874544a682032c29a4975348cad Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Mon, 24 Oct 2022 15:39:13 +0300 Subject: [PATCH 16/25] Changed flag behavior and added default blockchain config --- Cargo.lock | 125 +++++++++--------- src/debug.rs | 61 +++++---- src/helpers.rs | 334 +++++++++++++++++++++++++++++++++++++++++++++++-- src/main.rs | 16 ++- src/replay.rs | 84 ++++--------- 5 files changed, 464 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aba5845..b5457351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "api_derive" @@ -180,9 +180,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bincode" @@ -403,7 +403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "344adc371239ef32293cb1c4fe519592fcf21206c79c02854320afcdf3ab4917" dependencies = [ "percent-encoding", - "time 0.3.15", + "time 0.3.16", "version_check", ] @@ -419,7 +419,7 @@ dependencies = [ "publicsuffix", "serde", "serde_json", - "time 0.3.15", + "time 0.3.16", "url", ] @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" dependencies = [ "cc", "cxxbridge-flags", @@ -566,9 +566,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" dependencies = [ "cc", "codespan-reporting", @@ -581,15 +581,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" [[package]] name = "cxxbridge-macro" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -795,9 +795,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -805,15 +805,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -822,15 +822,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -839,21 +839,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -899,9 +899,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -1212,9 +1212,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" [[package]] name = "libsecp256k1" @@ -1545,9 +1545,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.76" +version = "0.9.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" dependencies = [ "autocfg", "cc", @@ -1826,7 +1826,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", ] [[package]] @@ -1885,7 +1885,7 @@ version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "bytes", "cookie", "cookie_store", @@ -2014,18 +2014,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -2034,9 +2034,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "indexmap", "itoa", @@ -2224,9 +2224,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", @@ -2326,21 +2326,32 @@ dependencies = [ [[package]] name = "time" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c" +checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" dependencies = [ "itoa", "libc", "num_threads", + "serde", + "time-core", "time-macros", ] +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + [[package]] name = "time-macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +dependencies = [ + "time-core", +] [[package]] name = "tiny-bip39" @@ -2514,7 +2525,7 @@ name = "ton_block" version = "1.8.3" source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 3.0.0", "ed25519", "ed25519-dalek", @@ -2532,7 +2543,7 @@ name = "ton_block_json" version = "0.7.33" source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "failure", "hex 0.4.3", "num", @@ -2676,7 +2687,7 @@ name = "ton_types" version = "1.11.4" source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 1.8.1", "failure", "hex 0.4.3", @@ -2794,7 +2805,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "byteorder", "bytes", "http", diff --git a/src/debug.rs b/src/debug.rs index 8b7f18ce..9b0ab934 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -17,7 +17,7 @@ use crate::config::Config; use crate::helpers::{load_ton_address, create_client, load_abi, now_ms, construct_account_from_tvc, TonClient, query_account_field, query_with_limit, create_client_verbose, abi_from_matches_or_config, load_debug_info, wc_from_matches_or_config, - TEST_MAX_LEVEL, MAX_LEVEL}; + TEST_MAX_LEVEL, MAX_LEVEL, get_blockchain_config}; use crate::replay::{ fetch, CONFIG_ADDR, replay, DUMP_NONE, DUMP_CONFIG, DUMP_ACCOUNT, construct_blockchain_config }; @@ -178,18 +178,18 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { .short("-c") .takes_value(true); - let empty_config_arg = Arg::with_name("EMPTY_CONFIG") - .help("Replay transaction without full dump of the config contract.") - .long("--empty_config") + let default_config_arg = Arg::with_name("DEFAULT_CONFIG") + .help("Execute debug with current blockchain config or default if it is not available.") + .long("--default_config") .short("-e") - .conflicts_with("CONFIG_PATH"); + .conflicts_with_all(&["CONFIG_PATH", "CONFIG_BOC"]); let config_save_path_arg = Arg::with_name("CONFIG_PATH") - .help("Path to the file with saved config contract transactions. If not set transactions will be fetched to file \"config.txns\".") + .help("Path to the file with saved config contract transactions. If not set and config contract state is not specified with other options transactions will be fetched to file \"config.txns\".") .long("--config") .short("-c") .takes_value(true) - .conflicts_with("EMPTY_CONFIG"); + .conflicts_with_all(&["DEFAULT_CONFIG", "CONFIG_BOC"]); let contract_path_arg = Arg::with_name("CONTRACT_PATH") .help("Path to the file with saved target contract transactions. If not set transactions will be fetched to file \"contract.txns\".") @@ -199,7 +199,8 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { let dump_config_arg = Arg::with_name("DUMP_CONFIG") .help("Dump the replayed config contract account state.") - .long("--dump_config"); + .long("--dump_config") + .conflicts_with("CONFIG_BOC"); let dump_contract_arg = Arg::with_name("DUMP_CONTRACT") .help("Dump the replayed target contract account state.") @@ -216,11 +217,6 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { .long("--now") .help("Now timestamp (in milliseconds) for execution. If not set it is equal to the current timestamp."); - let ignore_hashes = Arg::with_name("IGNORE_HASHES") - .help("Ignore hashes mismatch. This flag must be set while replaying a contract after setcode on the Node SE.") - .long("--ignore_hashes") - .short("-i"); - let msg_cmd = SubCommand::with_name("message") .about("Play message locally with trace") .arg(output_arg.clone()) @@ -289,11 +285,17 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { .arg(sign_arg.clone()) .arg(update_arg.clone()); + let config_boc_arg = Arg::with_name("CONFIG_BOC") + .help("Path to the config contract boc.") + .long("--config_boc") + .takes_value(true) + .conflicts_with_all(&["CONFIG_PATH", "DEFAULT_CONFIG"]); + SubCommand::with_name("debug") .about("Debug commands.") .subcommand(SubCommand::with_name("transaction") .about("Replay transaction with specified ID.") - .arg(empty_config_arg.clone()) + .arg(default_config_arg.clone()) .arg(config_save_path_arg.clone()) .arg(contract_path_arg.clone()) .arg(output_arg.clone()) @@ -303,10 +305,10 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { .arg(tx_id_arg.clone()) .arg(dump_config_arg.clone()) .arg(dump_contract_arg.clone()) - .arg(ignore_hashes.clone())) + .arg(config_boc_arg.clone())) .subcommand(SubCommand::with_name("account") .about("Loads list of the last transactions for the specified account. User should choose which one to debug.") - .arg(empty_config_arg.clone()) + .arg(default_config_arg.clone()) .arg(config_save_path_arg.clone()) .arg(contract_path_arg.clone()) .arg(output_arg.clone()) @@ -316,7 +318,7 @@ pub fn create_debug_command<'a, 'b>() -> App<'a, 'b> { .arg(address_arg.clone()) .arg(dump_config_arg.clone()) .arg(dump_contract_arg.clone()) - .arg(ignore_hashes.clone())) + .arg(config_boc_arg.clone())) .subcommand(SubCommand::with_name("replay") .about("Replay transaction on the saved account state.") .arg(output_arg.clone()) @@ -379,8 +381,8 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is let trace_path = Some(matches.value_of("LOG_PATH").unwrap_or(DEFAULT_TRACE_PATH)); let config_path = matches.value_of("CONFIG_PATH"); let contract_path = matches.value_of("CONTRACT_PATH"); - let is_empty_config = matches.is_present("EMPTY_CONFIG"); - + let is_default_config = matches.is_present("DEFAULT_CONFIG"); + let config_boc = matches.value_of("CONFIG_BOC"); let (tx_id, address) = if !is_account { let tx_id = matches.value_of("TX_ID"); if !config.is_json { @@ -404,10 +406,10 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is (tr_id, address) }; - let config_path = if is_empty_config { - None + let config_path = if is_default_config || config_boc.is_some() { + "" } else { - Some(match config_path { + match config_path { Some(config_path) => { config_path }, @@ -418,7 +420,7 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is fetch(config, CONFIG_ADDR, DEFAULT_CONFIG_PATH, None, true).await?; DEFAULT_CONFIG_PATH } - }) + } }; let contract_path = match contract_path { Some(contract_path) => { @@ -450,8 +452,16 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is dump_mask |= DUMP_ACCOUNT; } if !config.is_json { - println!("Replaying the last transactions..."); + println!("Replaying the transactions..."); } + + let blockchain_config = if is_default_config || config_boc.is_some() { + let bc_config = get_blockchain_config(config, config_boc).await?; + Some(bc_config) + } else { + None + }; + let tr = replay( contract_path, config_path, @@ -460,8 +470,7 @@ async fn debug_transaction_command(matches: &ArgMatches<'_>, config: &Config, is init_logger, dump_mask, config, - false, - !matches.is_present("IGNORE_HASHES"), + blockchain_config ).await?; decode_messages(tr.out_msgs, load_decode_abi(matches, config), config).await?; diff --git a/src/helpers.rs b/src/helpers.rs index e89f7b17..eba4844c 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -29,9 +29,11 @@ use std::str::FromStr; use clap::ArgMatches; use serde_json::Value; use ton_client::abi::Abi::Contract; +use ton_executor::BlockchainConfig; use url::Url; use crate::call::parse_params; use crate::{FullConfig, resolve_net_name}; +use crate::replay::{CONFIG_ADDR, construct_blockchain_config}; pub const TEST_MAX_LEVEL: log::LevelFilter = log::LevelFilter::Debug; pub const MAX_LEVEL: log::LevelFilter = log::LevelFilter::Warn; @@ -599,22 +601,25 @@ pub async fn load_account( pub fn load_debug_info(abi: &str) -> Option { - check_file_exists(abi, &[".json", ".abi"], ".dbg.json") + check_file_exists(abi, &[".json", ".abi"], &[".dbg.json", ".debug.json", ".map.json"]) } pub fn load_abi_from_tvc(tvc: &str) -> Option { - check_file_exists(tvc, &[".tvc"], ".abi.json") + check_file_exists(tvc, &[".tvc"], &[".abi.json"]) } -pub fn check_file_exists(path: &str, trim: &[&str], ending: &str) -> Option { +pub fn check_file_exists(path: &str, trim: &[&str], ending: &[&str]) -> Option { let mut path = path; for end in trim { path = path.trim_end_matches(end); } - let mut path = path.to_string(); - path.push_str(ending); - if std::path::Path::new(&path).exists() { - return Some(path); + let path = path.to_string(); + for end in ending { + let mut new_path = path.clone(); + new_path.push_str(end); + if std::path::Path::new(&new_path).exists() { + return Some(new_path); + } } None } @@ -702,3 +707,318 @@ pub fn contract_data_from_matches_or_config_alias( .or(keys); Ok((address, Some(abi), keys)) } + +pub fn blockchain_config_from_default_json() -> Result { + // Default config params from evernode-se https://github.com/tonlabs/evernode-se/blob/master/docker/ton-node/blockchain.conf.json + let json = r#"{ + "p0": "5555555555555555555555555555555555555555555555555555555555555555", + "p1": "3333333333333333333333333333333333333333333333333333333333333333", + "p2": "0000000000000000000000000000000000000000000000000000000000000000", + "p7": [ + { + "currency": 239, + "value": "666666666666" + }, + { + "currency": 4294967279, + "value": "1000000000000" + } + ], + "p8": { + "version": 5, + "capabilities": "1180974" + }, + "p9": [ + 0, + 1, + 9, + 10, + 12, + 14, + 15, + 16, + 17, + 18, + 20, + 21, + 22, + 23, + 24, + 25, + 28, + 34 + ], + "p10": [ + 0, + 1, + 9, + 10, + 12, + 14, + 15, + 16, + 17, + 32, + 34, + 36, + 4294966295, + 4294966296, + 4294966297 + ], + "p11": { + "normal_params": { + "min_tot_rounds": 2, + "max_tot_rounds": 3, + "min_wins": 2, + "max_losses": 2, + "min_store_sec": 1000000, + "max_store_sec": 10000000, + "bit_price": 1, + "cell_price": 500 + }, + "critical_params": { + "min_tot_rounds": 4, + "max_tot_rounds": 7, + "min_wins": 4, + "max_losses": 2, + "min_store_sec": 5000000, + "max_store_sec": 20000000, + "bit_price": 2, + "cell_price": 1000 + } + }, + "p12": [ + { + "workchain_id": 0, + "enabled_since": 1605687562, + "actual_min_split": 0, + "min_split": 4, + "max_split": 8, + "active": true, + "accept_msgs": true, + "flags": 0, + "zerostate_root_hash": "c52f085257330ec9b73b94a45b591f997849405a4de5b778edbde5f9775f9a8b", + "zerostate_file_hash": "bd1e95b4e69afbaf5b5186eeeca15a87e16c13feff53595ae6891c12a5790b05", + "version": 0, + "basic": true, + "vm_version": -1, + "vm_mode": 0 + }, + { + "workchain_id": 777, + "enabled_since": 1605687544, + "actual_min_split": 0, + "min_split": 5, + "max_split": 8, + "active": true, + "accept_msgs": false, + "flags": 0, + "zerostate_root_hash": "ee2f085257330ec9b73b94a45b591f997849405a4de5b778edbde5f9775f9a8b", + "zerostate_file_hash": "ff1e95b4e69afbaf5b5186eeeca15a87e16c13feff53595ae6891c12a5790b05", + "version": 0, + "basic": true, + "vm_version": -1, + "vm_mode": 0 + } + ], + "p13": { + "boc": "te6ccgEBAQEADQAAFRpRdIdugAEBIB9I" + }, + "p14": { + "masterchain_block_fee": "1700000000", + "basechain_block_fee": "1000000000" + }, + "p15": { + "validators_elected_for": 14400, + "elections_start_before": 7200, + "elections_end_before": 1800, + "stake_held_for": 7200 + }, + "p16": { + "max_validators": 1000, + "max_main_validators": 100, + "min_validators": 5 + }, + "p17": { + "min_stake": "10000000000000", + "max_stake": "10000000000000000", + "min_total_stake": "100000000000000", + "max_stake_factor": 196608 + }, + "p18": [ + { + "utime_since": 0, + "bit_price_ps": "1", + "cell_price_ps": "500", + "mc_bit_price_ps": "1000", + "mc_cell_price_ps": "500000" + } + ], + "p20": { + "flat_gas_limit": "1000", + "flat_gas_price": "10000000", + "gas_price": "655360000", + "gas_limit": "1000000", + "special_gas_limit": "100000000", + "gas_credit": "10000", + "block_gas_limit": "11000000", + "freeze_due_limit": "100000000", + "delete_due_limit": "1000000000" + }, + "p21": { + "flat_gas_limit": "1000", + "flat_gas_price": "1000000", + "gas_price": "65536000", + "gas_limit": "1000000", + "special_gas_limit": "1000000", + "gas_credit": "10000", + "block_gas_limit": "10000000", + "freeze_due_limit": "100000000", + "delete_due_limit": "1000000000" + }, + "p22": { + "bytes": { + "underload": 131072, + "soft_limit": 524288, + "hard_limit": 1048576 + }, + "gas": { + "underload": 900000, + "soft_limit": 1200000, + "hard_limit": 2000000 + }, + "lt_delta": { + "underload": 1000, + "soft_limit": 5000, + "hard_limit": 10000 + } + }, + "p23": { + "bytes": { + "underload": 131072, + "soft_limit": 524288, + "hard_limit": 1048576 + }, + "gas": { + "underload": 900000, + "soft_limit": 1200000, + "hard_limit": 2000000 + }, + "lt_delta": { + "underload": 1000, + "soft_limit": 5000, + "hard_limit": 10000 + } + }, + "p24": { + "lump_price": "10000000", + "bit_price": "655360000", + "cell_price": "65536000000", + "ihr_price_factor": 98304, + "first_frac": 21845, + "next_frac": 21845 + }, + "p25": { + "lump_price": "1000000", + "bit_price": "65536000", + "cell_price": "6553600000", + "ihr_price_factor": 98304, + "first_frac": 21845, + "next_frac": 21845 + }, + "p28": { + "shuffle_mc_validators": true, + "mc_catchain_lifetime": 250, + "shard_catchain_lifetime": 250, + "shard_validators_lifetime": 1000, + "shard_validators_num": 7 + }, + "p29": { + "new_catchain_ids": true, + "round_candidates": 3, + "next_candidate_delay_ms": 2000, + "consensus_timeout_ms": 16000, + "fast_attempts": 3, + "attempt_duration": 8, + "catchain_max_deps": 4, + "max_block_bytes": 2097152, + "max_collated_bytes": 2097152 + }, + "p31": [ + "0000000000000000000000000000000000000000000000000000000000000000", + "04f64c6afbff3dd10d8ba6707790ac9670d540f37a9448b0337baa6a5a92acac", + "3333333333333333333333333333333333333333333333333333333333333333" + ], + "p34": { + "utime_since": 1605687562, + "utime_until": 1605698362, + "total": 7, + "main": 7, + "total_weight": "119", + "list": [ + { + "public_key": "5457fef5bf496f65ea64d1d8bb4a90694f61fe2787cdb67d16f9ffe548d0b8d9", + "weight": "17" + }, + { + "public_key": "d3ccd99924c61509fc6f1c940a3b027cc2c68f351be9eecb2ce259b4721d9aee", + "weight": "17" + }, + { + "public_key": "51c45bdff0adbf75b61c186129f93361aad0bacff4b729d6061519dee5bc360c", + "weight": "17" + }, + { + "public_key": "f752195a66941a6526c5bd3aef65f07d20aa4b7d9ae57a0dbb01e9d4849ca30d", + "weight": "17" + }, + { + "public_key": "3d0537cd35cc24d1a2098e359b49594665f72cd9c8744c1e1b2e456c7060829a", + "weight": "17" + }, + { + "public_key": "b8639405595ec2a40d65673020e7638c4588d1a72dd2c6a80ecf47499913f509", + "weight": "17" + }, + { + "public_key": "bfa0d77ec39ac4fc386cfd0fb2a940b746502adbbdc361271042cea05f14e7fb", + "weight": "17" + } + ] + } +}"#; + let map = serde_json::from_str::>(&json) + .map_err(|e| format!("Failed to parse config params as json: {e}"))?; + let config_params = ton_block_json::parse_config(&map) + .map_err(|e| format!("Failed to parse config params: {e}"))?; + BlockchainConfig::with_config(config_params) + .map_err(|e| format!("Failed to construct default config: {e}")) +} + +// loads blockchain config from the config contract boc, if it is none tries to load config contract +// from the network, if it is unavailable returns default. +pub async fn get_blockchain_config(cli_config: &Config, config_contract_boc_path: Option<&str>) -> + Result { + match config_contract_boc_path { + Some(config_path) => { + let acc =Account::construct_from_file(config_path) + .map_err(|e| format!("Failed to load config contract account from file {config_path}: {e}"))?; + construct_blockchain_config(&acc) + }, + None => { + let ton_client = create_client(cli_config)?; + let config = query_account_field( + ton_client.clone(), + CONFIG_ADDR, + "boc", + ).await; + let config_account = config.and_then(|config| + Account::construct_from_base64(&config) + .map_err(|e| format!("Failed to construct config account: {e}"))); + match config_account { + Ok(config) => construct_blockchain_config(&config), + Err(_) => blockchain_config_from_default_json() + } + } + } +} diff --git a/src/main.rs b/src/main.rs index 76a4a890..2f6ad293 100644 --- a/src/main.rs +++ b/src/main.rs @@ -854,7 +854,8 @@ async fn main_internal() -> Result <(), String> { .long("--config") .short("-c") .takes_value(true) - .help("File containing zerostate and txns of -1:555..5 account.")) + .help("File containing zerostate and txns of -1:555..5 account.") + .conflicts_with("DEFAULT_CONFIG")) .arg(Arg::with_name("INPUT_TXNS") .required(true) .takes_value(true) @@ -863,14 +864,11 @@ async fn main_internal() -> Result <(), String> { .required(true) .takes_value(true) .help("Dump account state before this transaction ID and stop replaying.")) - .arg(Arg::with_name("CURRENT_CONFIG") - .help("Replay transaction with current network config.") - .long("--current_config") - .short("-e")) - .arg(Arg::with_name("IGNORE_HASHES") - .help("Ignore hashes mismatch. This flag must be set while replaying a contract after setcode on the Node SE.") - .long("--ignore_hashes") - .short("-i")); + .arg(Arg::with_name("DEFAULT_CONFIG") + .help("Replay transaction with current network config or default if it is not available.") + .long("--default_config") + .short("-e") + .conflicts_with("CONFIG_TXNS")); let matches = App::new("tonos_cli") .version(&*format!("{}\nCOMMIT_ID: {}\nBUILD_DATE: {}\nCOMMIT_DATE: {}\nGIT_BRANCH: {}", diff --git a/src/replay.rs b/src/replay.rs index 20e70bad..db587d92 100644 --- a/src/replay.rs +++ b/src/replay.rs @@ -22,8 +22,8 @@ use failure::err_msg; use serde::{Deserialize, Serialize}; use serde_json::Value; -use ton_block::{Account, ConfigParams, Deserializable, Message, Serializable, Transaction, - TransactionDescr, Block, HashmapAugType}; +use ton_block::{Account, ConfigParams, Deserializable, Message, Serializable, + Transaction, TransactionDescr, Block, HashmapAugType}; use ton_client::{ net::{AggregationFn, FieldAggregation, OrderBy, ParamsOfAggregateCollection, ParamsOfQueryCollection, SortDirection, aggregate_collection, query_collection}, @@ -34,7 +34,7 @@ use ton_types::{UInt256, serialize_tree_of_cells}; use ton_vm::executor::{Engine, EngineTraceInfo}; use crate::config::Config; -use crate::helpers::{create_client, query_account_field}; +use crate::helpers::{create_client, get_blockchain_config}; pub static CONFIG_ADDR: &str = "-1:5555555555555555555555555555555555555555555555555555555555555555"; @@ -248,10 +248,6 @@ impl State { Ok(Self { account, account_addr, tr: None, lines: Some(lines) }) } - pub fn set_account(&mut self, account: Account) { - self.account = account; - } - pub fn next_transaction(&mut self) -> Option<()> { if self.lines.is_some() { match self.lines.as_mut().unwrap().next() { @@ -284,42 +280,22 @@ fn choose<'a>(st1: &'a mut State, st2: &'a mut State) -> &'a mut State { pub async fn replay( input_filename: &str, - config_filename: Option<&str>, + config_filename: &str, txnid: &str, trace_callback: Option>, init_trace_last_logger: impl Fn() -> Result<(), String>, dump_mask: u8, cli_config: &Config, - load_current_net_config: bool, - exit_on_wrong_contract_hash: bool, + blockchain_config: Option, ) -> Result { let mut account_state = State::new(input_filename)?; let account_address = account_state.account_addr.clone(); - let mut empty_config = false; - let (mut config, mut config_state) = if load_current_net_config { - let ton_client = create_client(cli_config)?; - let config = query_account_field( - ton_client.clone(), - CONFIG_ADDR, - "boc", - ).await?; - let config = Account::construct_from_base64(&config).map_err(|_| "".to_string())?; - let mut state = State::default(); - state.set_account(config.clone()); - (construct_blockchain_config(&config)?, state) + let mut iterate_config = true; + let (mut config, mut config_state) = if let Some(bc_config) = blockchain_config { + iterate_config = false; + (bc_config, State::default()) } else { - let config_state = match config_filename { - Some(config_filename) => { - State::new(config_filename)? - } - None => { - empty_config = true; - State { - account_addr: CONFIG_ADDR.to_string(), - ..Default::default() - } - } - }; + let config_state = State::new(config_filename)?; assert_eq!(config_state.account_addr, CONFIG_ADDR); (BlockchainConfig::default(), config_state) }; @@ -340,7 +316,7 @@ pub async fn replay( let state = choose(&mut account_state, &mut config_state); let tr = state.tr.as_ref().ok_or("failed to obtain state transaction")?; - if !(load_current_net_config || empty_config) { + if iterate_config { if cur_block_lt == 0 || cur_block_lt != tr.block_lt { assert!(tr.block_lt > cur_block_lt); cur_block_lt = tr.block_lt; @@ -360,9 +336,7 @@ pub async fn replay( account_old_hash_remote.to_hex_string(), account_old_hash_local.to_hex_string()); } - if exit_on_wrong_contract_hash { - exit(1); - } + exit(1); } if tr.id == txnid { if dump_mask & DUMP_ACCOUNT != 0 { @@ -459,14 +433,12 @@ pub async fn replay( account_new_hash_remote.to_hex_string(), account_new_hash_local.to_hex_string(), tr.id); } - if exit_on_wrong_contract_hash { - let local_desc = tr_local.read_description() - .map_err(|e| format!("failed to read description: {}", e))?; - let remote_desc = tr.tr.read_description() - .map_err(|e| format!("failed to read description: {}", e))?; - assert_eq!(remote_desc, local_desc); - exit(2); - } + let local_desc = tr_local.read_description() + .map_err(|e| format!("failed to read description: {}", e))?; + let remote_desc = tr.tr.read_description() + .map_err(|e| format!("failed to read description: {}", e))?; + assert_eq!(remote_desc, local_desc); + exit(2); } if tr.id == txnid { @@ -558,9 +530,9 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res let config_path = format!("config-{}.boc", txnid); if !std::path::Path::new(config_path.as_str()).exists() { println!("Computing config: replaying {} up to {}", acc, txnid); - replay(format!("{}.txns", acc).as_str(),Some(config_txns_path.as_str()), + replay(format!("{}.txns", acc).as_str(),config_txns_path.as_str(), txnid, None, || Ok(()), DUMP_CONFIG, - config, false, true + config, None ).await.map_err(err_msg)?; } else { println!("Using pre-computed config {}", config_path); @@ -575,14 +547,13 @@ pub async fn fetch_block(config: &Config, block_id: &str, filename: &str) -> Res if !std::path::Path::new(format!("{}-{}.boc", account_filename, txnid).as_str()).exists() { replay( format!("{}.txns", account_filename).as_str(), - Some(format!("{}.txns", CONFIG_ADDR).as_str()), + format!("{}.txns", CONFIG_ADDR).as_str(), &txnid, None, || Ok(()), DUMP_ACCOUNT, &_config, - false, - true, + None, ).await.map_err(err_msg).unwrap(); } }) @@ -658,15 +629,14 @@ pub async fn fetch_command(m: &ArgMatches<'_>, config: &Config) -> Result<(), St } pub async fn replay_command(m: &ArgMatches<'_>, cli_config: &Config) -> Result<(), String> { - let (config_txns, load_config) = if m.is_present("CURRENT_CONFIG") { - ("", true) + let (config_txns, bc_config) = if m.is_present("DEFAULT_CONFIG") { + ("", Some(get_blockchain_config(cli_config, None).await?)) } else { - (m.value_of("CONFIG_TXNS").ok_or("Missing config txns filename")?, false) + (m.value_of("CONFIG_TXNS").ok_or("Missing config txns filename")?, None) }; let _ = replay(m.value_of("INPUT_TXNS").ok_or("Missing input txns filename")?, - Some(config_txns), m.value_of("TXNID").ok_or("Missing final txn id")?, - None, ||{Ok(())}, DUMP_ALL, cli_config, - load_config, !m.is_present("IGNORE_HASHES") + config_txns, m.value_of("TXNID").ok_or("Missing final txn id")?, + None, ||{Ok(())}, DUMP_ALL, cli_config, bc_config ).await?; Ok(()) } From 5f86e50eac3c1335c4ca463934fcf4f1b643a432 Mon Sep 17 00:00:00 2001 From: tonjen Date: Tue, 25 Oct 2022 08:35:09 +0000 Subject: [PATCH 17/25] Preparing to merge with the master --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index baea3361..3c6f0971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,7 +208,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap 3.2.21", + "clap 3.2.23", "env_logger", "lazy_static", "lazycell", @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.21" +version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", "bitflags", @@ -445,7 +445,7 @@ dependencies = [ "indexmap", "strsim 0.10.0", "termcolor", - "textwrap 0.15.0", + "textwrap 0.16.0", ] [[package]] @@ -1097,9 +1097,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes", "fnv", @@ -1553,14 +1553,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -2649,9 +2649,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" From a8b1c827e566dc5cf0cda338921728ef4f6ae2b1 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Tue, 25 Oct 2022 22:19:08 +0300 Subject: [PATCH 18/25] Added ability to decode message by id Also improved message decoding input automatic parse --- Cargo.lock | 135 ++++++++++++++++++++++------------------ src/decode.rs | 54 ++++++++++++---- src/helpers.rs | 27 ++++++-- tests/deploy_msg.base64 | 1 + tests/test_cli.rs | 15 ++++- 5 files changed, 152 insertions(+), 80 deletions(-) create mode 100644 tests/deploy_msg.base64 diff --git a/Cargo.lock b/Cargo.lock index 4aba5845..2b02f847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "api_derive" @@ -180,9 +180,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bincode" @@ -403,7 +403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "344adc371239ef32293cb1c4fe519592fcf21206c79c02854320afcdf3ab4917" dependencies = [ "percent-encoding", - "time 0.3.15", + "time 0.3.16", "version_check", ] @@ -419,7 +419,7 @@ dependencies = [ "publicsuffix", "serde", "serde_json", - "time 0.3.15", + "time 0.3.16", "url", ] @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" dependencies = [ "cc", "cxxbridge-flags", @@ -566,9 +566,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" dependencies = [ "cc", "codespan-reporting", @@ -581,15 +581,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" [[package]] name = "cxxbridge-macro" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -795,9 +795,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -805,15 +805,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -822,15 +822,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -839,21 +839,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -899,9 +899,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -916,9 +916,9 @@ checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "h2" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes", "fnv", @@ -1212,9 +1212,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" [[package]] name = "libsecp256k1" @@ -1338,14 +1338,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -1545,9 +1545,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.76" +version = "0.9.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" dependencies = [ "autocfg", "cc", @@ -1826,7 +1826,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", ] [[package]] @@ -1885,7 +1885,7 @@ version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "bytes", "cookie", "cookie_store", @@ -2014,18 +2014,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -2034,9 +2034,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "indexmap", "itoa", @@ -2224,9 +2224,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", @@ -2326,21 +2326,32 @@ dependencies = [ [[package]] name = "time" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c" +checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" dependencies = [ "itoa", "libc", "num_threads", + "serde", + "time-core", "time-macros", ] +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + [[package]] name = "time-macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +dependencies = [ + "time-core", +] [[package]] name = "tiny-bip39" @@ -2514,7 +2525,7 @@ name = "ton_block" version = "1.8.3" source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 3.0.0", "ed25519", "ed25519-dalek", @@ -2532,7 +2543,7 @@ name = "ton_block_json" version = "0.7.33" source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "failure", "hex 0.4.3", "num", @@ -2676,7 +2687,7 @@ name = "ton_types" version = "1.11.4" source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "crc 1.8.1", "failure", "hex 0.4.3", @@ -2794,7 +2805,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "byteorder", "bytes", "http", diff --git a/src/decode.rs b/src/decode.rs index 8cd64f5a..0828b476 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -12,7 +12,7 @@ */ use crate::{load_abi, print_args}; use crate::config::Config; -use crate::helpers::{decode_msg_body, print_account, create_client_local, create_client_verbose, query_account_field, abi_from_matches_or_config, load_ton_address, load_ton_abi}; +use crate::helpers::{decode_msg_body, print_account, create_client_local, create_client_verbose, query_account_field, abi_from_matches_or_config, load_ton_address, load_ton_abi, create_client, query_message}; use clap::{ArgMatches, SubCommand, Arg, App, AppSettings}; use ton_types::cells_serialization::serialize_tree_of_cells; use ton_types::{Cell, SliceData}; @@ -55,14 +55,14 @@ pub fn create_decode_command<'a, 'b>() -> App<'a, 'b> { .about("Decodes message file.") .arg(Arg::with_name("MSG") .required(true) - .help("Path to the message boc file (with binary data) or message in base64 if corresponding flag is used.")) + .help("Path to the message boc file (with binary data), message in base64 or message id.")) .arg(Arg::with_name("ABI") .long("--abi") .takes_value(true) .help("Path or link to the contract ABI file or pure json ABI data. Can be specified in the config file.")) .arg(Arg::with_name("BASE64") .long("--base64") - .help("Flag that changes behavior of the command to work with data in base64."))) + .help("Flag that changes behavior of the command to work with data in base64 (FLAG IS DEPRECATED)."))) .subcommand(tvc_cmd) .subcommand(SubCommand::with_name("account") .about("Top level command of account decode commands.") @@ -231,17 +231,45 @@ async fn decode_message_command(m: &ArgMatches<'_>, config: &Config) -> Result<( if !config.is_json { print_args!(msg, abi); } - let is_base64 = m.is_present("BASE64"); - let msg = msg.map(|msg| if is_base64 { - base64::decode(msg) - .map_err(|e| format!(" failed to decode msg in base64: {}", e)) + if m.is_present("BASE64") && !config.is_json { + println!("Flag --base64 is deprecated. Command can be used for base64 input without this flag.") + } + let input = msg.unwrap(); + let decoded_message = if std::path::Path::new(input).exists() { + let msg_bytes = std::fs::read(input) + .map_err(|e| format!(" failed to read msg from file {input}: {}", e))?; + match decode_message(msg_bytes.clone(), abi.clone()).await { + Ok(result) => result, + Err(e) => { + let message_str = String::from_utf8(msg_bytes) + .map_err(|_| format!("Failed to decode message from file: {e}"))?; + let message_bytes = base64::decode(&message_str) + .map_err(|e2| format!("Failed to decode message data: {e2}"))?; + decode_message(message_bytes, abi).await + .map_err(|e2| format!("Failed to decode message from file: {e2}"))? + } + } } else { - std::fs::read(msg) - .map_err(|e| format!(" failed to read msg from file {msg}: {}", e)) - }) - .transpose()? - .unwrap(); - println!("{}", decode_message(msg, abi).await?); + let base64_decode = base64::decode(input) + .map_err(|e| format!("{e}")); + let msg_decode = match base64_decode { + Ok(base64_decode) => decode_message(base64_decode, abi.clone()).await, + Err(e) => Err(e) + }; + match msg_decode { + Ok(result) => result, + Err(e) => { + let ton_client = create_client(config)?; + let query_boc = query_message(ton_client, input).await + .map_err(|e2| format!("Failed to decode message, specify path to the file, message id or message in base64.\nBase64 error: {e}\nQuery error: {e2}"))?; + let message_bytes = base64::decode(&query_boc) + .map_err(|e2| format!("Failed to decode queried message: {e2}"))?; + decode_message(message_bytes, abi).await + .map_err(|e2| format!("Failed to decode queried message: {e2}"))? + } + } + }; + println!("{decoded_message}"); Ok(()) } diff --git a/src/helpers.rs b/src/helpers.rs index e89f7b17..c861d362 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -194,7 +194,6 @@ pub fn create_client_verbose(config: &Config) -> Result { create_client(config) } - pub async fn query_raw( config: &Config, collection: &str, @@ -229,15 +228,14 @@ pub async fn query_raw( Ok(()) } - pub async fn query_with_limit( ton: TonClient, collection: &str, - filter: serde_json::Value, + filter: Value, result: &str, order: Option>, limit: Option, -) -> Result, ClientError> { +) -> Result, ClientError> { query_collection( ton, ParamsOfQueryCollection { @@ -253,6 +251,27 @@ pub async fn query_with_limit( .map(|r| r.result) } +pub async fn query_message( + ton: TonClient, + message_id: &str, +) -> Result { + let messages = query_with_limit( + ton.clone(), + "messages", + json!({ "id": { "eq": message_id } }), + "boc", + None, + Some(1), + ).await + .map_err(|e| format!("failed to query account data: {}", e))?; + if messages.is_empty() { + Err("message with specified id was not found.".to_string()) + } + else { + Ok(messages[0]["boc"].as_str().ok_or("Failed to obtain message boc.".to_string())?.to_string()) + } +} + pub async fn query_account_field(ton: TonClient, address: &str, field: &str) -> Result { let accounts = query_with_limit( ton.clone(), diff --git a/tests/deploy_msg.base64 b/tests/deploy_msg.base64 new file mode 100644 index 00000000..a8f83e49 --- /dev/null +++ b/tests/deploy_msg.base64 @@ -0,0 +1 @@ +te6ccgEBAgEAmQABRYgB/rmZKcHzzi5BRDu5n6pAqFnu7N2hpndIXAJYJ6T0vxYMAQDh0UERCirTGCONy01m6S+RgGVDIUsyXy8cm2zA7b0wCSQVCbMZLF7CBKn6IcPHFMSOobuEBwsCEG+k/cSz70qgA4AAAMGLxyvCMYw7TBL32QQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMsA= \ No newline at end of file diff --git a/tests/test_cli.rs b/tests/test_cli.rs index 52f350b3..c73f1283 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -1260,7 +1260,20 @@ fn test_decode_msg() -> Result<(), Box> { cmd.arg("--json") .arg("decode") .arg("msg") - .arg("--base64") + .arg("tests/deploy_msg.base64") + .arg("--abi") + .arg("tests/samples/accumulator.abi.json") + .assert() + .success() + .stdout(predicate::str::contains(r#"Type": "external inbound message"#)) + .stdout(predicate::str::contains(r#""destination": "0:ff5ccc94e0f9e71720a21ddccfd520542cf7766ed0d33ba42e012c13d27a5f8b"#)) + .stdout(predicate::str::contains(r#""Body": "te6ccgEBAQEAcwAA4dFBEQoq0xgjjctNZukvkYBlQyFLMl8vHJtswO29MAkkFQmzGSxewgSp+iHDxxTEjqG7hAcLAhBvpP3Es+9KoAOAAADBi8crwjGMO0wS99kEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADLA""#)) + .stdout(predicate::str::contains(r#""value": "0x0000000000000000000000000000000000000000000000000000000000000065""#)); + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("--json") + .arg("decode") + .arg("msg") .arg("te6ccgEBAgEAmQABRYgB/rmZKcHzzi5BRDu5n6pAqFnu7N2hpndIXAJYJ6T0vxYMAQDh0UERCirTGCONy01m6S+RgGVDIUsyXy8cm2zA7b0wCSQVCbMZLF7CBKn6IcPHFMSOobuEBwsCEG+k/cSz70qgA4AAAMGLxyvCMYw7TBL32QQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMsA=") .arg("--abi") .arg("tests/samples/accumulator.abi.json") From aa723ef7083e2289a341495c60b427d1fce6a465 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Tue, 25 Oct 2022 22:19:47 +0300 Subject: [PATCH 19/25] Updated version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b02f847..d6e7023f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2726,7 +2726,7 @@ dependencies = [ [[package]] name = "tonos-cli" -version = "0.28.21" +version = "0.28.22" dependencies = [ "assert_cmd", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 3190dd07..f2eea264 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.28.21' +version = '0.28.22' [dependencies] async-trait = '0.1.42' From c2e25affe5ad73f68d84b4a4db0c079f9bf93833 Mon Sep 17 00:00:00 2001 From: tonjen Date: Wed, 26 Oct 2022 08:32:15 +0000 Subject: [PATCH 20/25] Preparing to merge with the master --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6e7023f..3836f58d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1212,9 +1212,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.136" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libsecp256k1" @@ -1652,9 +1652,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "pom" From c8045aae28ac96dbac29e638f896099b5e763750 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Wed, 26 Oct 2022 20:11:43 +0300 Subject: [PATCH 21/25] Added test --- Cargo.lock | 6 +++--- tests/common/mod.rs | 11 +++++++++++ tests/test_cli.rs | 31 ++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3836f58d..e4664ced 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2523,7 +2523,7 @@ dependencies = [ [[package]] name = "ton_block" version = "1.8.3" -source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" +source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#86ae75c09870cd947b94f7f42257727533a5e7b0" dependencies = [ "base64 0.13.1", "crc 3.0.0", @@ -2541,7 +2541,7 @@ dependencies = [ [[package]] name = "ton_block_json" version = "0.7.33" -source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" +source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#6b93bce23702c86992191af383095a3f1f81c98f" dependencies = [ "base64 0.13.1", "failure", @@ -2685,7 +2685,7 @@ dependencies = [ [[package]] name = "ton_types" version = "1.11.4" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" +source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#363c35e9d0d7e954bbfc2e845f8a51b9dbbc166d" dependencies = [ "base64 0.13.1", "crc 1.8.1", diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 35c0c23a..8a986c39 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -86,6 +86,17 @@ pub fn grep_address(output: &[u8]) -> String { addr } +#[allow(dead_code)] +pub fn grep_message_id(output: &[u8]) -> String { + let mut message_id = String::from_utf8_lossy(output).to_string(); + let index = message_id.find("MessageId: ").map(|i| i + "MessageId: ".len()).unwrap_or(0); + message_id.replace_range(..index, ""); + if message_id.len() >= 64 { + message_id.replace_range(64.., ""); + } + message_id +} + #[allow(dead_code)] pub fn generate_key_and_address( key_path: &str, diff --git a/tests/test_cli.rs b/tests/test_cli.rs index c73f1283..8e223d18 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -10,6 +10,7 @@ mod common; use common::{BIN_NAME, NETWORK, giver_v2, grep_address, set_config, GIVER_V2_ABI, GIVER_V2_ADDR, GIVER_V2_KEY, generate_key_and_address, GIVER_ABI, generate_phrase_and_key}; +use crate::common::grep_message_id; const DEPOOL_ABI: &str = "tests/samples/fakeDepool.abi.json"; const DEPOOL_TVC: &str = "tests/samples/fakeDepool.tvc"; @@ -1236,7 +1237,6 @@ fn test_decode_msg() -> Result<(), Box> { .arg(SAFEMSIG_ABI_LINK) .assert() .success() - .stdout(predicate::str::contains("sendTransaction")) .stdout(predicate::str::contains("dest")) .stdout(predicate::str::contains("value")) .stdout(predicate::str::contains("bounce")) @@ -1284,6 +1284,35 @@ fn test_decode_msg() -> Result<(), Box> { .stdout(predicate::str::contains(r#""Body": "te6ccgEBAQEAcwAA4dFBEQoq0xgjjctNZukvkYBlQyFLMl8vHJtswO29MAkkFQmzGSxewgSp+iHDxxTEjqG7hAcLAhBvpP3Es+9KoAOAAADBi8crwjGMO0wS99kEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADLA""#)) .stdout(predicate::str::contains(r#""value": "0x0000000000000000000000000000000000000000000000000000000000000065""#)); + let mut cmd = Command::cargo_bin(BIN_NAME)?; + let output = cmd.arg("call") + .arg("--abi") + .arg(GIVER_V2_ABI) + .arg(GIVER_V2_ADDR) + .arg("--sign") + .arg(GIVER_V2_KEY) + .arg("sendTransaction") + .arg(format!(r#"{{"dest":"{}","value":100000000000,"bounce":false}}"#, GIVER_V2_ADDR)) + .output() + .expect("Failed to send message."); + + let message_id = grep_message_id(&output.stdout); + + let mut cmd = Command::cargo_bin(BIN_NAME)?; + cmd.arg("--json") + .arg("decode") + .arg("msg") + .arg(message_id) + .arg("--abi") + .arg(GIVER_V2_ABI) + .assert() + .success() + .stdout(predicate::str::contains("dest")) + .stdout(predicate::str::contains("value")) + .stdout(predicate::str::contains("bounce")) + .stdout(predicate::str::contains("BodyCall")) + .stdout(predicate::str::contains("sendTransaction")); + Ok(()) } From 183b1abe8c9ca4a85f74603b01081ae5228bf5a6 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Wed, 26 Oct 2022 20:16:26 +0300 Subject: [PATCH 22/25] Updated lock --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c6f0971..06495584 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1411,9 +1411,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.136" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libloading" @@ -1889,9 +1889,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "pom" @@ -2883,7 +2883,7 @@ dependencies = [ [[package]] name = "ton_block" version = "1.8.3" -source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" +source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#86ae75c09870cd947b94f7f42257727533a5e7b0" dependencies = [ "base64 0.13.1", "crc 3.0.0", @@ -2901,7 +2901,7 @@ dependencies = [ [[package]] name = "ton_block_json" version = "0.7.33" -source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" +source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#6b93bce23702c86992191af383095a3f1f81c98f" dependencies = [ "base64 0.13.1", "failure", @@ -3004,7 +3004,7 @@ dependencies = [ [[package]] name = "ton_labs_assembler" version = "1.2.49" -source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.49#3402cd94fe15dfc249acbf891d40a41fface87c3" +source = "git+https://github.com/tonlabs/ton-labs-assembler.git?tag=1.2.49#6d5c1f2c13b726d48523a791c769d69d7511337f" dependencies = [ "failure", "hex 0.4.3", @@ -3060,7 +3060,7 @@ dependencies = [ [[package]] name = "ton_types" version = "1.11.4" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" +source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#363c35e9d0d7e954bbfc2e845f8a51b9dbbc166d" dependencies = [ "base64 0.13.1", "crc 1.8.1", From 12dfc65ae21819b85da89652f1df3938e559d917 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Wed, 26 Oct 2022 21:12:35 +0300 Subject: [PATCH 23/25] Updated lock --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5457351..d110126d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -916,9 +916,9 @@ checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "h2" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes", "fnv", @@ -1212,9 +1212,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.136" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libsecp256k1" @@ -1338,14 +1338,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -1652,9 +1652,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "pom" @@ -2523,7 +2523,7 @@ dependencies = [ [[package]] name = "ton_block" version = "1.8.3" -source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#19a77eb0cccf6dc097ac934458976e1e91402ade" +source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.8.3#86ae75c09870cd947b94f7f42257727533a5e7b0" dependencies = [ "base64 0.13.1", "crc 3.0.0", @@ -2541,7 +2541,7 @@ dependencies = [ [[package]] name = "ton_block_json" version = "0.7.33" -source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#04cd85e67446e0cdb78c163433c9fba01f074aaa" +source = "git+https://github.com/tonlabs/ton-labs-block-json.git?tag=0.7.33#6b93bce23702c86992191af383095a3f1f81c98f" dependencies = [ "base64 0.13.1", "failure", @@ -2685,7 +2685,7 @@ dependencies = [ [[package]] name = "ton_types" version = "1.11.4" -source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#7f0063faa486298ba57ceb97e1d6e38447d6e0e3" +source = "git+https://github.com/tonlabs/ton-labs-types.git?tag=1.11.4#363c35e9d0d7e954bbfc2e845f8a51b9dbbc166d" dependencies = [ "base64 0.13.1", "crc 1.8.1", From 4228ebc48657c044d7477cb29c121013a8721849 Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Thu, 27 Oct 2022 14:26:53 +0300 Subject: [PATCH 24/25] Updated readme and changelog --- CHANGELOG.md | 10 ++- Cargo.lock | 170 +++------------------------------------------- Cargo.toml | 4 +- README.md | 62 +++++++++++++++++ tests/test_cli.rs | 4 +- 5 files changed, 83 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b49844..bd03ae38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,20 @@ All notable changes to this project will be documented in this file. +## Version: 0.29.1 + +### New +- Improved behavior of the `decode msg` command. Now it doesn't require `--base64` flag to decode base64 input. It can + also decode message by id in the blockchain and decode files with messages not in binary but with text in base64; +- Changed `debug transaction` and `debug account` commands flag `--empty_config` to `--default_config` which uses + current network config or default one if it is unavailable; +- Added [sold](https://github.com/tonlabs/TON-Solidity-Compiler/tree/master/sold) functionality as feature. + ## Version: 0.28.12 ### New - Added ability to specify link to the abi file of json data instead of path. - ## Version: 0.28.3 ### Breaking changes: diff --git a/Cargo.lock b/Cargo.lock index e84adec6..6c2e9813 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,29 +199,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.60.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" -dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "clap 3.2.23", - "env_logger", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "which", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -344,15 +321,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -407,17 +375,6 @@ dependencies = [ "generic-array 0.14.6", ] -[[package]] -name = "clang-sys" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "2.34.0" @@ -428,26 +385,11 @@ dependencies = [ "atty", "bitflags", "strsim 0.8.0", - "textwrap 0.11.0", + "textwrap", "unicode-width", "vec_map", ] -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "atty", - "bitflags", - "clap_lex 0.2.4", - "indexmap", - "strsim 0.10.0", - "termcolor", - "textwrap 0.16.0", -] - [[package]] name = "clap" version = "4.0.18" @@ -457,7 +399,7 @@ dependencies = [ "atty", "bitflags", "clap_derive", - "clap_lex 0.3.0", + "clap_lex", "once_cell", "strsim 0.10.0", "termcolor", @@ -476,15 +418,6 @@ dependencies = [ "syn", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.3.0" @@ -858,19 +791,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "extfmt" version = "0.1.1" @@ -1089,12 +1009,6 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "h2" version = "0.3.15" @@ -1233,12 +1147,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.20" @@ -1403,28 +1311,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if", - "winapi", -] - [[package]] name = "libsecp256k1" version = "0.6.0" @@ -1536,12 +1428,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.5.4" @@ -1581,16 +1467,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nom" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1843,12 +1719,6 @@ dependencies = [ "digest 0.10.5", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.2.0" @@ -2404,12 +2274,6 @@ dependencies = [ "digest 0.10.5", ] -[[package]] -name = "shlex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" - [[package]] name = "signal-hook" version = "0.3.14" @@ -2513,11 +2377,10 @@ dependencies = [ [[package]] name = "sold" -version = "0.65.0" -source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?branch=test#45543cf0cb2ae889fd31eaa4a35763a8e16a29e1" +version = "0.66.0" +source = "git+https://github.com/tonlabs/TON-Solidity-Compiler.git?tag=0.66.0#0436b43674dad4e61e7ccb910df169735f324eae" dependencies = [ "atty", - "bindgen", "clap 4.0.18", "cmake", "dunce", @@ -2647,12 +2510,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.37" @@ -3101,7 +2958,7 @@ dependencies = [ [[package]] name = "tonos-cli" -version = "0.28.22" +version = "0.29.1" dependencies = [ "assert_cmd", "async-trait", @@ -3197,8 +3054,8 @@ dependencies = [ [[package]] name = "tvm_linker" -version = "0.18.3" -source = "git+https://github.com/tonlabs/TVM-linker.git?tag=0.18.3#afb91fa5bac8d4343fa38bd510d0f5a47cf86278" +version = "0.18.4" +source = "git+https://github.com/tonlabs/TVM-linker.git?tag=0.18.4#4e97449a48c05600af00027d652519de61190b53" dependencies = [ "base64 0.13.1", "clap 2.34.0", @@ -3211,7 +3068,7 @@ dependencies = [ "log", "num", "num-traits", - "rand 0.7.3", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -3438,17 +3295,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "which" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" -dependencies = [ - "either", - "libc", - "once_cell", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 3bb18094..d82eb110 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'tonos-cli' readme = 'README.md' repository = 'https://github.com/tonlabs/tonos-cli' -version = '0.28.22' +version = '0.29.1' [features] sold = ["dep:sold"] @@ -56,7 +56,7 @@ ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.38.0' } ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.4' } ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.44' } ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.33' } -sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', branch = 'test', optional = true } +sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', tag = '0.66.0', optional = true } [dev-dependencies] assert_cmd = '1.0.3' diff --git a/README.md b/README.md index ed7b07ea..2e7b9280 100644 --- a/README.md +++ b/README.md @@ -3494,3 +3494,65 @@ Connecting to: Endpoints: ["https://mainnet.evercloud.dev/b2ad82504ff54fccb5bc6db8cbb3df1e" ... ``` + +## 14. Sold + +Starting from version 0.29.1 [sold](https://github.com/tonlabs/TON-Solidity-Compiler/tree/master/sold) functionality was +added to the tonos-cli. To use it one should build tonos-cli with corresponding feature: + +```bash +$ cargo build --release -F sold +``` + +tonos-cli build with such feature has command `compile solidity` which can compile source files with +[Solidity](https://github.com/tonlabs/TON-Solidity-Compiler) code. + +```bash +tonos-cli compile solidity [FLAGS] [OPTIONS] +``` + +FLAGS: + +`--abi-json` Get ABI without actual compilation. +`--ast-compact-json` Get AST of all source files in compact JSON format. +`--ast-json` Get AST of all source files in JSON format. +`--function-ids` Print name and id for each public function. +`--print_code` After ASM compilation do not generate TVC but print the code cell only. +`--private-function-ids` Print name and id for each private function. +`--tvm-refresh-remote` Force download and rewrite remote import files. + + +OPTIONS: + +`-c, --contract ` Contract to build if sources define more than one contract. +`--genkey ` Path to the file, where a new generated keypair for the contract will be saved. +`-I, --include-path ` Include additional path to search for imports. +`-L, --lib ` Library to use instead of default. +`-O, --output-dir ` Output directory (by default, current directory is used). +`-P, --output-prefix ` Output prefix (by default, input file stem is used as prefix). +`--setkey ` Seed phrase or path to the file with keypair. +`--wc ` Workchain id of the smart contract (default value is taken from the config). + +ARGS: + +`` Path to the Solidity source file. + +Example: + +```bash +$ tonos-cli compile solidity tests/samples/1_Accumulator.sol --genkey contract.key +Contract successfully compiled. Saved to file 1_Accumulator.tvc. +Contract initial hash: 2712519fefb219d76d640028943fe76287a280e3a9e75a0700147cea4e1b94c6 +Path to the TVC file: ./1_Accumulator.tvc +TVC file updated + +Seed phrase: "shallow lake thumb fantasy ship gift frog august crouch sausage ecology ecology" +Raw address: 0:956172c7577ca004f1f117e1aea8e99a37143dac7a1954dc8f013dfd77b897ad +testnet: +Non-bounceable address (for init): 0QCVYXLHV3ygBPHxF-GuqOmaNxQ9rHoZVNyPAT39d7iXra_6 +Bounceable address (for later access): kQCVYXLHV3ygBPHxF-GuqOmaNxQ9rHoZVNyPAT39d7iXrfI_ +mainnet: +Non-bounceable address (for init): UQCVYXLHV3ygBPHxF-GuqOmaNxQ9rHoZVNyPAT39d7iXrRRw +Bounceable address (for later access): EQCVYXLHV3ygBPHxF-GuqOmaNxQ9rHoZVNyPAT39d7iXrUm1 +Succeeded +``` \ No newline at end of file diff --git a/tests/test_cli.rs b/tests/test_cli.rs index d11e9a3f..2537385e 100644 --- a/tests/test_cli.rs +++ b/tests/test_cli.rs @@ -3310,7 +3310,7 @@ fn test_solidity_compile() -> Result<(), Box> { .arg(format!("{contract_path}.sol")); cmd.assert() .success() - .stdout(predicate::str::contains("Raw address: 0:f45b9b2538dcc4aef9d2b6e43228e73157a63ea27c78589135fbf29a16e6354a")); + .stdout(predicate::str::contains("Raw address: 0:2712519fefb219d76d640028943fe76287a280e3a9e75a0700147cea4e1b94c6")); check_compiled_files_and_delete("1_Accumulator")?; @@ -3324,7 +3324,7 @@ fn test_solidity_compile() -> Result<(), Box> { .arg("contract"); cmd.assert() .success() - .stdout(predicate::str::contains("Raw address: 0:f45b9b2538dcc4aef9d2b6e43228e73157a63ea27c78589135fbf29a16e6354a")); + .stdout(predicate::str::contains("Raw address: 0:2712519fefb219d76d640028943fe76287a280e3a9e75a0700147cea4e1b94c6")); check_compiled_files_and_delete("tests/samples/contract")?; From 6739849bed1bbb41dd126e688a2a57e58a538dfc Mon Sep 17 00:00:00 2001 From: SilkovAlexander Date: Fri, 28 Oct 2022 14:00:15 +0300 Subject: [PATCH 25/25] Removed option saved config from call and run commands --- CHANGELOG.md | 3 ++- Cargo.lock | 8 ++++---- src/call.rs | 17 +++++++---------- src/debug.rs | 44 ++++++++------------------------------------ src/main.rs | 19 ++++--------------- src/multisig.rs | 2 -- src/run.rs | 5 ++--- src/voting.rs | 3 --- 8 files changed, 27 insertions(+), 74 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd03ae38..40acffa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file. ## Version: 0.29.1 ### New +- Added [sold](https://github.com/tonlabs/TON-Solidity-Compiler/tree/master/sold) functionality as feature; - Improved behavior of the `decode msg` command. Now it doesn't require `--base64` flag to decode base64 input. It can also decode message by id in the blockchain and decode files with messages not in binary but with text in base64; - Changed `debug transaction` and `debug account` commands flag `--empty_config` to `--default_config` which uses current network config or default one if it is unavailable; -- Added [sold](https://github.com/tonlabs/TON-Solidity-Compiler/tree/master/sold) functionality as feature. +- Removed option `--saved_config` from call and run commands. ## Version: 0.28.12 diff --git a/Cargo.lock b/Cargo.lock index 6c2e9813..471d296a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1186,9 +1186,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" +checksum = "c422fb4f6e80490d0afcacf5c3de2c22ab8e631e0cd7cb2d4a3baf844720a52a" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1668,9 +1668,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" [[package]] name = "owned-alloc" diff --git a/src/call.rs b/src/call.rs index ef7812c5..b3a5ada7 100644 --- a/src/call.rs +++ b/src/call.rs @@ -12,7 +12,8 @@ */ use crate::config::Config; use crate::convert; -use crate::helpers::{TonClient, now_ms, create_client_verbose, load_abi, query_account_field, SDK_EXECUTION_ERROR_CODE, create_client, load_ton_abi}; +use crate::helpers::{TonClient, now_ms, create_client_verbose, load_abi, query_account_field, + SDK_EXECUTION_ERROR_CODE, create_client, load_ton_abi, get_blockchain_config}; use ton_client::abi::{encode_message, decode_message, ParamsOfDecodeMessage, ParamsOfEncodeMessage, Abi}; @@ -31,7 +32,6 @@ use ton_client::tvm::{ }; use ton_block::{Account, Serializable, Deserializable, Message}; use std::str::FromStr; -use clap::ArgMatches; use serde_json::{Value}; use ton_abi::ParamType; use ton_client::error::ClientError; @@ -256,7 +256,6 @@ pub async fn call_contract_with_result( params: &str, keys: Option, is_fee: bool, - matches: Option<&ArgMatches<'_>>, ) -> Result { let ton = if config.debug_fail != "None".to_string() { let log_path = format!("call_{}_{}.log", addr, method); @@ -268,7 +267,7 @@ pub async fn call_contract_with_result( } else { create_client_verbose(config)? }; - call_contract_with_client(ton, config, addr, abi_path, method, params, keys, is_fee, matches).await + call_contract_with_client(ton, config, addr, abi_path, method, params, keys, is_fee).await } pub async fn call_contract_with_client( @@ -280,7 +279,6 @@ pub async fn call_contract_with_client( params: &str, keys: Option, is_fee: bool, - matches: Option<&ArgMatches<'_>>, ) -> Result { let abi = load_abi(abi_path, config).await?; @@ -331,7 +329,7 @@ pub async fn call_contract_with_client( .map_err(|e| format!("Failed to serialize account: {}", e))?; let now = now_ms(); - Some((account, message.unwrap(), now)) + Some((account, message.unwrap(), now, get_blockchain_config(config, None).await?)) } else { None }; @@ -351,10 +349,10 @@ pub async fn call_contract_with_client( println!("Error: {:#}", res.clone().err().unwrap()); println!("Execution failed. Starting debug..."); } - let (mut account, message, now) = dump.unwrap(); + let (mut account, message, now, bc_config) = dump.unwrap(); let message = Message::construct_from_base64(&message) .map_err(|e| format!("failed to construct message: {}", e))?; - let _ = execute_debug(matches, Some(ton.clone()), &mut account, Some(&message), (now / 1000) as u32, now,now, false, config).await?; + let _ = execute_debug(bc_config, &mut account, Some(&message), (now / 1000) as u32, now,now, false, config).await?; if !config.is_json { let log_path = format!("call_{}_{}.log", addr, method); @@ -387,9 +385,8 @@ pub async fn call_contract( params: &str, keys: Option, is_fee: bool, - matches: Option<&ArgMatches<'_>>, ) -> Result<(), String> { - let result = call_contract_with_result(config, addr, abi_path, method, params, keys, is_fee, matches).await?; + let result = call_contract_with_result(config, addr, abi_path, method, params, keys, is_fee).await?; if !config.is_json { println!("Succeeded."); } diff --git a/src/debug.rs b/src/debug.rs index 9b0ab934..d936484a 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -15,11 +15,11 @@ use crate::{contract_data_from_matches_or_config_alias, FullConfig, print_args, use clap::{ArgMatches, SubCommand, Arg, App}; use crate::config::Config; use crate::helpers::{load_ton_address, create_client, load_abi, now_ms, construct_account_from_tvc, - TonClient, query_account_field, query_with_limit, create_client_verbose, + query_account_field, query_with_limit, create_client_verbose, abi_from_matches_or_config, load_debug_info, wc_from_matches_or_config, TEST_MAX_LEVEL, MAX_LEVEL, get_blockchain_config}; use crate::replay::{ - fetch, CONFIG_ADDR, replay, DUMP_NONE, DUMP_CONFIG, DUMP_ACCOUNT, construct_blockchain_config + fetch, CONFIG_ADDR, replay, DUMP_NONE, DUMP_CONFIG, DUMP_ACCOUNT }; use std::io::{Write, BufRead}; use std::collections::{HashSet, HashMap}; @@ -540,8 +540,7 @@ async fn replay_transaction_command(matches: &ArgMatches<'_>, config: &Config) - ).map_err(|e| format!("Failed to set logger: {}", e))?; let result_trans = execute_debug( - Some(matches), - Some(ton_client), + get_blockchain_config(config, config_path).await?, &mut account, msg.as_ref(), trans.now(), @@ -694,8 +693,7 @@ async fn debug_call_command(matches: &ArgMatches<'_>, full_config: &FullConfig, ).map_err(|e| format!("Failed to set logger: {}", e))?; let trans = execute_debug( - Some(matches), - Some(ton_client), + get_blockchain_config(&full_config.config, matches.value_of("CONFIG_PATH")).await?, &mut acc_root, Some(&message), (now / 1000) as u32, @@ -794,8 +792,7 @@ async fn debug_message_command(matches: &ArgMatches<'_>, config: &Config) -> Res let now = parse_now(matches)?; let trans = execute_debug( - Some(matches), - Some(ton_client), + get_blockchain_config(config, matches.value_of("CONFIG_PATH")).await?, &mut acc_root, Some(&message), (now / 1000) as u32, @@ -903,8 +900,7 @@ async fn debug_deploy_command(matches: &ArgMatches<'_>, config: &Config) -> Resu let now = parse_now(matches)?; let trans = execute_debug( - Some(matches), - Some(ton_client), + get_blockchain_config(config, matches.value_of("CONFIG_PATH")).await?, &mut acc_root, Some(&message), (now / 1000) as u32, @@ -1050,8 +1046,7 @@ fn choose_transaction(transactions: Vec) -> Result { } pub async fn execute_debug( - matches: Option<&ArgMatches<'_>>, - ton_client: Option, + bc_config: BlockchainConfig, account: &mut Cell, message: Option<&Message>, block_unixtime: u32, @@ -1060,29 +1055,6 @@ pub async fn execute_debug( is_getter: bool, tonos_config: &Config, ) -> Result { - let config_account = match matches { - Some(matches) => { - match matches.value_of("CONFIG_PATH") { - Some(bc_config) => { - Some(Account::construct_from_file(bc_config)) - } - _ => None - } - } - _ => None - }; - let config_account = match config_account { - Some(config_account) => {config_account } - _ => { - let acc = query_account_field( - ton_client.unwrap().clone(), - CONFIG_ADDR, - "boc", - ).await?; - Account::construct_from_base64(&acc) - } - }.map_err(|e| format!("Failed to construct config account: {}", e))?; - let bc_config = construct_blockchain_config(&config_account)?; let bc_config = if is_getter { let mut config = bc_config.raw_config().to_owned(); let gas = GasLimitsPrices { @@ -1118,7 +1090,7 @@ pub async fn execute_debug( last_tr_lt: Arc::new(AtomicU64::new(last_tr_lt)), seed_block: UInt256::default(), debug: true, - trace_callback: generate_callback(matches, tonos_config), + trace_callback: generate_callback(None, tonos_config), ..ExecuteParams::default() }; diff --git a/src/main.rs b/src/main.rs index c3bb0f48..7fc761db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,11 +110,6 @@ async fn main_internal() -> Result <(), String> { .takes_value(true) .help("Seed phrase or path to the file with keypair used to sign the message. Can be specified in the config file."); - let config_path_arg = Arg::with_name("CONFIG_PATH") - .help("Path to the file with saved config contract state. Is used for debug on fail.") - .long("--saved_config") - .takes_value(true); - let method_opt_arg = Arg::with_name("METHOD") .takes_value(true) .long("--method") @@ -141,8 +136,7 @@ async fn main_internal() -> Result <(), String> { .arg(abi_arg.clone()) .arg(keys_arg.clone()) .arg(method_opt_arg.clone()) - .arg(multi_params_arg.clone()) - .arg(config_path_arg.clone()); + .arg(multi_params_arg.clone()); let tvc_arg = Arg::with_name("TVC") .takes_value(true) @@ -212,8 +206,7 @@ async fn main_internal() -> Result <(), String> { .arg(multi_params_arg.clone()) .arg(boc_flag.clone()) .arg(tvc_flag.clone()) - .arg(bc_config_arg.clone()) - .arg(config_path_arg.clone()); + .arg(bc_config_arg.clone()); let runget_cmd = SubCommand::with_name("runget") .about("Runs get-method of a FIFT contract.") @@ -348,8 +341,7 @@ async fn main_internal() -> Result <(), String> { .arg(method_arg.clone()) .arg(params_arg.clone()) .arg(abi_arg.clone()) - .arg(sign_arg.clone()) - .arg(config_path_arg.clone()); + .arg(sign_arg.clone()); let send_cmd = SubCommand::with_name("send") .about("Sends a prepared message to the contract.") @@ -402,8 +394,7 @@ async fn main_internal() -> Result <(), String> { .arg(abi_arg.clone()) .arg(boc_flag.clone()) .arg(tvc_flag.clone()) - .arg(bc_config_arg.clone()) - .arg(config_path_arg.clone()); + .arg(bc_config_arg.clone()); let config_clear_cmd = SubCommand::with_name("clear") .setting(AppSettings::AllowLeadingHyphen) @@ -1236,7 +1227,6 @@ async fn call_command(matches: &ArgMatches<'_>, config: &Config, call: CallType) ¶ms.unwrap(), keys, is_fee, - Some(matches) ).await }, CallType::Msg => { @@ -1293,7 +1283,6 @@ async fn callx_command(matches: &ArgMatches<'_>, full_config: &FullConfig) -> Re ¶ms.unwrap(), keys, false, - Some(matches), ).await } diff --git a/src/multisig.rs b/src/multisig.rs index c55cc47a..be4d7344 100644 --- a/src/multisig.rs +++ b/src/multisig.rs @@ -321,7 +321,6 @@ pub async fn send_with_body( ¶ms, Some(keys.to_owned()), false, - None, ).await } @@ -383,7 +382,6 @@ async fn multisig_deploy_command(matches: &ArgMatches<'_>, config: &Config) -> R ¶ms, None, false, - None, ).await?; } diff --git a/src/run.rs b/src/run.rs index 921e534d..8430116a 100644 --- a/src/run.rs +++ b/src/run.rs @@ -22,7 +22,7 @@ use crate::debug::{execute_debug, DebugLogger}; use crate::helpers::{create_client, now, now_ms, SDK_EXECUTION_ERROR_CODE, TonClient, contract_data_from_matches_or_config_alias, abi_from_matches_or_config, AccountSource, create_client_local, create_client_verbose, load_abi, - load_account, load_params, unpack_alternative_params}; + load_account, load_params, unpack_alternative_params, get_blockchain_config}; use crate::message::prepare_message; pub async fn run_command(matches: &ArgMatches<'_>, full_config: &FullConfig, is_alternative: bool) -> Result<(), String> { @@ -169,8 +169,7 @@ async fn run( let message = Message::construct_from_base64(&msg.message) .map_err(|e| format!("failed to construct message: {}", e))?; match execute_debug( - Some(matches), - Some(ton_client), + get_blockchain_config(config, None).await?, &mut account, Some(&message), (now / 1000) as u32, diff --git a/src/voting.rs b/src/voting.rs index 08f762f7..6e1c0c8f 100644 --- a/src/voting.rs +++ b/src/voting.rs @@ -60,7 +60,6 @@ pub async fn create_proposal( ¶ms, keys, false, - None, ).await } } @@ -102,7 +101,6 @@ pub async fn vote( ¶ms, keys, false, - None, ).await } } @@ -122,7 +120,6 @@ pub async fn decode_proposal( "{}", None, false, - None, ).await?; let txns = result["transactions"].as_array()