diff --git a/Cargo.lock b/Cargo.lock index 198bad71a5..859062f9eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -58,9 +67,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" @@ -92,12 +101,6 @@ dependencies = [ "safemem", ] -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - [[package]] name = "base64" version = "0.12.3" @@ -122,9 +125,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.53.3" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" +checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36" dependencies = [ "bitflags", "cexpr", @@ -281,9 +284,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" dependencies = [ "jobserver", ] @@ -341,7 +344,7 @@ version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ - "ansi_term", + "ansi_term 0.11.0", "atty", "bitflags", "strsim", @@ -460,6 +463,16 @@ dependencies = [ "itertools 0.9.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.7.3" @@ -486,17 +499,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "maybe-uninit", -] - [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -578,7 +580,7 @@ checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] @@ -645,9 +647,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" dependencies = [ "cfg-if", ] @@ -693,7 +695,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", "synstructure", ] @@ -717,9 +719,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" +checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" dependencies = [ "cfg-if", "crc32fast", @@ -892,7 +894,7 @@ checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -1205,23 +1207,23 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "leo-ast" -version = "1.0.0" +version = "1.0.2" dependencies = [ "criterion", "from-pest", "lazy_static", - "log", "pest", "pest-ast", "pest_derive", "serde", "serde_json", "thiserror", + "tracing", ] [[package]] name = "leo-compiler" -version = "1.0.0" +version = "1.0.2" dependencies = [ "bincode", "hex", @@ -1231,7 +1233,6 @@ dependencies = [ "leo-package", "leo-state", "leo-typed", - "log", "num-bigint", "pest", "rand", @@ -1246,11 +1247,13 @@ dependencies = [ "snarkos-objects", "snarkos-utilities", "thiserror", + "tracing", + "tracing-subscriber", ] [[package]] name = "leo-gadgets" -version = "1.0.0" +version = "1.0.2" dependencies = [ "rand", "rand_xorshift", @@ -1262,7 +1265,7 @@ dependencies = [ [[package]] name = "leo-input" -version = "1.0.0" +version = "1.0.2" dependencies = [ "from-pest", "pest", @@ -1278,7 +1281,7 @@ dependencies = [ [[package]] name = "leo-lang" -version = "1.0.0" +version = "1.0.2" dependencies = [ "clap", "colored", @@ -1293,7 +1296,6 @@ dependencies = [ "leo-input", "leo-package", "leo-state", - "log", "notify", "num-bigint", "rand", @@ -1311,29 +1313,31 @@ dependencies = [ "snarkos-utilities", "thiserror", "toml", + "tracing", + "tracing-subscriber", "zip", ] [[package]] -name = "leo-liner" -version = "1.0.0" +name = "leo-linter" +version = "1.0.2" [[package]] name = "leo-package" -version = "1.0.0" +version = "1.0.2" dependencies = [ - "log", "serde", "serde_json", "thiserror", "toml", + "tracing", "walkdir", "zip", ] [[package]] name = "leo-state" -version = "1.0.0" +version = "1.0.2" dependencies = [ "leo-input", "leo-typed", @@ -1352,7 +1356,7 @@ dependencies = [ [[package]] name = "leo-typed" -version = "1.0.0" +version = "1.0.2" dependencies = [ "criterion", "leo-ast", @@ -1366,9 +1370,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" +checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" [[package]] name = "libloading" @@ -1382,9 +1386,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "6.7.4" +version = "6.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" +checksum = "eb5b56f651c204634b936be2f92dbb42c36867e00ff7fe2405591f3b9fa66f09" dependencies = [ "bindgen", "cc", @@ -1394,9 +1398,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.0.27" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ca8894883d250240341478bf987467332fbdd5da5c42426c69a8f93dbc302f2" +checksum = "23b34178653005c1181711c333f0e5604a14a1b5115c814fd42304bdd16245e0" dependencies = [ "cc", "libc", @@ -1428,6 +1432,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.8" @@ -1473,9 +1486,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" dependencies = [ "adler", ] @@ -1781,7 +1794,7 @@ dependencies = [ "pest_meta", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] @@ -1812,7 +1825,7 @@ checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] @@ -1853,9 +1866,9 @@ checksum = "b18befed8bc2b61abc79a457295e7e838417326da1586050b919414073977f19" [[package]] name = "ppv-lite86" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" [[package]] name = "proc-macro2" @@ -1960,9 +1973,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "cfd016f0c045ad38b5251be2c9c0ab806917f82da4d36b2a327e5166adad9270" dependencies = [ "autocfg", "crossbeam-deque", @@ -1972,12 +1985,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "91739a34c4355b5434ce54c9086c5895604a9c278586d1f1aa95e04f66b525a0" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -1991,9 +2004,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_users" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom", "redox_syscall", @@ -2019,6 +2032,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" dependencies = [ "byteorder", + "regex-syntax", ] [[package]] @@ -2038,9 +2052,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12427a5577082c24419c9c417db35cfeb65962efc7675bb6b0d5f1f9d315bfe6" +checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" dependencies = [ "base64 0.12.3", "bytes 0.5.6", @@ -2084,11 +2098,11 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ - "base64 0.11.0", + "base64 0.12.3", "blake2b_simd", "constant_time_eq", "crossbeam-utils", @@ -2247,7 +2261,7 @@ checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] @@ -2298,6 +2312,15 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sharded-slab" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "0.1.1" @@ -2327,9 +2350,9 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "snarkos-algorithms" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06bef65a6effe9a84009cd96b4bdd53166a736c02a69c738a7a1853283b3902a" +checksum = "cb07037b1575665f3a727ef444c513b4727dda85378c5eba26b4c881bc3046e8" dependencies = [ "blake2", "derivative", @@ -2348,9 +2371,9 @@ dependencies = [ [[package]] name = "snarkos-curves" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581dac15bd0c4ccf63951948e5c6a31a1f7401bc4921f98aa129cf9667baac8a" +checksum = "3aee88d337863483d07cd91e5dbc1c12de1375c1a133c49fe18f771924a80d6e" dependencies = [ "derivative", "rand", @@ -2364,20 +2387,20 @@ dependencies = [ [[package]] name = "snarkos-derives" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6db5a48fa1af675a3b4e19a60e0ea941172fda296990690226baa966808ac" +checksum = "a8f6ce35f9f73c13e5381c6938747935ca105e22717998489c3e5ddb8c13120d" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] name = "snarkos-dpc" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2740d419fa4747e6e358052303caf06e3aab7ad758ef5301e5a70320e7460d" +checksum = "51ecd7bcea91bbae1e636949b32908df2c674b7381387beadde364d6a3af6ad0" dependencies = [ "blake2", "derivative", @@ -2397,9 +2420,9 @@ dependencies = [ [[package]] name = "snarkos-errors" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fbdc0916755cdf9522f6abc20103681f0d23308067b1a53be91fe216392d37" +checksum = "df927c3b41badf8a8479dd6b23340e4799bec44abb7a479cb253d912e888a1ca" dependencies = [ "base58", "bech32", @@ -2414,9 +2437,9 @@ dependencies = [ [[package]] name = "snarkos-gadgets" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdc93bdddb0917013f4c7586b1207e90c714ddfdcf1265a69e0a82d5c7bc608" +checksum = "5f4bded425072f394dacf206323bcd3d2e199d6ec5f7ced3c36fb77f7d22300b" dependencies = [ "derivative", "digest 0.8.1", @@ -2430,9 +2453,9 @@ dependencies = [ [[package]] name = "snarkos-models" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e147408d94ad28fdf0de74c1225b2ec67860b9bddb2567013d93ccb299b333e" +checksum = "38d90d4fd9030e69dcbca1f7eaea3f14c08653f0f06600f42c2022e8cf72f82d" dependencies = [ "bincode", "derivative", @@ -2447,9 +2470,9 @@ dependencies = [ [[package]] name = "snarkos-objects" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62930e0e8ce3004c871ae640844e322d68cf9ad0ad73bf80f9082e1c0cd1ee71" +checksum = "a5ec3bdfbe179a157d1484e11ec65fdd3d2bf377ad1a7695753c5f613a57a790" dependencies = [ "base58", "bech32", @@ -2469,9 +2492,9 @@ dependencies = [ [[package]] name = "snarkos-parameters" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec4f9d1db48ac8b784d2499af9619c0ee5b3c619ca9467dbf102804aba721873" +checksum = "e8d7634a5cd35a680b81d58dbd842ee38413e81cd9ad6b8317cd93f84c9513c3" dependencies = [ "curl", "hex", @@ -2483,15 +2506,15 @@ dependencies = [ [[package]] name = "snarkos-profiler" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf0f5fd8121285811d5b5f7c61e85e176c2ca55d8009e24e151308a7eaa0db6" +checksum = "d0519c9371650425e332e3971ecfc691fbd1c67e03be15c20aba89ac8242ea2b" [[package]] name = "snarkos-storage" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6763f78edd89f0694feeaaa51a16ad663ee7bdec17f88bc239ab121507f794f4" +checksum = "0c31a1de407b5d19365e0463ecf4536725055f7b3c52dbe350e153386303eeea" dependencies = [ "bincode", "hex", @@ -2509,9 +2532,9 @@ dependencies = [ [[package]] name = "snarkos-utilities" -version = "1.0.0" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ad2b96414c45c2f90e9344b1420c9db2fbbb9435d6f1da3e2f819da1b08c05" +checksum = "6f6e1ccf791ace8d28266d3067d0bf93e3a0c1beafa472f186f55866fe8a7d73" dependencies = [ "bincode", "rand", @@ -2556,9 +2579,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", @@ -2573,7 +2596,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", "unicode-xid 0.2.1", ] @@ -2645,7 +2668,7 @@ checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", ] [[package]] @@ -2659,11 +2682,12 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -2679,9 +2703,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" [[package]] name = "tokio" @@ -2748,18 +2772,72 @@ checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" dependencies = [ "cfg-if", "log", + "tracing-attributes", "tracing-core", ] [[package]] -name = "tracing-core" -version = "0.1.14" +name = "tracing-attributes" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2 1.0.19", + "quote 1.0.7", + "syn 1.0.39", +] + +[[package]] +name = "tracing-core" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f0e00789804e99b20f12bc7003ca416309d28a6f495d6af58d1e2c2842461b5" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-log" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -2885,6 +2963,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasm-bindgen" version = "0.2.67" @@ -2908,7 +2992,7 @@ dependencies = [ "log", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", "wasm-bindgen-shared", ] @@ -2942,7 +3026,7 @@ checksum = "841a6d1c35c6f596ccea1f82504a192a60378f64b3bb0261904ad8f2f5657556" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 7884f4c471..f3cbd52d73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,19 @@ [package] name = "leo-lang" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "The Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "leo", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "leo", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" @@ -19,49 +25,133 @@ name = "leo" path = "leo/main.rs" [workspace] -members = [ "ast", "compiler", "gadgets", "input", "linter", "package", "typed", "state"] +members = [ + "ast", + "compiler", + "gadgets", + "input", + "linter", + "package", + "typed", + "state" +] -[dependencies] -leo-compiler = { path = "./compiler", version = "1.0.0" } -leo-gadgets = { path = "./gadgets", version = "1.0.0" } -leo-input = { path = "./input", version = "1.0.0" } -leo-package = { path = "./package", version = "1.0.0" } -leo-state = { path = "./state", version = "1.0.0" } +[dependencies.leo-compiler] +path = "./compiler" +version = "1.0.2" -snarkos-algorithms = { version = "1.0.0", default-features = false } -snarkos-curves = { version = "1.0.0", default-features = false } -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-gadgets = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } -snarkos-utilities = { version = "1.0.0" } +[dependencies.leo-gadgets] +path = "./gadgets" +version = "1.0.2" -clap = { version = "2.33.3" } -colored = { version = "2.0" } -dirs = { version = "3.0.1" } -console = { version = "0.12.0" } -dotenv = { version = "0.15.0" } -env_logger = { version = "0.7" } -from-pest = { version = "0.3.1" } -lazy_static = { version = "1.4.0" } -log = { version = "0.4" } -notify= { version = "4.0.15" } -num-bigint = { version = "0.3" } -rand = { version = "0.7" } -rand_core = { version = "0.5.1" } -reqwest = { version = "0.10.7", features = ["blocking", "json"] } -self_update = { version = "0.19.0", features = ["archive-zip"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } -toml = { version = "0.5" } -thiserror = { version = "1.0" } -zip = { version = "0.5" } +[dependencies.leo-input] +path = "./input" +version = "1.0.2" -[dev-dependencies] -rusty-hook = { version = "0.11.2" } +[dependencies.leo-package] +path = "./package" +version = "1.0.2" + +[dependencies.leo-state] +path = "./state" +version = "1.0.2" + +[dependencies.snarkos-algorithms] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-curves] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-gadgets] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-utilities] +version = "1.1.3" + +[dependencies.clap] +version = "2.33.3" + +[dependencies.colored] +version = "2.0" + +[dependencies.dirs] +version = "3.0.1" + +[dependencies.console] +version = "0.12.0" + +[dependencies.dotenv] +version = "0.15.0" + +[dependencies.env_logger] +version = "0.7" + +[dependencies.from-pest] +version = "0.3.1" + +[dependencies.lazy_static] +version = "1.4.0" + +[dependencies.notify] +version = "4.0.15" + +[dependencies.num-bigint] +version = "0.3" + +[dependencies.rand] +version = "0.7" + +[dependencies.rand_core] +version = "0.5.1" + +[dependencies.reqwest] +version = "0.10.7" +features = [ "blocking", "json" ] + +[dependencies.self_update] +version = "0.19.0" +features = [ "archive-zip" ] + +[dependencies.serde] +version = "1.0" +features = [ "derive" ] + +[dependencies.serde_json] +version = "1.0" + +[dependencies.thiserror] +version = "1.0" + +[dependencies.toml] +version = "0.5" + +[dependencies.tracing] +version = "0.1" + +[dependencies.tracing-subscriber] +version = "0.2" +features = [ "fmt" ] + +[dependencies.zip] +version = "0.5" + +[dev-dependencies.rusty-hook] +version = "0.11.2" [features] -default = [] -ci_skip = ["leo-compiler/ci_skip"] +default = [ ] +ci_skip = [ "leo-compiler/ci_skip" ] [profile.release] opt-level = 3 diff --git a/ast/Cargo.toml b/ast/Cargo.toml index b6e8336303..540eaf9143 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -1,13 +1,19 @@ [package] name = "leo-ast" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "AST of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" @@ -20,20 +26,37 @@ name = "ast" path = "benches/ast.rs" harness = false -[dependencies] -from-pest = { version = "0.3.1" } -lazy_static = { version = "1.3.0" } -log = { version = "0.4" } -pest = { version = "2.0" } -pest-ast = { version = "0.3.3" } -pest_derive = { version = "2.0" } -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } -thiserror = { version = "1.0" } +[dependencies.from-pest] +version = "0.3.1" -[dev-dependencies] -criterion = { version = "0.3" } +[dependencies.lazy_static] +version = "1.3.0" + +[dependencies.pest] +version = "2.0" + +[dependencies.pest-ast] +version = "0.3.3" + +[dependencies.pest_derive] +version = "2.0" + +[dependencies.serde] +version = "1.0" +features = [ "derive" ] + +[dependencies.serde_json] +version = "1.0" + +[dependencies.thiserror] +version = "1.0" + +[dependencies.tracing] +version = "0.1" + +[dev-dependencies.criterion] +version = "0.3" [features] -default = [] -ci_skip = [] +default = [ ] +ci_skip = [ ] diff --git a/ast/src/errors/syntax.rs b/ast/src/errors/syntax.rs index 9c5a19a30b..dab51bbc5e 100644 --- a/ast/src/errors/syntax.rs +++ b/ast/src/errors/syntax.rs @@ -59,7 +59,7 @@ impl From> for SyntaxError { rule => format!("{:?}", rule), }); - log::error!("{}\n", error); + tracing::error!("{}\n", error); SyntaxError::Error } diff --git a/ast/src/lib.rs b/ast/src/lib.rs index 88d9668365..a81e827486 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -63,7 +63,7 @@ impl<'ast> LeoAst<'ast> { // Builds the abstract syntax tree using pest derivation. let ast = files::File::<'ast>::from_pest(file).map_err(|_| ParserError::SyntaxTreeError)?; - log::debug!("{:#?}", ast); + tracing::debug!("{:#?}", ast); Ok(Self { ast }) } diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 23ca95ff67..bac031b641 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,45 +1,107 @@ [package] name = "leo-compiler" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Compiler of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" -[dependencies] -leo-ast = { path = "../ast", version = "1.0.0" } -leo-gadgets = { path = "../gadgets", version = "1.0.0" } -leo-input = { path = "../input", version = "1.0.0" } -leo-package = { path = "../package", version = "1.0.0"} -leo-typed = { path = "../typed", version = "1.0.0" } -leo-state = { path = "../state", version = "1.0.0" } +[dependencies.leo-ast] +path = "../ast" +version = "1.0.2" -snarkos-curves = { version = "1.0.0", default-features = false } -snarkos-dpc = { version = "1.0.0", default-features = false } -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-gadgets = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } -snarkos-objects = { version = "1.0.0", default-features = false } -snarkos-utilities = { version = "1.0.0" } +[dependencies.leo-gadgets] +path = "../gadgets" +version = "1.0.2" -bincode = { version = "1.0" } -hex = { version = "0.4.2" } -log = { version = "0.4" } -pest = { version = "2.0" } -rand = { version = "0.7" } -rand_xorshift = { version = "0.2", default-features = false } -serde = { version = "1.0" } -sha2 = { version = "0.9" } -thiserror = { version = "1.0" } +[dependencies.leo-input] +path = "../input" +version = "1.0.2" -[dev-dependencies] -num-bigint = { version = "0.3" } +[dependencies.leo-package] +path = "../package" +version = "1.0.2" + +[dependencies.leo-typed] +path = "../typed" +version = "1.0.2" + +[dependencies.leo-state] +path = "../state" +version = "1.0.2" + +[dependencies.snarkos-curves] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-dpc] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-gadgets] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-objects] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-utilities] +version = "1.1.3" + +[dependencies.bincode] +version = "1.0" + +[dependencies.hex] +version = "0.4.2" + +[dependencies.pest] +version = "2.0" + +[dependencies.rand] +version = "0.7" + +[dependencies.rand_xorshift] +version = "0.2" +default-features = false + +[dependencies.serde] +version = "1.0" + +[dependencies.sha2] +version = "0.9" + +[dependencies.thiserror] +version = "1.0" + +[dependencies.tracing] +version = "0.1" + +[dependencies.tracing-subscriber] +version = "0.2" + +[dev-dependencies.num-bigint] +version = "0.3" [features] -default = [] -ci_skip = ["leo-ast/ci_skip", "leo-typed/ci_skip"] +default = [ ] +ci_skip = [ "leo-ast/ci_skip", "leo-typed/ci_skip" ] diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 454103676a..15b908f761 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -133,7 +133,7 @@ impl> Compiler { self.program = typed_tree.into_repr(); self.imported_programs = ImportParser::parse(&self.program)?; - log::debug!("Program parsing complete\n{:#?}", self.program); + tracing::debug!("Program parsing complete\n{:#?}", self.program); Ok(()) } @@ -180,11 +180,12 @@ impl> Compiler { } /// Synthesizes the circuit for test functions with program input. - pub fn compile_test_constraints(self, input_pairs: InputPairs) -> Result<(), CompilerError> { + pub fn compile_test_constraints(self, input_pairs: InputPairs) -> Result<(u32, u32), CompilerError> { generate_test_constraints::( self.program, input_pairs, &self.imported_programs, + &self.main_file_path, &self.output_directory, ) } @@ -230,17 +231,12 @@ impl> ConstraintSynthesizer for Compil let output_directory = self.output_directory.clone(); let package_name = self.package_name.clone(); let result = self.generate_constraints_helper(cs).map_err(|e| { - log::error!("{}", e); + tracing::error!("{}", e); SynthesisError::Unsatisfiable })?; - log::info!("Program circuit successfully synthesized!"); - // Write results to file let output_file = OutputFile::new(&package_name); - - log::info!("Writing to output registers..."); - output_file.write(&output_directory, result.bytes()).unwrap(); Ok(()) diff --git a/compiler/src/console/console.rs b/compiler/src/console/console.rs index 1e2f8d2acf..637dc2bd37 100644 --- a/compiler/src/console/console.rs +++ b/compiler/src/console/console.rs @@ -25,21 +25,21 @@ impl> ConstrainedProgram { let string = self.format(cs, file_scope, function_scope, string)?; if unwrap_indicator_value(indicator) { - log::debug!("{}", string); + tracing::debug!("{}", string); } } ConsoleFunction::Error(string) => { let string = self.format(cs, file_scope, function_scope, string)?; if unwrap_indicator_value(indicator) { - log::error!("{}", string); + tracing::error!("{}", string); } } ConsoleFunction::Log(string) => { let string = self.format(cs, file_scope, function_scope, string)?; if unwrap_indicator_value(indicator) { - log::info!("{}", string); + tracing::info!("{}", string); } } } diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index d40933a51c..a95976a4e4 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -65,8 +65,9 @@ pub fn generate_test_constraints>( program: Program, input: InputPairs, imported_programs: &ImportParser, + main_file_path: &PathBuf, output_directory: &PathBuf, -) -> Result<(), CompilerError> { +) -> Result<(u32, u32), CompilerError> { let mut resolved_program = ConstrainedProgram::::new(); let program_name = program.get_name(); @@ -78,7 +79,11 @@ pub fn generate_test_constraints>( // Get default input let default = input.pairs.get(&program_name); - log::info!("Running {} tests", tests.len()); + tracing::info!("Running {} tests", tests.len()); + + // Count passed and failed tests + let mut passed = 0; + let mut failed = 0; for (test_name, test) in tests.into_iter() { let cs = &mut TestConstraintSystem::::new(); @@ -120,24 +125,37 @@ pub fn generate_test_constraints>( input, // pass program input into every test ); - if result.is_ok() { - log::info!( - "test {} compiled successfully. Constraint system satisfied: {}", - full_test_name, - cs.is_satisfied() - ); + match (result.is_ok(), cs.is_satisfied()) { + (true, true) => { + tracing::info!("{} ... ok", full_test_name); - // write result to file - let output = result?; - let output_file = OutputFile::new(&output_file_name); + // write result to file + let output = result?; + let output_file = OutputFile::new(&output_file_name); - log::info!("\tWriting output to registers in `{}.out` ...", output_file_name); + output_file.write(output_directory, output.bytes()).unwrap(); - output_file.write(output_directory, output.bytes()).unwrap(); - } else { - log::error!("test {} errored: {}", full_test_name, result.unwrap_err()); + // increment passed tests + passed += 1; + } + (true, false) => { + tracing::error!("{} constraint system not satisfied\n", full_test_name); + + // increment failed tests + failed += 1; + } + (false, _) => { + // Set file location of error + let mut error = result.unwrap_err(); + error.set_path(main_file_path.clone()); + + tracing::error!("{} failed due to error\n\n{}\n", full_test_name, error); + + // increment failed tests + failed += 1; + } } } - Ok(()) + Ok((passed, failed)) } diff --git a/compiler/src/errors/output_file.rs b/compiler/src/errors/output_file.rs index 8c4a51dd4d..8bb8b9d662 100644 --- a/compiler/src/errors/output_file.rs +++ b/compiler/src/errors/output_file.rs @@ -27,6 +27,9 @@ pub enum OutputFileError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("Cannot remove the provided file - {:?}", _0)] + FileRemovalError(PathBuf), + #[error("writing: {}", _0)] Writing(io::Error), } diff --git a/compiler/src/import/parser/parse_package.rs b/compiler/src/import/parser/parse_package.rs index 9ea0926820..0471c9dade 100644 --- a/compiler/src/import/parser/parse_package.rs +++ b/compiler/src/import/parser/parse_package.rs @@ -24,9 +24,11 @@ static SOURCE_DIRECTORY_NAME: &str = "src/"; static IMPORTS_DIRECTORY_NAME: &str = "imports/"; impl ImportParser { + // bring one or more import symbols into scope for the current constrained program + // we will recursively traverse sub packages here until we find the desired symbol pub fn parse_package_access(&mut self, entry: &DirEntry, access: &PackageAccess) -> Result<(), ImportError> { - // bring one or more import symbols into scope for the current constrained program - // we will recursively traverse sub packages here until we find the desired symbol + tracing::debug!("import {:?}", entry.path()); + match access { PackageAccess::Star(span) => self.parse_import_star(entry, span), PackageAccess::Symbol(symbol) => self.parse_import_symbol(entry, symbol), diff --git a/compiler/src/output/output_file.rs b/compiler/src/output/output_file.rs index b3eb0deaba..a77957d5dc 100644 --- a/compiler/src/output/output_file.rs +++ b/compiler/src/output/output_file.rs @@ -60,6 +60,18 @@ impl OutputFile { Ok(file.write_all(bytes)?) } + /// Removes the output file at the given path if it exists. Returns `true` on success, + /// `false` if the file doesn't exist, and `Error` if the file system fails during operation. + pub fn remove(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + if !path.exists() { + return Ok(false); + } + + fs::remove_file(&path).map_err(|_| OutputFileError::FileRemovalError(path.clone()))?; + Ok(true) + } + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { let mut path = path.to_owned(); if path.is_dir() { diff --git a/gadgets/Cargo.toml b/gadgets/Cargo.toml index 2afb11d561..8fd29aca23 100644 --- a/gadgets/Cargo.toml +++ b/gadgets/Cargo.toml @@ -1,24 +1,43 @@ [package] name = "leo-gadgets" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Gadgets of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" -[dependencies] -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } -snarkos-utilities = { version = "1.0.0" } +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false -rand = { version = "0.7", default-features = false } -rand_xorshift = { version = "0.2", default-features = false } -thiserror = { version = "1.0" } +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false -[dev-dependencies] -snarkos-utilities = { version = "1.0.0" } \ No newline at end of file +[dependencies.snarkos-utilities] +version = "1.1.3" + +[dependencies.rand] +version = "0.7" +default-features = false + +[dependencies.rand_xorshift] +version = "0.2" +default-features = false + +[dependencies.thiserror] +version = "1.0" + +[dev-dependencies.snarkos-utilities] +version = "1.1.3" diff --git a/input/Cargo.toml b/input/Cargo.toml index 6b73a68fb1..3ba99f88bf 100644 --- a/input/Cargo.toml +++ b/input/Cargo.toml @@ -1,25 +1,53 @@ [package] name = "leo-input" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Input parser of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" -[dependencies] -snarkos-algorithms = { version = "1.0.0", default-features = false } -snarkos-curves = { version = "1.0.0", default-features = false } -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-gadgets = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } +[dependencies.snarkos-algorithms] +version = "1.1.3" +default-features = false -from-pest = { version = "0.3.1" } -pest = { version = "2.0" } -pest-ast = { version = "0.3.3" } -pest_derive = { version = "2.0" } -thiserror = { version = "1.0" } +[dependencies.snarkos-curves] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-gadgets] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false + +[dependencies.from-pest] +version = "0.3.1" + +[dependencies.pest] +version = "2.0" + +[dependencies.pest-ast] +version = "0.3.3" + +[dependencies.pest_derive] +version = "2.0" + +[dependencies.thiserror] +version = "1.0" diff --git a/leo/commands/add.rs b/leo/commands/add.rs index 25b70e7575..95c30065e5 100644 --- a/leo/commands/add.rs +++ b/leo/commands/add.rs @@ -21,12 +21,7 @@ // leo add -a author -p package_name // -use crate::{ - cli::CLI, - cli_types::*, - config::*, - errors::{AddError::*, CLIError::AddError}, -}; +use crate::{cli::CLI, cli_types::*, config::*, errors::AddError::*}; use leo_package::{ imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME}, root::Manifest, @@ -88,6 +83,10 @@ impl CLI for AddCommand { } fn output(options: Self::Options) -> Result { + // Begin "Adding" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Adding"); + let _enter = span.enter(); + let token = read_token()?; let path = current_dir()?; @@ -111,13 +110,11 @@ impl CLI for AddCommand { Ok(response) => (response, package_name), //Cannot connect to the server Err(_error) => { - return Err(AddError(ConnectionUnavailable( - "Could not connect to the package manager".into(), - ))); + return Err(ConnectionUnavailable("Could not connect to the package manager".into()).into()); } } } - _ => return Err(AddError(MissingAuthorOrPackageName)), + _ => return Err(MissingAuthorOrPackageName.into()), }; let mut path = current_dir()?; @@ -131,13 +128,13 @@ impl CLI for AddCommand { let mut zip_arhive = match zip::ZipArchive::new(reader) { Ok(zip) => zip, - Err(error) => return Err(AddError(ZipError(error.to_string().into()))), + Err(error) => return Err(ZipError(error.to_string().into()).into()), }; for i in 0..zip_arhive.len() { let file = match zip_arhive.by_index(i) { Ok(file) => file, - Err(error) => return Err(AddError(ZipError(error.to_string().into()))), + Err(error) => return Err(ZipError(error.to_string().into()).into()), }; let file_name = file.name(); @@ -156,7 +153,7 @@ impl CLI for AddCommand { } } - log::info!("Successfully added a package"); + tracing::info!("Successfully added a package\n"); Ok(()) } } diff --git a/leo/commands/build.rs b/leo/commands/build.rs index e557563b52..429f3463a4 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -32,7 +32,7 @@ use snarkos_curves::{bls12_377::Bls12_377, edwards_bls12::Fq}; use snarkos_models::gadgets::r1cs::ConstraintSystem; use clap::ArgMatches; -use std::{convert::TryFrom, env::current_dir}; +use std::{convert::TryFrom, env::current_dir, time::Instant}; #[derive(Debug)] pub struct BuildCommand; @@ -55,6 +55,10 @@ impl CLI for BuildCommand { #[cfg_attr(tarpaulin, skip)] fn output(_options: Self::Options) -> Result { + // Begin "Compiling" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Compiler"); + let enter = span.enter(); + let path = current_dir()?; // Get the package name @@ -71,6 +75,11 @@ impl CLI for BuildCommand { let mut output_directory = package_path.clone(); output_directory.push(OUTPUTS_DIRECTORY_NAME); + tracing::info!("Starting..."); + + // Start the timer + let start = Instant::now(); + // Compile the package starting with the lib.leo file if LibFile::exists_at(&package_path) { // Construct the path to the library file in the source directory @@ -78,14 +87,16 @@ impl CLI for BuildCommand { lib_file_path.push(SOURCE_DIRECTORY_NAME); lib_file_path.push(LIB_FILE_NAME); + // Log compilation of library file to console + tracing::info!("Compiling library... ({:?})", lib_file_path); + // Compile the library file but do not output let _program = Compiler::::parse_program_without_input( package_name.clone(), lib_file_path.clone(), output_directory.clone(), )?; - - log::info!("Compiled library file {:?}", lib_file_path); + tracing::info!("Complete"); }; // Compile the main.leo file along with constraints @@ -104,6 +115,9 @@ impl CLI for BuildCommand { // Load the state file at `package_name.in` let state_string = StateFile::new(&package_name).read_from(&path)?; + // Log compilation of files to console + tracing::info!("Compiling main program... ({:?})", main_file_path); + // Load the program at `main_file_path` let program = Compiler::::parse_program_with_input( package_name.clone(), @@ -127,8 +141,9 @@ impl CLI for BuildCommand { }; let temporary_program = program.clone(); let output = temporary_program.compile_constraints(&mut cs)?; - log::debug!("Compiled constraints - {:#?}", output); - log::debug!("Number of constraints - {:#?}", cs.num_constraints()); + + tracing::debug!("Compiled constraints - {:#?}", output); + tracing::debug!("Number of constraints - {:#?}", cs.num_constraints()); // Serialize the circuit let circuit_object = SerializedCircuit::from(cs); @@ -163,14 +178,24 @@ impl CLI for BuildCommand { // Write the new checksum to the output directory checksum_file.write_to(&path, program_checksum)?; - log::debug!("Checksum saved ({:?})", path); + tracing::debug!("Checksum saved ({:?})", path); } - log::info!("Compiled program file {:?}", main_file_path); + tracing::info!("Complete"); + + // Drop "Compiling" context for console logging + drop(enter); + + // Begin "Finished" context for console logging todo: @collin figure a way to get this output with tracing without dropping span + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!("Completed in {} milliseconds\n", start.elapsed().as_millis()); + }); return Ok(Some((program, checksum_differs))); } + drop(enter); + // Return None when compiling a package for publishing // The published package does not need to have a main.leo Ok(None) diff --git a/leo/commands/clean.rs b/leo/commands/clean.rs index 4722993965..d28c919c8d 100644 --- a/leo/commands/clean.rs +++ b/leo/commands/clean.rs @@ -21,6 +21,8 @@ use leo_package::{ }; use clap::ArgMatches; +use leo_compiler::OutputFile; +use leo_package::outputs::CircuitFile; use std::{convert::TryFrom, env::current_dir}; #[derive(Debug)] @@ -44,6 +46,10 @@ impl CLI for CleanCommand { #[cfg_attr(tarpaulin, skip)] fn output(_options: Self::Options) -> Result { + // Begin "Clean" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Cleaning"); + let enter = span.enter(); + // Get the package name let path = current_dir()?; let package_name = Manifest::try_from(&path)?.get_package_name(); @@ -51,6 +57,12 @@ impl CLI for CleanCommand { // Remove the checksum from the output directory ChecksumFile::new(&package_name).remove(&path)?; + // Remove the serialized circuit from the output directory + CircuitFile::new(&package_name).remove(&path)?; + + // Remove the program output file from the output directory + OutputFile::new(&package_name).remove(&path)?; + // Remove the proving key from the output directory ProvingKeyFile::new(&package_name).remove(&path)?; @@ -60,6 +72,14 @@ impl CLI for CleanCommand { // Remove the proof from the output directory ProofFile::new(&package_name).remove(&path)?; + // Drop "Compiling" context for console logging + drop(enter); + + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!("Program workspace cleaned\n"); + }); + Ok(()) } } diff --git a/leo/commands/deploy.rs b/leo/commands/deploy.rs index 1522590ec2..44f73b0ef9 100644 --- a/leo/commands/deploy.rs +++ b/leo/commands/deploy.rs @@ -49,6 +49,10 @@ impl CLI for DeployCommand { #[cfg_attr(tarpaulin, skip)] fn output(options: Self::Options) -> Result { + // Begin "Deploy" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Deploying"); + let _enter = span.enter(); + let path = current_dir()?; match BuildCommand::output(options)? { @@ -56,7 +60,7 @@ impl CLI for DeployCommand { // Get the package name let _package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Unimplemented - `leo deploy`"); + tracing::error!("Unimplemented - `leo deploy`"); Ok(()) } diff --git a/leo/commands/init.rs b/leo/commands/init.rs index 92086bba40..c5b2f43791 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.rs @@ -49,6 +49,10 @@ impl CLI for InitCommand { #[cfg_attr(tarpaulin, skip)] fn output(options: Self::Options) -> Result { + // Begin "Initializing" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Initializing"); + let _enter = span.enter(); + let path = current_dir()?; // Derive the package name @@ -113,6 +117,8 @@ impl CLI for InitCommand { } } + tracing::info!("Successfully initialized package \"{}\"\n", package_name); + Ok(()) } } diff --git a/leo/commands/lint.rs b/leo/commands/lint.rs index f055bdd0cb..2c78f22cc1 100644 --- a/leo/commands/lint.rs +++ b/leo/commands/lint.rs @@ -49,6 +49,10 @@ impl CLI for LintCommand { #[cfg_attr(tarpaulin, skip)] fn output(options: Self::Options) -> Result { + // Begin "Linting" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Linting"); + let _enter = span.enter(); + let path = current_dir()?; match BuildCommand::output(options)? { @@ -56,7 +60,7 @@ impl CLI for LintCommand { // Get the package name let _package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Unimplemented - `leo lint`"); + tracing::error!("Unimplemented - `leo lint`"); Ok(()) } diff --git a/leo/commands/login.rs b/leo/commands/login.rs index 415445961a..d805ac8fc6 100644 --- a/leo/commands/login.rs +++ b/leo/commands/login.rs @@ -25,10 +25,7 @@ use crate::{ cli::CLI, cli_types::*, config::*, - errors::{ - CLIError::LoginError, - LoginError::{CannotGetToken, NoConnectionFound, NoCredentialsProvided, WrongLoginOrPassword}, - }, + errors::LoginError::{CannotGetToken, NoConnectionFound, NoCredentialsProvided, WrongLoginOrPassword}, }; use std::collections::HashMap; @@ -78,6 +75,10 @@ impl CLI for LoginCommand { } fn output(options: Self::Options) -> Result { + // Begin "Login" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Login"); + let _enter = span.enter(); + let token = match options { // Login using existing token (Some(token), _, _) => Some(token), @@ -95,22 +96,19 @@ impl CLI for LoginCommand { Ok(result) => match result.json() { Ok(json) => json, Err(_error) => { - log::error!("Wrong login or password"); - return Err(WrongLoginOrPassword("Wrong login or password".into()).into()); + return Err(WrongLoginOrPassword.into()); } }, //Cannot connect to the server Err(_error) => { - return Err(LoginError(NoConnectionFound( - "Could not connect to the package manager".into(), - ))); + return Err(NoConnectionFound.into()); } }; match response.get("token") { Some(token) => Some(token.clone()), None => { - return Err(CannotGetToken("No token was provided in the response".into()).into()); + return Err(CannotGetToken.into()); } } } @@ -124,12 +122,12 @@ impl CLI for LoginCommand { Some(token) => { write_token(token.as_str())?; - log::info!("Login successful."); + tracing::info!("success"); Ok(token) } _ => { - log::error!("Failed to login. Please run `leo login -h` for help."); + tracing::error!("Failed to login. Please run `leo login -h` for help."); Err(NoCredentialsProvided.into()) } diff --git a/leo/commands/new.rs b/leo/commands/new.rs index 6880e85eb3..74e3d52251 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -21,7 +21,7 @@ use crate::{ }; use leo_package::{ inputs::*, - root::{Gitignore, Manifest}, + root::{Gitignore, Manifest, README}, source::{LibFile, MainFile, SourceDirectory}, }; @@ -61,6 +61,10 @@ impl CLI for NewCommand { #[cfg_attr(tarpaulin, skip)] fn output(options: Self::Options) -> Result { + // Begin "Initializing" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Initializing"); + let _enter = span.enter(); + let mut path = current_dir()?; // Derive the package name @@ -91,6 +95,9 @@ impl CLI for NewCommand { // Create the .gitignore file Gitignore::new().write_to(&path)?; + // Create the README.md file + README::new(&package_name).write_to(&path)?; + // Create the source directory SourceDirectory::create(&path)?; @@ -112,6 +119,8 @@ impl CLI for NewCommand { MainFile::new(&package_name).write_to(&path)?; } + tracing::info!("Successfully initialized package \"{}\"\n", package_name); + Ok(()) } } diff --git a/leo/commands/prove.rs b/leo/commands/prove.rs index eebb39347e..3773edcbd9 100644 --- a/leo/commands/prove.rs +++ b/leo/commands/prove.rs @@ -48,11 +48,15 @@ impl CLI for ProveCommand { fn output(options: Self::Options) -> Result { let (program, parameters, prepared_verifying_key) = SetupCommand::output(options)?; + // Begin "Prover" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Prover"); + let enter = span.enter(); + // Get the package name let path = current_dir()?; let package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Proving..."); + tracing::info!("Starting..."); // Start the timer let start = Instant::now(); @@ -60,15 +64,21 @@ impl CLI for ProveCommand { let rng = &mut thread_rng(); let program_proof = Groth16::>::prove(¶meters, program, rng)?; - // Output the proving time - log::info!("Prover completed in {:?} milliseconds", start.elapsed().as_millis()); + // Finish the timer + let end = start.elapsed().as_millis(); // Write the proof file to the output directory let mut proof = vec![]; program_proof.write(&mut proof)?; ProofFile::new(&package_name).write_to(&path, &proof)?; - log::info!("Completed program proving"); + // Drop "Prover" context for console logging + drop(enter); + + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!("Completed in {:?} milliseconds\n", end); + }); Ok((program_proof, prepared_verifying_key)) } diff --git a/leo/commands/publish.rs b/leo/commands/publish.rs index a268042233..cc81281cab 100644 --- a/leo/commands/publish.rs +++ b/leo/commands/publish.rs @@ -22,7 +22,6 @@ use crate::{ errors::{ commands::PublishError::{ConnectionUnavalaible, PackageNotPublished}, CLIError, - CLIError::PublishError, PublishError::{MissingPackageDescription, MissingPackageLicense, MissingPackageRemote}, }, }; @@ -70,6 +69,10 @@ impl CLI for PublishCommand { // Build all program files. let _output = BuildCommand::output(())?; + // Begin "Publishing" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Publishing"); + let _enter = span.enter(); + // Get the package manifest let path = current_dir()?; let package_manifest = Manifest::try_from(&path)?; @@ -78,16 +81,16 @@ impl CLI for PublishCommand { let package_version = package_manifest.get_package_version(); if package_manifest.get_package_description().is_none() { - return Err(PublishError(MissingPackageDescription)); + return Err(MissingPackageDescription.into()); } if package_manifest.get_package_license().is_none() { - return Err(PublishError(MissingPackageLicense)); + return Err(MissingPackageLicense.into()); } let package_remote = match package_manifest.get_package_remote() { Some(remote) => remote, - None => return Err(PublishError(MissingPackageRemote)), + None => return Err(MissingPackageRemote.into()), }; // Create the output directory @@ -96,7 +99,7 @@ impl CLI for PublishCommand { // Create zip file let zip_file = ZipFile::new(&package_name); if zip_file.exists_at(&path) { - log::debug!("Existing package zip file found. Clearing it to regenerate."); + tracing::debug!("Existing package zip file found. Clearing it to regenerate."); // Remove the existing package zip file ZipFile::new(&package_name).remove(&path)?; } @@ -104,8 +107,8 @@ impl CLI for PublishCommand { zip_file.write(&path)?; let form_data = Form::new() - .text("name", package_name) - .text("remote", package_remote) + .text("name", package_name.clone()) + .text("remote", format!("{}/{}", package_remote.author, package_name)) .text("version", package_version) .file("file", zip_file.get_file_path(&path))?; @@ -118,8 +121,8 @@ impl CLI for PublishCommand { // If not logged in, then try logging in using JWT. Err(_error) => { - log::warn!("You should be logged in before attempting to publish a package"); - log::info!("Trying to log in using JWT..."); + tracing::warn!("You should be logged in before attempting to publish a package"); + tracing::info!("Trying to log in using JWT..."); let options = (None, None, None); LoginCommand::output(options)? @@ -145,17 +148,17 @@ impl CLI for PublishCommand { Ok(json_result) => match json_result.json::() { Ok(json) => json, Err(error) => { - log::warn!("{:?}", error); - return Err(PublishError(PackageNotPublished("Package not published".into()))); + tracing::warn!("{:?}", error); + return Err(PackageNotPublished("Package not published".into()).into()); } }, Err(error) => { - log::warn!("{:?}", error); - return Err(PublishError(ConnectionUnavalaible("Connection error".into()))); + tracing::warn!("{:?}", error); + return Err(ConnectionUnavalaible("Connection error".into()).into()); } }; - log::info!("Package published successfully with id: {}", result.package_id); + tracing::info!("Package published successfully with id: {}", result.package_id); Ok(Some(result.package_id)) } } diff --git a/leo/commands/remove.rs b/leo/commands/remove.rs index 7abdbbbaa3..46e1ac5687 100644 --- a/leo/commands/remove.rs +++ b/leo/commands/remove.rs @@ -49,6 +49,10 @@ impl CLI for RemoveCommand { #[cfg_attr(tarpaulin, skip)] fn output(options: Self::Options) -> Result { + // Begin "Removing" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Removing"); + let _enter = span.enter(); + let path = current_dir()?; match BuildCommand::output(options)? { @@ -56,7 +60,7 @@ impl CLI for RemoveCommand { // Get the package name let _package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Unimplemented - `leo remove`"); + tracing::info!("Unimplemented - `leo remove`"); Ok(()) } diff --git a/leo/commands/run.rs b/leo/commands/run.rs index a3931d77b2..76dcaf839c 100644 --- a/leo/commands/run.rs +++ b/leo/commands/run.rs @@ -22,7 +22,7 @@ use snarkos_curves::bls12_377::{Bls12_377, Fr}; use snarkos_models::algorithms::SNARK; use clap::ArgMatches; -use std::time::{Duration, Instant}; +use std::time::Instant; #[derive(Debug)] pub struct RunCommand; @@ -47,10 +47,16 @@ impl CLI for RunCommand { fn output(options: Self::Options) -> Result<(), CLIError> { let (proof, prepared_verifying_key) = ProveCommand::output(options)?; - let mut verifying = Duration::new(0, 0); + // Begin "Verifying" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Verifier"); + let enter = span.enter(); + tracing::info!("Starting..."); + + // Start the timer let start = Instant::now(); + // Run the verifier let is_success = Groth16::, Vec>::verify( &prepared_verifying_key, &vec![], @@ -58,12 +64,22 @@ impl CLI for RunCommand { ) .unwrap(); - verifying += start.elapsed(); + // End the timer + let end = start.elapsed().as_millis(); - println!(" "); - println!(" Verifier time : {:?} milliseconds", verifying.as_millis()); - println!(" Verifier output : {}", is_success); - println!(" "); + // Log the verifier output + match is_success { + true => tracing::info!("Proof is valid"), + false => tracing::error!("Proof is invalid"), + }; + + // Drop "Verifying" context for console logging + drop(enter); + + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!("Completed in {:?} milliseconds\n", end); + }); Ok(()) } diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs index 634374f7b2..80247a79f4 100644 --- a/leo/commands/setup.rs +++ b/leo/commands/setup.rs @@ -66,58 +66,82 @@ impl CLI for SetupCommand { match BuildCommand::output(options)? { Some((program, checksum_differs)) => { + // Begin "Setup" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Setup"); + let enter = span.enter(); + // Check if a proving key and verification key already exists let keys_exist = ProvingKeyFile::new(&package_name).exists_at(&path) && VerificationKeyFile::new(&package_name).exists_at(&path); // If keys do not exist or the checksum differs, run the program setup // If keys do not exist or the checksum differs, run the program setup - let (proving_key, prepared_verifying_key) = if !keys_exist || checksum_differs { - log::info!("Setup starting..."); + let (end, proving_key, prepared_verifying_key) = if !keys_exist || checksum_differs { + tracing::info!("Starting..."); - // Start the timer - let start = Instant::now(); + // Start the timer for setup + let setup_start = Instant::now(); // Run the program setup operation let rng = &mut thread_rng(); let (proving_key, prepared_verifying_key) = Groth16::, Vec>::setup(program.clone(), rng).unwrap(); - // Output the setup time - log::info!("Setup completed in {:?} milliseconds", start.elapsed().as_millis()); + // End the timer + let end = setup_start.elapsed().as_millis(); // TODO (howardwu): Convert parameters to a 'proving key' struct for serialization. // Write the proving key file to the output directory + let proving_key_file = ProvingKeyFile::new(&package_name); + tracing::info!("Saving proving key ({:?})", proving_key_file.full_path(&path)); let mut proving_key_bytes = vec![]; proving_key.write(&mut proving_key_bytes)?; - ProvingKeyFile::new(&package_name).write_to(&path, &proving_key_bytes)?; - log::info!("Saving proving key ({:?})", path); + let _ = proving_key_file.write_to(&path, &proving_key_bytes)?; + tracing::info!("Complete"); // Write the verification key file to the output directory + let verification_key_file = VerificationKeyFile::new(&package_name); + tracing::info!("Saving verification key ({:?})", verification_key_file.full_path(&path)); let mut verification_key = vec![]; proving_key.vk.write(&mut verification_key)?; - VerificationKeyFile::new(&package_name).write_to(&path, &verification_key)?; - log::info!("Saving verification key ({:?})", path); + let _ = verification_key_file.write_to(&path, &verification_key)?; + tracing::info!("Complete"); - (proving_key, prepared_verifying_key) + (end, proving_key, prepared_verifying_key) } else { - log::info!("Loading saved setup..."); + tracing::info!("Detected saved setup"); + + // Start the timer for setup + let setup_start = Instant::now(); // Read the proving key file from the output directory + tracing::info!("Loading proving key..."); let proving_key_bytes = ProvingKeyFile::new(&package_name).read_from(&path)?; let proving_key = Parameters::::read(proving_key_bytes.as_slice(), true)?; + tracing::info!("Complete"); // Read the verification key file from the output directory + tracing::info!("Loading verification key..."); let verifying_key_bytes = VerificationKeyFile::new(&package_name).read_from(&path)?; let verifying_key = VerifyingKey::::read(verifying_key_bytes.as_slice())?; // Derive the prepared verifying key file from the verifying key let prepared_verifying_key = PreparedVerifyingKey::::from(verifying_key); + tracing::info!("Complete"); - (proving_key, prepared_verifying_key) + // End the timer + let end = setup_start.elapsed().as_millis(); + + (end, proving_key, prepared_verifying_key) }; - log::info!("Program setup complete"); + // Drop "Setup" context for console logging + drop(enter); + + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!("Completed in {:?} milliseconds\n", end); + }); Ok((program, proving_key, prepared_verifying_key)) } diff --git a/leo/commands/test.rs b/leo/commands/test.rs index 1b8e9a5168..a069b38d07 100644 --- a/leo/commands/test.rs +++ b/leo/commands/test.rs @@ -17,20 +17,20 @@ use crate::{ cli::*, cli_types::*, - errors::{CLIError, TestError}, + errors::{CLIError, TestError::ProgramFileDoesNotExist}, }; use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; use leo_package::{ inputs::*, outputs::{OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, root::Manifest, - source::{MainFile, MAIN_FILE_NAME, SOURCE_DIRECTORY_NAME}, + source::{LibFile, MainFile, LIB_FILE_NAME, MAIN_FILE_NAME, SOURCE_DIRECTORY_NAME}, }; use snarkos_curves::edwards_bls12::Fq; use clap::ArgMatches; -use std::{convert::TryFrom, env::current_dir}; +use std::{convert::TryFrom, env::current_dir, time::Instant}; #[derive(Debug)] pub struct TestCommand; @@ -65,15 +65,17 @@ impl CLI for TestCommand { package_path.pop(); } - // Verify the main file exists - if !MainFile::exists_at(&package_path) { - return Err(TestError::MainFileDoesNotExist(package_path.as_os_str().to_owned()).into()); - } + let mut file_path = package_path.clone(); + file_path.push(SOURCE_DIRECTORY_NAME); - // Construct the path to the main file in the source directory - let mut main_file_path = package_path.clone(); - main_file_path.push(SOURCE_DIRECTORY_NAME); - main_file_path.push(MAIN_FILE_NAME); + // Verify a main or library file exists + if MainFile::exists_at(&package_path) { + file_path.push(MAIN_FILE_NAME); + } else if LibFile::exists_at(&package_path) { + file_path.push(LIB_FILE_NAME); + } else { + return Err(ProgramFileDoesNotExist(package_path.into()).into()); + } // Construct the path to the output directory; let mut output_directory = package_path.clone(); @@ -82,10 +84,17 @@ impl CLI for TestCommand { // Create the output directory OutputsDirectory::create(&package_path)?; + // Begin "Test" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Test"); + let enter = span.enter(); + + // Start the timer + let start = Instant::now(); + // Parse the current main program file let program = Compiler::::parse_program_without_input( package_name.clone(), - main_file_path.clone(), + file_path.clone(), output_directory, )?; @@ -94,8 +103,33 @@ impl CLI for TestCommand { // Run tests let temporary_program = program.clone(); - let output = temporary_program.compile_test_constraints(pairs)?; - log::debug!("Compiled constraints - {:#?}", output); + let (passed, failed) = temporary_program.compile_test_constraints(pairs)?; + + // Drop "Test" context for console logging + drop(enter); + + // Set the result of the test command to passed if no tests failed. + if failed == 0 { + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| { + tracing::info!( + "Tests passed in {} milliseconds. {} passed; {} failed;\n", + start.elapsed().as_millis(), + passed, + failed + ); + }); + } else { + // Begin "Finished" context for console logging + tracing::span!(tracing::Level::ERROR, "Finished").in_scope(|| { + tracing::error!( + "Tests failed in {} milliseconds. {} passed; {} failed;\n", + start.elapsed().as_millis(), + passed, + failed + ); + }); + }; Ok(()) } diff --git a/leo/commands/update.rs b/leo/commands/update.rs index 0abc9cb160..0258ba81d7 100644 --- a/leo/commands/update.rs +++ b/leo/commands/update.rs @@ -34,9 +34,9 @@ impl UpdateCommand { .build()? .fetch()?; - log::info!("List of available Leo's versions"); + tracing::info!("List of available Leo's versions"); for release in releases { - log::info!("* {}", release.version); + tracing::info!("* {}", release.version); } Ok(()) } @@ -73,26 +73,30 @@ impl CLI for UpdateCommand { } fn output(options: Self::Options) -> Result { + // Begin "Updating" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Updating"); + let _enter = span.enter(); + match options { (true,) => match UpdateCommand::show_available_releases() { Ok(_) => return Ok(()), Err(e) => { - log::error!("Could not fetch that latest version of Leo"); - log::error!("{}", e); + tracing::error!("Could not fetch that latest version of Leo"); + tracing::error!("{}", e); } }, (false,) => match UpdateCommand::update_to_latest_release() { Ok(status) => { if status.uptodate() { - log::info!("Leo is already on the latest version: {}", status.version()); + tracing::info!("Leo is already on the latest version: {}", status.version()); } else if status.updated() { - log::info!("Leo has successfully updated to version: {}", status.version()); + tracing::info!("Leo has successfully updated to version: {}", status.version()); } return Ok(()); } Err(e) => { - log::error!("Could not update Leo to the latest version"); - log::error!("{}", e); + tracing::error!("Could not update Leo to the latest version"); + tracing::error!("{}", e); } }, } diff --git a/leo/commands/watch.rs b/leo/commands/watch.rs index f4c07e298d..1bf0570078 100644 --- a/leo/commands/watch.rs +++ b/leo/commands/watch.rs @@ -43,11 +43,16 @@ impl CLI for WatchCommand { } fn output(_options: Self::Options) -> Result { + // Begin "Watching" context for console logging + let span = tracing::span!(tracing::Level::INFO, "Watching"); + let _enter = span.enter(); + let (tx, rx) = channel(); let mut watcher = watcher(tx, Duration::from_secs(INTERVAL)).unwrap(); watcher.watch(LEO_SOURCE_DIR, RecursiveMode::Recursive).unwrap(); - log::info!("Watching Leo source code"); + tracing::info!("Watching Leo source code"); + loop { match rx.recv() { // See changes on the write event @@ -55,11 +60,11 @@ impl CLI for WatchCommand { let options = (); match BuildCommand::output(options) { Ok(_output) => { - log::info!("Built successfully"); + tracing::info!("Built successfully"); } Err(e) => { // Syntax error - log::error!("Error {:?}", e); + tracing::error!("Error {:?}", e); } }; } @@ -68,7 +73,7 @@ impl CLI for WatchCommand { // Watch error Err(e) => { - log::error!("watch error: {:?}", e) + tracing::error!("watch error: {:?}", e) // TODO (howardwu): Add graceful termination. } } diff --git a/leo/errors/cli.rs b/leo/errors/cli.rs index 8fd2cb1c4a..ca160a609f 100644 --- a/leo/errors/cli.rs +++ b/leo/errors/cli.rs @@ -15,6 +15,7 @@ // along with the Leo library. If not, see . use crate::errors::*; +use leo_compiler::errors::OutputFileError; use leo_package::errors::*; #[derive(Debug, Error)] @@ -26,7 +27,7 @@ pub enum CLIError { BuildError(BuildError), #[error("{}", _0)] - BytesFileError(ZipFileError), + ZipFileError(ZipFileError), #[error("{}", _0)] ChecksumFileError(ChecksumFileError), @@ -47,7 +48,7 @@ pub enum CLIError { ImportsDirectoryError(ImportsDirectoryError), #[error("{}", _0)] - InputDirectoryError(InputsDirectoryError), + InputsDirectoryError(InputsDirectoryError), #[error("{}", _0)] InputFileError(InputFileError), @@ -68,7 +69,10 @@ pub enum CLIError { NewError(NewError), #[error("{}", _0)] - OutputDirectoryError(OutputsDirectoryError), + OutputFileError(OutputFileError), + + #[error("{}", _0)] + OutputsDirectoryError(OutputsDirectoryError), #[error("{}", _0)] ProofFileError(ProofFileError), @@ -107,226 +111,92 @@ pub enum CLIError { VerificationKeyFileError(VerificationKeyFileError), } -impl From for CLIError { - fn from(error: ZipFileError) -> Self { - log::error!("{}\n", error); - CLIError::BytesFileError(error) +macro_rules! impl_cli_error { + ($($t:tt), +) => { + $(impl From<$t> for CLIError { + fn from(error: $t) -> Self { + tracing::error!("{}\n", error); + + CLIError::$t(error) + } + })* } } -impl From for CLIError { - fn from(error: BuildError) -> Self { - log::error!("{}\n", error); - CLIError::BuildError(error) - } -} - -impl From for CLIError { - fn from(error: AddError) -> Self { - log::error!("{}\n", error); - CLIError::AddError(error) - } -} - -impl From for CLIError { - fn from(error: ChecksumFileError) -> Self { - log::error!("{}\n", error); - CLIError::ChecksumFileError(error) - } -} - -impl From for CLIError { - fn from(error: CircuitFileError) -> Self { - log::error!("{}\n", error); - CLIError::CircuitFileError(error) - } -} - -impl From for CLIError { - fn from(error: GitignoreError) -> Self { - log::error!("{}\n", error); - CLIError::GitignoreError(error) - } -} - -impl From for CLIError { - fn from(error: InitError) -> Self { - log::error!("{}\n", error); - CLIError::InitError(error) - } -} - -impl From for CLIError { - fn from(error: ImportsDirectoryError) -> Self { - log::error!("{}\n", error); - CLIError::ImportsDirectoryError(error) - } -} - -impl From for CLIError { - fn from(error: InputsDirectoryError) -> Self { - log::error!("{}\n", error); - CLIError::InputDirectoryError(error) - } -} - -impl From for CLIError { - fn from(error: InputFileError) -> Self { - log::error!("{}\n", error); - CLIError::InputFileError(error) - } -} - -impl From for CLIError { - fn from(error: LibFileError) -> Self { - log::error!("{}\n", error); - CLIError::LibFileError(error) - } -} - -impl From for CLIError { - fn from(error: LoginError) -> Self { - log::error!("{}\n", error); - CLIError::LoginError(error) - } -} - -impl From for CLIError { - fn from(error: MainFileError) -> Self { - log::error!("{}\n", error); - CLIError::MainFileError(error) - } -} - -impl From for CLIError { - fn from(error: ManifestError) -> Self { - log::error!("{}\n", error); - CLIError::ManifestError(error) - } -} - -impl From for CLIError { - fn from(error: NewError) -> Self { - log::error!("{}\n", error); - CLIError::NewError(error) - } -} - -impl From for CLIError { - fn from(error: OutputsDirectoryError) -> Self { - log::error!("{}\n", error); - CLIError::OutputDirectoryError(error) - } -} - -impl From for CLIError { - fn from(error: ProofFileError) -> Self { - log::error!("{}\n", error); - CLIError::ProofFileError(error) - } -} - -impl From for CLIError { - fn from(error: ProvingKeyFileError) -> Self { - log::error!("{}\n", error); - CLIError::ProvingKeyFileError(error) - } -} - -impl From for CLIError { - fn from(error: PublishError) -> Self { - log::error!("{}\n", error); - CLIError::PublishError(error) - } -} - -impl From for CLIError { - fn from(error: READMEError) -> Self { - log::error!("{}\n", error); - CLIError::READMEError(error) - } -} - -impl From for CLIError { - fn from(error: RunError) -> Self { - log::error!("{}\n", error); - CLIError::RunError(error) - } -} - -impl From for CLIError { - fn from(error: SourceDirectoryError) -> Self { - log::error!("{}\n", error); - CLIError::SourceDirectoryError(error) - } -} - -impl From for CLIError { - fn from(error: StateFileError) -> Self { - log::error!("{}\n", error); - CLIError::StateFileError(error) - } -} - -impl From for CLIError { - fn from(error: TestError) -> Self { - log::error!("{}\n", error); - CLIError::TestError(error) - } -} - -impl From for CLIError { - fn from(error: VerificationKeyFileError) -> Self { - log::error!("{}\n", error); - CLIError::VerificationKeyFileError(error) - } -} +impl_cli_error!( + AddError, + BuildError, + CircuitFileError, + ChecksumFileError, + GitignoreError, + ImportsDirectoryError, + InitError, + InputsDirectoryError, + InputFileError, + LibFileError, + LoginError, + MainFileError, + ManifestError, + NewError, + OutputFileError, + OutputsDirectoryError, + ProofFileError, + ProvingKeyFileError, + PublishError, + READMEError, + RunError, + SourceDirectoryError, + StateFileError, + TestError, + VerificationKeyFileError, + ZipFileError +); impl From for CLIError { fn from(error: leo_compiler::errors::CompilerError) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("leo_compiler", "Program failed due to previous error".into()) } } impl From for CLIError { fn from(error: leo_input::errors::InputParserError) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("leo_input", "Program failed due to previous error".into()) } } impl From for CLIError { fn from(error: reqwest::Error) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("rewquest", format!("{}", error)) } } impl From for CLIError { fn from(error: snarkos_errors::algorithms::snark::SNARKError) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("snarkos_errors", format!("{}", error)) } } impl From for CLIError { fn from(error: snarkos_errors::gadgets::SynthesisError) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("snarkos_errors", format!("{}", error)) } } impl From for CLIError { fn from(error: serde_json::error::Error) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("serde_json", format!("{}", error)) } } impl From for CLIError { fn from(error: std::io::Error) -> Self { - log::error!("{}\n", error); + tracing::error!("{}\n", error); CLIError::Crate("std::io", format!("{}", error)) } } diff --git a/leo/errors/commands/login.rs b/leo/errors/commands/login.rs index 4cc57315af..838f8550c8 100644 --- a/leo/errors/commands/login.rs +++ b/leo/errors/commands/login.rs @@ -14,19 +14,17 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::ffi::OsString; - #[derive(Debug, Error)] pub enum LoginError { - #[error("{:?}", _0)] - CannotGetToken(OsString), + #[error("No token was provided in the response")] + CannotGetToken, - #[error("No connection found {:?}", _0)] - NoConnectionFound(OsString), + #[error("Could not connect to the package manager")] + NoConnectionFound, #[error("No login credentials were provided")] NoCredentialsProvided, - #[error("Wrong login or password {:?}", _0)] - WrongLoginOrPassword(OsString), + #[error("Wrong login or password")] + WrongLoginOrPassword, } diff --git a/leo/errors/commands/test.rs b/leo/errors/commands/test.rs index cd293013ed..8071f0f579 100644 --- a/leo/errors/commands/test.rs +++ b/leo/errors/commands/test.rs @@ -13,16 +13,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . - -use leo_package::errors::ManifestError; - use std::ffi::OsString; #[derive(Debug, Error)] pub enum TestError { - #[error("main file {:?} does not exist", _0)] - MainFileDoesNotExist(OsString), - - #[error("{}", _0)] - ManifestError(#[from] ManifestError), + #[error("could not find main or library file in {:?}", _0)] + ProgramFileDoesNotExist(OsString), } diff --git a/leo/leo-version b/leo/leo-version new file mode 100644 index 0000000000..570c796513 --- /dev/null +++ b/leo/leo-version @@ -0,0 +1 @@ +v1.0.2 diff --git a/leo/logger.rs b/leo/logger.rs index 421cb35c33..4095f3c159 100644 --- a/leo/logger.rs +++ b/leo/logger.rs @@ -15,42 +15,200 @@ // along with the Leo library. If not, see . use colored::Colorize; -use std::io::Write; +use std::fmt; +use tracing::{event::Event, subscriber::Subscriber}; +use tracing_subscriber::{ + fmt::{format::*, time::*, FmtContext, FormattedFields}, + registry::LookupSpan, + FmtSubscriber, +}; -const LEVEL_NAME_LENGTH: usize = 10; +#[derive(Debug, Clone)] +pub struct Format { + format: F, + pub(crate) timer: T, + pub(crate) ansi: bool, + pub(crate) display_target: bool, + pub(crate) display_level: bool, + pub(crate) display_thread_id: bool, + pub(crate) display_thread_name: bool, +} -#[allow(dead_code)] -fn colored_string(level: log::Level, message: &str) -> colored::ColoredString { - match level { - log::Level::Error => message.bold().red(), - log::Level::Warn => message.bold().yellow(), - log::Level::Info => message.bold().cyan(), - log::Level::Debug => message.bold().magenta(), - log::Level::Trace => message.bold(), +impl Format { + /// Use the full JSON format. + /// + /// The full format includes fields from all entered spans. + /// + /// # Example Output + /// + /// ```ignore,json + /// {"timestamp":"Feb 20 11:28:15.096","level":"INFO","target":"mycrate","fields":{"message":"some message", "key": "value"}} + /// ``` + /// + /// # Options + /// + /// - [`Format::flatten_event`] can be used to enable flattening event fields into the root + /// object. + /// + /// [`Format::flatten_event`]: #method.flatten_event + #[cfg(feature = "json")] + pub fn json(self) -> Format { + Format { + format: Json::default(), + timer: self.timer, + ansi: self.ansi, + display_target: self.display_target, + display_level: self.display_level, + display_thread_id: self.display_thread_id, + display_thread_name: self.display_thread_name, + } + } + + /// Use the given [`timer`] for log message timestamps. + /// + /// See [`time`] for the provided timer implementations. + /// + /// Note that using the `chrono` feature flag enables the + /// additional time formatters [`ChronoUtc`] and [`ChronoLocal`]. + /// + /// [`time`]: ./time/index.html + /// [`timer`]: ./time/trait.FormatTime.html + /// [`ChronoUtc`]: ./time/struct.ChronoUtc.html + /// [`ChronoLocal`]: ./time/struct.ChronoLocal.html + pub fn with_timer(self, timer: T2) -> Format { + Format { + format: self.format, + timer, + ansi: self.ansi, + display_target: self.display_target, + display_level: self.display_level, + display_thread_id: self.display_thread_id, + display_thread_name: self.display_thread_name, + } + } + + /// Do not emit timestamps with log messages. + pub fn without_time(self) -> Format { + Format { + format: self.format, + timer: (), + ansi: self.ansi, + display_target: self.display_target, + display_level: self.display_level, + display_thread_id: self.display_thread_id, + display_thread_name: self.display_thread_name, + } + } + + /// Enable ANSI terminal colors for formatted output. + pub fn with_ansi(self, ansi: bool) -> Format { + Format { ansi, ..self } + } + + /// Sets whether or not an event's target is displayed. + pub fn with_target(self, display_target: bool) -> Format { + Format { display_target, ..self } + } + + /// Sets whether or not an event's level is displayed. + pub fn with_level(self, display_level: bool) -> Format { + Format { display_level, ..self } + } + + /// Sets whether or not the [thread ID] of the current thread is displayed + /// when formatting events + /// + /// [thread ID]: https://doc.rust-lang.org/stable/std/thread/struct.ThreadId.html + pub fn with_thread_ids(self, display_thread_id: bool) -> Format { + Format { + display_thread_id, + ..self + } + } + + /// Sets whether or not the [name] of the current thread is displayed + /// when formatting events + /// + /// [name]: https://doc.rust-lang.org/stable/std/thread/index.html#naming-threads + pub fn with_thread_names(self, display_thread_name: bool) -> Format { + Format { + display_thread_name, + ..self + } + } +} + +impl Default for Format { + fn default() -> Self { + Format { + format: Full, + timer: SystemTime, + ansi: true, + display_target: true, + display_level: true, + display_thread_id: false, + display_thread_name: false, + } + } +} +impl FormatEvent for Format +where + S: Subscriber + for<'a> LookupSpan<'a>, + N: for<'a> FormatFields<'a> + 'static, + T: FormatTime, +{ + fn format_event(&self, ctx: &FmtContext<'_, S, N>, writer: &mut dyn fmt::Write, event: &Event<'_>) -> fmt::Result { + let meta = event.metadata(); + + if self.display_level { + fn colored_string(level: &tracing::Level, message: &str) -> colored::ColoredString { + match *level { + tracing::Level::ERROR => message.bold().red(), + tracing::Level::WARN => message.bold().yellow(), + tracing::Level::INFO => message.bold().cyan(), + tracing::Level::DEBUG => message.bold().magenta(), + tracing::Level::TRACE => message.bold(), + } + } + + let mut message = "".to_string(); + + let scope = ctx.scope(); + for span in scope { + message += span.metadata().name(); + + let ext = span.extensions(); + let fields = &ext + .get::>() + .expect("Unable to find FormattedFields in extensions; this is a bug"); + if !fields.is_empty() { + message += &format!("{{{}}}", fields); + } + } + + write!(writer, "{:>12} ", colored_string(meta.level(), &message)).expect("Error writing event"); + } + + ctx.format_fields(writer, event)?; + writeln!(writer) } } /// Initialize logger with custom format and verbosity. -pub fn init_logger(app_name: &'static str, verbosity: usize) { - env_logger::builder() - .filter_level(match verbosity { - 0 => log::LevelFilter::Warn, - 1 => log::LevelFilter::Info, - 2 => log::LevelFilter::Debug, - _ => log::LevelFilter::Trace, +pub fn init_logger(_app_name: &'static str, verbosity: usize) { + let subscriber = FmtSubscriber::builder() + // all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.) + // will be written to stdout. + .with_max_level(match verbosity { + 0 => tracing::Level::WARN, + 1 => tracing::Level::INFO, + 2 => tracing::Level::DEBUG, + _ => tracing::Level::TRACE }) - .format(move |buf, record| { - let mut padding = String::from("\n"); - for _ in 0..(app_name.len() + LEVEL_NAME_LENGTH + 4) { - padding.push(' '); - } + .without_time() + .with_target(false) + .event_format(Format::default()) + .finish(); - writeln!( - buf, - "{:>5} {}", - colored_string(record.level(), app_name), - record.args().to_string().replace("\n", &padding) - ) - }) - .init(); + tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); } diff --git a/leo/main.rs b/leo/main.rs index ed4d4473e4..ae9ea633ec 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -21,7 +21,7 @@ use clap::{App, AppSettings, Arg}; #[cfg_attr(tarpaulin, skip)] fn main() -> Result<(), CLIError> { let arguments = App::new("leo") - .version("v1.0.0") + .version(include_str!("./leo-version")) .about("Leo compiler and package manager") .author("The Aleo Team ") .settings(&[ @@ -61,7 +61,7 @@ fn main() -> Result<(), CLIError> { if config.auto_update { if let Ok(status) = UpdateCommand::update_to_latest_release() { if status.updated() { - log::info!("Leo has successfully updated to version: {}", status.version()); + tracing::info!("Leo has successfully updated to version: {}", status.version()); } } } diff --git a/linter/Cargo.toml b/linter/Cargo.toml index 99cb726527..129ed49dfd 100644 --- a/linter/Cargo.toml +++ b/linter/Cargo.toml @@ -1,14 +1,20 @@ +dependencies = { } + [package] -name = "leo-liner" -version = "1.0.0" -authors = ["The Aleo Team "] +name = "leo-linter" +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Linter of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" - -[dependencies] diff --git a/package/Cargo.toml b/package/Cargo.toml index fa44c06b8f..14afff3175 100644 --- a/package/Cargo.toml +++ b/package/Cargo.toml @@ -1,21 +1,40 @@ [package] name = "leo-package" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Package parser of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" -[dependencies] -log = { version = "0.4" } -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } -thiserror = { version = "1.0" } -toml = { version = "0.5" } -walkdir = { version = "2" } -zip = { version = "0.5" } +[dependencies.serde] +version = "1.0" +features = [ "derive" ] + +[dependencies.serde_json] +version = "1.0" + +[dependencies.thiserror] +version = "1.0" + +[dependencies.toml] +version = "0.5" + +[dependencies.tracing] +version = "0.1" + +[dependencies.walkdir] +version = "2" + +[dependencies.zip] +version = "0.5" diff --git a/package/src/outputs/proof.rs b/package/src/outputs/proof.rs index 4d0a41482f..d6c33d28f9 100644 --- a/package/src/outputs/proof.rs +++ b/package/src/outputs/proof.rs @@ -59,7 +59,7 @@ impl ProofFile { let mut file = File::create(&path)?; file.write_all(proof)?; - log::info!("Proof stored ({:?})", path); + tracing::info!("Saving proof... ({:?})", path); Ok(()) } diff --git a/package/src/outputs/proving_key.rs b/package/src/outputs/proving_key.rs index 03fd71f157..3d5a13c085 100644 --- a/package/src/outputs/proving_key.rs +++ b/package/src/outputs/proving_key.rs @@ -39,6 +39,10 @@ impl ProvingKeyFile { } } + pub fn full_path(&self, path: &PathBuf) -> PathBuf { + self.setup_file_path(path) + } + pub fn exists_at(&self, path: &PathBuf) -> bool { let path = self.setup_file_path(path); path.exists() @@ -52,13 +56,13 @@ impl ProvingKeyFile { } /// Writes the given proving key to a file. - pub fn write_to(&self, path: &PathBuf, proving_key: &[u8]) -> Result<(), ProvingKeyFileError> { + pub fn write_to(&self, path: &PathBuf, proving_key: &[u8]) -> Result { let path = self.setup_file_path(path); let mut file = File::create(&path)?; file.write_all(proving_key)?; - Ok(()) + Ok(path) } /// Removes the proving key at the given path if it exists. Returns `true` on success, diff --git a/package/src/outputs/verification_key.rs b/package/src/outputs/verification_key.rs index 83c9913b56..0509bc1b3e 100644 --- a/package/src/outputs/verification_key.rs +++ b/package/src/outputs/verification_key.rs @@ -39,6 +39,10 @@ impl VerificationKeyFile { } } + pub fn full_path(&self, path: &PathBuf) -> PathBuf { + self.setup_file_path(path) + } + pub fn exists_at(&self, path: &PathBuf) -> bool { let path = self.setup_file_path(path); path.exists() @@ -52,13 +56,13 @@ impl VerificationKeyFile { } /// Writes the given verification key to a file. - pub fn write_to(&self, path: &PathBuf, verification_key: &[u8]) -> Result<(), VerificationKeyFileError> { + pub fn write_to(&self, path: &PathBuf, verification_key: &[u8]) -> Result { let path = self.setup_file_path(path); let mut file = File::create(&path)?; file.write_all(verification_key)?; - Ok(()) + Ok(path) } /// Removes the verification key at the given path if it exists. Returns `true` on success, diff --git a/package/src/root/manifest.rs b/package/src/root/manifest.rs index f18c98b30b..293e993683 100644 --- a/package/src/root/manifest.rs +++ b/package/src/root/manifest.rs @@ -26,13 +26,18 @@ use std::{ pub const MANIFEST_FILE_NAME: &str = "Leo.toml"; +#[derive(Clone, Deserialize)] +pub struct Remote { + pub author: String, +} + #[derive(Deserialize)] pub struct Package { pub name: String, pub version: String, pub description: Option, pub license: Option, - pub remote: Option, + pub remote: Option, } #[derive(Deserialize)] @@ -77,7 +82,7 @@ impl Manifest { self.package.license.clone() } - pub fn get_package_remote(&self) -> Option { + pub fn get_package_remote(&self) -> Option { self.package.remote.clone() } @@ -98,8 +103,10 @@ impl Manifest { name = "{name}" version = "0.1.0" description = "The {name} package" -remote = "[AUTHOR]/{name}" -license = "LICENSE-MIT" +license = "MIT" + +[remote] +author = "[AUTHOR]" # Add your Aleo Package Manager username, team's name, or organization's name. "#, name = self.package.name ) @@ -115,7 +122,7 @@ impl TryFrom<&PathBuf> for Manifest { path.push(PathBuf::from(MANIFEST_FILE_NAME)); } - let mut file = File::open(path).map_err(|error| ManifestError::Opening(MANIFEST_FILE_NAME, error))?; + let mut file = File::open(path.clone()).map_err(|error| ManifestError::Opening(MANIFEST_FILE_NAME, error))?; let size = file .metadata() .map_err(|error| ManifestError::Metadata(MANIFEST_FILE_NAME, error))? @@ -125,6 +132,65 @@ impl TryFrom<&PathBuf> for Manifest { file.read_to_string(&mut buffer) .map_err(|error| ManifestError::Reading(MANIFEST_FILE_NAME, error))?; - Ok(toml::from_str(&buffer).map_err(|error| ManifestError::Parsing(MANIFEST_FILE_NAME, error))?) + // Determine if the old remote format is being used, and update to new convention + + let mut old_remote_format: Option<&str> = None; + let mut new_remote_format_exists = false; + + let mut new_toml = "".to_owned(); + + // Read each individual line of the toml file + for line in buffer.lines() { + // Determine if the old remote format is being used + if line.starts_with("remote") { + let remote = line + .split("=") // Split the line as 'remote' = '"{author}/{package_name}"' + .collect::>()[1]; // Fetch just '"{author}/{package_name}"' + old_remote_format = Some(remote); + continue; + } + + // Determine if the new remote format is being used + if line.starts_with("[remote]") { + new_remote_format_exists = true; + } + new_toml += line; + new_toml += "\n"; + } + + // Update the remote format + if let Some(old_remote) = old_remote_format { + // If both the old remote and new remote are missing, + // then skip appending the new remote, just keep the old remote. + if !new_remote_format_exists { + // Fetch the author from the old remote. + let remote_author = old_remote + .split("/") // Split the old remote as '"{author}' and '{package_name}"' + .collect::>()[0] // Fetch just the '"{author}' + .replace(&['\"', ' '][..], ""); // Remove the quotes from the author string + + // Construct the new remote section. + let new_remote = format!( + r#" +[remote] +author = "{author}" +"#, + author = remote_author + ); + + // Append the new remote to the bottom of the manifest file. + new_toml += &new_remote; + } + } + + // Rewrite the toml file if it has been updated + if buffer != new_toml { + let mut file = File::create(&path).map_err(|error| ManifestError::Creating(MANIFEST_FILE_NAME, error))?; + file.write_all(new_toml.as_bytes()) + .map_err(|error| ManifestError::Writing(MANIFEST_FILE_NAME, error))?; + } + + // Read the toml file + Ok(toml::from_str(&new_toml).map_err(|error| ManifestError::Parsing(MANIFEST_FILE_NAME, error))?) } } diff --git a/package/src/root/zip.rs b/package/src/root/zip.rs index ea89ea747d..055452debf 100644 --- a/package/src/root/zip.rs +++ b/package/src/root/zip.rs @@ -94,14 +94,14 @@ impl ZipFile { // Add file/directory exclusion let included = is_included(name); - log::debug!("Checking if {:?} is included - {}", name, included); + tracing::debug!("Checking if {:?} is included - {}", name, included); if !included { continue; } // Write file or directory if path.is_file() { - log::info!("Adding file {:?} as {:?}", path, name); + tracing::info!("Adding file {:?} as {:?}", path, name); zip.start_file_from_path(name, options)?; let mut f = File::open(path)?; @@ -111,14 +111,14 @@ impl ZipFile { } else if name.as_os_str().len() != 0 { // Only if not root Avoids path spec / warning // and mapname conversion failed error on unzip - log::info!("Adding directory {:?} as {:?}", path, name); + tracing::info!("Adding directory {:?} as {:?}", path, name); zip.add_directory_from_path(name, options)?; } } zip.finish()?; - log::info!("Package zip file created successfully {:?}", path); + tracing::info!("Package zip file created successfully {:?}", path); Ok(()) } diff --git a/state/Cargo.toml b/state/Cargo.toml index b038fd11f3..760baa0a87 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -1,31 +1,65 @@ [package] name = "leo-state" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "State parser of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" -[dependencies] -leo-input = { path = "../input", version = "1.0.0" } -leo-typed = { path = "../typed", version = "1.0.0" } +[dependencies.leo-input] +path = "../input" +version = "1.0.2" -snarkos-algorithms = { version = "1.0.0", default-features = false } -snarkos-curves = { version = "1.0.0", default-features = false } -snarkos-dpc = { version = "1.0.0", default-features = false } -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } -snarkos-objects = { version = "1.0.0", default-features = false } -snarkos-utilities = { version = "1.0.0" } +[dependencies.leo-typed] +path = "../typed" +version = "1.0.2" -rand = { version = "0.7" } -rand_xorshift = { version = "0.2" } -thiserror = { version = "1.0" } +[dependencies.snarkos-algorithms] +version = "1.1.3" +default-features = false -[dev-dependencies] -snarkos-storage = { version = "1.0.0" } +[dependencies.snarkos-curves] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-dpc] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-objects] +version = "1.1.3" +default-features = false + +[dependencies.snarkos-utilities] +version = "1.1.3" + +[dependencies.rand] +version = "0.7" + +[dependencies.rand_xorshift] +version = "0.2" + +[dependencies.thiserror] +version = "1.0" + +[dev-dependencies.snarkos-storage] +version = "1.1.4" diff --git a/typed/Cargo.toml b/typed/Cargo.toml index 9127b0e6bb..8d84a3565c 100644 --- a/typed/Cargo.toml +++ b/typed/Cargo.toml @@ -1,13 +1,19 @@ [package] name = "leo-typed" -version = "1.0.0" -authors = ["The Aleo Team "] +version = "1.0.2" +authors = [ "The Aleo Team " ] description = "Typed AST of the Leo programming language" homepage = "https://aleo.org" repository = "https://github.com/AleoHQ/leo" -keywords = ["aleo", "cryptography", "leo", "programming-language", "zero-knowledge"] -categories = ["cryptography::cryptocurrencies", "web-programming"] -include = ["Cargo.toml", "src", "README.md", "LICENSE.md"] +keywords = [ + "aleo", + "cryptography", + "leo", + "programming-language", + "zero-knowledge" +] +categories = [ "cryptography::cryptocurrencies", "web-programming" ] +include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" @@ -20,20 +26,34 @@ name = "typed_ast" path = "benches/typed_ast.rs" harness = false -[dependencies] -leo-ast = { path = "../ast", version = "1.0.0" } -leo-input = { path = "../input", version = "1.0.0" } +[dependencies.leo-ast] +path = "../ast" +version = "1.0.2" -snarkos-errors = { version = "1.0.0", default-features = false } -snarkos-models = { version = "1.0.0", default-features = false } +[dependencies.leo-input] +path = "../input" +version = "1.0.2" -pest = { version = "2.0" } -serde = { version = "1.0" } -serde_json = { version = "1.0" } +[dependencies.snarkos-errors] +version = "1.1.3" +default-features = false -[dev-dependencies] -criterion = { version = "0.3" } +[dependencies.snarkos-models] +version = "1.1.3" +default-features = false + +[dependencies.pest] +version = "2.0" + +[dependencies.serde] +version = "1.0" + +[dependencies.serde_json] +version = "1.0" + +[dev-dependencies.criterion] +version = "0.3" [features] -default = [] -ci_skip = ["leo-ast/ci_skip"] +default = [ ] +ci_skip = [ "leo-ast/ci_skip" ]