From ed23b95abe314665aa9280114019b86b8fe79901 Mon Sep 17 00:00:00 2001 From: 0xriazaka <0xriazaka@gmail.com> Date: Sat, 21 Sep 2024 00:44:14 +0100 Subject: [PATCH 1/6] Split MevApi trait into two #11036 --- crates/rpc/rpc-api/src/mev.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/rpc/rpc-api/src/mev.rs b/crates/rpc/rpc-api/src/mev.rs index ebe6f5ee8708..e3486f3077b9 100644 --- a/crates/rpc/rpc-api/src/mev.rs +++ b/crates/rpc/rpc-api/src/mev.rs @@ -6,7 +6,21 @@ use reth_rpc_types::mev::{ /// Mev rpc interface. #[cfg_attr(not(feature = "client"), rpc(server, namespace = "mev"))] #[cfg_attr(feature = "client", rpc(server, client, namespace = "mev"))] -pub trait MevApi { +pub trait MevSimApi { + /// Similar to `mev_sendBundle` but instead of submitting a bundle to the relay, it returns + /// a simulation result. Only fully matched bundles can be simulated. + #[method(name = "simBundle")] + async fn sim_bundle( + &self, + bundle: SendBundleRequest, + sim_overrides: SimBundleOverrides, + ) -> jsonrpsee::core::RpcResult; +} + +/// Mev rpc interface. +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "mev"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "mev"))] +pub trait MevFullApi { /// Submitting bundles to the relay. It takes in a bundle and provides a bundle hash as a /// return value. #[method(name = "sendBundle")] From 0b3fc03b717371562b3912b102b76d8c5e236a23 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 22 Sep 2024 14:27:13 +0200 Subject: [PATCH 2/6] Fix exports --- crates/rpc/rpc-api/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-api/src/lib.rs b/crates/rpc/rpc-api/src/lib.rs index 89968960fb4b..73775112dcf5 100644 --- a/crates/rpc/rpc-api/src/lib.rs +++ b/crates/rpc/rpc-api/src/lib.rs @@ -39,7 +39,7 @@ pub mod servers { admin::AdminApiServer, debug::DebugApiServer, engine::{EngineApiServer, EngineEthApiServer}, - mev::MevApiServer, + mev::{MevFullApiServer, MevSimApiServer}, net::NetApiServer, otterscan::OtterscanServer, reth::RethApiServer, @@ -69,7 +69,7 @@ pub mod clients { engine::{EngineApiClient, EngineEthApiClient}, ganache::GanacheApiClient, hardhat::HardhatApiClient, - mev::MevApiClient, + mev::{MevFullApiClient, MevSimApiClient}, net::NetApiClient, otterscan::OtterscanClient, reth::RethApiClient, From 6a178c38f19559bbc4a3cb90c4ce025fde150e4a Mon Sep 17 00:00:00 2001 From: 0xriazaka <0xriazaka@gmail.com> Date: Sat, 28 Sep 2024 23:37:25 +0100 Subject: [PATCH 3/6] Remove unsafe from impl Compact for ClientVersion --- crates/storage/db-models/src/client_version.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/storage/db-models/src/client_version.rs b/crates/storage/db-models/src/client_version.rs index de074ac88c6e..a28e7385f658 100644 --- a/crates/storage/db-models/src/client_version.rs +++ b/crates/storage/db-models/src/client_version.rs @@ -28,20 +28,16 @@ impl Compact for ClientVersion { where B: bytes::BufMut + AsMut<[u8]>, { - self.version.as_bytes().to_compact(buf); - self.git_sha.as_bytes().to_compact(buf); - self.build_timestamp.as_bytes().to_compact(buf) + self.version.to_compact(buf); + self.git_sha.to_compact(buf); + self.build_timestamp.to_compact(buf) } fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) { - let (version, buf) = Vec::::from_compact(buf, len); - let (git_sha, buf) = Vec::::from_compact(buf, len); - let (build_timestamp, buf) = Vec::::from_compact(buf, len); - let client_version = Self { - version: unsafe { String::from_utf8_unchecked(version) }, - git_sha: unsafe { String::from_utf8_unchecked(git_sha) }, - build_timestamp: unsafe { String::from_utf8_unchecked(build_timestamp) }, - }; + let (version, buf) = String::from_compact(buf, len); + let (git_sha, buf) = String::from_compact(buf, len); + let (build_timestamp, buf) = String::from_compact(buf, len); + let client_version = Self { version, git_sha, build_timestamp }; (client_version, buf) } } From a9aca175b6fe136e45f6a98e15a33229b899fc56 Mon Sep 17 00:00:00 2001 From: 0xriazaka <0xriazaka@gmail.com> Date: Sat, 28 Sep 2024 23:44:42 +0100 Subject: [PATCH 4/6] Remove unsafe from impl Compact for ClientVersion --- crates/storage/codecs/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index 3b05ce8e94fb..a02e0ba4683c 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -78,6 +78,21 @@ pub trait Compact: Sized { } } +impl Compact for String { + fn to_compact(&self, buf: &mut B) -> usize + where + B: bytes::BufMut + AsMut<[u8]>, + { + self.as_bytes().to_compact(buf) + } + + fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) { + let (vec, buf) = Vec::::from_compact(buf, len); + let string = String::from_utf8(vec).unwrap(); // Safe conversion + (string, buf) + } +} + impl Compact for &T { fn to_compact(&self, buf: &mut B) -> usize where From c1aa26182a7143d4bff8b26b5b5deefe51838bc9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 17 Oct 2024 21:59:46 +0200 Subject: [PATCH 5/6] chore: clippy --- crates/storage/codecs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index a02e0ba4683c..1ef11b4193f2 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -88,7 +88,7 @@ impl Compact for String { fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) { let (vec, buf) = Vec::::from_compact(buf, len); - let string = String::from_utf8(vec).unwrap(); // Safe conversion + let string = Self::from_utf8(vec).unwrap(); // Safe conversion (string, buf) } } From 538ec04aad7e6468684687fa24db97af0bd43808 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:12:55 +0200 Subject: [PATCH 6/6] no-std --- crates/storage/codecs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index 59f45c966a7b..54ca046cb71a 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -78,7 +78,7 @@ pub trait Compact: Sized { } } -impl Compact for String { +impl Compact for alloc::string::String { fn to_compact(&self, buf: &mut B) -> usize where B: bytes::BufMut + AsMut<[u8]>,