From cd64555185ae646724929013b17b95999ee21835 Mon Sep 17 00:00:00 2001 From: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:31:11 -0300 Subject: [PATCH 1/6] follow-up(miden-proving-service): address missing comments (#1078) * review: remove unused deps * review: remove testing feature from docs and README * review: remove once_cell dep * review: add license section to readme * review: use crate_root for proto files dir * review: rename midne-remote-provers, mark it as no_std in lib.rs * chore: update comment in build.rs * review: do not use .take * review: swap --features and --exclude calls in makefile * review: fix license section in readme --- CHANGELOG.md | 2 +- Cargo.lock | 447 +++++++----------- Cargo.toml | 2 +- Makefile | 10 +- bin/proving-service/Cargo.toml | 6 +- bin/proving-service/README.md | 12 +- bin/proving-service/build.rs | 2 +- bin/proving-service/src/proxy/mod.rs | 7 +- .../Cargo.toml | 4 +- .../README.md | 4 + .../build.rs | 6 +- .../src/generated/mod.rs | 0 .../src/generated/nostd/api.rs | 0 .../src/generated/nostd/mod.rs | 0 .../src/generated/std/api.rs | 0 .../src/generated/std/mod.rs | 0 .../src/lib.rs | 10 +- .../src/prover.rs | 5 +- 18 files changed, 204 insertions(+), 313 deletions(-) rename {miden-remote-provers => miden-proving-service-client}/Cargo.toml (94%) rename {miden-remote-provers => miden-proving-service-client}/README.md (93%) rename {miden-remote-provers => miden-proving-service-client}/build.rs (93%) rename {miden-remote-provers => miden-proving-service-client}/src/generated/mod.rs (100%) rename {miden-remote-provers => miden-proving-service-client}/src/generated/nostd/api.rs (100%) rename {miden-remote-provers => miden-proving-service-client}/src/generated/nostd/mod.rs (100%) rename {miden-remote-provers => miden-proving-service-client}/src/generated/std/api.rs (100%) rename {miden-remote-provers => miden-proving-service-client}/src/generated/std/mod.rs (100%) rename {miden-remote-provers => miden-proving-service-client}/src/lib.rs (77%) rename {miden-remote-provers => miden-proving-service-client}/src/prover.rs (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b361c114c..b97cf06d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ - Remove multi-threaded account seed generation due to single-threaded generation being faster (#1061). - Made `AccountIdError` public (#1067). - Made `BasicFungibleFaucet::MAX_DECIMALS` public (#1063). -- [BREAKING] Removed `miden-tx-prover` crate and created `miden-proving-service` and `miden-remote-provers` (#1047). +- [BREAKING] Removed `miden-tx-prover` crate and created `miden-proving-service` and `miden-proving-service-client` (#1047). - Deduplicate `masm` procedures across kernel and miden lib to a shared `util` module (#1070). ## 0.6.2 (2024-11-20) diff --git a/Cargo.lock b/Cargo.lock index 18a0dbd88..68bf3fe80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,10 +242,10 @@ dependencies = [ "axum-core", "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.5.2", + "hyper", "hyper-util", "itoa", "matchit", @@ -258,7 +258,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower 0.5.2", "tower-layer", @@ -275,13 +275,13 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -311,12 +311,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -1092,25 +1086,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.7.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.7" @@ -1122,7 +1097,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.2.0", + "http", "indexmap 2.7.0", "slab", "tokio", @@ -1178,12 +1153,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hermit-abi" version = "0.4.0" @@ -1207,17 +1176,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.2.0" @@ -1229,17 +1187,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -1247,7 +1194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http", ] [[package]] @@ -1258,8 +1205,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -1277,47 +1224,40 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.32" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", + "h2", + "http", + "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] -name = "hyper" -version = "1.5.2" +name = "hyper-rustls" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ - "bytes", - "futures-channel", "futures-util", - "h2 0.4.7", - "http 1.2.0", - "http-body 1.0.1", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "smallvec", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", "tokio", - "want", + "tokio-rustls", + "tower-service", ] [[package]] @@ -1326,7 +1266,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.2", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -1335,15 +1275,18 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper 0.14.32", + "http-body-util", + "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", ] [[package]] @@ -1355,9 +1298,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.2.0", - "http-body 1.0.1", - "hyper 1.5.2", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", @@ -1554,12 +1497,6 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" -[[package]] -name = "integer-encoding" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" - [[package]] name = "ipnet" version = "2.10.1" @@ -2061,12 +1998,10 @@ dependencies = [ "miden-objects", "miden-tx", "miette", - "once_cell", - "opentelemetry 0.27.1", - "opentelemetry-jaeger", + "opentelemetry", "opentelemetry-otlp", - "opentelemetry-semantic-conventions 0.27.0", - "opentelemetry_sdk 0.27.1", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk", "pingora", "pingora-core", "pingora-limits", @@ -2090,11 +2025,10 @@ dependencies = [ "tracing-opentelemetry", "tracing-subscriber", "uuid", - "winter-maybe-async", ] [[package]] -name = "miden-remote-provers" +name = "miden-proving-service-client" version = "0.1.0" dependencies = [ "async-trait", @@ -2389,16 +2323,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - [[package]] name = "object" version = "0.36.7" @@ -2464,20 +2388,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "opentelemetry" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" -dependencies = [ - "futures-core", - "futures-sink", - "js-sys", - "once_cell", - "pin-project-lite", - "thiserror 1.0.69", -] - [[package]] name = "opentelemetry" version = "0.27.1" @@ -2492,21 +2402,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "opentelemetry-jaeger" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501b471b67b746d9a07d4c29f8be00f952d1a2eca356922ede0098cbaddff19f" -dependencies = [ - "async-trait", - "futures-core", - "futures-util", - "opentelemetry 0.23.0", - "opentelemetry-semantic-conventions 0.15.0", - "opentelemetry_sdk 0.23.0", - "thrift", -] - [[package]] name = "opentelemetry-otlp" version = "0.27.0" @@ -2515,10 +2410,10 @@ checksum = "91cf61a1868dacc576bf2b2a1c3e9ab150af7272909e80085c3173384fe11f76" dependencies = [ "async-trait", "futures-core", - "http 1.2.0", - "opentelemetry 0.27.1", + "http", + "opentelemetry", "opentelemetry-proto", - "opentelemetry_sdk 0.27.1", + "opentelemetry_sdk", "prost", "thiserror 1.0.69", "tokio", @@ -2532,43 +2427,18 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6e05acbfada5ec79023c85368af14abd0b307c015e9064d249b2a950ef459a6" dependencies = [ - "opentelemetry 0.27.1", - "opentelemetry_sdk 0.27.1", + "opentelemetry", + "opentelemetry_sdk", "prost", "tonic", ] -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1869fb4bb9b35c5ba8a1e40c9b128a7b4c010d07091e864a29da19e4fe2ca4d7" - [[package]] name = "opentelemetry-semantic-conventions" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc1b6902ff63b32ef6c489e8048c5e253e2e4a803ea3ea7e783914536eb15c52" -[[package]] -name = "opentelemetry_sdk" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" -dependencies = [ - "async-trait", - "futures-channel", - "futures-executor", - "futures-util", - "lazy_static", - "once_cell", - "opentelemetry 0.23.0", - "ordered-float 4.6.0", - "percent-encoding", - "rand", - "thiserror 1.0.69", -] - [[package]] name = "opentelemetry_sdk" version = "0.27.1" @@ -2580,7 +2450,7 @@ dependencies = [ "futures-executor", "futures-util", "glob", - "opentelemetry 0.27.1", + "opentelemetry", "percent-encoding", "rand", "serde_json", @@ -2590,24 +2460,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - -[[package]] -name = "ordered-float" -version = "4.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" -dependencies = [ - "num-traits", -] - [[package]] name = "os_str_bytes" version = "6.6.1" @@ -2759,7 +2611,7 @@ dependencies = [ "blake2", "bytes", "hex", - "http 1.2.0", + "http", "httparse", "httpdate", "indexmap 1.9.3", @@ -2798,8 +2650,8 @@ dependencies = [ "daemonize", "flate2", "futures", - "h2 0.4.7", - "http 1.2.0", + "h2", + "http", "httparse", "httpdate", "libc", @@ -2845,7 +2697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcb3f62d852da015e76ced56e93e6d52941679a9825281c90f2897841129e59d" dependencies = [ "bytes", - "http 1.2.0", + "http", "httparse", "pingora-error", "pingora-http", @@ -2861,7 +2713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70202f126056f366549afc804741e12dd9f419cfc79a0063ab15653007a0f4c6" dependencies = [ "bytes", - "http 1.2.0", + "http", "pingora-error", ] @@ -2894,7 +2746,7 @@ dependencies = [ "derivative", "fnv", "futures", - "http 1.2.0", + "http", "log", "pingora-core", "pingora-error", @@ -2942,8 +2794,8 @@ dependencies = [ "bytes", "clap 3.2.25", "futures", - "h2 0.4.7", - "http 1.2.0", + "h2", + "http", "log", "once_cell", "pingora-cache", @@ -3379,20 +3231,23 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ - "base64 0.21.7", + "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -3405,16 +3260,17 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -3426,6 +3282,21 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmp" version = "0.8.14" @@ -3525,13 +3396,43 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "rustls" +version = "0.23.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ - "base64 0.21.7", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -3964,17 +3865,14 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -3989,20 +3887,20 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.7.0", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -4129,28 +4027,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "thrift" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" -dependencies = [ - "byteorder", - "integer-encoding", - "log", - "ordered-float 2.10.1", - "threadpool", -] - [[package]] name = "thrift_codec" version = "0.1.1" @@ -4229,6 +4105,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.17" @@ -4309,13 +4195,13 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.22.1", + "base64", "bytes", - "h2 0.4.7", - "http 1.2.0", - "http-body 1.0.1", + "h2", + "http", + "http-body", "http-body-util", - "hyper 1.5.2", + "hyper", "hyper-timeout", "hyper-util", "percent-encoding", @@ -4363,10 +4249,10 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5299dd20801ad736dccb4a5ea0da7376e59cd98f213bf1c3d478cf53f4834b58" dependencies = [ - "base64 0.22.1", + "base64", "bytes", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "pin-project", "tokio-stream", @@ -4383,12 +4269,12 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef5ca6e7bdd0042c440d36b6df97c1436f1d45871ce18298091f114004b1beb4" dependencies = [ - "base64 0.22.1", + "base64", "byteorder", "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "httparse", "js-sys", @@ -4431,7 +4317,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower-layer", "tower-service", @@ -4446,8 +4332,8 @@ checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.7.0", "bytes", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "pin-project-lite", "tower-layer", @@ -4518,8 +4404,8 @@ checksum = "97a971f6058498b5c0f1affa23e7ea202057a7301dbff68e968b2d578bcbd053" dependencies = [ "js-sys", "once_cell", - "opentelemetry 0.27.1", - "opentelemetry_sdk 0.27.1", + "opentelemetry", + "opentelemetry_sdk", "smallvec", "tracing", "tracing-core", @@ -4661,6 +4547,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.4" @@ -4942,6 +4834,17 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -5118,16 +5021,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winter-air" version = "0.10.3" @@ -5323,6 +5216,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zerovec" version = "0.10.4" diff --git a/Cargo.toml b/Cargo.toml index 4a6acab50..dfd217821 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = [ "miden-lib", "miden-tx", - "miden-remote-provers", + "miden-proving-service-client", "objects", "bin/bench-tx", "bin/proving-service", diff --git a/Makefile b/Makefile index 17fbccefc..e8034b1d7 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ clippy: ## Runs Clippy with configs .PHONY: clippy-no-std clippy-no-std: ## Runs Clippy with configs - cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib --exclude miden-proving-service --features tx-prover -- -D warnings + cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib --features tx-prover --exclude miden-proving-service -- -D warnings .PHONY: fix @@ -105,12 +105,12 @@ build: ## By default we should build in release mode .PHONY: build-no-std build-no-std: ## Build without the standard library - ${BUILD_KERNEL_ERRORS} cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib --exclude miden-proving-service --features tx-prover + ${BUILD_KERNEL_ERRORS} cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib --features tx-prover --exclude miden-proving-service .PHONY: build-no-std-testing build-no-std-testing: ## Build without the standard library. Includes the `testing` feature - cargo build --no-default-features --target wasm32-unknown-unknown --workspace --exclude miden-bench-tx --exclude miden-proving-service --features testing,tx-prover + cargo build --no-default-features --target wasm32-unknown-unknown --workspace --exclude miden-bench-tx --features testing,tx-prover --exclude miden-proving-service .PHONY: build-async @@ -129,7 +129,3 @@ bench-tx: ## Run transaction benchmarks .PHONY: install-proving-service install-proving-service: ## Install proving service's CLI cargo install --path bin/proving-service --bin miden-proving-service --locked --features concurrent - -.PHONY: install-proving-service-testing -install-proving-service-testing: ## Install proving service's CLI intended for testing purposes - cargo install --path bin/proving-service --bin miden-proving-service --locked --features concurrent,testing diff --git a/bin/proving-service/Cargo.toml b/bin/proving-service/Cargo.toml index bf8ec6438..f7fdec068 100644 --- a/bin/proving-service/Cargo.toml +++ b/bin/proving-service/Cargo.toml @@ -17,7 +17,6 @@ path = "src/main.rs" [features] default = ["concurrent"] -testing = ["miden-objects/testing", "miden-lib/testing", "miden-tx/testing"] concurrent = ["miden-tx/concurrent"] [dependencies] @@ -29,19 +28,17 @@ figment = { version = "0.10", features = ["toml", "env"] } miden-lib = { workspace = true, default-features = false } miden-objects = { workspace = true, default-features = false, features = ["std"] } miden-tx = { workspace = true, default-features = false, features = ["std"] } -once_cell = "1.19" opentelemetry = { version = "0.27", features = ["metrics", "trace"] } opentelemetry-otlp = { version = "0.27", features = ["grpc-tonic"] } opentelemetry_sdk = { version = "0.27", features = ["metrics", "rt-tokio"] } opentelemetry-semantic-conventions = "0.27" -opentelemetry-jaeger = "0.22" prometheus = "0.13" prost = { version = "0.13", default-features = false, features = ["derive"] } pingora = { version = "0.4", features = [ "lb" ] } pingora-core = "0.4" pingora-proxy = "0.4" pingora-limits = "0.4" -reqwest = { version = "0.11" } +reqwest = { version = "0.12" } serde = { version = "1.0", features = ["derive"] } serde_qs = { version = "0.13" } tokio = { version = "1.38", features = ["full"] } @@ -55,7 +52,6 @@ tracing = { version = "0.1" } tracing-opentelemetry = "0.28" tracing-subscriber = { version = "0.3", features = ["fmt", "json", "env-filter"] } uuid = { version = "1.11", features = ["v4"] } -winter-maybe-async = { version = "0.10" } [dev-dependencies] miden-lib = { workspace = true , default-features = false, features = ["testing"]} diff --git a/bin/proving-service/README.md b/bin/proving-service/README.md index 7b5d71ef2..eeba9021d 100644 --- a/bin/proving-service/README.md +++ b/bin/proving-service/README.md @@ -16,12 +16,6 @@ make install-proving-service The CLI can be installed from the source code using specific git revisions with `cargo install`. Note that since these aren't official releases we cannot provide much support for any issues you run into, so consider this for advanced users only. -Note that for the prover worker you might need to enable the `testing` feature in case the transactions were executed with reduced proof-of-work requirements (or otherwise, the proving process will fail). This step will also generate the necessary protobuf-related files. You can achieve that by generating the binary with: - -```bash -make install-proving-service-testing -``` - ## Worker To start the worker service you will need to run: @@ -154,6 +148,8 @@ Description of this crate's feature: | Features | Description | | ------------ | ------------------------------------------------------------------------------------------------------------| -| `std` | Enable usage of Rust's `std`, use `--no-default-features` for `no-std` support. | | `concurrent` | Enables concurrent code to speed up runtime execution. | -| `testing` | Enables testing utilities and reduces proof-of-work requirements to speed up tests' runtimes. | + +## License + +This project is [MIT licensed](../../LICENSE). diff --git a/bin/proving-service/build.rs b/bin/proving-service/build.rs index e4187a324..3bb23b9be 100644 --- a/bin/proving-service/build.rs +++ b/bin/proving-service/build.rs @@ -24,7 +24,7 @@ fn compile_tonic_server_proto() -> miette::Result<()> { PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set")); let dst_dir = crate_root.join("src").join("generated"); - // Construct the path to the miden-remote-provers/proto/api.proto file + // Construct the path to the proto/api.proto file let proto_dir = crate_root .parent() // Go up to the workspace root .expect("bin directory should exist") diff --git a/bin/proving-service/src/proxy/mod.rs b/bin/proving-service/src/proxy/mod.rs index 511a102ad..7e770322d 100644 --- a/bin/proving-service/src/proxy/mod.rs +++ b/bin/proving-service/src/proxy/mod.rs @@ -2,7 +2,7 @@ use std::{ collections::VecDeque, future::Future, pin::Pin, - sync::Arc, + sync::{Arc, LazyLock}, time::{Duration, Instant}, }; @@ -13,7 +13,6 @@ use metrics::{ REQUEST_FAILURE_COUNT, REQUEST_LATENCY, REQUEST_RETRIES, WORKER_BUSY, WORKER_COUNT, WORKER_REQUEST_COUNT, WORKER_UNHEALTHY, }; -use once_cell::sync::Lazy; use pingora::{ http::ResponseHeader, lb::Backend, @@ -275,7 +274,7 @@ impl LoadBalancerState { } /// Rate limiter -static RATE_LIMITER: Lazy = Lazy::new(|| Rate::new(Duration::from_secs(1))); +static RATE_LIMITER: LazyLock = LazyLock::new(|| Rate::new(Duration::from_secs(1))); // REQUEST QUEUE // ================================================================================================ @@ -329,7 +328,7 @@ impl RequestQueue { } /// Shared state. It keeps track of the order of the requests to then assign them to the workers. -static QUEUE: Lazy = Lazy::new(RequestQueue::new); +static QUEUE: LazyLock = LazyLock::new(RequestQueue::new); // REQUEST CONTEXT // ================================================================================================ diff --git a/miden-remote-provers/Cargo.toml b/miden-proving-service-client/Cargo.toml similarity index 94% rename from miden-remote-provers/Cargo.toml rename to miden-proving-service-client/Cargo.toml index d3d2a6228..018c683f7 100644 --- a/miden-remote-provers/Cargo.toml +++ b/miden-proving-service-client/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "miden-remote-provers" +name = "miden-proving-service-client" version = "0.1.0" description = "client library that provides a client for the remote provers" readme = "README.md" -keywords = ["miden", "miden-remote-provers"] +keywords = ["miden", "miden-proving-service-client"] license.workspace = true authors.workspace = true repository.workspace = true diff --git a/miden-remote-provers/README.md b/miden-proving-service-client/README.md similarity index 93% rename from miden-remote-provers/README.md rename to miden-proving-service-client/README.md index 4031a4344..698332618 100644 --- a/miden-remote-provers/README.md +++ b/miden-proving-service-client/README.md @@ -10,3 +10,7 @@ Description of this crate's features: | ------------ | ------------------------------------------------------------------------------------------------------------| | `std` | Enable usage of Rust's `std`, use `--no-default-features` for `no-std` support. | | `tx-prover` | Makes the `RemoteTransactionProver` struct public. | + +## License + +This project is [MIT licensed](../LICENSE). diff --git a/miden-remote-provers/build.rs b/miden-proving-service-client/build.rs similarity index 93% rename from miden-remote-provers/build.rs rename to miden-proving-service-client/build.rs index 9ac9f1cdb..8799c04ce 100644 --- a/miden-remote-provers/build.rs +++ b/miden-proving-service-client/build.rs @@ -27,11 +27,7 @@ fn compile_tonic_client_proto() -> miette::Result<()> { let dst_dir = crate_root.join("src").join("generated"); // Compute the directory of the `proto` definitions - let cwd: PathBuf = env::current_dir().expect("current directory"); - - let cwd = cwd.parent().expect("navigating to parent directory"); - - let proto_dir: PathBuf = cwd.join("proto"); + let proto_dir = crate_root.parent().expect("workspace root should exist").join("proto"); // Remove `api.rs` if it exists. fs::remove_file(dst_dir.join("api.rs")).into_diagnostic().ok(); diff --git a/miden-remote-provers/src/generated/mod.rs b/miden-proving-service-client/src/generated/mod.rs similarity index 100% rename from miden-remote-provers/src/generated/mod.rs rename to miden-proving-service-client/src/generated/mod.rs diff --git a/miden-remote-provers/src/generated/nostd/api.rs b/miden-proving-service-client/src/generated/nostd/api.rs similarity index 100% rename from miden-remote-provers/src/generated/nostd/api.rs rename to miden-proving-service-client/src/generated/nostd/api.rs diff --git a/miden-remote-provers/src/generated/nostd/mod.rs b/miden-proving-service-client/src/generated/nostd/mod.rs similarity index 100% rename from miden-remote-provers/src/generated/nostd/mod.rs rename to miden-proving-service-client/src/generated/nostd/mod.rs diff --git a/miden-remote-provers/src/generated/std/api.rs b/miden-proving-service-client/src/generated/std/api.rs similarity index 100% rename from miden-remote-provers/src/generated/std/api.rs rename to miden-proving-service-client/src/generated/std/api.rs diff --git a/miden-remote-provers/src/generated/std/mod.rs b/miden-proving-service-client/src/generated/std/mod.rs similarity index 100% rename from miden-remote-provers/src/generated/std/mod.rs rename to miden-proving-service-client/src/generated/std/mod.rs diff --git a/miden-remote-provers/src/lib.rs b/miden-proving-service-client/src/lib.rs similarity index 77% rename from miden-remote-provers/src/lib.rs rename to miden-proving-service-client/src/lib.rs index a7f005324..60f2f81e7 100644 --- a/miden-remote-provers/src/lib.rs +++ b/miden-proving-service-client/src/lib.rs @@ -1,6 +1,10 @@ +#![no_std] +use alloc::string::{String, ToString}; + extern crate alloc; -use alloc::string::String; +#[cfg(feature = "std")] +extern crate std; use thiserror::Error; @@ -12,8 +16,8 @@ mod prover; #[cfg(feature = "tx-prover")] pub use prover::RemoteTransactionProver; -/// Contains the protobuf definitions -pub const PROTO_MESSAGES: &str = include_str!("../../proto/api.proto"); +/// Protobuf definition for the Miden proving service +pub const SERVICE_PROTO: &str = include_str!("../../proto/api.proto"); /// ERRORS /// =============================================================================================== diff --git a/miden-remote-provers/src/prover.rs b/miden-proving-service-client/src/prover.rs similarity index 98% rename from miden-remote-provers/src/prover.rs rename to miden-proving-service-client/src/prover.rs index 213e6370d..2318d0a38 100644 --- a/miden-remote-provers/src/prover.rs +++ b/miden-proving-service-client/src/prover.rs @@ -80,8 +80,9 @@ impl TransactionProver for RemoteTransactionProver { let mut client = self .client .write() - .take() - .ok_or_else(|| TransactionProverError::other("client should be connected"))?; + .as_ref() + .ok_or_else(|| TransactionProverError::other("client should be connected"))? + .clone(); let request = tonic::Request::new(crate::generated::ProveTransactionRequest { transaction_witness: tx_witness.to_bytes(), From 801f18e8504e178ddc34891313ff596700e1d18f Mon Sep 17 00:00:00 2001 From: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:49:12 -0300 Subject: [PATCH 2/6] feat: missing BlockNumber s (#1080) * feat: missing BlockNumber s docs: update changelog * review: replace missing u32 with BlockNumber --- CHANGELOG.md | 2 +- miden-lib/src/notes/mod.rs | 3 +- miden-lib/src/transaction/mod.rs | 17 +++--- miden-tx/src/testing/mock_chain/mod.rs | 2 +- miden-tx/src/tests/kernel_tests/test_note.rs | 2 +- miden-tx/src/tests/kernel_tests/test_tx.rs | 8 +-- miden-tx/tests/integration/scripts/p2idr.rs | 4 +- objects/src/block/header.rs | 4 +- objects/src/notes/execution_hint.rs | 55 ++++++++++---------- objects/src/notes/file.rs | 15 ++++-- objects/src/notes/metadata.rs | 2 +- objects/src/transaction/outputs.rs | 3 +- objects/src/transaction/proven_tx.rs | 11 ++-- 13 files changed, 70 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b97cf06d6..5b04a2110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ - Added tracing to the `miden-tx-prover` CLI (#1014). - Added metrics to the `miden-tx-prover` proxy (#1017). - Implemented `to_hex` for `AccountIdPrefix` and `epoch_block_num` for `BlockHeader` (#1039). -- Add `BlockNumber` struct (#1043). - Introduce `AccountIdBuilder` to simplify `AccountId` generation in tests (#1045). - Introduced `AccountComponentTemplate` with TOML serialization and templating (#1015, #1027). - [BREAKING] Updated the names and values of the kernel procedure offsets and corresponding kernel procedures (#1037). @@ -33,6 +32,7 @@ - Made `BasicFungibleFaucet::MAX_DECIMALS` public (#1063). - [BREAKING] Removed `miden-tx-prover` crate and created `miden-proving-service` and `miden-proving-service-client` (#1047). - Deduplicate `masm` procedures across kernel and miden lib to a shared `util` module (#1070). +- [BREAKING] Added `BlockNumber` struct (#1043, #1080). ## 0.6.2 (2024-11-20) diff --git a/miden-lib/src/notes/mod.rs b/miden-lib/src/notes/mod.rs index 2c7e27cd6..2997e1588 100644 --- a/miden-lib/src/notes/mod.rs +++ b/miden-lib/src/notes/mod.rs @@ -3,6 +3,7 @@ use alloc::vec::Vec; use miden_objects::{ accounts::AccountId, assets::Asset, + block::BlockNumber, crypto::rand::FeltRng, notes::{ Note, NoteAssets, NoteDetails, NoteExecutionHint, NoteExecutionMode, NoteInputs, @@ -65,7 +66,7 @@ pub fn create_p2idr_note( assets: Vec, note_type: NoteType, aux: Felt, - recall_height: u32, + recall_height: BlockNumber, rng: &mut R, ) -> Result { let note_script = scripts::p2idr(); diff --git a/miden-lib/src/transaction/mod.rs b/miden-lib/src/transaction/mod.rs index aa8789894..02390e928 100644 --- a/miden-lib/src/transaction/mod.rs +++ b/miden-lib/src/transaction/mod.rs @@ -3,6 +3,7 @@ use alloc::{string::ToString, sync::Arc, vec::Vec}; use miden_objects::{ accounts::{AccountCode, AccountHeader, AccountId, AccountStorageHeader}, assembly::{Assembler, DefaultSourceManager, KernelLibrary}, + block::BlockNumber, crypto::merkle::{MerkleError, MerklePath}, transaction::{ OutputNote, OutputNotes, TransactionArgs, TransactionInputs, TransactionOutputs, @@ -220,7 +221,7 @@ impl TransactionKernel { pub fn build_output_stack( final_acct_hash: Digest, output_notes_hash: Digest, - expiration_block_num: u32, + expiration_block_num: BlockNumber, ) -> StackOutputs { let mut outputs: Vec = Vec::with_capacity(9); outputs.push(Felt::from(expiration_block_num)); @@ -252,7 +253,7 @@ impl TransactionKernel { /// - Overflow addresses are not empty. pub fn parse_output_stack( stack: &StackOutputs, - ) -> Result<(Digest, Digest, u32), TransactionOutputError> { + ) -> Result<(Digest, Digest, BlockNumber), TransactionOutputError> { let output_notes_hash = stack .get_stack_word(OUTPUT_NOTES_COMMITMENT_WORD_IDX * 4) .expect("first word missing") @@ -267,11 +268,13 @@ impl TransactionKernel { .get_stack_item(EXPIRATION_BLOCK_ELEMENT_IDX) .expect("element on index 8 missing"); - let expiration_block_num = u32::try_from(expiration_block_num.as_int()).map_err(|_| { - TransactionOutputError::OutputStackInvalid( - "Expiration block number should be smaller than u32::MAX".into(), - ) - })?; + let expiration_block_num = u32::try_from(expiration_block_num.as_int()) + .map_err(|_| { + TransactionOutputError::OutputStackInvalid( + "Expiration block number should be smaller than u32::MAX".into(), + ) + })? + .into(); if stack.get_stack_word(12).expect("fourth word missing") != EMPTY_WORD { return Err(TransactionOutputError::OutputStackInvalid( diff --git a/miden-tx/src/testing/mock_chain/mod.rs b/miden-tx/src/testing/mock_chain/mod.rs index 5c63d2aae..7122471a6 100644 --- a/miden-tx/src/testing/mock_chain/mod.rs +++ b/miden-tx/src/testing/mock_chain/mod.rs @@ -384,7 +384,7 @@ impl MockChain { target_account_id: AccountId, asset: &[Asset], note_type: NoteType, - reclaim_height: Option, + reclaim_height: Option, ) -> Result { let mut rng = RpoRandomCoin::new(Word::default()); diff --git a/miden-tx/src/tests/kernel_tests/test_note.rs b/miden-tx/src/tests/kernel_tests/test_note.rs index 4f9b38b5a..19e47c2a3 100644 --- a/miden-tx/src/tests/kernel_tests/test_note.rs +++ b/miden-tx/src/tests/kernel_tests/test_note.rs @@ -562,7 +562,7 @@ fn test_build_note_metadata() { sender, NoteType::Private, NoteTag::from_account_id(receiver, NoteExecutionMode::Local).unwrap(), - NoteExecutionHint::after_block(500).unwrap(), + NoteExecutionHint::after_block(500.into()).unwrap(), Felt::try_from(1u64 << 63).unwrap(), ) .unwrap(); diff --git a/miden-tx/src/tests/kernel_tests/test_tx.rs b/miden-tx/src/tests/kernel_tests/test_tx.rs index dfc7afdf0..9435a4f47 100644 --- a/miden-tx/src/tests/kernel_tests/test_tx.rs +++ b/miden-tx/src/tests/kernel_tests/test_tx.rs @@ -82,7 +82,7 @@ fn test_create_note() { ", recipient = prepare_word(&recipient), PUBLIC_NOTE = NoteType::Public as u8, - note_execution_hint = Felt::from(NoteExecutionHint::after_block(23).unwrap()), + note_execution_hint = Felt::from(NoteExecutionHint::after_block(23.into()).unwrap()), tag = tag, ); @@ -104,7 +104,7 @@ fn test_create_note() { account_id, NoteType::Public, tag, - NoteExecutionHint::after_block(23).unwrap(), + NoteExecutionHint::after_block(23.into()).unwrap(), Felt::new(27), ) .unwrap() @@ -242,7 +242,7 @@ fn test_get_output_notes_commitment() { tx_context.tx_inputs().account().id(), NoteType::Public, output_tag_2, - NoteExecutionHint::after_block(123).unwrap(), + NoteExecutionHint::after_block(123.into()).unwrap(), ZERO, ) .unwrap(); @@ -631,7 +631,7 @@ fn test_build_recipient_hash() { output_serial_no = prepare_word(&output_serial_no), PUBLIC_NOTE = NoteType::Public as u8, tag = tag, - execution_hint = Felt::from(NoteExecutionHint::after_block(2).unwrap()), + execution_hint = Felt::from(NoteExecutionHint::after_block(2.into()).unwrap()), aux = aux, ); diff --git a/miden-tx/tests/integration/scripts/p2idr.rs b/miden-tx/tests/integration/scripts/p2idr.rs index fe255d055..e48ffcb17 100644 --- a/miden-tx/tests/integration/scripts/p2idr.rs +++ b/miden-tx/tests/integration/scripts/p2idr.rs @@ -25,8 +25,8 @@ fn p2idr_script() { let malicious_account = mock_chain.add_existing_wallet(Auth::BasicAuth, vec![]); // Create the reclaim block heights - let reclaim_block_height_in_time = 7_u32; - let reclaim_block_height_reclaimable = 2_u32; + let reclaim_block_height_in_time = 7.into(); + let reclaim_block_height_reclaimable = 2.into(); // Create the notes with the P2IDR script let note_in_time = mock_chain diff --git a/objects/src/block/header.rs b/objects/src/block/header.rs index 4a0f57ed3..c51422fba 100644 --- a/objects/src/block/header.rs +++ b/objects/src/block/header.rs @@ -69,7 +69,7 @@ impl BlockHeader { kernel_root, proof_hash, timestamp, - block_num.as_u32(), + block_num, ); // The sub hash is merged with the note_root - hash(sub_hash, note_root) to produce the @@ -204,7 +204,7 @@ impl BlockHeader { kernel_root: Digest, proof_hash: Digest, timestamp: u32, - block_num: u32, + block_num: BlockNumber, ) -> Digest { let mut elements: Vec = Vec::with_capacity(32); elements.extend_from_slice(prev_hash.as_elements()); diff --git a/objects/src/notes/execution_hint.rs b/objects/src/notes/execution_hint.rs index fe2f88e89..7f14dd4e8 100644 --- a/objects/src/notes/execution_hint.rs +++ b/objects/src/notes/execution_hint.rs @@ -3,7 +3,7 @@ use vm_core::Felt; -use crate::NoteError; +use crate::{block::BlockNumber, NoteError}; /// Specifies the conditions under which a note is ready to be consumed. /// These conditions are meant to be encoded in the note script as well. @@ -79,7 +79,7 @@ impl NoteExecutionHint { /// # Errors /// /// Returns an error if `block_num` is equal to [`u32::MAX`]. - pub fn after_block(block_num: u32) -> Result { + pub fn after_block(block_num: BlockNumber) -> Result { AfterBlockNumber::new(block_num) .map(|block_number| NoteExecutionHint::AfterBlock { block_num: block_number }) } @@ -104,7 +104,7 @@ impl NoteExecutionHint { } Ok(NoteExecutionHint::Always) }, - Self::AFTER_BLOCK_TAG => NoteExecutionHint::after_block(payload), + Self::AFTER_BLOCK_TAG => NoteExecutionHint::after_block(payload.into()), Self::ON_BLOCK_SLOT_TAG => { let remainder = (payload >> 24 & 0xff) as u8; if remainder != 0 { @@ -128,7 +128,8 @@ impl NoteExecutionHint { /// - `None` if we don't know whether the note can be consumed. /// - `Some(true)` if the note is consumable for the given `block_num` /// - `Some(false)` if the note is not consumable for the given `block_num` - pub fn can_be_consumed(&self, block_num: u32) -> Option { + pub fn can_be_consumed(&self, block_num: BlockNumber) -> Option { + let block_num = block_num.as_u32(); match self { NoteExecutionHint::None => None, NoteExecutionHint::Always => Some(true), @@ -213,7 +214,7 @@ impl From for u64 { /// /// Used for the [`NoteExecutionHint::AfterBlock`] variant where this constraint is needed. #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct AfterBlockNumber(u32); +pub struct AfterBlockNumber(BlockNumber); impl AfterBlockNumber { /// Creates a new [`AfterBlockNumber`] from the given `block_number`. @@ -222,8 +223,8 @@ impl AfterBlockNumber { /// /// Returns an error if: /// - `block_number` is equal to `u32::MAX`. - pub fn new(block_number: u32) -> Result { - if block_number == u32::MAX { + pub fn new(block_number: BlockNumber) -> Result { + if block_number.as_u32() == u32::MAX { Err(NoteError::NoteExecutionHintAfterBlockCannotBeU32Max) } else { Ok(Self(block_number)) @@ -232,13 +233,13 @@ impl AfterBlockNumber { /// Returns the block number as a `u32`. pub fn as_u32(&self) -> u32 { - self.0 + self.0.as_u32() } } impl From for u32 { fn from(block_number: AfterBlockNumber) -> Self { - block_number.0 + block_number.0.as_u32() } } @@ -246,7 +247,7 @@ impl TryFrom for AfterBlockNumber { type Error = NoteError; fn try_from(block_number: u32) -> Result { - Self::new(block_number) + Self::new(block_number.into()) } } @@ -269,7 +270,7 @@ mod tests { fn test_serialization_round_trip() { assert_hint_serde(NoteExecutionHint::None); assert_hint_serde(NoteExecutionHint::Always); - assert_hint_serde(NoteExecutionHint::after_block(15).unwrap()); + assert_hint_serde(NoteExecutionHint::after_block(15.into()).unwrap()); assert_hint_serde(NoteExecutionHint::OnBlockSlot { round_len: 9, slot_len: 12, @@ -279,7 +280,7 @@ mod tests { #[test] fn test_encode_round_trip() { - let hint = NoteExecutionHint::after_block(15).unwrap(); + let hint = NoteExecutionHint::after_block(15.into()).unwrap(); let hint_int: u64 = hint.into(); let decoded_hint: NoteExecutionHint = hint_int.try_into().unwrap(); assert_eq!(hint, decoded_hint); @@ -300,25 +301,25 @@ mod tests { #[test] fn test_can_be_consumed() { let none = NoteExecutionHint::none(); - assert!(none.can_be_consumed(100).is_none()); + assert!(none.can_be_consumed(100.into()).is_none()); let always = NoteExecutionHint::always(); - assert!(always.can_be_consumed(100).unwrap()); + assert!(always.can_be_consumed(100.into()).unwrap()); - let after_block = NoteExecutionHint::after_block(12345).unwrap(); - assert!(!after_block.can_be_consumed(12344).unwrap()); - assert!(after_block.can_be_consumed(12345).unwrap()); + let after_block = NoteExecutionHint::after_block(12345.into()).unwrap(); + assert!(!after_block.can_be_consumed(12344.into()).unwrap()); + assert!(after_block.can_be_consumed(12345.into()).unwrap()); let on_block_slot = NoteExecutionHint::on_block_slot(10, 7, 1); - assert!(!on_block_slot.can_be_consumed(127).unwrap()); // Block 127 is not in the slot 128..255 - assert!(on_block_slot.can_be_consumed(128).unwrap()); // Block 128 is in the slot 128..255 - assert!(on_block_slot.can_be_consumed(255).unwrap()); // Block 255 is in the slot 128..255 - assert!(!on_block_slot.can_be_consumed(256).unwrap()); // Block 256 is not in the slot 128..255 - assert!(on_block_slot.can_be_consumed(1152).unwrap()); // Block 1152 is in the slot 1152..1279 - assert!(on_block_slot.can_be_consumed(1279).unwrap()); // Block 1279 is in the slot 1152..1279 - assert!(on_block_slot.can_be_consumed(2176).unwrap()); // Block 2176 is in the slot 2176..2303 - assert!(!on_block_slot.can_be_consumed(2175).unwrap()); // Block 1279 is in the slot - // 2176..2303 + assert!(!on_block_slot.can_be_consumed(127.into()).unwrap()); // Block 127 is not in the slot 128..255 + assert!(on_block_slot.can_be_consumed(128.into()).unwrap()); // Block 128 is in the slot 128..255 + assert!(on_block_slot.can_be_consumed(255.into()).unwrap()); // Block 255 is in the slot 128..255 + assert!(!on_block_slot.can_be_consumed(256.into()).unwrap()); // Block 256 is not in the slot 128..255 + assert!(on_block_slot.can_be_consumed(1152.into()).unwrap()); // Block 1152 is in the slot 1152..1279 + assert!(on_block_slot.can_be_consumed(1279.into()).unwrap()); // Block 1279 is in the slot 1152..1279 + assert!(on_block_slot.can_be_consumed(2176.into()).unwrap()); // Block 2176 is in the slot 2176..2303 + assert!(!on_block_slot.can_be_consumed(2175.into()).unwrap()); // Block 1279 is in the slot + // 2176..2303 } #[test] @@ -335,7 +336,7 @@ mod tests { #[test] fn test_after_block_fails_on_u32_max() { assert_matches!( - NoteExecutionHint::after_block(u32::MAX).unwrap_err(), + NoteExecutionHint::after_block(u32::MAX.into()).unwrap_err(), NoteError::NoteExecutionHintAfterBlockCannotBeU32Max ); } diff --git a/objects/src/notes/file.rs b/objects/src/notes/file.rs index 39899de75..2663f6736 100644 --- a/objects/src/notes/file.rs +++ b/objects/src/notes/file.rs @@ -2,6 +2,7 @@ use vm_core::utils::{ByteReader, ByteWriter, Deserializable, Serializable}; use vm_processor::DeserializationError; use super::{Note, NoteDetails, NoteId, NoteInclusionProof, NoteTag}; +use crate::block::BlockNumber; // NOTE FILE // ================================================================================================ @@ -20,7 +21,7 @@ pub enum NoteFile { /// treated as a hint. NoteDetails { details: NoteDetails, - after_block_num: u32, + after_block_num: BlockNumber, tag: Option, }, /// The note has been recorded on chain. @@ -29,7 +30,11 @@ pub enum NoteFile { impl From for NoteFile { fn from(details: NoteDetails) -> Self { - NoteFile::NoteDetails { details, after_block_num: 0, tag: None } + NoteFile::NoteDetails { + details, + after_block_num: 0.into(), + tag: None, + } } } @@ -77,7 +82,7 @@ impl Deserializable for NoteFile { 0 => Ok(NoteFile::NoteId(NoteId::read_from(source)?)), 1 => { let details = NoteDetails::read_from(source)?; - let after_block_num = u32::read_from(source)?; + let after_block_num = BlockNumber::read_from(source)?; let tag = Option::::read_from(source)?; Ok(NoteFile::NoteDetails { details, after_block_num, tag }) }, @@ -175,7 +180,7 @@ mod tests { let note = create_example_note(); let file = NoteFile::NoteDetails { details: note.details.clone(), - after_block_num: 456, + after_block_num: 456.into(), tag: Some(NoteTag::from(123)), }; let mut buffer = Vec::new(); @@ -186,7 +191,7 @@ mod tests { match file_copy { NoteFile::NoteDetails { details, after_block_num, tag } => { assert_eq!(details, note.details); - assert_eq!(after_block_num, 456); + assert_eq!(after_block_num, 456.into()); assert_eq!(tag, Some(NoteTag::from(123))); }, _ => panic!("Invalid note file variant"), diff --git a/objects/src/notes/metadata.rs b/objects/src/notes/metadata.rs index 50547f762..dd7caa711 100644 --- a/objects/src/notes/metadata.rs +++ b/objects/src/notes/metadata.rs @@ -306,7 +306,7 @@ mod tests { NoteExecutionHint::always(), NoteExecutionHint::none(), NoteExecutionHint::on_block_slot(10, 11, 12), - NoteExecutionHint::after_block(u32::MAX - 1).unwrap(), + NoteExecutionHint::after_block((u32::MAX - 1).into()).unwrap(), ] { let metadata = NoteMetadata::new(sender, note_type, tag, execution_hint, aux).unwrap(); NoteMetadata::read_from_bytes(&metadata.to_bytes()) diff --git a/objects/src/transaction/outputs.rs b/objects/src/transaction/outputs.rs index fc93e47ea..775ecb32d 100644 --- a/objects/src/transaction/outputs.rs +++ b/objects/src/transaction/outputs.rs @@ -6,6 +6,7 @@ use vm_processor::DeserializationError; use crate::{ accounts::AccountHeader, + block::BlockNumber, notes::{compute_note_hash, Note, NoteAssets, NoteHeader, NoteId, NoteMetadata, PartialNote}, Digest, Felt, Hasher, TransactionOutputError, Word, MAX_OUTPUT_NOTES_PER_TX, }; @@ -20,7 +21,7 @@ pub struct TransactionOutputs { /// Set of output notes created by the transaction. pub output_notes: OutputNotes, /// Defines up to which block the transaction is considered valid. - pub expiration_block_num: u32, + pub expiration_block_num: BlockNumber, } // OUTPUT NOTES diff --git a/objects/src/transaction/proven_tx.rs b/objects/src/transaction/proven_tx.rs index 492ecf5f0..ed29ababf 100644 --- a/objects/src/transaction/proven_tx.rs +++ b/objects/src/transaction/proven_tx.rs @@ -5,6 +5,7 @@ use miden_verifier::ExecutionProof; use super::{InputNote, ToInputNoteCommitments}; use crate::{ accounts::delta::AccountUpdateDetails, + block::BlockNumber, notes::NoteHeader, transaction::{ AccountId, Digest, InputNotes, Nullifier, OutputNote, OutputNotes, TransactionId, @@ -37,7 +38,7 @@ pub struct ProvenTransaction { block_ref: Digest, /// The block number by which the transaction will expire, as defined by the executed scripts. - expiration_block_num: u32, + expiration_block_num: BlockNumber, /// A STARK proof that attests to the correct execution of the transaction. proof: ExecutionProof, @@ -85,7 +86,7 @@ impl ProvenTransaction { } /// Returns the block number at which the transaction will expire. - pub fn expiration_block_num(&self) -> u32 { + pub fn expiration_block_num(&self) -> BlockNumber { self.expiration_block_num } @@ -166,7 +167,7 @@ impl Deserializable for ProvenTransaction { let output_notes = OutputNotes::read_from(source)?; let block_ref = Digest::read_from(source)?; - let expiration_block_num = u32::read_from(source)?; + let expiration_block_num = BlockNumber::read_from(source)?; let proof = ExecutionProof::read_from(source)?; let id = TransactionId::new( @@ -220,7 +221,7 @@ pub struct ProvenTransactionBuilder { block_ref: Digest, /// The block number by which the transaction will expire, as defined by the executed scripts. - expiration_block_num: u32, + expiration_block_num: BlockNumber, /// A STARK proof that attests to the correct execution of the transaction. proof: ExecutionProof, @@ -236,7 +237,7 @@ impl ProvenTransactionBuilder { initial_account_hash: Digest, final_account_hash: Digest, block_ref: Digest, - expiration_block_num: u32, + expiration_block_num: BlockNumber, proof: ExecutionProof, ) -> Self { Self { From 0fa800ac698cf37e2c9f0f7fc470ba61c08e5cdd Mon Sep 17 00:00:00 2001 From: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:40:10 -0300 Subject: [PATCH 3/6] fix: missing BlockNumber update in error struct (#1082) --- CHANGELOG.md | 2 +- miden-tx/src/errors/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b04a2110..7de0e5ad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ - Made `BasicFungibleFaucet::MAX_DECIMALS` public (#1063). - [BREAKING] Removed `miden-tx-prover` crate and created `miden-proving-service` and `miden-proving-service-client` (#1047). - Deduplicate `masm` procedures across kernel and miden lib to a shared `util` module (#1070). -- [BREAKING] Added `BlockNumber` struct (#1043, #1080). +- [BREAKING] Added `BlockNumber` struct (#1043, #1080, #1082). ## 0.6.2 (2024-11-20) diff --git a/miden-tx/src/errors/mod.rs b/miden-tx/src/errors/mod.rs index dad109738..22067015d 100644 --- a/miden-tx/src/errors/mod.rs +++ b/miden-tx/src/errors/mod.rs @@ -2,8 +2,8 @@ use alloc::{boxed::Box, string::String}; use core::error::Error; use miden_objects::{ - accounts::AccountId, notes::NoteId, AccountError, Felt, ProvenTransactionError, - TransactionInputError, TransactionOutputError, + accounts::AccountId, block::BlockNumber, notes::NoteId, AccountError, Felt, + ProvenTransactionError, TransactionInputError, TransactionOutputError, }; use miden_verifier::VerificationError; use thiserror::Error; @@ -115,7 +115,7 @@ pub enum DataStoreError { #[error("account with id {0} not found in data store")] AccountNotFound(AccountId), #[error("block with number {0} not found in data store")] - BlockNotFound(u32), + BlockNotFound(BlockNumber), #[error("failed to create transaction inputs")] InvalidTransactionInput(#[source] TransactionInputError), #[error("note with id {0} is already consumed")] From df98433b55ad2d2db7e4cbee09bfd8da1c3c41c3 Mon Sep 17 00:00:00 2001 From: igamigo Date: Fri, 17 Jan 2025 18:41:59 -0300 Subject: [PATCH 4/6] fix: Add `#[macro_use]` (#1083) * fix: Add #[macro_use] * fix: Change to suppressing warning --- miden-proving-service-client/Cargo.toml | 1 - miden-proving-service-client/src/lib.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/miden-proving-service-client/Cargo.toml b/miden-proving-service-client/Cargo.toml index 018c683f7..320a5e251 100644 --- a/miden-proving-service-client/Cargo.toml +++ b/miden-proving-service-client/Cargo.toml @@ -10,7 +10,6 @@ repository.workspace = true rust-version.workspace = true edition.workspace = true - [lib] crate-type = ["lib"] diff --git a/miden-proving-service-client/src/lib.rs b/miden-proving-service-client/src/lib.rs index 60f2f81e7..eaf08da16 100644 --- a/miden-proving-service-client/src/lib.rs +++ b/miden-proving-service-client/src/lib.rs @@ -1,7 +1,11 @@ #![no_std] -use alloc::string::{String, ToString}; - +// We allow unused imports here in order because this `macro_use` only makes sense for code +// generated by prost under certain circumstances (when `tx-prover` is enabled and the environment +// is not wasm) +#![allow(unused_imports)] +#[macro_use] extern crate alloc; +use alloc::string::{String, ToString}; #[cfg(feature = "std")] extern crate std; From 2acaa0a82d305ad294e659a0c538975c772a39b7 Mon Sep 17 00:00:00 2001 From: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:29:51 -0300 Subject: [PATCH 5/6] docs: remove client's testing feature in docs (#1081) --- docs/introduction/get-started/create-account-use-faucet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction/get-started/create-account-use-faucet.md b/docs/introduction/get-started/create-account-use-faucet.md index 159626a0e..70a9bf3b7 100644 --- a/docs/introduction/get-started/create-account-use-faucet.md +++ b/docs/introduction/get-started/create-account-use-faucet.md @@ -21,7 +21,7 @@ The Miden client facilitates interaction with the Miden rollup and provides a wa 2. Install the Miden client. ```shell - cargo install miden-cli --features testing,concurrent + cargo install miden-cli --features concurrent ``` You can now use the `miden --version` command, and you should see `Miden 0.7.0`. From d678c9ea2e791b15a56abd4fa92160ded9fee484 Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Sun, 19 Jan 2025 14:09:25 -0800 Subject: [PATCH 6/6] chore: fix typos --- miden-lib/asm/kernels/transaction/api.masm | 2 +- miden-lib/asm/kernels/transaction/lib/account.masm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/miden-lib/asm/kernels/transaction/api.masm b/miden-lib/asm/kernels/transaction/api.masm index 249cca995..8d70d3cd0 100644 --- a/miden-lib/asm/kernels/transaction/api.masm +++ b/miden-lib/asm/kernels/transaction/api.masm @@ -301,7 +301,7 @@ end #! Outputs: [VALUE, pad(12)] #! #! Where: -#! - index is the index of the storage slot that contains the the map root. +#! - index is the index of the storage slot that contains the map root. #! - VALUE is the value of the map item at KEY. #! #! Panics if: diff --git a/miden-lib/asm/kernels/transaction/lib/account.masm b/miden-lib/asm/kernels/transaction/lib/account.masm index 26d929c11..f6b6a25c4 100644 --- a/miden-lib/asm/kernels/transaction/lib/account.masm +++ b/miden-lib/asm/kernels/transaction/lib/account.masm @@ -566,7 +566,7 @@ end #! - We assume that index has been validated and is within bounds. #! #! Where: -#! - index is the index of the storage slot that contains the the map root. +#! - index is the index of the storage slot that contains the map root. #! - VALUE is the value of the map item at KEY. #! #! Panics if: