From 53fa9a7d2bfca0d5ef56797ef3320ab60d663cc1 Mon Sep 17 00:00:00 2001 From: Mike <32080293+fulltimemike@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:59:52 -0500 Subject: [PATCH 1/4] Fix rps --- node/rest/src/lib.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 20314996a6..38b7c28478 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -110,12 +110,21 @@ impl, R: Routing> Rest { // Prepare the rate limiting setup. let governor_config = Box::new( - GovernorConfigBuilder::default() - .per_second(1) - .burst_size(rest_rps) - .error_handler(|error| Response::new(error.to_string().into())) - .finish() - .expect("Couldn't set up rate limiting for the REST server!"), + GovernorConfigBuilder::default() + .per_nanosecond((1_000_000_000 / rest_rps) as u64) + .burst_size(rest_rps) + .error_handler(|error| { + // Properly return a 429 Too Many Requests error + let error_message = error.to_string(); + let mut response = Response::new(error_message.clone().into()); + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + if error_message.contains("Too Many Requests") { + *response.status_mut() = StatusCode::TOO_MANY_REQUESTS; + } + response + }) + .finish() + .expect("Couldn't set up rate limiting for the REST server!"), ); // Get the network being used. From e0d1bedfe3443e8cc6b8355dddad033d16e50542 Mon Sep 17 00:00:00 2001 From: Mike <32080293+fulltimemike@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:10:17 -0500 Subject: [PATCH 2/4] Undo rust version bump Signed-off-by: Mike <32080293+fulltimemike@users.noreply.github.com> --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index dbd41264aa..32a6ce3c71 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.81.0 +1.76.0 From 5013044ac001d3d36e0b78c9251455ada522b1a4 Mon Sep 17 00:00:00 2001 From: Mike <32080293+fulltimemike@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:38:27 -0500 Subject: [PATCH 3/4] Rebase off aleoNet/staging and fix fmt --- node/rest/src/lib.rs | 30 +++++++++++++++--------------- node/router/src/heartbeat.rs | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 38b7c28478..17881a5116 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -110,21 +110,21 @@ impl, R: Routing> Rest { // Prepare the rate limiting setup. let governor_config = Box::new( - GovernorConfigBuilder::default() - .per_nanosecond((1_000_000_000 / rest_rps) as u64) - .burst_size(rest_rps) - .error_handler(|error| { - // Properly return a 429 Too Many Requests error - let error_message = error.to_string(); - let mut response = Response::new(error_message.clone().into()); - *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; - if error_message.contains("Too Many Requests") { - *response.status_mut() = StatusCode::TOO_MANY_REQUESTS; - } - response - }) - .finish() - .expect("Couldn't set up rate limiting for the REST server!"), + GovernorConfigBuilder::default() + .per_nanosecond((1_000_000_000 / rest_rps) as u64) + .burst_size(rest_rps) + .error_handler(|error| { + // Properly return a 429 Too Many Requests error + let error_message = error.to_string(); + let mut response = Response::new(error_message.clone().into()); + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + if error_message.contains("Too Many Requests") { + *response.status_mut() = StatusCode::TOO_MANY_REQUESTS; + } + response + }) + .finish() + .expect("Couldn't set up rate limiting for the REST server!"), ); // Get the network being used. diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 63f0f0ddd8..7b5477302d 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -21,7 +21,7 @@ use crate::{ use snarkvm::prelude::Network; use colored::Colorize; -use rand::{prelude::IteratorRandom, rngs::OsRng, Rng}; +use rand::{Rng, prelude::IteratorRandom, rngs::OsRng}; /// A helper function to compute the maximum of two numbers. /// See Rust issue 92391: https://github.com/rust-lang/rust/issues/92391. From fc2905f6e1c33e40cb5493c7fb803c047379b96a Mon Sep 17 00:00:00 2001 From: Mike <32080293+fulltimemike@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:44:15 -0500 Subject: [PATCH 4/4] undo rust version change --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 32a6ce3c71..dbd41264aa 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.76.0 +1.81.0