diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..3db16b59ab --- /dev/null +++ b/.gitmodules @@ -0,0 +1,18 @@ +[submodule "deps/ledger"] + path = ledger + url = ../ledger.git +[submodule "deps/mina-p2p-messages-rs"] + path = mina-p2p-messages-rs + url = ../mina-p2p-messages-rs.git + branch = openmina-snarker +[submodule "deps/algebra"] + path = deps/algebra + url = https://github.com/openmina/algebra + branch = openmina +[submodule "deps/proof-systems"] + path = deps/proof-systems + url = https://github.com/openmina/proof-systems + branch = ledger-newtypes +[submodule "deps/redux-rs"] + path = deps/redux-rs + url = https://github.com/openmina/redux-rs.git diff --git a/Cargo.lock b/Cargo.lock index c271f393bc..df3c649936 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,12 +178,52 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", ] [[package]] @@ -201,7 +241,6 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "ark-ec" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "ark-ff", "ark-serialize", @@ -215,7 +254,6 @@ dependencies = [ [[package]] name = "ark-ff" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "ark-ff-asm", "ark-ff-macros", @@ -233,7 +271,6 @@ dependencies = [ [[package]] name = "ark-ff-asm" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "quote", "syn 1.0.109", @@ -242,7 +279,6 @@ dependencies = [ [[package]] name = "ark-ff-macros" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "num-bigint", "num-traits", @@ -253,7 +289,6 @@ dependencies = [ [[package]] name = "ark-poly" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "ark-ff", "ark-serialize", @@ -266,7 +301,6 @@ dependencies = [ [[package]] name = "ark-serialize" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "ark-serialize-derive", "ark-std", @@ -276,7 +310,6 @@ dependencies = [ [[package]] name = "ark-serialize-derive" version = "0.3.0" -source = "git+https://github.com/openmina/algebra?branch=openmina#017531e7aaa15a2c856532b0843876e371b01122" dependencies = [ "proc-macro2", "quote", @@ -398,7 +431,7 @@ dependencies = [ "log", "parking", "polling", - "rustix", + "rustix 0.37.20", "slab", "socket2 0.4.9", "waker-fn", @@ -443,17 +476,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -549,6 +571,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bitvec" version = "1.0.1" @@ -727,7 +755,6 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "serde", "time 0.1.45", "wasm-bindgen", "winapi", @@ -763,24 +790,51 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", + "clap_builder", + "clap_derive", + "once_cell", ] +[[package]] +name = "clap_builder" +version = "4.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.22", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + [[package]] name = "cli" version = "0.1.0" dependencies = [ "bytes", + "clap", "console", "hex", "mina-tree", @@ -794,11 +848,16 @@ dependencies = [ "shared", "snark", "snarker", - "structopt", "tokio", "warp", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "concurrent-queue" version = "2.2.0" @@ -1080,16 +1139,6 @@ dependencies = [ "darling_macro 0.14.4", ] -[[package]] -name = "darling" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" -dependencies = [ - "darling_core 0.20.1", - "darling_macro 0.20.1", -] - [[package]] name = "darling_core" version = "0.13.4" @@ -1100,7 +1149,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn 1.0.109", ] @@ -1114,24 +1163,10 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn 1.0.109", ] -[[package]] -name = "darling_core" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 2.0.22", -] - [[package]] name = "darling_macro" version = "0.13.4" @@ -1154,17 +1189,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "darling_macro" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" -dependencies = [ - "darling_core 0.20.1", - "quote", - "syn 2.0.22", -] - [[package]] name = "data-encoding" version = "2.4.0" @@ -1350,18 +1374,6 @@ dependencies = [ "signature 1.6.4", ] -[[package]] -name = "ecdsa" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12844141594ad74185a926d030f3b605f6a903b4e3fec351f3ea338ac5b7637e" -dependencies = [ - "der 0.6.1", - "elliptic-curve", - "rfc6979", - "signature 2.0.0", -] - [[package]] name = "ecies-ed25519" version = "0.5.1" @@ -1475,7 +1487,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "syn 1.0.109", @@ -1669,10 +1681,6 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper", -] [[package]] name = "futures-util" @@ -1762,31 +1770,6 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "gloo-utils" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" -dependencies = [ - "js-sys", - "serde", - "serde_json", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "group" version = "0.12.1" @@ -1801,7 +1784,6 @@ dependencies = [ [[package]] name = "groupmap" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -1849,7 +1831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes", "headers-core", "http", @@ -1867,30 +1849,12 @@ dependencies = [ "http", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -2122,7 +2086,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -2141,9 +2104,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -2212,6 +2172,17 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.1", + "rustix 0.38.3", + "windows-sys 0.48.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -2248,7 +2219,6 @@ dependencies = [ [[package]] name = "kimchi" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -2273,7 +2243,7 @@ dependencies = [ "rayon", "rmp-serde", "serde", - "serde_with 1.14.0", + "serde_with", "strum", "strum_macros", "thiserror", @@ -2286,26 +2256,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lib" -version = "0.1.0" -dependencies = [ - "derive_more", - "libp2p", - "mina-p2p-messages", - "node-p2p", - "num_enum", - "redux", - "regex", - "serde", - "serde_json", - "shared", - "snark", - "strum", - "strum_macros", - "thiserror", -] - [[package]] name = "libc" version = "0.2.147" @@ -2342,7 +2292,6 @@ dependencies = [ "libp2p-quic", "libp2p-swarm", "libp2p-tcp", - "libp2p-wasm-ext", "libp2p-webrtc", "libp2p-yamux", "multiaddr", @@ -2453,14 +2402,11 @@ dependencies = [ "log", "multiaddr", "multihash 0.17.0", - "p256 0.12.0", "quick-protobuf", "rand 0.8.5", - "sec1", "serde", "sha2 0.10.7", "thiserror", - "void", "zeroize", ] @@ -2590,7 +2536,6 @@ dependencies = [ "fnv", "futures", "futures-timer", - "getrandom 0.2.10", "instant", "libp2p-core", "libp2p-identity", @@ -2600,7 +2545,6 @@ dependencies = [ "smallvec", "tokio", "void", - "wasm-bindgen-futures", ] [[package]] @@ -2608,7 +2552,7 @@ name = "libp2p-swarm-derive" version = "0.32.0" source = "git+https://github.com/openmina/rust-libp2p?branch=webrtc-v0.51.3#9f0a1bba70bee064cde13be2457fdce6330b7817" dependencies = [ - "heck 0.4.1", + "heck", "quote", "syn 2.0.22", ] @@ -2647,21 +2591,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "libp2p-wasm-ext" -version = "0.39.0" -source = "git+https://github.com/openmina/rust-libp2p?branch=webrtc-v0.51.3#9f0a1bba70bee064cde13be2457fdce6330b7817" -dependencies = [ - "futures", - "js-sys", - "libp2p-core", - "log", - "parity-send-wrapper", - "wasm-bindgen", - "wasm-bindgen-futures", - "x509-parser 0.14.0", -] - [[package]] name = "libp2p-webrtc" version = "0.4.0-alpha.4" @@ -2717,6 +2646,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "lock_api" version = "0.4.10" @@ -2821,7 +2756,6 @@ dependencies = [ [[package]] name = "mina-curves" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -2830,7 +2764,6 @@ dependencies = [ [[package]] name = "mina-hasher" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ff", "bitvec", @@ -2867,7 +2800,6 @@ dependencies = [ [[package]] name = "mina-poseidon" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -2878,13 +2810,12 @@ dependencies = [ "rand 0.8.5", "rayon", "serde", - "serde_with 1.14.0", + "serde_with", ] [[package]] name = "mina-signer" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -3099,7 +3030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -3152,7 +3083,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", @@ -3164,7 +3095,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -3172,22 +3103,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "node-p2p" -version = "0.1.0" -dependencies = [ - "binprot", - "derive_more", - "libp2p", - "mina-p2p-messages", - "redux", - "serde", - "shared", - "snark", - "strum", - "strum_macros", -] - [[package]] name = "nohash-hasher" version = "0.2.0" @@ -3281,7 +3196,6 @@ dependencies = [ [[package]] name = "o1-utils" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -3296,7 +3210,7 @@ dependencies = [ "rand_core 0.6.4", "rayon", "serde", - "serde_with 1.14.0", + "serde_with", "sha2 0.10.7", "thiserror", ] @@ -3346,23 +3260,11 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ - "ecdsa 0.14.8", + "ecdsa", "elliptic-curve", "sha2 0.10.7", ] -[[package]] -name = "p256" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c124b3cbce43bcbac68c58ec181d98ed6cc7e6d0aa7c3ba97b2563410b0e55" -dependencies = [ - "ecdsa 0.15.1", - "elliptic-curve", - "primeorder", - "sha2 0.10.7", -] - [[package]] name = "p2p" version = "0.1.0" @@ -3400,7 +3302,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ - "ecdsa 0.14.8", + "ecdsa", "elliptic-curve", "sha2 0.10.7", ] @@ -3415,12 +3317,6 @@ dependencies = [ "libm", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parking" version = "2.1.0" @@ -3580,7 +3476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", @@ -3592,7 +3488,6 @@ dependencies = [ [[package]] name = "poly-commitment" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ec", "ark-ff", @@ -3609,7 +3504,7 @@ dependencies = [ "rand_core 0.6.4", "rayon", "serde", - "serde_with 1.14.0", + "serde_with", "thiserror", ] @@ -3665,15 +3560,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "primeorder" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b54f7131b3dba65a2f414cf5bd25b66d4682e4608610668eae785750ba4c5b2" -dependencies = [ - "elliptic-curve", -] - [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -3943,7 +3829,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -3952,13 +3838,12 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redux" version = "0.1.0" -source = "git+https://github.com/openmina/redux-rs.git#155f8208f3105174cbd32172e7580b164d772349" dependencies = [ "enum_dispatch", "serde", @@ -4102,6 +3987,12 @@ dependencies = [ "webrtc-util 0.7.0 (git+https://github.com/openmina/webrtc.git?branch=openmina-7bf14382)", ] +[[package]] +name = "rust-format" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e7c00b6c3bf5e38a880eec01d7e829d12ca682079f8238a464def3c4b31627" + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -4147,11 +4038,24 @@ version = "0.37.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.3", "windows-sys 0.48.0", ] @@ -4313,12 +4217,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" version = "1.0.164" @@ -4378,23 +4276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ "serde", - "serde_with_macros 1.5.2", -] - -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "base64 0.13.1", - "chrono", - "hex", - "indexmap", - "serde", - "serde_json", - "serde_with_macros 2.3.3", - "time 0.3.22", + "serde_with_macros", ] [[package]] @@ -4409,18 +4291,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling 0.20.1", - "proc-macro2", - "quote", - "syn 2.0.22", -] - [[package]] name = "sha-1" version = "0.9.8" @@ -4524,10 +4394,6 @@ name = "signature" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] [[package]] name = "slab" @@ -4596,6 +4462,7 @@ dependencies = [ "p2p", "redux", "regex", + "rust-format", "serde", "serde_json", "shared", @@ -4679,42 +4546,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "strum" version = "0.24.1" @@ -4727,7 +4564,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "rustversion", @@ -4826,7 +4663,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -4847,15 +4684,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -5193,7 +5021,6 @@ dependencies = [ [[package]] name = "turshi" version = "0.1.0" -source = "git+https://github.com/openmina/proof-systems?branch=ledger-newtypes#debf1501e0f319771ffc1d5a65de5b2cf60e44b8" dependencies = [ "ark-ff", "hex", @@ -5254,12 +5081,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "unicode-width" version = "0.1.10" @@ -5325,6 +5146,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.3.4" @@ -5334,12 +5161,6 @@ dependencies = [ "getrandom 0.2.10", ] -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -5425,38 +5246,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm" -version = "0.1.0" -dependencies = [ - "binprot", - "cfg-if", - "derive_more", - "gloo-utils", - "hex", - "js-sys", - "lib", - "libp2p", - "mina-hasher", - "mina-p2p-messages", - "mina-signer", - "rand 0.8.5", - "rayon", - "redux", - "serde", - "serde_json", - "serde_with 2.3.3", - "sha2 0.10.7", - "shared", - "smallvec", - "tracing-subscriber", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-timer", - "wasm_thread", - "web-sys", -] - [[package]] name = "wasm-bindgen" version = "0.2.87" @@ -5732,7 +5521,7 @@ dependencies = [ "hkdf 0.12.3", "hmac 0.12.1", "log", - "p256 0.11.1", + "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", @@ -5769,7 +5558,7 @@ dependencies = [ "hkdf 0.12.3", "hmac 0.12.1", "log", - "p256 0.11.1", + "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", @@ -5972,7 +5761,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -5992,7 +5781,7 @@ version = "0.7.0" source = "git+https://github.com/openmina/webrtc.git?branch=openmina-7bf14382#0c5e610bac06ac3f411442ee71c6142ef98dfefc" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", diff --git a/Cargo.toml b/Cargo.toml index e862ff806e..d7fd5bb964 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,17 @@ members = [ "p2p", "snarker", "node/shared", - "node/p2p", - "node/lib", + # "node/p2p", + # "node/lib", "node/snark", - "node/wasm" + # "node/wasm" + + "mina-p2p-messages-rs", + "ledger", ] +exclude = [ "deps/redux-rs" ] + [profile.fuzz] inherits = "release" opt-level = 3 @@ -23,18 +28,41 @@ panic = "abort" incremental = false codegen-units = 1 +[patch.'https://github.com/openmina/algebra'] +ark-ff = { path = "deps/algebra/ff" } +ark-ec = { path = "deps/algebra/ec" } +ark-poly = { path = "deps/algebra/poly" } +ark-serialize = { path = "deps/algebra/serialize" } + [patch.crates-io] -ark-ff = { git = "https://github.com/openmina/algebra", branch = "openmina" } -ark-ec = { git = "https://github.com/openmina/algebra", branch = "openmina" } -ark-poly = { git = "https://github.com/openmina/algebra", branch = "openmina" } -ark-serialize = { git = "https://github.com/openmina/algebra", branch = "openmina" } +ark-ff = { path = "deps/algebra/ff" } +ark-ec = { path = "deps/algebra/ec" } +ark-poly = { path = "deps/algebra/poly" } +ark-serialize = { path = "deps/algebra/serialize" } + +[patch.'https://github.com/openmina/proof-systems'] +mina-hasher = { path = "deps/proof-systems/hasher" } +mina-signer = { path = "deps/proof-systems/signer" } +mina-curves = { path = "deps/proof-systems/curves" } +o1-utils = { path = "deps/proof-systems/utils" } +kimchi = { path = "deps/proof-systems/kimchi" } +poly-commitment = { path = "deps/proof-systems/poly-commitment" } +mina-poseidon = { path = "deps/proof-systems/poseidon" } [patch.'https://github.com/o1-labs/proof-systems'] -mina-hasher = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -mina-signer = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -mina-curves = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -o1-utils = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -kimchi = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -poly-commitment = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } -mina-poseidon = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes" } +mina-hasher = { path = "deps/proof-systems/hasher" } +mina-signer = { path = "deps/proof-systems/signer" } +mina-curves = { path = "deps/proof-systems/curves" } +o1-utils = { path = "deps/proof-systems/utils" } +kimchi = { path = "deps/proof-systems/kimchi" } +poly-commitment = { path = "deps/proof-systems/poly-commitment" } +mina-poseidon = { path = "deps/proof-systems/poseidon" } + +[patch.'https://github.com/openmina/redux-rs'] +redux = { path = "deps/redux-rs" } + +[patch.'https://github.com/openmina/mina-p2p-messages-rs'] +mina-p2p-messages = { path = "mina-p2p-messages-rs", features = [ "hashing" ] } +[patch.'https://github.com/openmina/ledger'] +ledger = { path = "ledger", package = "mina-tree" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6ddeff1763..5f24768500 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -21,9 +21,11 @@ redux = { git = "https://github.com/openmina/redux-rs.git", features = ["serde"] ledger = { package = "mina-tree", git = "https://github.com/openmina/ledger", rev = "a14554563c886d00ac6a26bb1e05dfdd41a57c32" } console = "0.15.5" -structopt = "0.3.26" +clap = { version = "4.3", features = [ "derive", "env" ] } shared = { path = "../node/shared" } snark = { path = "../node/snark" } snarker = { path = "../snarker" } bytes = "1.4.0" +tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] } +tracing = "0.1.37" diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 791dfd851d..d85b8f1cbd 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -3,10 +3,17 @@ pub mod snarker; pub type CommandError = Box; -#[derive(Debug, structopt::StructOpt)] -#[structopt(name = "openmina", about = "Openmina Cli")] +#[derive(Debug, clap::Parser)] +#[command(name = "openmina", about = "Openmina Cli")] +pub struct OpenminaCli { + #[command(subcommand)] + pub command: Command, +} + +#[derive(Debug, clap::Subcommand)] pub enum Command { Snark(snark::Snark), + /// Standalone snarker Snarker(snarker::Snarker), } diff --git a/cli/src/commands/snark/mod.rs b/cli/src/commands/snark/mod.rs index a6012e5f35..f3abe34993 100644 --- a/cli/src/commands/snark/mod.rs +++ b/cli/src/commands/snark/mod.rs @@ -1,16 +1,21 @@ pub mod precalculate_block_verifier_index_and_srs; pub use precalculate_block_verifier_index_and_srs::PrecalculateBlockVerifierIndexAndSrs; -#[derive(Debug, structopt::StructOpt)] -#[structopt(name = "openmina", about = "Openmina Cli")] -pub enum Snark { +#[derive(Debug, clap::Args)] +pub struct Snark { + #[command(subcommand)] + pub command: SnarkCommand, +} + +#[derive(Debug, clap::Subcommand)] +pub enum SnarkCommand { PrecalculateBlockVerifierIndexAndSrs(PrecalculateBlockVerifierIndexAndSrs), } impl Snark { pub fn run(self) -> Result<(), crate::CommandError> { - match self { - Self::PrecalculateBlockVerifierIndexAndSrs(v) => v.run(), + match self.command { + SnarkCommand::PrecalculateBlockVerifierIndexAndSrs(v) => v.run(), } } } diff --git a/cli/src/commands/snark/precalculate_block_verifier_index_and_srs.rs b/cli/src/commands/snark/precalculate_block_verifier_index_and_srs.rs index c18829b025..377ec3120e 100644 --- a/cli/src/commands/snark/precalculate_block_verifier_index_and_srs.rs +++ b/cli/src/commands/snark/precalculate_block_verifier_index_and_srs.rs @@ -4,12 +4,10 @@ use std::path::PathBuf; use ::snark::{get_srs, get_verifier_index, srs_to_bytes, verifier_index_to_bytes}; use sha2::{Digest, Sha256}; -#[derive(Debug, structopt::StructOpt)] -#[structopt( - about = "Precalculate Block Verifier Index and SRS, to be quickly loaded ready to be used for block verification" -)] +#[derive(Debug, clap::Args)] +/// Precalculate Block Verifier Index and SRS, to be quickly loaded ready to be used for block verification pub struct PrecalculateBlockVerifierIndexAndSrs { - #[structopt(short, long, parse(from_os_str), default_value = ".")] + #[arg(default_value = ".")] pub out: PathBuf, } diff --git a/cli/src/commands/snarker/mod.rs b/cli/src/commands/snarker/mod.rs index 84f4f88c05..e2479a0217 100644 --- a/cli/src/commands/snarker/mod.rs +++ b/cli/src/commands/snarker/mod.rs @@ -3,12 +3,14 @@ use std::sync::Arc; use std::time::Duration; use rand::prelude::*; -use serde::Serialize; use snarker::p2p::service_impl::TaskSpawner; +use shared::info; +use shared::log::inner::Level; use tokio::select; use tokio::sync::{mpsc, oneshot}; +use serde::Serialize; -use snarker::account::AccountSecretKey; +use snarker::account::{AccountSecretKey, AccountPublicKey}; use snarker::event_source::{ Event, EventSourceProcessEventsAction, EventSourceWaitForEventsAction, EventSourceWaitTimeoutAction, @@ -34,23 +36,32 @@ mod http_server; mod rpc; use rpc::RpcP2pConnectionOutgoingResponse; +mod tracing; -#[derive(Debug, structopt::StructOpt)] -#[structopt(name = "snarker", about = "Openmina snarker")] +/// Openmina snarker +#[derive(Debug, clap::Args)] pub struct Snarker { - #[structopt(long, default_value = "3000")] - pub http_port: u16, - #[structopt(short, long)] + /// Chain ID + #[arg(long, short = 'i', env)] pub chain_id: String, + + /// Snarker public key + #[arg(long, short = 'k', env)] + pub public_key: AccountPublicKey, + + /// Port to listen to + #[arg(long, short, default_value = "3000")] + pub port: u16, + + /// Verbosity level + #[arg(long, short, default_value = "info")] + pub verbosity: Level, } impl Snarker { pub fn run(self) -> Result<(), crate::CommandError> { - // stderrlog::new() - // .verbosity(5) - // // .module(module_path!()) // remove this line to see libp2p logs. - // .init() - // .unwrap(); + tracing::initialize(self.verbosity); + if let Err(ref e) = rayon::ThreadPoolBuilder::new() .num_threads(num_cpus::get().max(2) - 1) .build_global() @@ -72,19 +83,6 @@ impl Snarker { let secret_key = SecretKey::from_bytes(bytes); let pub_key = secret_key.public_key(); let peer_id = PeerId::from_public_key(pub_key.clone()); - eprintln!("peer_id: {peer_id}"); - - let sec_key: AccountSecretKey = match std::env::var("MINA_SNARKER_SEC_KEY") { - Ok(v) => match v.parse() { - Err(err) => { - return Err(format!("error while parsing `MINA_SNARKER_SEC_KEY`: {err}").into()) - } - Ok(v) => v, - }, - Err(err) => { - return Err(format!("env `MINA_SNARKER_SEC_KEY` not set! {err}").into()); - } - }; let config = Config { ledger: LedgerConfig {}, @@ -94,7 +92,7 @@ impl Snarker { block_verifier_srs: snarker::snark::get_srs().into(), }, snarker: SnarkerConfig { - public_key: sec_key.public_key(), + public_key: self.public_key, job_commitments: JobCommitmentsConfig { commitment_timeout: Duration::from_secs(6 * 60), }, @@ -172,7 +170,7 @@ impl Snarker { let mut rpc_service = rpc::RpcService::new(); - let http_port = self.http_port; + let http_port = self.port; let rpc_sender = RpcSender { tx: rpc_service.req_sender().clone(), }; diff --git a/cli/src/commands/snarker/tracing.rs b/cli/src/commands/snarker/tracing.rs new file mode 100644 index 0000000000..4aa7faa00f --- /dev/null +++ b/cli/src/commands/snarker/tracing.rs @@ -0,0 +1,31 @@ +use std::fmt::Result; + +use tracing::Level; +use tracing_subscriber::fmt::{format::Writer, time::FormatTime}; + +fn redux_timer(w: &mut Writer<'_>) -> Result { + match redux::SystemTime::now().duration_since(redux::SystemTime::UNIX_EPOCH) { + Ok(v) => { + write!(w, "{}", v.as_nanos()) + } + Err(_) => write!(w, "unknown-time"), + } +} + +#[allow(dead_code)] +struct ReduxTimer; + +impl FormatTime for ReduxTimer { + fn format_time(&self, w: &mut Writer<'_>) -> Result { + redux_timer(w) + } +} + +pub fn initialize(max_log_level: Level) { + let subscriber = tracing_subscriber::FmtSubscriber::builder() + .with_max_level(max_log_level) + //.with_timer(ReduxTimer) + .finish(); + tracing::subscriber::set_global_default(subscriber) + .expect("global subscriber should be configurable"); +} diff --git a/cli/src/main.rs b/cli/src/main.rs index d2e4dc1f7c..7596dafd89 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,13 +1,12 @@ pub mod commands; -pub use commands::{Command, CommandError}; +use clap::Parser; +pub use commands::CommandError; mod exit_with_error; pub use exit_with_error::exit_with_error; -use structopt::StructOpt; - fn main() { - match commands::Command::from_args().run() { + match commands::OpenminaCli::parse().command.run() { Ok(_) => {} Err(err) => exit_with_error(err), } diff --git a/deps/algebra b/deps/algebra new file mode 160000 index 0000000000..017531e7aa --- /dev/null +++ b/deps/algebra @@ -0,0 +1 @@ +Subproject commit 017531e7aaa15a2c856532b0843876e371b01122 diff --git a/deps/proof-systems b/deps/proof-systems new file mode 160000 index 0000000000..debf1501e0 --- /dev/null +++ b/deps/proof-systems @@ -0,0 +1 @@ +Subproject commit debf1501e0f319771ffc1d5a65de5b2cf60e44b8 diff --git a/deps/redux-rs b/deps/redux-rs new file mode 160000 index 0000000000..8c5e611913 --- /dev/null +++ b/deps/redux-rs @@ -0,0 +1 @@ +Subproject commit 8c5e611913256f4e326a3e83970c9eae215297f2 diff --git a/ledger b/ledger new file mode 160000 index 0000000000..a14554563c --- /dev/null +++ b/ledger @@ -0,0 +1 @@ +Subproject commit a14554563c886d00ac6a26bb1e05dfdd41a57c32 diff --git a/mina-p2p-messages-rs b/mina-p2p-messages-rs new file mode 160000 index 0000000000..0885885a3d --- /dev/null +++ b/mina-p2p-messages-rs @@ -0,0 +1 @@ +Subproject commit 0885885a3d5ebb1119f236184e2f7f1af6a520e8 diff --git a/node/lib/Cargo.toml b/node/lib/Cargo.toml index fa8e1f5ca3..1c8a6098a4 100644 --- a/node/lib/Cargo.toml +++ b/node/lib/Cargo.toml @@ -22,3 +22,4 @@ snark = { path = "../snark" } [build-dependencies] regex = "1" +rust-format = "0.3" diff --git a/node/lib/build.rs b/node/lib/build.rs index cb072d9807..f1a4a5401d 100644 --- a/node/lib/build.rs +++ b/node/lib/build.rs @@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; use regex::Regex; +use rust_format::Formatter; fn visit_dirs(dir: &PathBuf, cb: &mut dyn FnMut(&DirEntry)) -> io::Result<()> { if dir.is_dir() { @@ -67,7 +68,9 @@ fn main() -> Result<(), Box> { let Some(line) = lines.next() else { break }; let line = line.unwrap(); - let Some(matches) = action_def_re.captures(&line) else { continue }; + let Some(matches) = action_def_re.captures(&line) else { + continue; + }; match &matches[1] { "struct" => { if let Some(action_name) = matches.get(2) { @@ -198,9 +201,9 @@ fn main() -> Result<(), Box> { let contents = format!("{use_deps}\n\n{use_statements}\n\n{action_kind_def}\n\n{action_kind_get_impls}\n"); - fs::write(crate_dir.join("src/action_kind.rs"), contents)?; - - std::process::Command::new("cargo").arg("fmt").output()?; + let path = crate_dir.join("src/action_kind.rs"); + fs::write(&path, contents)?; + rust_format::RustFmt::default().format_file(&path).expect("failed to format generated file"); Ok(()) } diff --git a/node/shared/src/log.rs b/node/shared/src/log.rs index 6e731ecd87..155e473621 100644 --- a/node/shared/src/log.rs +++ b/node/shared/src/log.rs @@ -4,10 +4,7 @@ /// of the following: `redux::Store`, global state where time is stored, /// `redux::ActionMeta::time()`. pub fn system_time() -> redux::Timestamp { - let time = redux::SystemTime::now() - .duration_since(redux::SystemTime::UNIX_EPOCH) - .unwrap(); - redux::Timestamp::new(time.as_nanos() as u64) + redux::Timestamp::now() } pub fn time_to_str(t: redux::Timestamp) -> String { @@ -19,38 +16,45 @@ pub mod inner { pub use tracing::*; } +#[macro_export] +macro_rules! log_entry { + ($level:ident, $time:expr; $($tts:tt)*) => { + $crate::log::inner::$level!(time = $crate::log::time_to_str($time), $($tts)*); + } +} + #[macro_export] macro_rules! trace { ($time:expr; $($tts:tt)*) => { - ::shared::log::inner::trace!(time = ::shared::log::time_to_str($time), $($tts)*); + $crate::log_entry!(trace, $time; $($tts)*); } } #[macro_export] macro_rules! debug { ($time:expr; $($tts:tt)*) => { - ::shared::log::inner::debug!(time = ::shared::log::time_to_str($time), $($tts)*); + $crate::log_entry!(debug, $time; $($tts)*); } } #[macro_export] macro_rules! info { ($time:expr; $($tts:tt)*) => { - ::shared::log::inner::info!(time = ::shared::log::time_to_str($time), $($tts)*); + $crate::log_entry!(info, $time; $($tts)*); } } #[macro_export] macro_rules! warn { ($time:expr; $($tts:tt)*) => { - ::shared::log::inner::warn!(time = ::shared::log::time_to_str($time), $($tts)*); + $crate::log_entry!(warn, $time; $($tts)*); } } #[macro_export] macro_rules! error { ($time:expr; $($tts:tt)*) => { - ::shared::log::inner::error!(time = ::shared::log::time_to_str($time), $($tts)*); + $crate::log_entry!(error, $time; $($tts)*); } } diff --git a/snarker/Cargo.toml b/snarker/Cargo.toml index 0a99579696..33b156e6bc 100644 --- a/snarker/Cargo.toml +++ b/snarker/Cargo.toml @@ -29,3 +29,4 @@ p2p = { path = "../p2p" } [build-dependencies] regex = "1" +rust-format = "0.3" diff --git a/snarker/build.rs b/snarker/build.rs index b699317985..c4a538de03 100644 --- a/snarker/build.rs +++ b/snarker/build.rs @@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; use regex::Regex; +use rust_format::Formatter; fn visit_dirs(dir: &PathBuf, cb: &mut dyn FnMut(&DirEntry)) -> io::Result<()> { if dir.is_dir() { @@ -72,7 +73,9 @@ fn main() -> Result<(), Box> { let Some(line) = lines.next() else { break }; let line = line.unwrap(); - let Some(matches) = action_def_re.captures(&line) else { continue }; + let Some(matches) = action_def_re.captures(&line) else { + continue; + }; match &matches[1] { "struct" => { if let Some(action_name) = matches.get(2) { @@ -207,9 +210,9 @@ fn main() -> Result<(), Box> { let contents = format!("{use_deps}\n\n{use_statements}\n\n{action_kind_def}\n\n{action_kind_get_impls}\n"); - fs::write(crate_dir.join("src/action_kind.rs"), contents)?; - - std::process::Command::new("cargo").arg("fmt").output()?; + let path = crate_dir.join("src/action_kind.rs"); + fs::write(&path, contents)?; + rust_format::RustFmt::default().format_file(&path).expect("failed to format generated file"); Ok(()) } diff --git a/snarker/src/account/public_key.rs b/snarker/src/account/public_key.rs index 48a5b371c2..bda4a282c0 100644 --- a/snarker/src/account/public_key.rs +++ b/snarker/src/account/public_key.rs @@ -1,5 +1,7 @@ +use std::str::FromStr; + use binprot_derive::{BinProtRead, BinProtWrite}; -use mina_p2p_messages::v2::{NonZeroCurvePoint, NonZeroCurvePointUncompressedStableV1}; +use mina_p2p_messages::{v2::{NonZeroCurvePoint, NonZeroCurvePointUncompressedStableV1}, b58::FromBase58CheckError}; use serde::{Deserialize, Serialize}; use mina_signer::{CompressedPubKey, PubKey}; @@ -36,3 +38,12 @@ impl From for NonZeroCurvePoint { value.0 } } + + +impl FromStr for AccountPublicKey { + type Err = FromBase58CheckError; + + fn from_str(s: &str) -> Result { + Ok(Self(s.parse()?)) + } +}