diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 55ef4a8c40..6c86d26024 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,13 +1,5 @@ version: 2 updates: - - package-ecosystem: "cargo" - directory: "/" - schedule: - interval: "weekly" - target-branch: "dev" - ignore: - - dependency-name: "axum" - versions: ["> 0.7.4"] - package-ecosystem: "docker" directory: "/crates/cli/docker" schedule: diff --git a/Cargo.lock b/Cargo.lock index 49ae1d2b2c..a86cc9e493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -671,9 +671,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", "axum-core", @@ -695,9 +695,9 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -705,9 +705,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes 1.7.1", @@ -718,7 +718,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -3067,7 +3067,7 @@ dependencies = [ "pin-project-lite", "socket2 0.5.7", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -4655,9 +4655,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes 1.7.1", "prost-derive", @@ -4665,13 +4665,13 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes 1.7.1", "heck", - "itertools 0.12.1", + "itertools 0.13.0", "log", "multimap", "once_cell", @@ -4686,12 +4686,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.72", @@ -4699,9 +4699,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -7023,9 +7023,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes 1.7.1", @@ -7163,20 +7163,35 @@ dependencies = [ "tokio", "tower-layer", "tower-service", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", "tracing", ] [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -7290,22 +7305,21 @@ dependencies = [ [[package]] name = "twirp-build-rs" -version = "0.3.0" +version = "0.13.0-succinct" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25019d8d3244a6a380f621129e4ed63a04bb91617effd46440405aad43588c40" +checksum = "8160cc3d9282e192ec842f1ab44e9d396312ff5472bdab58f5e7f4d882b22eea" dependencies = [ "prost-build", ] [[package]] name = "twirp-rs" -version = "0.3.0" +version = "0.13.0-succinct" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfa3161d8eee0abcad4e762f4215381a430cc1281870d575b0f1e4fbfc74b8ce" +checksum = "27dfcc06b8d9262bc2d4b8d1847c56af9971a52dd8a0076876de9db763227d0d" dependencies = [ "async-trait", "axum", - "bytes 1.7.1", "futures", "http 1.1.0", "http-body-util", @@ -7316,7 +7330,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower", + "tower 0.5.1", "url", ] diff --git a/crates/cuda/Cargo.toml b/crates/cuda/Cargo.toml index cb45ba910c..4409e479f2 100644 --- a/crates/cuda/Cargo.toml +++ b/crates/cuda/Cargo.toml @@ -13,20 +13,20 @@ categories = { workspace = true } sp1-core-machine = { workspace = true } sp1-prover = { workspace = true } sp1-stark = { workspace = true } -prost = "0.12" -prost-types = "0.12" +prost = "0.13" +prost-types = "0.13" bincode = "1.3.3" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" tokio = { version = "^1.38.0", features = ["full"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -twirp = { package = "twirp-rs", version = "0.3.0-succinct" } +twirp = { package = "twirp-rs", version = "0.13.0-succinct" } ctrlc = "3.4.4" [build-dependencies] -prost-build = { version = "0.12", optional = true } -twirp-build = { package = "twirp-build-rs", version = "0.3.0-succinct", optional = true } +prost-build = { version = "0.13", optional = true } +twirp-build = { package = "twirp-build-rs", version = "0.13.0-succinct", optional = true } [dev-dependencies] sp1-core-machine = { workspace = true, features = ["programs"] } diff --git a/crates/cuda/src/proto/api.rs b/crates/cuda/src/proto/api.rs index f36b4e4da5..54aea9d77d 100644 --- a/crates/cuda/src/proto/api.rs +++ b/crates/cuda/src/proto/api.rs @@ -1,66 +1,56 @@ // This file is @generated by prost-build. #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReadyRequest {} #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReadyResponse { #[prost(bool, tag = "1")] pub ready: bool, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ProveCoreRequest { #[prost(bytes = "vec", tag = "1")] pub data: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ProveCoreResponse { #[prost(bytes = "vec", tag = "1")] pub result: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CompressRequest { #[prost(bytes = "vec", tag = "1")] pub data: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CompressResponse { #[prost(bytes = "vec", tag = "1")] pub result: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ShrinkRequest { #[prost(bytes = "vec", tag = "1")] pub data: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ShrinkResponse { #[prost(bytes = "vec", tag = "1")] pub result: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct WrapRequest { #[prost(bytes = "vec", tag = "1")] pub data: ::prost::alloc::vec::Vec, } #[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct WrapResponse { #[prost(bytes = "vec", tag = "1")] @@ -96,38 +86,79 @@ pub trait ProverService { req: WrapRequest, ) -> Result; } -pub fn router(api: std::sync::Arc) -> twirp::Router +#[twirp::async_trait::async_trait] +impl ProverService for std::sync::Arc +where + T: ProverService + Sync + Send, +{ + async fn ready( + &self, + ctx: twirp::Context, + req: ReadyRequest, + ) -> Result { + T::ready(&*self, ctx, req).await + } + async fn prove_core( + &self, + ctx: twirp::Context, + req: ProveCoreRequest, + ) -> Result { + T::prove_core(&*self, ctx, req).await + } + async fn compress( + &self, + ctx: twirp::Context, + req: CompressRequest, + ) -> Result { + T::compress(&*self, ctx, req).await + } + async fn shrink( + &self, + ctx: twirp::Context, + req: ShrinkRequest, + ) -> Result { + T::shrink(&*self, ctx, req).await + } + async fn wrap( + &self, + ctx: twirp::Context, + req: WrapRequest, + ) -> Result { + T::wrap(&*self, ctx, req).await + } +} +pub fn router(api: T) -> twirp::Router where - T: ProverService + Send + Sync + 'static, + T: ProverService + Clone + Send + Sync + 'static, { twirp::details::TwirpRouterBuilder::new(api) .route( "/Ready", - |api: std::sync::Arc, ctx: twirp::Context, req: ReadyRequest| async move { + |api: T, ctx: twirp::Context, req: ReadyRequest| async move { api.ready(ctx, req).await }, ) .route( "/ProveCore", - |api: std::sync::Arc, ctx: twirp::Context, req: ProveCoreRequest| async move { + |api: T, ctx: twirp::Context, req: ProveCoreRequest| async move { api.prove_core(ctx, req).await }, ) .route( "/Compress", - |api: std::sync::Arc, ctx: twirp::Context, req: CompressRequest| async move { + |api: T, ctx: twirp::Context, req: CompressRequest| async move { api.compress(ctx, req).await }, ) .route( "/Shrink", - |api: std::sync::Arc, ctx: twirp::Context, req: ShrinkRequest| async move { + |api: T, ctx: twirp::Context, req: ShrinkRequest| async move { api.shrink(ctx, req).await }, ) .route( "/Wrap", - |api: std::sync::Arc, ctx: twirp::Context, req: WrapRequest| async move { + |api: T, ctx: twirp::Context, req: WrapRequest| async move { api.wrap(ctx, req).await }, ) @@ -159,32 +190,27 @@ impl ProverServiceClient for twirp::client::Client { &self, req: ReadyRequest, ) -> Result { - let url = self.base_url.join("api.ProverService/Ready")?; - self.request(url, req).await + self.request("api.ProverService/Ready", req).await } async fn prove_core( &self, req: ProveCoreRequest, ) -> Result { - let url = self.base_url.join("api.ProverService/ProveCore")?; - self.request(url, req).await + self.request("api.ProverService/ProveCore", req).await } async fn compress( &self, req: CompressRequest, ) -> Result { - let url = self.base_url.join("api.ProverService/Compress")?; - self.request(url, req).await + self.request("api.ProverService/Compress", req).await } async fn shrink( &self, req: ShrinkRequest, ) -> Result { - let url = self.base_url.join("api.ProverService/Shrink")?; - self.request(url, req).await + self.request("api.ProverService/Shrink", req).await } async fn wrap(&self, req: WrapRequest) -> Result { - let url = self.base_url.join("api.ProverService/Wrap")?; - self.request(url, req).await + self.request("api.ProverService/Wrap", req).await } } diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index a394f142e0..b52880c4f6 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -10,10 +10,10 @@ keywords = { workspace = true } categories = { workspace = true } [dependencies] -prost = "0.12" +prost = "0.13" serde = { version = "1.0.204", features = ["derive"] } serde_json = "1.0.121" -twirp = { package = "twirp-rs", version = "0.3.0-succinct" , optional=true } +twirp = { package = "twirp-rs", version = "0.13.0-succinct", optional = true } async-trait = "0.1.81" reqwest-middleware = { version = "0.3.2", optional = true } reqwest = { version = "0.12.4", features = [ @@ -24,10 +24,10 @@ reqwest = { version = "0.12.4", features = [ anyhow = "1.0.83" sp1-prover = { workspace = true } sp1-core-machine = { workspace = true } -sp1-cuda = { workspace = true , optional = true} +sp1-cuda = { workspace = true, optional = true } futures = "0.3.30" bincode = "1.3.3" -tokio = { version = "1.39.2", features = ["full"], optional = true} +tokio = { version = "1.39.2", features = ["full"], optional = true } p3-matrix = { workspace = true } p3-commit = { workspace = true } p3-field = { workspace = true } @@ -37,14 +37,14 @@ indicatif = "0.17.8" tracing = "0.1.40" hex = "0.4.3" log = "0.4.22" -axum = { version = "=0.7.4", optional = true } +axum = { version = "0.7.7", optional = true } alloy-sol-types = { version = "0.7.7", optional = true } sha2 = "0.10.8" dirs = "5.0.1" tempfile = "3.10.1" num-bigint = "0.4.6" cfg-if = "1.0" -ethers = { version = "2", default-features = false, optional = true} +ethers = { version = "2", default-features = false, optional = true } strum_macros = "0.26.4" strum = "0.26.3" thiserror = "1.0.63" @@ -62,7 +62,14 @@ neon = ["sp1-core-machine/neon"] native-gnark = ["sp1-prover/native-gnark"] # TODO: Once alloy has a 1.* release, we can likely remove this feature flag, as there will be less # dependency resolution issues. -network = ["dep:alloy-sol-types", "dep:tokio", "dep:ethers", "dep:reqwest", "dep:twirp", "dep:reqwest-middleware"] +network = [ + "dep:alloy-sol-types", + "dep:tokio", + "dep:ethers", + "dep:reqwest", + "dep:twirp", + "dep:reqwest-middleware", +] cuda = ["sp1-cuda"] [build-dependencies] diff --git a/crates/sdk/src/proto/network.rs b/crates/sdk/src/proto/network.rs index d2f2e118e2..545c9db255 100644 --- a/crates/sdk/src/proto/network.rs +++ b/crates/sdk/src/proto/network.rs @@ -1,8 +1,6 @@ // This file is @generated by prost-build. /// The request to create a proof, the first step in requesting a proof. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct CreateProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -21,9 +19,7 @@ pub struct CreateProofRequest { pub circuit_version: ::prost::alloc::string::String, } /// The response for creating a proof. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct CreateProofResponse { /// The proof identifier. #[prost(string, tag = "1")] @@ -38,9 +34,7 @@ pub struct CreateProofResponse { /// The request to submit a proof, the second step in requesting a proof. MUST be called when the /// proof is in a PROOF_REQUESTED state and MUST be called after uploading the program and stdin to /// the URLs provided during create proof. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct SubmitProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -53,15 +47,11 @@ pub struct SubmitProofRequest { pub proof_id: ::prost::alloc::string::String, } /// The response for submitting a proof, empty on success. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] pub struct SubmitProofResponse {} /// The request to claim a proof, which agrees to fulfill the proof by the deadline. MUST be called /// when the proof is in a PROOF_REQUESTED state. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct ClaimProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -75,9 +65,7 @@ pub struct ClaimProofRequest { } /// The response for claiming a proof, giving identifiers for the locations to retrieve the program /// and stdin, as well as the location to upload the proof. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct ClaimProofResponse { /// The artifact identifier for the program location. #[prost(string, tag = "1")] @@ -91,9 +79,7 @@ pub struct ClaimProofResponse { } /// The request to unclaim a proof, which cancels the claim to fulfill the proof. MUST be called /// when the proof is in a PROOF_CLAIMED state and MUST be called by the prover who claimed it. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct UnclaimProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -112,14 +98,10 @@ pub struct UnclaimProofRequest { pub description: ::prost::alloc::string::String, } /// The response for unclaiming a proof, empty on success. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] pub struct UnclaimProofResponse {} /// The request to update a proof's CPU cycle count. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct ModifyCpuCyclesRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -135,15 +117,11 @@ pub struct ModifyCpuCyclesRequest { pub cycles: u64, } /// The response for updating a proof's CPU cycle count, empty on success. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] pub struct ModifyCpuCyclesResponse {} /// The request to fulfill a proof. MUST be called after the proof has been uploaded and MUST be called /// when the proof is in a PROOF_CLAIMED state. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct FulfillProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -156,9 +134,7 @@ pub struct FulfillProofRequest { pub proof_id: ::prost::alloc::string::String, } /// The response for fulfilling a proof, empty on success. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] pub struct FulfillProofResponse { /// The amount of time, in seconds, between proof claim and fulfillment. #[prost(uint64, tag = "1")] @@ -166,9 +142,7 @@ pub struct FulfillProofResponse { } /// The request to relay a proof through the NetworkGateway on a given chain. MUST be called when the /// proof is in a PROOF_FULFILLED state. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct RelayProofRequest { /// The signature of the message. #[prost(bytes = "vec", tag = "1")] @@ -193,45 +167,35 @@ pub struct RelayProofRequest { pub callback_data: ::prost::alloc::vec::Vec, } /// The response for relaying a proof. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct RelayProofResponse { /// The transaction identifier. #[prost(string, tag = "1")] pub tx_id: ::prost::alloc::string::String, } /// The request for an account nonce. Used to check current nonce for the account, which must match when signing and sending a message. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetNonceRequest { /// The account's address for which to get the nonce. #[prost(bytes = "vec", tag = "1")] pub address: ::prost::alloc::vec::Vec, } /// The response for a nonce request. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] pub struct GetNonceResponse { /// The nonce for the given address. It should be signed along with the rest of the message. #[prost(uint64, tag = "1")] pub nonce: u64, } /// The request to get a proof status by a given proof ID. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetProofStatusRequest { /// The proof identifier. #[prost(string, tag = "1")] pub proof_id: ::prost::alloc::string::String, } /// The response for a proof status request. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetProofStatusResponse { /// The status of the proof request. #[prost(enumeration = "ProofStatus", tag = "1")] @@ -248,9 +212,7 @@ pub struct GetProofStatusResponse { pub unclaim_description: ::core::option::Option<::prost::alloc::string::String>, } /// The request to get proof requests by a given status. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetProofRequestsRequest { /// The status of the proof requests to filter for. #[prost(enumeration = "ProofStatus", tag = "1")] @@ -260,9 +222,7 @@ pub struct GetProofRequestsRequest { pub circuit_version: ::core::option::Option<::prost::alloc::string::String>, } /// A proof request. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct RequestedProof { /// The proof identifier. #[prost(string, tag = "1")] @@ -278,9 +238,7 @@ pub struct RequestedProof { pub circuit_version: ::prost::alloc::string::String, } /// The response for getting proof requests by a given status. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetProofRequestsResponse { /// The proof identifiers of the proof requests. Limited to the 10 most recent proof requests with /// that status. @@ -288,18 +246,14 @@ pub struct GetProofRequestsResponse { pub proofs: ::prost::alloc::vec::Vec, } /// The request to get the status of a relay request. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetRelayStatusRequest { /// The transaction identifier. #[prost(string, tag = "1")] pub tx_id: ::prost::alloc::string::String, } /// The response for getting the status of a relay request. -#[derive(serde::Serialize, serde::Deserialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] pub struct GetRelayStatusResponse { /// The status of the transaction. #[prost(enumeration = "TransactionStatus", tag = "1")] @@ -345,11 +299,11 @@ impl ProofMode { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ProofMode::Unspecified => "PROOF_MODE_UNSPECIFIED", - ProofMode::Core => "PROOF_MODE_CORE", - ProofMode::Compressed => "PROOF_MODE_COMPRESSED", - ProofMode::Plonk => "PROOF_MODE_PLONK", - ProofMode::Groth16 => "PROOF_MODE_GROTH16", + Self::Unspecified => "PROOF_MODE_UNSPECIFIED", + Self::Core => "PROOF_MODE_CORE", + Self::Compressed => "PROOF_MODE_COMPRESSED", + Self::Plonk => "PROOF_MODE_PLONK", + Self::Groth16 => "PROOF_MODE_GROTH16", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -400,12 +354,12 @@ impl ProofStatus { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ProofStatus::ProofUnspecifiedStatus => "PROOF_UNSPECIFIED_STATUS", - ProofStatus::ProofPreparing => "PROOF_PREPARING", - ProofStatus::ProofRequested => "PROOF_REQUESTED", - ProofStatus::ProofClaimed => "PROOF_CLAIMED", - ProofStatus::ProofUnclaimed => "PROOF_UNCLAIMED", - ProofStatus::ProofFulfilled => "PROOF_FULFILLED", + Self::ProofUnspecifiedStatus => "PROOF_UNSPECIFIED_STATUS", + Self::ProofPreparing => "PROOF_PREPARING", + Self::ProofRequested => "PROOF_REQUESTED", + Self::ProofClaimed => "PROOF_CLAIMED", + Self::ProofUnclaimed => "PROOF_UNCLAIMED", + Self::ProofFulfilled => "PROOF_FULFILLED", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -457,12 +411,12 @@ impl TransactionStatus { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - TransactionStatus::TransactionUnspecifiedStatus => "TRANSACTION_UNSPECIFIED_STATUS", - TransactionStatus::TransactionScheduled => "TRANSACTION_SCHEDULED", - TransactionStatus::TransactionBroadcasted => "TRANSACTION_BROADCASTED", - TransactionStatus::TransactionTimedout => "TRANSACTION_TIMEDOUT", - TransactionStatus::TransactionFailed => "TRANSACTION_FAILED", - TransactionStatus::TransactionFinalized => "TRANSACTION_FINALIZED", + Self::TransactionUnspecifiedStatus => "TRANSACTION_UNSPECIFIED_STATUS", + Self::TransactionScheduled => "TRANSACTION_SCHEDULED", + Self::TransactionBroadcasted => "TRANSACTION_BROADCASTED", + Self::TransactionTimedout => "TRANSACTION_TIMEDOUT", + Self::TransactionFailed => "TRANSACTION_FAILED", + Self::TransactionFinalized => "TRANSACTION_FINALIZED", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -507,9 +461,9 @@ impl UnclaimReason { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - UnclaimReason::Unspecified => "UNCLAIM_REASON_UNSPECIFIED", - UnclaimReason::Invalid => "UNCLAIM_REASON_INVALID", - UnclaimReason::Abandoned => "UNCLAIM_REASON_ABANDONED", + Self::Unspecified => "UNCLAIM_REASON_UNSPECIFIED", + Self::Invalid => "UNCLAIM_REASON_INVALID", + Self::Abandoned => "UNCLAIM_REASON_ABANDONED", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -582,74 +536,142 @@ pub trait NetworkService { req: GetRelayStatusRequest, ) -> Result; } -pub fn router(api: std::sync::Arc) -> twirp::Router +#[twirp::async_trait::async_trait] +impl NetworkService for std::sync::Arc +where + T: NetworkService + Sync + Send, +{ + async fn create_proof( + &self, + ctx: twirp::Context, + req: CreateProofRequest, + ) -> Result { + T::create_proof(&*self, ctx, req).await + } + async fn submit_proof( + &self, + ctx: twirp::Context, + req: SubmitProofRequest, + ) -> Result { + T::submit_proof(&*self, ctx, req).await + } + async fn claim_proof( + &self, + ctx: twirp::Context, + req: ClaimProofRequest, + ) -> Result { + T::claim_proof(&*self, ctx, req).await + } + async fn unclaim_proof( + &self, + ctx: twirp::Context, + req: UnclaimProofRequest, + ) -> Result { + T::unclaim_proof(&*self, ctx, req).await + } + async fn modify_cpu_cycles( + &self, + ctx: twirp::Context, + req: ModifyCpuCyclesRequest, + ) -> Result { + T::modify_cpu_cycles(&*self, ctx, req).await + } + async fn fulfill_proof( + &self, + ctx: twirp::Context, + req: FulfillProofRequest, + ) -> Result { + T::fulfill_proof(&*self, ctx, req).await + } + async fn relay_proof( + &self, + ctx: twirp::Context, + req: RelayProofRequest, + ) -> Result { + T::relay_proof(&*self, ctx, req).await + } + async fn get_nonce( + &self, + ctx: twirp::Context, + req: GetNonceRequest, + ) -> Result { + T::get_nonce(&*self, ctx, req).await + } + async fn get_proof_status( + &self, + ctx: twirp::Context, + req: GetProofStatusRequest, + ) -> Result { + T::get_proof_status(&*self, ctx, req).await + } + async fn get_proof_requests( + &self, + ctx: twirp::Context, + req: GetProofRequestsRequest, + ) -> Result { + T::get_proof_requests(&*self, ctx, req).await + } + async fn get_relay_status( + &self, + ctx: twirp::Context, + req: GetRelayStatusRequest, + ) -> Result { + T::get_relay_status(&*self, ctx, req).await + } +} +pub fn router(api: T) -> twirp::Router where - T: NetworkService + Send + Sync + 'static, + T: NetworkService + Clone + Send + Sync + 'static, { twirp::details::TwirpRouterBuilder::new(api) - .route( - "/CreateProof", - |api: std::sync::Arc, ctx: twirp::Context, req: CreateProofRequest| async move { - api.create_proof(ctx, req).await - }, - ) - .route( - "/SubmitProof", - |api: std::sync::Arc, ctx: twirp::Context, req: SubmitProofRequest| async move { - api.submit_proof(ctx, req).await - }, - ) - .route( - "/ClaimProof", - |api: std::sync::Arc, ctx: twirp::Context, req: ClaimProofRequest| async move { - api.claim_proof(ctx, req).await - }, - ) + .route("/CreateProof", |api: T, ctx: twirp::Context, req: CreateProofRequest| async move { + api.create_proof(ctx, req).await + }) + .route("/SubmitProof", |api: T, ctx: twirp::Context, req: SubmitProofRequest| async move { + api.submit_proof(ctx, req).await + }) + .route("/ClaimProof", |api: T, ctx: twirp::Context, req: ClaimProofRequest| async move { + api.claim_proof(ctx, req).await + }) .route( "/UnclaimProof", - |api: std::sync::Arc, ctx: twirp::Context, req: UnclaimProofRequest| async move { + |api: T, ctx: twirp::Context, req: UnclaimProofRequest| async move { api.unclaim_proof(ctx, req).await }, ) .route( "/ModifyCpuCycles", - |api: std::sync::Arc, ctx: twirp::Context, req: ModifyCpuCyclesRequest| async move { + |api: T, ctx: twirp::Context, req: ModifyCpuCyclesRequest| async move { api.modify_cpu_cycles(ctx, req).await }, ) .route( "/FulfillProof", - |api: std::sync::Arc, ctx: twirp::Context, req: FulfillProofRequest| async move { + |api: T, ctx: twirp::Context, req: FulfillProofRequest| async move { api.fulfill_proof(ctx, req).await }, ) - .route( - "/RelayProof", - |api: std::sync::Arc, ctx: twirp::Context, req: RelayProofRequest| async move { - api.relay_proof(ctx, req).await - }, - ) - .route( - "/GetNonce", - |api: std::sync::Arc, ctx: twirp::Context, req: GetNonceRequest| async move { - api.get_nonce(ctx, req).await - }, - ) + .route("/RelayProof", |api: T, ctx: twirp::Context, req: RelayProofRequest| async move { + api.relay_proof(ctx, req).await + }) + .route("/GetNonce", |api: T, ctx: twirp::Context, req: GetNonceRequest| async move { + api.get_nonce(ctx, req).await + }) .route( "/GetProofStatus", - |api: std::sync::Arc, ctx: twirp::Context, req: GetProofStatusRequest| async move { + |api: T, ctx: twirp::Context, req: GetProofStatusRequest| async move { api.get_proof_status(ctx, req).await }, ) .route( "/GetProofRequests", - |api: std::sync::Arc, ctx: twirp::Context, req: GetProofRequestsRequest| async move { + |api: T, ctx: twirp::Context, req: GetProofRequestsRequest| async move { api.get_proof_requests(ctx, req).await }, ) .route( "/GetRelayStatus", - |api: std::sync::Arc, ctx: twirp::Context, req: GetRelayStatusRequest| async move { + |api: T, ctx: twirp::Context, req: GetRelayStatusRequest| async move { api.get_relay_status(ctx, req).await }, ) @@ -706,77 +728,66 @@ impl NetworkServiceClient for twirp::client::Client { &self, req: CreateProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/CreateProof")?; - self.request(url, req).await + self.request("network.NetworkService/CreateProof", req).await } async fn submit_proof( &self, req: SubmitProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/SubmitProof")?; - self.request(url, req).await + self.request("network.NetworkService/SubmitProof", req).await } async fn claim_proof( &self, req: ClaimProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/ClaimProof")?; - self.request(url, req).await + self.request("network.NetworkService/ClaimProof", req).await } async fn unclaim_proof( &self, req: UnclaimProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/UnclaimProof")?; - self.request(url, req).await + self.request("network.NetworkService/UnclaimProof", req).await } async fn modify_cpu_cycles( &self, req: ModifyCpuCyclesRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/ModifyCpuCycles")?; - self.request(url, req).await + self.request("network.NetworkService/ModifyCpuCycles", req).await } async fn fulfill_proof( &self, req: FulfillProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/FulfillProof")?; - self.request(url, req).await + self.request("network.NetworkService/FulfillProof", req).await } async fn relay_proof( &self, req: RelayProofRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/RelayProof")?; - self.request(url, req).await + self.request("network.NetworkService/RelayProof", req).await } async fn get_nonce( &self, req: GetNonceRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/GetNonce")?; - self.request(url, req).await + self.request("network.NetworkService/GetNonce", req).await } async fn get_proof_status( &self, req: GetProofStatusRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/GetProofStatus")?; - self.request(url, req).await + self.request("network.NetworkService/GetProofStatus", req).await } async fn get_proof_requests( &self, req: GetProofRequestsRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/GetProofRequests")?; - self.request(url, req).await + self.request("network.NetworkService/GetProofRequests", req).await } async fn get_relay_status( &self, req: GetRelayStatusRequest, ) -> Result { - let url = self.base_url.join("network.NetworkService/GetRelayStatus")?; - self.request(url, req).await + self.request("network.NetworkService/GetRelayStatus", req).await } }