mirror of
https://github.com/AleoHQ/leo.git
synced 2025-01-04 16:15:11 +03:00
Merge pull request #306 from AleoHQ/feature/tracing
Migrate to tracing for console output
This commit is contained in:
commit
0023ee8ef4
393
Cargo.lock
generated
393
Cargo.lock
generated
@ -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"
|
||||
@ -341,7 +350,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",
|
||||
@ -1210,13 +1219,13 @@ dependencies = [
|
||||
"criterion",
|
||||
"from-pest",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"pest",
|
||||
"pest-ast",
|
||||
"pest_derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1231,21 +1240,22 @@ dependencies = [
|
||||
"leo-package",
|
||||
"leo-state",
|
||||
"leo-typed",
|
||||
"log",
|
||||
"num-bigint",
|
||||
"pest",
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"serde",
|
||||
"sha2",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves",
|
||||
"snarkos-dpc",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-gadgets",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-objects 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models",
|
||||
"snarkos-objects",
|
||||
"snarkos-utilities",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1254,9 +1264,9 @@ version = "1.0.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@ -1268,11 +1278,11 @@ dependencies = [
|
||||
"pest",
|
||||
"pest-ast",
|
||||
"pest_derive",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-errors",
|
||||
"snarkos-gadgets",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@ -1293,7 +1303,6 @@ dependencies = [
|
||||
"leo-input",
|
||||
"leo-package",
|
||||
"leo-state",
|
||||
"log",
|
||||
"notify",
|
||||
"num-bigint",
|
||||
"rand",
|
||||
@ -1303,14 +1312,16 @@ dependencies = [
|
||||
"self_update",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-errors",
|
||||
"snarkos-gadgets",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@ -1322,11 +1333,11 @@ version = "1.0.0"
|
||||
name = "leo-package"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"tracing",
|
||||
"walkdir",
|
||||
"zip",
|
||||
]
|
||||
@ -1339,14 +1350,14 @@ dependencies = [
|
||||
"leo-typed",
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-dpc",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-objects 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-objects",
|
||||
"snarkos-storage",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@ -1360,8 +1371,8 @@ dependencies = [
|
||||
"pest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1428,6 +1439,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"
|
||||
@ -2019,6 +2039,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2298,6 +2319,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,8 +2357,9 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-algorithms"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f587075180fbb776f9b0a7a6ae9af814ea9800173c338ad358dc0418f074b846"
|
||||
dependencies = [
|
||||
"blake2",
|
||||
"derivative",
|
||||
@ -2339,72 +2370,26 @@ dependencies = [
|
||||
"rayon",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-models 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-profiler 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-algorithms"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06bef65a6effe9a84009cd96b4bdd53166a736c02a69c738a7a1853283b3902a"
|
||||
dependencies = [
|
||||
"blake2",
|
||||
"derivative",
|
||||
"digest 0.8.1",
|
||||
"itertools 0.9.0",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rayon",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-profiler 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-profiler",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-curves"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9a3b914e8c06fda98b0eb66037c548d7bf8458f116b7a3d020ac5c15e8400f3"
|
||||
dependencies = [
|
||||
"derivative",
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-models 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-curves"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "581dac15bd0c4ccf63951948e5c6a31a1f7401bc4921f98aa129cf9667baac8a"
|
||||
dependencies = [
|
||||
"derivative",
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-derives"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.38",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2420,30 +2405,31 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-dpc"
|
||||
version = "1.0.0"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b2740d419fa4747e6e358052303caf06e3aab7ad758ef5301e5a70320e7460d"
|
||||
checksum = "3d628262e9c79f24826762867e053fa9beab207a2782579db48b38970e1c5d96"
|
||||
dependencies = [
|
||||
"blake2",
|
||||
"derivative",
|
||||
"hex",
|
||||
"itertools 0.9.0",
|
||||
"rand",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-errors",
|
||||
"snarkos-gadgets",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-objects 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-parameters 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-profiler 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models",
|
||||
"snarkos-objects",
|
||||
"snarkos-parameters",
|
||||
"snarkos-profiler",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-errors"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03b9d85575ed5ef6fa64821a53acbff55dd935e5d9447c7a3233ed689f0170f6"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
@ -2456,58 +2442,27 @@ dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-errors"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45fbdc0916755cdf9522f6abc20103681f0d23308067b1a53be91fe216392d37"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
"bincode",
|
||||
"hex",
|
||||
"jsonrpc-core",
|
||||
"thiserror",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-gadgets"
|
||||
version = "1.0.0"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fdc93bdddb0917013f4c7586b1207e90c714ddfdcf1265a69e0a82d5c7bc608"
|
||||
checksum = "c7ee25ebd815b406118ec5f81a280818bd7f40c05e288064774b1939fdc8d0e9"
|
||||
dependencies = [
|
||||
"derivative",
|
||||
"digest 0.8.1",
|
||||
"itertools 0.9.0",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-models"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"derivative",
|
||||
"itertools 0.9.0",
|
||||
"rand",
|
||||
"rand_xorshift",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-models"
|
||||
version = "1.0.0"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e147408d94ad28fdf0de74c1225b2ec67860b9bddb2567013d93ccb299b333e"
|
||||
checksum = "fd7f31748377c4a7b9abc3cb932478b87ee7d2fedb5298ff5c8de2991784d056"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"derivative",
|
||||
@ -2516,14 +2471,15 @@ dependencies = [
|
||||
"rand_xorshift",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-objects"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a39eb0cfc10f667bd47f137cbf52eb4ba695e8c430c324eed1033f4b346fbe23"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
@ -2534,46 +2490,11 @@ dependencies = [
|
||||
"rand",
|
||||
"serde",
|
||||
"sha2",
|
||||
"snarkos-algorithms 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-curves 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-models 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-objects"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62930e0e8ce3004c871ae640844e322d68cf9ad0ad73bf80f9082e1c0cd1ee71"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
"chrono",
|
||||
"derivative",
|
||||
"hex",
|
||||
"once_cell",
|
||||
"rand",
|
||||
"serde",
|
||||
"sha2",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-curves 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-parameters"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
dependencies = [
|
||||
"curl",
|
||||
"hex",
|
||||
"snarkos-algorithms 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-models 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-curves",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2582,18 +2503,14 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec4f9d1db48ac8b784d2499af9619c0ee5b3c619ca9467dbf102804aba721873"
|
||||
dependencies = [
|
||||
"curl",
|
||||
"hex",
|
||||
"snarkos-algorithms 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-models 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-utilities 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-profiler"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-profiler"
|
||||
version = "1.0.0"
|
||||
@ -2602,8 +2519,9 @@ checksum = "7cf0f5fd8121285811d5b5f7c61e85e176c2ca55d8009e24e151308a7eaa0db6"
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-storage"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b2e135ee32d10fb561f6071770a6f2db31f1a01d0a07af3e62c467aee5a5d16"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"hex",
|
||||
@ -2611,35 +2529,24 @@ dependencies = [
|
||||
"rand",
|
||||
"rocksdb",
|
||||
"serde",
|
||||
"snarkos-algorithms 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-models 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-objects 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-parameters 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-utilities 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-algorithms",
|
||||
"snarkos-errors",
|
||||
"snarkos-models",
|
||||
"snarkos-objects",
|
||||
"snarkos-parameters",
|
||||
"snarkos-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-utilities"
|
||||
version = "1.0.0"
|
||||
source = "git+ssh://git@github.com/AleoHQ/snarkOS.git#9fda1b628c627bf717556e81dc10bee667f77a52"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"rand",
|
||||
"snarkos-derives 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
"snarkos-errors 1.0.0 (git+ssh://git@github.com/AleoHQ/snarkOS.git)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snarkos-utilities"
|
||||
version = "1.0.0"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21ad2b96414c45c2f90e9344b1420c9db2fbbb9435d6f1da3e2f819da1b08c05"
|
||||
checksum = "8a20c792056bd64407305a53f406a96b6f032edcf8dc96c24262ed91d4603361"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"rand",
|
||||
"snarkos-derives 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-errors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"snarkos-derives",
|
||||
"snarkos-errors",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2871,9 +2778,21 @@ checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.14"
|
||||
@ -2883,6 +2802,48 @@ 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"
|
||||
|
17
Cargo.toml
17
Cargo.toml
@ -28,12 +28,12 @@ leo-input = { path = "./input", version = "1.0.0" }
|
||||
leo-package = { path = "./package", version = "1.0.0" }
|
||||
leo-state = { path = "./state", version = "1.0.0" }
|
||||
|
||||
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" }
|
||||
snarkos-algorithms = { version = "1.1.3", default-features = false }
|
||||
snarkos-curves = { version = "1.1.3", default-features = false }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-gadgets = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
snarkos-utilities = { version = "1.1.3" }
|
||||
|
||||
clap = { version = "2.33.3" }
|
||||
colored = { version = "2.0" }
|
||||
@ -43,7 +43,6 @@ 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" }
|
||||
@ -52,8 +51,10 @@ 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" }
|
||||
toml = { version = "0.5" }
|
||||
tracing = { version = "0.1" }
|
||||
tracing-subscriber = { version = "0.2", features = ["fmt"] }
|
||||
zip = { version = "0.5" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -23,13 +23,14 @@ 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" }
|
||||
tracing = { version = "0.1" }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.3" }
|
||||
|
@ -59,7 +59,7 @@ impl From<Error<Rule>> for SyntaxError {
|
||||
rule => format!("{:?}", rule),
|
||||
});
|
||||
|
||||
log::error!("{}\n", error);
|
||||
tracing::error!("{}\n", error);
|
||||
|
||||
SyntaxError::Error
|
||||
}
|
||||
|
@ -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 })
|
||||
}
|
||||
|
@ -19,23 +19,24 @@ leo-package = { path = "../package", version = "1.0.0"}
|
||||
leo-typed = { path = "../typed", version = "1.0.0" }
|
||||
leo-state = { path = "../state", version = "1.0.0" }
|
||||
|
||||
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" }
|
||||
snarkos-curves = { version = "1.1.3", default-features = false }
|
||||
snarkos-dpc = { version = "1.1.3", default-features = false }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-gadgets = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
snarkos-objects = { version = "1.1.3", default-features = false }
|
||||
snarkos-utilities = { version = "1.1.3" }
|
||||
|
||||
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" }
|
||||
tracing = { version = "0.1" }
|
||||
tracing-subscriber = { version = "0.2" }
|
||||
|
||||
[dev-dependencies]
|
||||
num-bigint = { version = "0.3" }
|
||||
|
@ -133,7 +133,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
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<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
}
|
||||
|
||||
/// 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::<F, G>(
|
||||
self.program,
|
||||
input_pairs,
|
||||
&self.imported_programs,
|
||||
&self.main_file_path,
|
||||
&self.output_directory,
|
||||
)
|
||||
}
|
||||
@ -230,17 +231,12 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstraintSynthesizer<F> 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(())
|
||||
|
@ -25,21 +25,21 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,9 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
|
||||
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::<F, G>::new();
|
||||
let program_name = program.get_name();
|
||||
|
||||
@ -78,7 +79,11 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
|
||||
// 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::<F>::new();
|
||||
@ -120,24 +125,37 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
|
||||
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))
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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<bool, OutputFileError> {
|
||||
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() {
|
||||
|
@ -12,13 +12,13 @@ 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" }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
snarkos-utilities = { version = "1.1.3" }
|
||||
|
||||
rand = { version = "0.7", default-features = false }
|
||||
rand_xorshift = { version = "0.2", default-features = false }
|
||||
thiserror = { version = "1.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
snarkos-utilities = { version = "1.0.0" }
|
||||
snarkos-utilities = { version = "1.1.3" }
|
@ -12,11 +12,11 @@ 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 }
|
||||
snarkos-algorithms = { version = "1.1.3", default-features = false }
|
||||
snarkos-curves = { version = "1.1.3", default-features = false }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-gadgets = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
|
||||
from-pest = { version = "0.3.1" }
|
||||
pest = { version = "2.0" }
|
||||
|
@ -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<Self::Output, crate::errors::CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
}
|
||||
|
@ -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<Self::Output, CLIError> {
|
||||
// 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::<Fq, EdwardsGroupType>::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::<Fq, EdwardsGroupType>::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)
|
||||
|
@ -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<Self::Output, CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ impl CLI for DeployCommand {
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ impl CLI for InitCommand {
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ impl CLI for LintCommand {
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
|
@ -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<Self::Output, crate::errors::CLIError> {
|
||||
// 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())
|
||||
}
|
||||
|
@ -61,6 +61,10 @@ impl CLI for NewCommand {
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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
|
||||
@ -112,6 +116,8 @@ impl CLI for NewCommand {
|
||||
MainFile::new(&package_name).write_to(&path)?;
|
||||
}
|
||||
|
||||
tracing::info!("Successfully initialized package \"{}\"\n", package_name);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,15 @@ impl CLI for ProveCommand {
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
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::<Bls12_377, _, Vec<Fr>>::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))
|
||||
}
|
||||
|
@ -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)?;
|
||||
}
|
||||
@ -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::<ResponseJson>() {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ impl CLI for RemoveCommand {
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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(())
|
||||
}
|
||||
|
@ -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::<Bls12_377, Compiler<Fr, EdwardsGroupType>, Vec<Fr>>::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(())
|
||||
}
|
||||
|
@ -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::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::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::<Bls12_377>::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::<Bls12_377>::read(verifying_key_bytes.as_slice())?;
|
||||
|
||||
// Derive the prepared verifying key file from the verifying key
|
||||
let prepared_verifying_key = PreparedVerifyingKey::<Bls12_377>::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))
|
||||
}
|
||||
|
@ -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::<Fq, EdwardsGroupType>::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(())
|
||||
}
|
||||
|
@ -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<Self::Output, crate::errors::CLIError> {
|
||||
// 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);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -43,11 +43,16 @@ impl CLI for WatchCommand {
|
||||
}
|
||||
|
||||
fn output(_options: Self::Options) -> Result<Self::Output, CLIError> {
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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<ZipFileError> 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<BuildError> for CLIError {
|
||||
fn from(error: BuildError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::BuildError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AddError> for CLIError {
|
||||
fn from(error: AddError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::AddError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ChecksumFileError> for CLIError {
|
||||
fn from(error: ChecksumFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::ChecksumFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CircuitFileError> for CLIError {
|
||||
fn from(error: CircuitFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::CircuitFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GitignoreError> for CLIError {
|
||||
fn from(error: GitignoreError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::GitignoreError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InitError> for CLIError {
|
||||
fn from(error: InitError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::InitError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ImportsDirectoryError> for CLIError {
|
||||
fn from(error: ImportsDirectoryError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::ImportsDirectoryError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InputsDirectoryError> for CLIError {
|
||||
fn from(error: InputsDirectoryError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::InputDirectoryError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InputFileError> for CLIError {
|
||||
fn from(error: InputFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::InputFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LibFileError> for CLIError {
|
||||
fn from(error: LibFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::LibFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LoginError> for CLIError {
|
||||
fn from(error: LoginError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::LoginError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MainFileError> for CLIError {
|
||||
fn from(error: MainFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::MainFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ManifestError> for CLIError {
|
||||
fn from(error: ManifestError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::ManifestError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NewError> for CLIError {
|
||||
fn from(error: NewError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::NewError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OutputsDirectoryError> for CLIError {
|
||||
fn from(error: OutputsDirectoryError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::OutputDirectoryError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ProofFileError> for CLIError {
|
||||
fn from(error: ProofFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::ProofFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ProvingKeyFileError> for CLIError {
|
||||
fn from(error: ProvingKeyFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::ProvingKeyFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PublishError> for CLIError {
|
||||
fn from(error: PublishError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::PublishError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<READMEError> for CLIError {
|
||||
fn from(error: READMEError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::READMEError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RunError> for CLIError {
|
||||
fn from(error: RunError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::RunError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SourceDirectoryError> for CLIError {
|
||||
fn from(error: SourceDirectoryError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::SourceDirectoryError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StateFileError> for CLIError {
|
||||
fn from(error: StateFileError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::StateFileError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TestError> for CLIError {
|
||||
fn from(error: TestError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::TestError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<VerificationKeyFileError> 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<leo_compiler::errors::CompilerError> 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<leo_input::errors::InputParserError> 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<reqwest::Error> for CLIError {
|
||||
fn from(error: reqwest::Error) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("rewquest", format!("{}", error))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<snarkos_errors::algorithms::snark::SNARKError> 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<snarkos_errors::gadgets::SynthesisError> 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<serde_json::error::Error> 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<std::io::Error> for CLIError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("std::io", format!("{}", error))
|
||||
}
|
||||
}
|
||||
|
@ -14,19 +14,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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,
|
||||
}
|
||||
|
@ -13,16 +13,10 @@
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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),
|
||||
}
|
||||
|
218
leo/logger.rs
218
leo/logger.rs
@ -15,42 +15,200 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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<F = Full, T = SystemTime> {
|
||||
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<F, T> Format<F, T> {
|
||||
/// 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<Json, T> {
|
||||
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<T2>(self, timer: T2) -> Format<F, T2> {
|
||||
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<F, ()> {
|
||||
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<F, T> {
|
||||
Format { ansi, ..self }
|
||||
}
|
||||
|
||||
/// Sets whether or not an event's target is displayed.
|
||||
pub fn with_target(self, display_target: bool) -> Format<F, T> {
|
||||
Format { display_target, ..self }
|
||||
}
|
||||
|
||||
/// Sets whether or not an event's level is displayed.
|
||||
pub fn with_level(self, display_level: bool) -> Format<F, T> {
|
||||
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<F, T> {
|
||||
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<F, T> {
|
||||
Format {
|
||||
display_thread_name,
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Format<Full, SystemTime> {
|
||||
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<S, N, T> FormatEvent<S, N> for Format<Full, T>
|
||||
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::<FormattedFields<N>>()
|
||||
.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");
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ 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" }
|
||||
tracing = { version = "0.1" }
|
||||
walkdir = { version = "2" }
|
||||
zip = { version = "0.5" }
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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<PathBuf, ProvingKeyFileError> {
|
||||
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,
|
||||
|
@ -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<PathBuf, VerificationKeyFileError> {
|
||||
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,
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -15,17 +15,17 @@ edition = "2018"
|
||||
leo-input = { path = "../input", version = "1.0.0" }
|
||||
leo-typed = { path = "../typed", version = "1.0.0" }
|
||||
|
||||
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" }
|
||||
snarkos-algorithms = { version = "1.1.3", default-features = false }
|
||||
snarkos-curves = { version = "1.1.3", default-features = false }
|
||||
snarkos-dpc = { version = "1.1.3", default-features = false }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
snarkos-objects = { version = "1.1.3", default-features = false }
|
||||
snarkos-utilities = { version = "1.1.3" }
|
||||
|
||||
rand = { version = "0.7" }
|
||||
rand_xorshift = { version = "0.2" }
|
||||
thiserror = { version = "1.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
snarkos-storage = { version = "1.0.0" }
|
||||
snarkos-storage = { version = "1.1.3" }
|
||||
|
@ -24,8 +24,8 @@ harness = false
|
||||
leo-ast = { path = "../ast", version = "1.0.0" }
|
||||
leo-input = { path = "../input", version = "1.0.0" }
|
||||
|
||||
snarkos-errors = { version = "1.0.0", default-features = false }
|
||||
snarkos-models = { version = "1.0.0", default-features = false }
|
||||
snarkos-errors = { version = "1.1.3", default-features = false }
|
||||
snarkos-models = { version = "1.1.3", default-features = false }
|
||||
|
||||
pest = { version = "2.0" }
|
||||
serde = { version = "1.0" }
|
||||
|
Loading…
Reference in New Issue
Block a user