Repository: dusk-network/rusk (language: rust)

Issue:
Querying the balance of an address via the local node



Discussion / hints:

Fix patch:
diff --git a/rusk/CHANGELOG.md b/rusk/CHANGELOG.md
index f072e7cae..1adf89a94 100644
--- a/rusk/CHANGELOG.md
+++ b/rusk/CHANGELOG.md
@@ -7,10 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## Unreleased
 
+### Added
+
+- Add `/on/account:<address>/status` endpoint [#3422]
+
 ### Changed
 
 - Change dependency declaration to not require strict equal [#3405]
 
+### Removed
+
+- Remove legacy event system 
+
 ## [1.0.1] - 2025-01-20
 
 ### Added
@@ -296,6 +304,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Add build system that generates keys for circuits and caches them.
 
 <!-- Issues -->
+[#3422]: https://github.com/dusk-network/rusk/issues/3422
 [#3405]: https://github.com/dusk-network/rusk/issues/3405
 [#3359]: https://github.com/dusk-network/rusk/issues/3359
 [#3206]: https://github.com/dusk-network/rusk/issues/3206
diff --git a/rusk/src/lib/http.rs b/rusk/src/lib/http.rs
index dec08ceac..420af4da3 100644
--- a/rusk/src/lib/http.rs
+++ b/rusk/src/lib/http.rs
@@ -17,7 +17,7 @@ mod stream;
 
 pub(crate) use event::{
     BinaryWrapper, DataType, ExecutionError, MessageResponse as EventResponse,
-    RequestData, Target,
+    RequestData,
 };
 
 use dusk_core::abi::Event;
@@ -74,7 +74,7 @@ use crate::VERSION;
 
 pub use self::event::{RuesDispatchEvent, RuesEvent, RUES_LOCATION_PREFIX};
 
-use self::event::{MessageRequest, ResponseData, RuesEventUri, SessionId};
+use self::event::{ResponseData, RuesEventUri, SessionId};
 use self::stream::{Listener, Stream};
 
 const RUSK_VERSION_HEADER: &str = "Rusk-Version";
@@ -148,26 +148,6 @@ pub struct DataSources {
 
 #[async_trait]
 impl HandleRequest for DataSources {
-    fn can_handle(&self, request: &MessageRequest) -> bool {
-        self.sources.iter().any(|s| s.can_handle(request))
-    }
-    async fn handle(
-        &self,
-        request: &MessageRequest,
-    ) -> anyhow::Result<ResponseData> {
-        info!(
-            "Received {:?}:{} request",
-            request.event.target, request.event.topic
-        );
-        request.check_rusk_version()?;
-        for h in &self.sources {
-            if h.can_handle(request) {
-                return h.handle(request).await;
-            }
-        }
-        Err(anyhow::anyhow!("unsupported target type"))
-    }
-
     fn can_handle_rues(&self, event: &RuesDispatchEvent) -> bool {
         self.sources.iter().any(|s| s.can_handle_rues(event))
     }
@@ -254,155 +234,6 @@ async fn listening_loop<H>(
     }
 }
 
-async fn handle_stream<H: HandleRequest>(
-    sources: Arc<H>,
-    websocket: HyperWebsocket,
-    target: Target,
-    mut shutdown: broadcast::Receiver<Infallible>,
-) {
-    let mut stream = match websocket.await {
-        Ok(stream) => stream,
-        Err(_) => return,
-    };
-
-    // Add this block to disable requests through websockets
-    // {
-    //     let _ = stream
-    //         .close(Some(CloseFrame {
-    //             code: CloseCode::Unsupported,
-    //             reason: Cow::from("Websocket is currently unsupported"),
-    //         }))
-    //         .await;
-    //     #[allow(clippy::needless_return)]
-    //     return;
-    // }
-
-    let (responder, mut responses) = mpsc::unbounded_channel::<EventResponse>();
-
-    'outer: loop {
-        tokio::select! {
-            // If the server shuts down we send a close frame to the client
-            // and stop.
-            _ = shutdown.recv() => {
-                let _ = stream.close(Some(CloseFrame {
-                    code: CloseCode::Away,
-                    reason: Cow::from("Shutting down"),
-                })).await;
-                break;
-            }
-
-            rsp = responses.recv() => {
-                // `responder` is never dropped so this can never be `None`
-                let rsp = rsp.unwrap();
-
-                if let DataType::Channel(c) = rsp.data {
-                    let mut datas = stream_iter(c).map(|e| {
-                        EventResponse {
-                            data: e.into(),
-                            headers: rsp.headers.clone(),
-                            error: None
-                        }
-                    });//.await;
-                    while let Some(c) = datas.next().await {
-                        let rsp = serde_json::to_string(&c).unwrap_or_else(|err| {
-                            serde_json::to_string(
-                                &EventResponse::from_error(
-                                    format!("Failed serializing response: {err}")
-                                )).expect("serializing error response should succeed")
-                            });
-
-                        // If we error in sending the message we send a close frame
-                        // to the client and stop.
-                        if stream.send(Message::Text(rsp)).await.is_err() {
-                            let _ = stream.close(Some(CloseFrame {
-                            code: CloseCode::Error,
-                            reason: Cow::from("Failed sending response"),
-                            })).await;
-                            // break;
-                        }
-                    }
-
-
-                } else {
-                    // Serialize the response to text. If this does not succeed,
-                    // we simply serialize an error response.
-                    let rsp = serde_json::to_string(&rsp).unwrap_or_else(|err| {
-                        serde_json::to_string(
-                            &EventResponse::from_error(
-                                format!("Failed serializing response: {err}")
-                            )).expect("serializing error response should succeed")
-                        });
-
-                    // If we error in sending the message we send a close frame
-                    // to the client and stop.
-                    if stream.send(Message::Text(rsp)).await.is_err() {
-                        let _ = stream.close(Some(CloseFrame {
-                        code: CloseCode::Error,
-                        reason: Cow::from("Failed sending response"),
-                        })).await;
-                        break;
-                    }
-                }
-            }
-
-            msg = stream.next() => {
-
-                let mut req = match msg {
-                    Some(Ok(msg)) => match msg {
-                        // We received a text request.
-                        Message::Text(msg) => {
-                            serde_json::from_str(&msg)
-                                .map_err(|err| anyhow::anyhow!("Failed deserializing request: {err}"))
-                        },
-                        // We received a binary request.
-                        Message::Binary(msg) => {
-                            MessageRequest::parse(&msg)
-                                .map_err(|err| anyhow::anyhow!("Failed deserializing request: {err}"))
-                        }
-                        // Any other type of message is unsupported.
-                        _ => Err(anyhow::anyhow!("Only text and binary messages are supported"))
-                    }
-                    // Errored while receiving the message, we will
-                    // close the stream and return a close frame.
-                    Some(Err(err)) => {
-                        Err(anyhow::anyhow!("Failed receiving message: {err}"))
-                    }
-                    // The stream has stopped producing messages, and we
-                    // should close it and stop. The client likely has done
-                    // this on purpose, and it's a part of the normal
-                    // operation of the server.
-                    None => {
-                        let _ = stream.close(Some(CloseFrame {
-                            code: CloseCode::Normal,
-                            reason: Cow::from("Stream stopped"),
-                        })).await;
-                        break;
-                    }
-                };
-                match req {
-                    // We received a valid request and should spawn a new task to handle it
-                    Ok(mut req) => {
-                        req.event.target=target.clone();
-                        task::spawn(handle_execution(
-                            sources.clone(),
-                            req,
-                            responder.clone(),
-                        ));
-                    },
-                    Err(e) => {
-                        let _ = stream.close(Some(CloseFrame {
-                            code: CloseCode::Error,
-                            reason: Cow::from(e.to_string()),
-                        })).await;
-                        break;
-                    }
-                }
-
-            }
-        }
-    }
-}
-
 struct ExecutionService<H> {
     sources: Arc<H>,
     sockets_map:
@@ -627,41 +458,6 @@ async fn handle_stream_rues<H: HandleRequest>(
     sockets.remove(&sid);
 }
 
-async fn handle_dispatch<H: HandleRequest>(
-    uri: RuesEventUri,
-    body: Incoming,
-    handler: Arc<H>,
-    sender: mpsc::Sender<Result<RuesEvent, AnyhowError>>,
-) {
-    let bytes = match body.collect().await {
-        Ok(bytes) => bytes.to_bytes(),
-        Err(err) => {
-            let _ = sender.send(Err(err.into())).await;
-            return;
-        }
-    };
-
-    let req = match MessageRequest::parse(&bytes) {
-        Ok(req) => req,
-        Err(err) => {
-            let _ = sender.send(Err(err)).await;
-            return;
-        }
-    };
-
-    let rsp = match handler.handle(&req).await {
-        Ok(rsp) => rsp,
-        Err(err) => {
-            let _ = sender.send(Err(err)).await;
-            return;
-        }
-    };
-
-    let (data, headers) = rsp.into_inner();
-
-    sender.send(Ok(RuesEvent { uri, data, headers })).await;
-}
-
 fn response(
     status: StatusCode,
     body: impl Into<Bytes>,
@@ -830,66 +626,7 @@ where
         return Ok(response);
     }
 
-    if hyper_tungstenite::is_upgrade_request(&req) {
-        let target = req.uri().path().try_into()?;
-
-        let (response, websocket) = hyper_tungstenite::upgrade(&mut req, None)?;
-        task::spawn(handle_stream(sources, websocket, target, shutdown));
-
-        Ok(response.map(Into::into))
-    } else {
-        let (execution_request, binary_resp) =
-            MessageRequest::from_request(req).await?;
-
-        let mut resp_headers = execution_request.x_headers();
-
-        let (responder, mut receiver) = mpsc::unbounded_channel();
-        handle_execution(sources, execution_request, responder).await;
-
-        let execution_response = receiver
-            .recv()
-            .await
-            .expect("An execution should always return a response");
-        resp_headers.extend(execution_response.headers.clone());
-        let mut resp = execution_response.into_http(binary_resp)?;
-
-        for (k, v) in resp_headers {
-            let k = HeaderName::from_str(&k)?;
-            let v = match v {
-                serde_json::Value::String(s) => HeaderValue::from_str(&s),
-                serde_json::Value::Null => HeaderValue::from_str(""),
-                _ => HeaderValue::from_str(&v.to_string()),
-            }?;
-            resp.headers_mut().append(k, v);
-        }
-
-        Ok(resp)
-    }
-}
-
-async fn handle_execution<H>(
-    sources: Arc<H>,
-    request: MessageRequest,
-    responder: mpsc::UnboundedSender<EventResponse>,
-) where
-    H: HandleRequest,
-{
-    let mut rsp = sources
-        .handle(&request)
-        .await
-        .map(|data| {
-            let (data, mut headers) = data.into_inner();
-            headers.append(&mut request.x_headers());
-            EventResponse {
-                data,
-                error: None,
-                headers,
-            }
-        })
-        .unwrap_or_else(|e| request.to_error(e.to_string()));
-
-    rsp.set_header(RUSK_VERSION_HEADER, serde_json::json!(*VERSION));
-    let _ = responder.send(rsp);
+    Err(ExecutionError::Generic(anyhow::anyhow!("Unsupported path")))
 }
 
 async fn handle_execution_rues<H>(
@@ -923,12 +660,6 @@ async fn handle_execution_rues<H>(
 
 #[async_trait]
 pub trait HandleRequest: Send + Sync + 'static {
-    fn can_handle(&self, request: &MessageRequest) -> bool;
-    async fn handle(
-        &self,
-        request: &MessageRequest,
-    ) -> anyhow::Result<ResponseData>;
-
     fn can_handle_rues(&self, request: &RuesDispatchEvent) -> bool;
     async fn handle_rues(
         &self,
@@ -941,7 +672,6 @@ mod tests {
     use std::{fs, thread};
 
     use super::*;
-    use event::Event as EventRequest;
 
     use dusk_core::abi::ContractId;
     use node_data::events::contract::{
@@ -962,26 +692,15 @@ mod tests {
 
     #[async_trait]
     impl HandleRequest for TestHandle {
-        fn can_handle(&self, _request: &MessageRequest) -> bool {
-            true
-        }
-
         fn can_handle_rues(&self, request: &RuesDispatchEvent) -> bool {
-            false
+            true
         }
         async fn handle_rues(
             &self,
             request: &RuesDispatchEvent,
         ) -> anyhow::Result<ResponseData> {
-            unimplemented!()
-        }
-
-        async fn handle(
-            &self,
-            request: &MessageRequest,
-        ) -> anyhow::Result<ResponseData> {
-            let response = match request.event.to_route() {
-                (_, _, "stream") => {
+            let response = match request.uri.inner() {
+                ("test", _, "stream") => {
                     let (sender, rec) = std::sync::mpsc::channel();
                     thread::spawn(move || {
                         for f in STREAMED_DATA.iter() {
@@ -990,7 +709,10 @@ mod tests {
                     });
                     ResponseData::new(rec)
                 }
-                _ => ResponseData::new(request.event_data().to_vec()),
+                ("test", _, "echo") => {
+                    ResponseData::new(request.data.as_bytes().to_vec())
+                }
+                _ => anyhow::bail!("Unsupported"),
             };
             Ok(response)
         }
@@ -1017,19 +739,12 @@ mod tests {
         let data = Vec::from(&b"I am call data 0"[..]);
         let data = RequestData::Binary(BinaryWrapper { inner: data });
 
-        let event = EventRequest {
-            target: Target::None,
-            data,
-            topic: "topic".into(),
-        };
-
-        let request = serde_json::to_vec(&event)
-            .expect("Serializing request should succeed");
+        let request_bytes = data.as_bytes();
 
         let client = reqwest::Client::new();
         let response = client
-            .post(format!("http://{}/01/target", server.local_addr))
-            .body(request)
+            .post(format!("http://{}/on/test/echo", server.local_addr))
+            .body(request_bytes.to_vec())
             .send()
             .await
             .expect("Requesting should succeed");
@@ -1038,7 +753,6 @@ mod tests {
             response.bytes().await.expect("There should be a response");
         let response_bytes =
             hex::decode(response_bytes).expect("data to be hex encoded");
-        let request_bytes = event.data.as_bytes();
 
         assert_eq!(
             request_bytes, response_bytes,
@@ -1071,15 +785,7 @@ mod tests {
 
         let data = Vec::from(&b"I am call data 0"[..]);
         let data = RequestData::Binary(BinaryWrapper { inner: data });
-
-        let event = EventRequest {
-            target: Target::None,
-            data,
-            topic: "topic".into(),
-        };
-
-        let request = serde_json::to_vec(&event)
-            .expect("Serializing request should succeed");
+        let request_bytes = data.as_bytes().to_vec();
 
         let client = reqwest::ClientBuilder::new()
             .add_root_certificate(certificate)
@@ -1089,10 +795,10 @@ mod tests {
 
         let response = client
             .post(format!(
-                "https://localhost:{}/01/target",
+                "https://localhost:{}/on/test/echo",
                 server.local_addr.port()
             ))
-            .body(request)
+            .body(request_bytes.clone())
             .send()
             .await
             .expect("Requesting should succeed");
@@ -1101,7 +807,6 @@ mod tests {
             response.bytes().await.expect("There should be a response");
         let response_bytes =
             hex::decode(response_bytes).expect("data to be hex encoded");
-        let request_bytes = event.data.as_bytes();
 
         assert_eq!(
             request_bytes, response_bytes,
@@ -1109,90 +814,6 @@ mod tests {
         );
     }
 
-    #[tokio::test(flavor = "multi_thread")]
-    async fn websocket_queries() {
-        let cert_and_key: Option<(String, String)> = None;
-
-        let (_, event_receiver) = broadcast::channel(16);
-        let ws_event_channel_cap = 2;
-
-        let server = HttpServer::bind(
-            TestHandle,
-            event_receiver,
-            ws_event_channel_cap,
-            "localhost:0",
-            HeaderMap::new(),
-            cert_and_key,
-        )
-        .await
-        .expect("Binding the server to the address should succeed");
-
-        let stream = TcpStream::connect(server.local_addr)
-            .expect("Connecting to the server should succeed");
-
-        let ws_uri = format!("ws://{}/01/stream", server.local_addr);
-        let (mut stream, _) = client(ws_uri, stream)
-            .expect("Handshake with the server should succeed");
-
-        let event = EventRequest {
-            target: Target::None,
-            data: RequestData::Text("Not used".into()),
-            topic: "stream".into(),
-        };
-        let request_x_header: serde_json::Map<String, serde_json::Value> =
-            serde_json::from_str(r#"{"X-requestid": "100"}"#)
-                .expect("headers to be serialized");
-
-        let request = MessageRequest {
-            event,
-            headers: request_x_header.clone(),
-        };
-
-        let request = serde_json::to_string(&request).unwrap();
-
-        stream
-            .send(Message::Text(request))
-            .expect("Sending request to the server should succeed");
-
-        let mut responses = vec![];
-
-        while responses.len() < STREAMED_DATA.len() {
-            let msg = stream
-                .read()
-                .expect("Response should be received without error");
-
-            let msg = match msg {
-                Message::Text(msg) => msg,
-                _ => panic!("Shouldn't receive anything but text"),
-            };
-            let response: EventResponse = serde_json::from_str(&msg)
-                .expect("Response should deserialize successfully");
-
-            let mut response_x_header = response.headers.clone();
-            response_x_header.retain(|k, _| k.to_lowercase().starts_with("x-"));
-            assert_eq!(
-                response_x_header, request_x_header,
-                "x-headers to be propagated back"
-            );
-            assert!(response.error.is_none(), "There should be no error");
-            match response.data {
-                DataType::Binary(BinaryWrapper { inner }) => {
-                    responses.push(inner);
-                }
-                _ => panic!("WS stream is supposed to return binary data"),
-            }
-        }
-
-        for (idx, response) in responses.iter().enumerate() {
-            let expected_data = STREAMED_DATA[idx];
-            assert_eq!(
-                &response[..],
-                expected_data,
-                "Response data should be the same as the request `fn_args`"
-            );
-        }
-    }
-
     #[tokio::test(flavor = "multi_thread")]
     async fn websocket_rues() {
         let cert_and_key: Option<(String, String)> = None;
diff --git a/rusk/src/lib/http/chain.rs b/rusk/src/lib/http/chain.rs
index c345b8c62..bbe17e313 100644
--- a/rusk/src/lib/http/chain.rs
+++ b/rusk/src/lib/http/chain.rs
@@ -53,14 +53,6 @@ fn variables_from_headers(headers: &Map<String, Value>) -> Variables {
 
 #[async_trait]
 impl HandleRequest for RuskNode {
-    fn can_handle(&self, request: &MessageRequest) -> bool {
-        let route = request.event.to_route();
-        if matches!(route, (Target::Host(_), "rusk", "preverify")) {
-            return true;
-        }
-        matches!(route, (Target::Host(_), "Chain", _))
-    }
-
     fn can_handle_rues(&self, request: &RuesDispatchEvent) -> bool {
         #[allow(clippy::match_like_matches_macro)]
         match request.uri.inner() {
@@ -107,38 +99,6 @@ impl HandleRequest for RuskNode {
             _ => anyhow::bail!("Unsupported"),
         }
     }
-    async fn handle(
-        &self,
-        request: &MessageRequest,
-    ) -> anyhow::Result<ResponseData> {
-        match &request.event.to_route() {
-            (Target::Host(_), "Chain", "gql") => {
-                self.handle_gql(&request.event.data, &request.headers).await
-            }
-            (Target::Host(_), "rusk", "preverify") => {
-                self.handle_preverify(request.event_data()).await
-            }
-            (Target::Host(_), "Chain", "propagate_tx") => {
-                self.propagate_tx(request.event_data()).await
-            }
-            (Target::Host(_), "Chain", "alive_nodes") => {
-                let amount = request.event.data.as_string().trim().parse()?;
-                self.alive_nodes(amount).await
-            }
-            (Target::Host(_), "Chain", "info") => self.get_info().await,
-            (Target::Host(_), "Chain", "gas") => {
-                let max_transactions = request
-                    .event
-                    .data
-                    .as_string()
-                    .trim()
-                    .parse::<usize>()
-                    .unwrap_or(usize::MAX);
-                self.get_gas_price(max_transactions).await
-            }
-            _ => anyhow::bail!("Unsupported"),
-        }
-    }
 }
 impl RuskNode {
     async fn handle_gql(
diff --git a/rusk/src/lib/http/event.rs b/rusk/src/lib/http/event.rs
index 04b2b51e2..2bf21c523 100644
--- a/rusk/src/lib/http/event.rs
+++ b/rusk/src/lib/http/event.rs
@@ -32,144 +32,6 @@ use tungstenite::http::HeaderValue;
 
 use super::{RUSK_VERSION_HEADER, RUSK_VERSION_STRICT_HEADER};
 
-/// A request sent by the websocket client.
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Event {
-    #[serde(skip)]
-    pub target: Target,
-    pub topic: String,
-    pub data: RequestData,
-}
-
-impl Event {
-    pub fn to_route(&self) -> (&Target, &str, &str) {
-        (&self.target, self.target.inner(), self.topic.as_ref())
-    }
-}
-
-/// A request sent by the websocket client.
-#[derive(Debug, Serialize, Deserialize)]
-pub struct MessageRequest {
-    pub headers: serde_json::Map<String, serde_json::Value>,
-    pub event: Event,
-}
-
-impl MessageRequest {
-    pub fn to_error<S>(&self, err: S) -> MessageResponse
-    where
-        S: AsRef<str>,
-    {
-        MessageResponse {
-            headers: self.x_headers(),
-            data: DataType::None,
-            error: Some(err.as_ref().to_string()),
-        }
-    }
-
-    pub fn event_data(&self) -> &[u8] {
-        self.event.data.as_bytes()
-    }
-}
-
-#[derive(Debug, Deserialize, Serialize, Default, Clone)]
-pub enum Target {
-    #[default]
-    None,
-    Contract(String), // 0x01
-    Host(String),     // 0x02
-    Debugger(String), // 0x03
-}
-
-impl Target {
-    pub fn inner(&self) -> &str {
-        match self {
-            Self::None => "",
-            Self::Contract(s) => s,
-            Self::Host(s) => s,
-            Self::Debugger(s) => s,
-        }
-    }
-}
-
-impl TryFrom<&str> for Target {
-    type Error = anyhow::Error;
-    fn try_from(value: &str) -> Result<Self, Self::Error> {
-        let paths: Vec<_> =
-            value.split('/').skip_while(|p| p.is_empty()).collect();
-        let target_type: i32 = paths
-            .first()
-            .ok_or_else(|| anyhow::anyhow!("Missing target type"))?
-            .parse()?;
-        let target = paths
-            .get(1)
-            .ok_or_else(|| anyhow::anyhow!("Missing target"))?
-            .to_string();
-
-        let target = match target_type {
-            0x01 => Target::Contract(target),
-            0x02 => Target::Host(target),
-            0x03 => Target::Debugger(target),
-            ty => {
-                return Err(anyhow::anyhow!("Unsupported target type '{ty}'"))
-            }
-        };
-
-        Ok(target)
-    }
-}
-
-impl MessageRequest {
-    pub fn x_headers(&self) -> serde_json::Map<String, serde_json::Value> {
-        let mut h = self.headers.clone();
-        h.retain(|k, _| k.to_lowercase().starts_with("x-"));
-        h
-    }
-
-    pub fn header(&self, name: &str) -> Option<&serde_json::Value> {
-        self.headers
-            .iter()
-            .find_map(|(k, v)| k.eq_ignore_ascii_case(name).then_some(v))
-    }
-
-    pub fn parse(bytes: &[u8]) -> anyhow::Result<Self> {
-        let (headers, bytes) = parse_header(bytes)?;
-        let event = Event::parse(bytes)?;
-        Ok(Self { event, headers })
-    }
-
-    pub async fn from_request(
-        req: Request<Incoming>,
-    ) -> anyhow::Result<(Self, bool)> {
-        let headers = req
-            .headers()
-            .iter()
-            .map(|(k, v)| {
-                let v = if v.is_empty() {
-                    serde_json::Value::Null
-                } else {
-                    serde_json::from_slice::<serde_json::Value>(v.as_bytes())
-                        .unwrap_or(serde_json::Value::String(
-                            v.to_str().unwrap().to_string(),
-                        ))
-                };
-                (k.to_string().to_lowercase(), v)
-            })
-            .collect();
-        let (event, binary_response) = Event::from_request(req).await?;
-
-        let req = MessageRequest { event, headers };
-
-        Ok((req, binary_response))
-    }
-
-    pub fn check_rusk_version(&self) -> anyhow::Result<()> {
-        check_rusk_version(
-            self.header(RUSK_VERSION_HEADER),
-            self.header(RUSK_VERSION_STRICT_HEADER).is_some(),
-        )
-    }
-}
-
 #[derive(Debug, Deserialize, Serialize)]
 pub struct MessageResponse {
     pub headers: serde_json::Map<String, serde_json::Value>,
@@ -465,52 +327,6 @@ pub struct BinaryWrapper {
     pub inner: Vec<u8>,
 }
 
-impl Event {
-    pub fn parse(bytes: &[u8]) -> anyhow::Result<Self> {
-        let (topic, bytes) = parse_string(bytes)?;
-        let data = bytes.to_vec().into();
-
-        Ok(Self {
-            target: Target::None,
-            topic,
-            data,
-        })
-    }
-    pub async fn from_request(
-        req: Request<Incoming>,
-    ) -> anyhow::Result<(Self, bool)> {
-        let (parts, req_body) = req.into_parts();
-        // HTTP REQUEST
-        let binary_request = parts
-            .headers
-            .get(CONTENT_TYPE)
-            .and_then(|h| h.to_str().ok())
-            .map(|v| v.eq_ignore_ascii_case(CONTENT_TYPE_BINARY))
-            .unwrap_or_default();
-
-        let target = parts.uri.path().try_into()?;
-
-        let body = req_body.collect().await?.to_bytes();
-
-        let mut event = match binary_request {
-            true => Event::parse(&body)
-                .map_err(|e| anyhow::anyhow!("Invalid data {e}"))?,
-            false => serde_json::from_slice(&body)
-                .map_err(|e| anyhow::anyhow!("Invalid data {e}"))?,
-        };
-        event.target = target;
-
-        let binary_response = binary_request
-            || parts
-                .headers
-                .get(ACCEPT)
-                .and_then(|h| h.to_str().ok())
-                .map(|v| v.eq_ignore_ascii_case(CONTENT_TYPE_BINARY))
-                .unwrap_or_default();
-
-        Ok((event, binary_response))
-    }
-}
 const CONTENT_TYPE: &str = "content-type";
 const ACCEPT: &str = "accept";
 const CONTENT_TYPE_BINARY: &str = "application/octet-stream";
@@ -979,17 +795,3 @@ pub fn check_rusk_version(
     }
     Ok(())
 }
-
-#[cfg(test)]
-mod tests {
-
-    use super::*;
-
-    #[test]
-    fn event() {
-        let data =
-            "120000006c65617665735f66726f6d5f6865696768740000000000000000";
-        let data = hex::decode(data).unwrap();
-        let event = Event::parse(&data).unwrap();
-    }
-}
diff --git a/rusk/src/lib/http/prover.rs b/rusk/src/lib/http/prover.rs
index b0a4ba511..613fcbbfa 100644
--- a/rusk/src/lib/http/prover.rs
+++ b/rusk/src/lib/http/prover.rs
@@ -13,9 +13,6 @@ use super::*;
 
 #[async_trait]
 impl HandleRequest for LocalProver {
-    fn can_handle(&self, request: &MessageRequest) -> bool {
-        matches!(request.event.to_route(), (_, "rusk", topic) | (_, "prover", topic) if topic.starts_with("prove_"))
-    }
     fn can_handle_rues(&self, request: &RuesDispatchEvent) -> bool {
         matches!(request.uri.inner(), ("prover", _, "prove"))
     }
@@ -32,18 +29,4 @@ impl HandleRequest for LocalProver {
         };
         Ok(ResponseData::new(response))
     }
-
-    async fn handle(
-        &self,
-        request: &MessageRequest,
-    ) -> anyhow::Result<ResponseData> {
-        let topic = request.event.topic.as_str();
-        let response = match topic {
-            "prove_execute" => LocalProver
-                .prove(request.event_data())
-                .map_err(|e| anyhow!(e))?,
-            _ => anyhow::bail!("Unsupported"),
-        };
-        Ok(ResponseData::new(response))
-    }
 }
diff --git a/rusk/src/lib/http/rusk.rs b/rusk/src/lib/http/rusk.rs
index 0ecf80f42..88b1f1412 100644
--- a/rusk/src/lib/http/rusk.rs
+++ b/rusk/src/lib/http/rusk.rs
@@ -4,15 +4,16 @@
 //
 // Copyright (c) DUSK NETWORK. All rights reserved.
 
-use super::event::Event;
 use super::*;
 
-use dusk_bytes::Serializable;
+use dusk_bytes::{DeserializableSlice, Serializable};
 use dusk_core::abi::ContractId;
+use dusk_core::signatures::bls::PublicKey as BlsPublicKey;
 use dusk_core::stake::StakeFundOwner;
 use node::vm::VMExecution;
 use rusk_profile::CRS_17_HASH;
 use serde::Serialize;
+use serde_json::json;
 use std::sync::{mpsc, Arc};
 use std::thread;
 use tokio::task;
@@ -24,26 +25,12 @@ const RUSK_FEEDER_HEADER: &str = "Rusk-Feeder";
 
 #[async_trait]
 impl HandleRequest for Rusk {
-    fn can_handle(&self, request: &MessageRequest) -> bool {
-        let route = request.event.to_route();
-        if matches!(route, (Target::Host(_), "rusk", "preverify")) {
-            // moved to chain
-            // here just for backward compatibility
-            return false;
-        }
-        if route.2.starts_with("prove_") {
-            return false;
-        }
-        matches!(
-            route,
-            (Target::Contract(_), ..) | (Target::Host(_), "rusk", _)
-        )
-    }
     fn can_handle_rues(&self, request: &RuesDispatchEvent) -> bool {
         #[allow(clippy::match_like_matches_macro)]
         match request.uri.inner() {
             ("contracts", Some(_), _) => true,
             ("node", _, "provisioners") => true,
+            ("account", Some(_), "status") => true,
             ("node", _, "crs") => true,
             _ => false,
         }
@@ -59,41 +46,15 @@ impl HandleRequest for Rusk {
                 self.handle_contract_query(contract_id, method, data, feeder)
             }
             ("node", _, "provisioners") => self.get_provisioners(),
-            ("node", _, "crs") => self.get_crs(),
-            _ => Err(anyhow::anyhow!("Unsupported")),
-        }
-    }
 
-    async fn handle(
-        &self,
-        request: &MessageRequest,
-    ) -> anyhow::Result<ResponseData> {
-        match &request.event.to_route() {
-            (Target::Contract(_), ..) => {
-                let feeder = request.header(RUSK_FEEDER_HEADER).is_some();
-                self.handle_contract_query_legacy(&request.event, feeder)
-            }
-            (Target::Host(_), "rusk", "provisioners") => {
-                self.get_provisioners()
-            }
-            (Target::Host(_), "rusk", "crs") => self.get_crs(),
+            ("account", Some(pk), "status") => self.get_account(pk),
+            ("node", _, "crs") => self.get_crs(),
             _ => Err(anyhow::anyhow!("Unsupported")),
         }
     }
 }
 
 impl Rusk {
-    fn handle_contract_query_legacy(
-        &self,
-        event: &Event,
-        feeder: bool,
-    ) -> anyhow::Result<ResponseData> {
-        let contract = event.target.inner();
-        let topic = &event.topic;
-        let data = event.data.as_bytes();
-
-        self.handle_contract_query(contract, topic, data, feeder)
-    }
     fn handle_contract_query(
         &self,
         contract: &str,
@@ -151,6 +112,24 @@ impl Rusk {
         Ok(ResponseData::new(serde_json::to_value(prov)?))
     }
 
+    fn get_account(&self, pk: &str) -> anyhow::Result<ResponseData> {
+        let pk = bs58::decode(pk)
+            .into_vec()
+            .map_err(|_| anyhow::anyhow!("Invalid bs58 account"))?;
+        let pk = BlsPublicKey::from_slice(&pk)
+            .map_err(|_| anyhow::anyhow!("Invalid bls account"))?;
+        let account = self
+            .account(&pk)
+            .map(|account| {
+                json!({
+                    "balance": account.balance,
+                    "nonce": account.nonce,
+                })
+            })
+            .map_err(|e| anyhow::anyhow!("Cannot query the state {e:?}"))?;
+        Ok(ResponseData::new(account))
+    }
+
     fn get_crs(&self) -> anyhow::Result<ResponseData> {
         let crs = rusk_profile::get_common_reference_string()?;
         Ok(ResponseData::new(crs).with_header("crs-hash", CRS_17_HASH))


Test patch: